List all Network Interface Controller
771501
def list_nic(self, instance_id):
        
        #NOTE: interfaces a list of novaclient.v2.servers.Server
        interfaces = self.client.servers.interface_list(instance_id)
        return interfaces
1234761
def EnumerateInterfacesFromClient(args):
  """"""
  del args  # Unused

  libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c"))
  ifa = Ifaddrs()
  p_ifa = ctypes.pointer(ifa)
  libc.getifaddrs(ctypes.pointer(p_ifa))

  addresses = {}
  macs = {}
  ifs = set()

  m = p_ifa
  while m:
    ifname = ctypes.string_at(m.contents.ifa_name)
    ifs.add(ifname)
    try:
      iffamily = ord(m.contents.ifa_addr[0])

      if iffamily == 0x2:  # AF_INET
        data = ctypes.cast(m.contents.ifa_addr, ctypes.POINTER(Sockaddrin))
        ip4 = bytes(list(data.contents.sin_addr))
        address_type = rdf_client_network.NetworkAddress.Family.INET
        address = rdf_client_network.NetworkAddress(
            address_type=address_type, packed_bytes=ip4)
        addresses.setdefault(ifname, []).append(address)

      if iffamily == 0x11:  # AF_PACKET
        data = ctypes.cast(m.contents.ifa_addr, ctypes.POINTER(Sockaddrll))
        addlen = data.contents.sll_halen
        macs[ifname] = bytes(list(data.contents.sll_addr[:addlen]))

      if iffamily == 0xA:  # AF_INET6
        data = ctypes.cast(m.contents.ifa_addr, ctypes.POINTER(Sockaddrin6))
        ip6 = bytes(list(data.contents.sin6_addr))
        address_type = rdf_client_network.NetworkAddress.Family.INET6
        address = rdf_client_network.NetworkAddress(
            address_type=address_type, packed_bytes=ip6)
        addresses.setdefault(ifname, []).append(address)
    except ValueError:
      # Some interfaces don't have a iffamily and will raise a null pointer
      # exception. We still want to send back the name.
      pass

    m = m.contents.ifa_next

  libc.freeifaddrs(p_ifa)

  for interface in ifs:
    mac = macs.setdefault(interface, b"")
    address_list = addresses.setdefault(interface, b"")
    args = {"ifname": interface}
    if mac:
      args["mac_address"] = mac
    if addresses:
      args["addresses"] = address_list
    yield rdf_client_network.Interface(**args)
1244244
def list_devices(self):
        """"""
        if self.plm.devices:
            for addr in self.plm.devices:
                device = self.plm.devices[addr]
                if device.address.is_x10:
                    _LOGGING.info('Device: %s %s', device.address.human,
                                  device.description)
                else:
                    _LOGGING.info('Device: %s cat: 0x%02x subcat: 0x%02x '
                                  'desc: %s, model: %s',
                                  device.address.human, device.cat,
                                  device.subcat, device.description,
                                  device.model)
        else:
            _LOGGING.info('No devices found')
            if not self.plm.transport:
                _LOGGING.info('IM connection has not been made.')
                _LOGGING.info('Use `connect [device]` to open the connection')
733782
def get_connected_devices():
        
        all_daplinks = []
        all_interfaces = _get_interfaces()
        for interface in all_interfaces:
            try:
                new_daplink = DAPAccessCMSISDAP(None, interface=interface)
                all_daplinks.append(new_daplink)
            except DAPAccessIntf.TransferError:
                logger = logging.getLogger(__name__)
                logger.error('Failed to get unique id', exc_info=session.Session.get_current().log_tracebacks)
        return all_daplinks
342258
def _list_vlans_by_name(self, name):
        
        results = self.list_vlans(name=name, mask='id')
        return [result['id'] for result in results]
1215087
def _get_interface_commands(self, sg_id, profile, delete=False):
        """"""
        rule_prefix = ""
        if delete:
            rule_prefix = "no "
        switch_cmds = {}
        switchports = self._get_switchports(profile)
        for switch_ip, intf in switchports:
            cmds = []
            intf_id = self._get_port_for_acl(intf, switch_ip)
            cmds.append("interface %s" % intf_id)
            name = self._acl_name(sg_id, n_const.INGRESS_DIRECTION)
            cmds.append(rule_prefix + "ip access-group %s %s" %
                        (name, a_const.INGRESS_DIRECTION))
            name = self._acl_name(sg_id, n_const.EGRESS_DIRECTION)
            cmds.append(rule_prefix + "ip access-group %s %s" %
                        (name, a_const.EGRESS_DIRECTION))
            cmds.append("exit")
            if switch_ip not in switch_cmds.keys():
                switch_cmds[switch_ip] = []
            switch_cmds[switch_ip].extend(cmds)
        return switch_cmds
484871
def network_interfaces
      netifcs = []
      procfs_file("net", "dev") do |file|
        file.read.scan(NET_DATA) do |columns|
          type = case columns[0]
            when /^eth/ then NetworkInterface::ETHERNET_TYPE
            when /^lo/  then NetworkInterface::LOOPBACK_TYPE
          end

          netifcs << NetworkInterface.new(columns[0].to_sym, columns[1].to_i,
                                          columns[3].to_i,   columns[4].to_i,
                                          columns[9].to_i,   columns[11].to_i,
                                          type)
        end
      end
      netifcs
    end
843648
def _list_interface_private_addrs(eni_desc):
    '''
    
    '''
    primary = eni_desc.get('privateIpAddress')
    if not primary:
        return None

    addresses = [primary]

    lst = eni_desc.get('privateIpAddressesSet', {}).get('item', [])
    if not isinstance(lst, list):
        return addresses

    for entry in lst:
        if entry.get('primary') == 'true':
            continue
        if entry.get('privateIpAddress'):
            addresses.append(entry.get('privateIpAddress'))

    return addresses
939475
def list_domains():
    '''
    
    '''
    with _get_xapi_session() as xapi:
        hosts = xapi.VM.get_all()
        ret = []

        for _host in hosts:
            if xapi.VM.get_record(_host)['is_control_domain'] is False:
                ret.append(xapi.VM.get_name_label(_host))

        return ret
294057
def network_interfaces_list_all(**kwargs):
    '''
    

    '''
    result = {}
    netconn = __utils__['azurearm.get_client']('network', **kwargs)
    try:
        nics = __utils__['azurearm.paged_object_to_list'](netconn.network_interfaces.list_all())

        for nic in nics:
            result[nic['name']] = nic
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('network', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result
1358345
def list_networks(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request
        return self.list('networks', self.networks_path, retrieve_all,
                         **_params)
1046356
def network_io_counters(interface=None):
    '''
    
    '''
    if not interface:
        return dict(psutil.net_io_counters()._asdict())
    else:
        stats = psutil.net_io_counters(pernic=True)
        if interface in stats:
            return dict(stats[interface]._asdict())
        else:
            return False
896916
def virtual_interface_list(provider, names, **kwargs):
    '''
    

    '''
    client = _get_client()
    return client.extra_action(provider=provider, names=names, action='virtual_interface_list', **kwargs)
703161
def addresses(self):
        
        addresses = []
        for i in self.all_interfaces:
            if isinstance(i, VlanInterface):
                for v in i.interfaces:
                    addresses.append((v.address, v.network_value, v.nicid))
            else:
                addresses.append((i.address, i.network_value, i.nicid))
        return addresses
1211849
def interfaces(self):
        
        if 'interfaces' not in self._cached_values:
            self._cached_values['interfaces'] = []
            for name, interface in six.iteritems(self.settings.INTERFACES):
                interface_name = 'interface_%s' % name
                # Hostname:port + unix socket
                try:
                    listen = self.config_parser.get(interface_name, 'Listen')
                except CONFIGPARSER_EXC:
                    listen = interface.get('LISTEN')
                try:
                    unix_socket = self.config_parser.get(
                        interface_name, 'UnixSocket')
                except CONFIGPARSER_EXC:
                    unix_socket = interface.get('UNIX_SOCKET')
                if not listen and not unix_socket:
                    raise ValueError(
                        'Interface MUST listen either on TCP '
                        'or UNIX socket or both')
                host, port = parse_host(listen) if listen else (None, None)
                # Processes
                try:
                    processes = self.config_parser.getint(
                        interface_name, 'Processes')
                except CONFIGPARSER_EXC:
                    processes = int(interface.get('PROCESSES', 1))
                # Urls
                try:
                    urls_obj_name = self.config_parser.get(
                        interface_name, 'Urls')
                except CONFIGPARSER_EXC:
                    urls_obj_name = interface.get('URLS', '')
                if urls_obj_name:
                    urls = import_object(urls_obj_name)
                else:
                    urls = ()

                self._cached_values['interfaces'].append(
                    self.Interface(
                        name, host, port, unix_socket, processes, urls)
                )
        return self._cached_values['interfaces']
279532
def _get_base_interface_info(interface):
    '''
    
    '''
    blacklist = {
        'tcpip': {
            'name': [],
            'type': [],
            'additional_protocol': False
        },
        'disabled': {
            'name': ['eth0'],
            'type': ['gadget'],
            'additional_protocol': False
        },
        'ethercat': {
            'name': ['eth0'],
            'type': ['gadget', 'usb', 'wlan'],
            'additional_protocol': True
        },
        '_': {
            'usb': 'sys',
            'gadget': 'uevent',
            'wlan': 'uevent'
        }
    }
    return {
        'label': interface.name,
        'connectionid': interface.name,
        'supported_adapter_modes': _get_possible_adapter_modes(interface.name, blacklist),
        'adapter_mode': _get_adapter_mode_info(interface.name),
        'up': interface.flags & IFF_RUNNING != 0,
        'ipv4': {
            'supportedrequestmodes': ['dhcp_linklocal', 'dhcp_only', 'linklocal_only', 'static'],
            'requestmode': _get_request_mode_info(interface.name)
        },
        'hwaddr': interface.hwaddr[:-1]
    }
866869
def EnumerateInterfacesFromClient(args):
  
  del args  # Unused.

  pythoncom.CoInitialize()
  for interface in (wmi.WMI().Win32_NetworkAdapterConfiguration() or []):
    addresses = []
    for ip_address in interface.IPAddress or []:
      addresses.append(
          rdf_client_network.NetworkAddress(human_readable_address=ip_address))

    response = rdf_client_network.Interface(ifname=interface.Description)
    if interface.MACAddress:
      response.mac_address = binascii.unhexlify(
          interface.MACAddress.replace(":", ""))
    if addresses:
      response.addresses = addresses

    yield response