Router connection information
8134
def connectionType()
            joinThread()
            type = getCString()
            if MiniUPnP.UPNP_GetConnectionTypeInfo(@urls.controlURL,
                       @data.servicetype,type) != 0 then
                raise UPnPException.new, "Error while retriving connection info."
            end
            type.rstrip
        end
707667
def check_connection(self):
        """"""
        host = self.urlparts[1]
        addresses = socket.getaddrinfo(host, 80, 0, 0, socket.SOL_TCP)
        args = {'host': host}
        if addresses:
            args['ips'] = [x[4][0] for x in addresses]
            self.set_result(_('%(host)s resolved to IPs %(ips)s') % args, valid=True)
        else:
            self.set_result(_('%(host)r could not be resolved') % args, valid=False)
980917
def _get_connection_info():
    """"""

    info = 'Connection: %s,' % CONN.url
    if CONN.creds is not None:
        info += ' userid=%s,' % CONN.creds[0]
    else:
        info += ' no creds,'

    info += ' cacerts=%s,' % ('sys-default' if CONN.ca_certs is None
                              else CONN.ca_certs)

    info += ' verifycert=%s,' % ('off' if CONN.no_verification else 'on')

    info += ' default-namespace=%s' % CONN.default_namespace
    if CONN.x509 is not None:
        info += ', client-cert=%s' % CONN.x509['cert_file']
        try:
            kf = CONN.x509['key_file']
        except KeyError:
            kf = "none"
        info += ":%s" % kf

    if CONN.timeout is not None:
        info += ', timeout=%s' % CONN.timeout

    # pylint: disable=protected-access
    info += ' stats=%s, ' % ('on' if CONN._statistics else 'off')

    info += 'log=%s' % ('on' if CONN._operation_recorders else 'off')

    if isinstance(CONN, FakedWBEMConnection):
        info += ', mock-server'

    return fill(info, 78, subsequent_indent='    ')
993589
def cli(env, ip_address):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    addr_info = mgr.ip_lookup(ip_address)

    if not addr_info:
        raise exceptions.CLIAbort('Not found')

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', addr_info['id']])
    table.add_row(['ip', addr_info['ipAddress']])

    subnet_table = formatting.KeyValueTable(['name', 'value'])
    subnet_table.align['name'] = 'r'
    subnet_table.align['value'] = 'l'
    subnet_table.add_row(['id', addr_info['subnet']['id']])
    subnet_table.add_row(['identifier',
                          '%s/%s' % (addr_info['subnet']['networkIdentifier'],
                                     str(addr_info['subnet']['cidr']))])
    subnet_table.add_row(['netmask', addr_info['subnet']['netmask']])
    if addr_info['subnet'].get('gateway'):
        subnet_table.add_row(['gateway', addr_info['subnet']['gateway']])
    subnet_table.add_row(['type', addr_info['subnet'].get('subnetType')])

    table.add_row(['subnet', subnet_table])

    if addr_info.get('virtualGuest') or addr_info.get('hardware'):
        device_table = formatting.KeyValueTable(['name', 'value'])
        device_table.align['name'] = 'r'
        device_table.align['value'] = 'l'
        if addr_info.get('virtualGuest'):
            device = addr_info['virtualGuest']
            device_type = 'vs'
        else:
            device = addr_info['hardware']
            device_type = 'server'
        device_table.add_row(['id', device['id']])
        device_table.add_row(['name', device['fullyQualifiedDomainName']])
        device_table.add_row(['type', device_type])
        table.add_row(['device', device_table])
    env.fout(table)
1306354
private function _network()
    {
        if (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                if (preg_match("/^([^\s:]+):\saddress\s(\S+)\snetmask/", $line, $ar_buf)) {
                    $dev = new NetDevice();
                    $dev->setName($ar_buf[1]);
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
                            $dev->setInfo($ar_buf[2]);
                    }
                    $this->sys->setNetDevices($dev);
                }
            }
        }
    }
21129
def delete_router(self, router):
        '''
        
        '''
        router_id = self._find_router_id(router)
        ret = self.network_conn.delete_router(router=router_id)
        return ret if ret else True
355631
def add_router_references(self, snet, address, dnets):
        """"""
        if _debug: NetworkServiceAccessPoint._debug("add_router_references %r %r %r", snet, address, dnets)

        # see if we have an adapter for the snet
        if snet not in self.adapters:
            raise RuntimeError("no adapter for network: %d" % (snet,))

        # pass this along to the cache
        self.router_info_cache.update_router_info(snet, address, dnets)
862957
def _get_path_infomation(self):
        """"""
        long_identifier = self._device_path.split('/')[4]
        protocol, remainder = long_identifier.split('-', 1)
        identifier, _, device_type = remainder.rsplit('-', 2)
        return (protocol, identifier, device_type)
985342
def get_hardware_router_type_id(self, context):
        """"""
        cctxt = self.client.prepare()
        return cctxt.call(context,
                          'get_hardware_router_type_id',
                          host=self.host)
477411
def network_info():
    

    def extract(host, family):
        return socket.getaddrinfo(host, None, family)[0][4][0]
    host = socket.gethostname()
    response = {
        'hostname': host,
        'ipv4': None,
        'ipv6': None
    }
    with suppress(IndexError, socket.gaierror):
        response['ipv4'] = extract(host, socket.AF_INET)
    with suppress(IndexError, socket.gaierror):
        response['ipv6'] = extract(host, socket.AF_INET6)
    return response
277208
function extractConnectionInfo(opts) {
    var params = {};
    var defaultServer = opts.secureCommands ?
                        { hostname: '127.0.0.1', port: 4445 } :
                        { hostname: 'ondemand.saucelabs.com', port: 80 };

    params.hostname = opts.hostname || defaultServer.hostname;
    params.port     = opts.port || defaultServer.port;
    if (opts.key) {
      params.accessKey = opts.key;
    }
    ['auth', 'username'].forEach(function(prop) {
      if (opts[prop]) {
        params[prop] = opts[prop];
      }
    });
    return params;
  }
868689
def parse_routing_info(cls, records):
        
        if len(records) != 1:
            raise RoutingProtocolError("Expected exactly one record")
        record = records[0]
        routers = []
        readers = []
        writers = []
        try:
            servers = record["servers"]
            for server in servers:
                role = server["role"]
                addresses = []
                for address in server["addresses"]:
                    addresses.append(SocketAddress.parse(address, DEFAULT_PORT))
                if role == "ROUTE":
                    routers.extend(addresses)
                elif role == "READ":
                    readers.extend(addresses)
                elif role == "WRITE":
                    writers.extend(addresses)
            ttl = record["ttl"]
        except (KeyError, TypeError):
            raise RoutingProtocolError("Cannot parse routing info")
        else:
            return cls(routers, readers, writers, ttl)
1274355
def router_main(self):    
        '''
        
        '''
        while True:
            gotpkt = True
            try:
                timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
            except NoPackets:
                log_debug("No packets available in recv_packet")
                gotpkt = False
            except Shutdown:
                log_debug("Got shutdown signal")
                break

            if gotpkt:
                log_debug("Got a packet: {}".format(str(pkt)))
1230103
def network_info(host=None,
                 admin_username=None,
                 admin_password=None,
                 module=None):
    '''
    
    '''

    inv = inventory(host=host, admin_username=admin_username,
                    admin_password=admin_password)
    if inv is None:
        cmd = {}
        cmd['retcode'] = -1
        cmd['stdout'] = 'Problem getting switch inventory'
        return cmd

    if module not in inv.get('switch') and module not in inv.get('server'):
        cmd = {}
        cmd['retcode'] = -1
        cmd['stdout'] = 'No module {0} found.'.format(module)
        return cmd

    cmd = __execute_ret('getniccfg', host=host,
                        admin_username=admin_username,
                        admin_password=admin_password,
                        module=module)

    if cmd['retcode'] != 0:
        log.warning('racadm returned an exit code of %s', cmd['retcode'])

    cmd['stdout'] = 'Network:\n' + 'Device = ' + module + '\n' + \
                    cmd['stdout']
    return __parse_drac(cmd['stdout'])
306387
def connect(self):
        
        sock = None
        try:
            sock = _configured_socket(self.address, self.opts)
        except socket.error as error:
            if sock is not None:
                sock.close()
            _raise_connection_failure(self.address, error)

        sock_info = SocketInfo(sock, self, self.address)
        if self.handshake:
            sock_info.ismaster(self.opts.metadata, None)
        return sock_info
319059
def get_connections(self):
        
        path = Client.urls['all_connections']
        conns = self._call(path, 'GET')
        return conns
777145
def gateways_info():
    
    data = netifaces.gateways()
    results = {'default': {}}

    with suppress(KeyError):
        results['ipv4'] = data[netifaces.AF_INET]
        results['default']['ipv4'] = data['default'][netifaces.AF_INET]
    with suppress(KeyError):
        results['ipv6'] = data[netifaces.AF_INET6]
        results['default']['ipv6'] = data['default'][netifaces.AF_INET6]

    return results