Return interfaces details.
324351
def get_interfaces(self):
        """"""
        result = {}

        interfaces = junos_views.junos_iface_table(self.device)
        interfaces.get()

        # convert all the tuples to our pre-defined dict structure
        for iface in interfaces.keys():
            result[iface] = {
                'is_up': interfaces[iface]['is_up'],
                'is_enabled': interfaces[iface]['is_enabled'],
                'description': (interfaces[iface]['description'] or u''),
                'last_flapped': float((interfaces[iface]['last_flapped'] or -1)),
                'mac_address': napalm_base.helpers.convert(
                    napalm_base.helpers.mac,
                    interfaces[iface]['mac_address'],
                    py23_compat.text_type(interfaces[iface]['mac_address'])),
                'speed': -1
            }
            # result[iface]['last_flapped'] = float(result[iface]['last_flapped'])

            match = re.search(r'(\d+)(\w*)', interfaces[iface]['speed'] or u'')
            if match is None:
                continue
            speed_value = napalm_base.helpers.convert(int, match.group(1), -1)
            if speed_value == -1:
                continue
            speed_unit = match.group(2)
            if speed_unit.lower() == 'gbps':
                speed_value *= 1000
            result[iface]['speed'] = speed_value

        return result
420010
def get_interface_by_instance_name(self, name):
        ''''''
        with self._mutex:
            for intf in self.interfaces:
                if intf.instance_name == name:
                    return intf
            return None
322138
def create_interface(self):
        """"""
        return Interface(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
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']
448959
def interfaces_info():
    
    def replace(value):
        if value == netifaces.AF_LINK:
            return 'link'
        if value == netifaces.AF_INET:
            return 'ipv4'
        if value == netifaces.AF_INET6:
            return 'ipv6'
        return value

    results = {}
    for iface in netifaces.interfaces():
        addrs = netifaces.ifaddresses(iface)
        results[iface] = {replace(k): v for k, v in addrs.items()}

    return results
106525
def _get_host_details(self):
        """"""
        # Assuming only one system present as part of collection,
        # as we are dealing with iLO's here.
        status, headers, system = self._rest_get('/rest/v1/Systems/1')
        if status < 300:
            stype = self._get_type(system)
            if stype not in ['ComputerSystem.0', 'ComputerSystem.1']:
                msg = "%s is not a valid system type " % stype
                raise exception.IloError(msg)
        else:
            msg = self._get_extended_error(system)
            raise exception.IloError(msg)

        return system
1015384
def connecting_interfaces(self, interfaces):
        

        data = {'interfaces': interfaces}

        url = 'api/v3/connections/' + str(interfaces[0].get('id')) + '/' + str(interfaces[1].get('id')) + '/'

        return super(ApiInterfaceRequest, self).post(url, data)
625369
def getInterfaceList (self, flags=0):
        """"""
        if sys.platform == 'darwin':
            command = ['ifconfig', '-l']
            if flags & self.IFF_UP:
                command.append('-u')
            # replace with subprocess.check_output() for Python 2.7
            res = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
            return res.split()
        # initial 8kB buffer to hold interface data
        bufsize = 8192
        # 80kB buffer should be enough for most boxen
        max_bufsize = bufsize * 10
        while True:
            buf = array.array('c', '\0' * bufsize)
            ifreq = struct.pack("iP", buf.buffer_info()[1], buf.buffer_info()[0])
            try:
                result = self._ioctl(self.SIOCGIFCONF, ifreq)
                break
            except IOError as msg:
                # in case of EINVAL the buffer size was too small
                if msg[0] != errno.EINVAL or bufsize == max_bufsize:
                    raise
            # increase buffer
            bufsize += 8192
        # loop over interface names
        data = buf.tostring()
        iflist = []
        size, ptr = struct.unpack("iP", result)
        i = 0
        while i < size:
            ifconf = data[i:i+self.ifr_size]
            name = struct.unpack("16s%ds" % (self.ifr_size-16), ifconf)[0]
            name = name.split('\0', 1)[0]
            if name:
                if flags and not (self.getFlags(name) & flags):
                    continue
                iflist.append(name)
            i += self.ifr_size
        return iflist
1258695
def get_facts(self):
        """"""
        commands = []
        commands.append('show version')
        commands.append('show hostname')
        commands.append('show interfaces')

        result = self.device.run_commands(commands)

        version = result[0]
        hostname = result[1]
        interfaces_dict = result[2]['interfaces']

        uptime = time.time() - version['bootupTimestamp']

        interfaces = [i for i in interfaces_dict.keys() if '.' not in i]
        interfaces = string_parsers.sorted_nicely(interfaces)

        return {
            'hostname': hostname['hostname'],
            'fqdn': hostname['fqdn'],
            'vendor': u'Arista',
            'model': version['modelName'],
            'serial_number': version['serialNumber'],
            'os_version': version['internalVersion'],
            'uptime': int(uptime),
            'interface_list': interfaces,
        }
695425
def find_interfaces(device, **kwargs):
    
    interfaces = []
    try:
        for cfg in device:
            try:
                interfaces.extend(usb_find_desc(cfg, find_all=True, **kwargs))
            except:
                pass
    except:
        pass
    return interfaces
1130439
def interfaces():
    '''
    
    '''
    if salt.utils.platform.is_windows():
        return win_interfaces()
    elif salt.utils.platform.is_netbsd():
        return netbsd_interfaces()
    else:
        return linux_interfaces()
152274
def _ExtractInterfaceMetadata(self, metadata):
    
    interfaces = []
    for network_interface in metadata:
      mac_address = network_interface.get('mac')
      interface = self.network_utils.GetNetworkInterface(mac_address)
      ip_addresses = []
      if interface:
        ip_addresses.extend(network_interface.get('forwardedIps', []))
        if self.ip_aliases:
          ip_addresses.extend(network_interface.get('ipAliases', []))
        if self.target_instance_ips:
          ip_addresses.extend(network_interface.get('targetInstanceIps', []))
        interfaces.append(NetworkDaemon.NetworkInterface(
            interface, ip_addresses, network_interface.get('ip', [])))
      else:
        message = 'Network interface not found for MAC address: %s.'
        self.logger.warning(message, mac_address)
    return interfaces
728563
def interfaces(self):
        """"""
        
        ifaces = []
        for f in sorted(os.listdir(CTRL_IFACE_DIR)):
            sock_file = '/'.join([CTRL_IFACE_DIR, f])
            mode = os.stat(sock_file).st_mode
            if stat.S_ISSOCK(mode):
                iface = {}
                iface['name'] = f
                ifaces.append(iface)
                self._connect_to_wpa_s(f)

        return ifaces
897095
def ip_interfaces():
    '''
    
    '''
    # Provides:
    #   ip_interfaces

    if salt.utils.platform.is_proxy():
        return {}

    ret = {}
    ifaces = _get_interfaces()
    for face in ifaces:
        iface_ips = []
        for inet in ifaces[face].get('inet', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for inet in ifaces[face].get('inet6', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for secondary in ifaces[face].get('secondary', []):
            if 'address' in secondary:
                iface_ips.append(secondary['address'])
        ret[face] = iface_ips
    return {'ip_interfaces': ret}
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]
    }
262132
def fetch_interfaces(self):
        
        return get('ISteamWebAPIUtil', 'GetSupportedAPIList', 1,
            https=self.https,
            apihost=self.apihost,
            caller=None,
            session=self.session,
            params={'format': 'json',
                    'key': self.key,
                    },
            )
715572
def list_interfaces(style=None):
    '''
    
    '''
    ret = {}
    tmp = None
    iface = None
    out = __salt__['cmd.run']('iwconfig')
    for line in out.splitlines():
        if not line:
            continue
        if 'no wireless extensions' in line:
            continue
        comps = line.strip().split('  ')
        if not line.startswith(' '):
            if tmp is not None:
                ret[iface] = tmp.copy()
            iface = comps.pop(0)
            tmp = {'extra': []}
        for item in comps:
            if ':' in item:
                parts = item.split(':')
                key = parts[0].strip()
                value = parts[1].strip()
                if key == 'ESSID':
                    value = value.lstrip('"').rstrip('"')
                tmp[key] = value
            elif '=' in item:
                parts = item.split('=')
                tmp[parts[0].strip()] = parts[1].strip()
            else:
                tmp['extra'].append(item)

    ret[iface] = tmp.copy()

    if style == 'list':
        return ret.keys()

    return ret