List IPSec VPN tunnel contexts
195807
def cli(env):
    """"""
    manager = SoftLayer.IPSECManager(env.client)
    contexts = manager.get_tunnel_contexts()

    table = formatting.Table(['id',
                              'name',
                              'friendly name',
                              'internal peer IP address',
                              'remote peer IP address',
                              'created'])
    for context in contexts:
        table.add_row([context.get('id', ''),
                       context.get('name', ''),
                       context.get('friendlyName', ''),
                       context.get('internalPeerIpAddress', ''),
                       context.get('customerPeerIpAddress', ''),
                       context.get('createDate', '')])
    env.fout(table)
613683
def ips(self):
        """"""
        r = []
        names = ['X_FORWARDED_FOR', 'CLIENT_IP', 'X_REAL_IP', 'X_FORWARDED', 
               'X_CLUSTER_CLIENT_IP', 'FORWARDED_FOR', 'FORWARDED', 'VIA',
               'REMOTE_ADDR']

        for name in names:
            vs = self.get_header(name, '')
            if vs:
                r.extend(map(lambda v: v.strip(), vs.split(',')))

            vs = self.environ.get(name, '')
            if vs:
                r.extend(map(lambda v: v.strip(), vs.split(',')))

        return r
911989
def GetForwardedIps(self, interface, interface_ip=None):
    
    try:
      ips = netifaces.ifaddresses(interface)
      ips = ips[netifaces.AF_INET]
    except (ValueError, IndexError):
      return []
    forwarded_ips = []
    for ip in ips:
      if ip['addr'] != interface_ip:
        full_addr = '%s/%d' % (ip['addr'], netaddr.IPAddress(ip['netmask']).netmask_bits())
        forwarded_ips.append(full_addr)
    return self.ParseForwardedIps(forwarded_ips)
137505
def get_delete_security_group_commands(self, sg_id):
        """"""
        cmds = []
        cmds.append("no ip access-list %s" %
                    self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
        cmds.append("no ip access-list %s" %
                    self._acl_name(sg_id, n_const.EGRESS_DIRECTION))
        return cmds
772637
def get_network_instances(self, name=""):
        """"""

        output = self._show_vrf()
        vrfs = {}
        all_vrf_interfaces = {}
        for vrf in output:
            if (
                vrf.get("route_distinguisher", "") == "<not set>"
                or vrf.get("route_distinguisher", "") == "None"
            ):
                vrf["route_distinguisher"] = ""
            else:
                vrf["route_distinguisher"] = py23_compat.text_type(
                    vrf["route_distinguisher"]
                )
            interfaces = {}
            for interface_raw in vrf.get("interfaces", []):
                interface = interface_raw.split(",")
                for line in interface:
                    if line.strip() != "":
                        interfaces[py23_compat.text_type(line.strip())] = {}
                        all_vrf_interfaces[py23_compat.text_type(line.strip())] = {}

            vrfs[py23_compat.text_type(vrf["name"])] = {
                "name": py23_compat.text_type(vrf["name"]),
                "type": "L3VRF",
                "state": {"route_distinguisher": vrf["route_distinguisher"]},
                "interfaces": {"interface": interfaces},
            }
        all_interfaces = self.get_interfaces_ip().keys()
        vrfs["default"] = {
            "name": "default",
            "type": "DEFAULT_INSTANCE",
            "state": {"route_distinguisher": ""},
            "interfaces": {
                "interface": {
                    k: {} for k in all_interfaces if k not in all_vrf_interfaces.keys()
                }
            },
        }

        if name:
            if name in vrfs:
                return {py23_compat.text_type(name): vrfs[name]}
            return {}
        else:
            return vrfs
344768
def list(cls, spec=None):
        

        if spec is None:
            spec = {}

        xmlrpc = XMLRPCConnection()
        try:
            pref_list = xmlrpc.connection.list_prefix(
                {
                    'prefix': spec,
                    'auth': AuthOptions().options
                })
        except xmlrpclib.Fault as xml_fault:
            raise _fault_to_exception(xml_fault)
        res = list()
        for pref in pref_list:
            p = Prefix.from_dict(pref)
            res.append(p)

        return res
327429
def ip_access_control_lists(self):
        
        if self._ip_access_control_lists is None:
            self._ip_access_control_lists = IpAccessControlListList(
                self._version,
                account_sid=self._solution['account_sid'],
            )
        return self._ip_access_control_lists
473281
def cli(env, context_id):
    
    manager = SoftLayer.IPSECManager(env.client)
    # ensure context can be retrieved by given id
    manager.get_tunnel_context(context_id)

    succeeded = manager.apply_configuration(context_id)
    if succeeded:
        env.out('Configuration request received for context #{}'
                .format(context_id))
    else:
        raise CLIHalt('Failed to enqueue configuration request for context #{}'
                      .format(context_id))
1129755
def cli(env, context_id, static_ip, remote_ip, note):
    
    manager = SoftLayer.IPSECManager(env.client)
    # ensure context can be retrieved by given id
    manager.get_tunnel_context(context_id)

    translation = manager.create_translation(context_id,
                                             static_ip=static_ip,
                                             remote_ip=remote_ip,
                                             notes=note)
    env.out('Created translation from {} to {} #{}'
            .format(static_ip, remote_ip, translation['id']))
1344772
def list_ports(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-ports'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
341385
def list():
    ""
    for node in env.nodes:
        print "%s (%s, %s)" % (node.tags["Name"], node.ip_address,
            node.private_ip_address)
486048
def getservers(self, vhost = None):
        '''
        
        '''
        if vhost is not None:
            return [s for s in self.connections if s.protocol.vhost == vhost]
        else:
            return list(self.connections)
311959
def list_():
    '''
    
    '''
    pki_dir = __salt__['config.get']('pki_dir', '')

    # We have to replace the minion/master directories
    pki_dir = pki_dir.replace('minion', 'master')

    # The source code below is (nearly) a copy of salt.key.Key.list_keys
    key_dirs = _check_minions_directories(pki_dir)

    ret = {}

    for dir_ in key_dirs:
        ret[os.path.basename(dir_)] = []
        try:
            for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(dir_)):
                if not fn_.startswith('.'):
                    if os.path.isfile(os.path.join(dir_, fn_)):
                        ret[os.path.basename(dir_)].append(fn_)
        except (OSError, IOError):
            # key dir kind is not created yet, just skip
            continue

    return ret
566071
def get_authn_contexts(self):
        
        authn_context_nodes = self.__query_assertion('/saml:AuthnStatement/saml:AuthnContext/saml:AuthnContextClassRef')
        return [OneLogin_Saml2_XML.element_text(node) for node in authn_context_nodes]
1224289
def wafer_sso_url(context, sso_method):
    '''
    
    '''
    request = context.request
    url = reverse(getattr(views, '%s_login' % sso_method))
    if 'next' in request.GET:
        url += '?' + urlencode({'next': request.GET['next']})
    return url
619502
def check_ips(self, addrs):
        
        tasks = []
        for addr in addrs:
            tasks.append(self._check_ip(addr))
        return self._loop.run_until_complete(asyncio.gather(*tasks))
1054420
def vulns_list(self, service_id=None, service_port=None, hostfilter=None):
        
        return self.send.service_vulns_list(service_id, service_port, hostfilter)