Get vlan attached ifaces.
9633
def ifaces(cls, name):
        
        ifaces = Iface.list({'vlan_id': cls.usable_id(name)})
        ret = []
        for iface in ifaces:
            ret.append(Iface.info(iface['id']))
        return ret
135511
def get_vlan_from_associate_reply(self, reply, vsiid, mac):
        
        try:
            verify_flag, fail_reason = self.crosscheck_reply_vsiid_mac(
                reply, vsiid, mac)
            if not verify_flag:
                return constants.INVALID_VLAN, fail_reason
            mode_str = reply.partition("mode = ")[2].split()[0]
            if mode_str != "assoc":
                fail_reason = self.get_vdp_failure_reason(reply)
                return constants.INVALID_VLAN, fail_reason
        except Exception:
            fail_reason = vdp_const.mode_failure_reason % (reply)
            LOG.error("%s", fail_reason)
            return constants.INVALID_VLAN, fail_reason
        check_filter, fail_reason = self.check_filter_validity(
            reply, "filter = ")
        if not check_filter:
            return constants.INVALID_VLAN, fail_reason
        try:
            vlan_val = reply.partition("filter = ")[2].split('-')[0]
            vlan = int(vlan_val)
        except ValueError:
            fail_reason = vdp_const.format_failure_reason % (reply)
            LOG.error("%s", fail_reason)
            return constants.INVALID_VLAN, fail_reason
        return vlan, None
929858
public static vlan_stats[] get(nitro_service service) throws Exception{
		vlan_stats obj = new vlan_stats();
		vlan_stats[] response = (vlan_stats[])obj.stat_resources(service);
		return response;
	}
227284
def _ifconfig_getnode():
    """"""

    # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
    for args in ('', '-a', '-av'):
        mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1)
        if mac:
            return mac

    import socket
    ip_addr = socket.gethostbyname(socket.gethostname())

    # Try getting the MAC addr from arp based on our IP address (Solaris).
    mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1)
    if mac:
        return mac

    # This might work on HP-UX.
    mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0)
    if mac:
        return mac

    return None
439281
def get_network():
    """"""
    meta = SoftLayer.MetadataManager()
    network_tables = []
    for network_func in [meta.public_network, meta.private_network]:
        network = network_func()

        table = formatting.KeyValueTable(['name', 'value'])
        table.align['name'] = 'r'
        table.align['value'] = 'l'
        table.add_row(['mac addresses',
                       formatting.listing(network['mac_addresses'],
                                          separator=',')])
        table.add_row(['router', network['router']])
        table.add_row(['vlans',
                       formatting.listing(network['vlans'], separator=',')])
        table.add_row(['vlan ids',
                       formatting.listing(network['vlan_ids'], separator=',')])
        network_tables.append(table)

    return network_tables
422177
public static ns_vlan[] get(nitro_service client) throws Exception
	{
		ns_vlan resource = new ns_vlan();
		resource.validate("get");
		return (ns_vlan[]) resource.get_resources(client);
	}
525938
def vlan_id(self):
        
        nicid = self.nicid
        if nicid:
            v = nicid.split('.')
            if len(v) > 1:
                return nicid.split('.')[1]
19996
def _get_nics(dom):
    '''
    
    '''
    nics = {}
    doc = ElementTree.fromstring(dom.XMLDesc(0))
    for iface_node in doc.findall('devices/interface'):
        nic = {}
        nic['type'] = iface_node.get('type')
        for v_node in iface_node:
            if v_node.tag == 'mac':
                nic['mac'] = v_node.get('address')
            if v_node.tag == 'model':
                nic['model'] = v_node.get('type')
            if v_node.tag == 'target':
                nic['target'] = v_node.get('dev')
            # driver, source, and match can all have optional attributes
            if re.match('(driver|source|address)', v_node.tag):
                temp = {}
                for key, value in six.iteritems(v_node.attrib):
                    temp[key] = value
                nic[v_node.tag] = temp
            # virtualport needs to be handled separately, to pick up the
            # type attribute of the virtualport itself
            if v_node.tag == 'virtualport':
                temp = {}
                temp['type'] = v_node.get('type')
                for key, value in six.iteritems(v_node.attrib):
                    temp[key] = value
                nic['virtualport'] = temp
        if 'mac' not in nic:
            continue
        nics[nic['mac']] = nic
    return nics
271207
def update(self, vlans):
        

        data = {'vlans': vlans}
        vlans_ids = [str(vlan.get('id')) for vlan in vlans]

        return super(ApiVlan, self).put('api/v3/vlan/%s/' %
                                        ';'.join(vlans_ids), data)
528885
def from_name(cls, name):
        """"""
        result = cls.list()
        vlans = {}
        for vlan in result:
            vlans[vlan['name']] = vlan['id']

        return vlans.get(name)
1244622
def get_interface(iface):
    '''
    
    '''
    path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
    return _read_file(path)
1272067
def get_bridge_nics(bridge, vnic_dir='/sys/devices/virtual/net'):
    """"""
    brif_regex = "%s/%s/brif/*" % (vnic_dir, bridge)
    return [x.split('/')[-1] for x in glob.glob(brif_regex)]
1233339
def _port_bound(self, port_id, network_id, network_type, physical_network,
                    segmentation_id, port_security_enabled, set_port_sriov):
        """"""
        LOG.debug("Binding port %s", port_id)

        if network_id not in self._network_vswitch_map:
            self._provision_network(
                port_id, network_id, network_type,
                physical_network, segmentation_id)

        vswitch_map = self._network_vswitch_map[network_id]
        vswitch_map['ports'].append(port_id)

        LOG.debug("Trying to connect the current port to vswitch %r.",
                  vswitch_map['vswitch_name'])
        self._utils.connect_vnic_to_vswitch(
            vswitch_name=vswitch_map['vswitch_name'],
            switch_port_name=port_id,
        )
        if set_port_sriov:
            LOG.debug("Enabling SR-IOV for port: %s", port_id)
            self._utils.set_vswitch_port_sriov(port_id, True)
342258
def _list_vlans_by_name(self, name):
        
        results = self.list_vlans(name=name, mask='id')
        return [result['id'] for result in results]
750876
public static vlan_interface_binding[] get(nitro_service service, Long id) throws Exception{
		vlan_interface_binding obj = new vlan_interface_binding();
		obj.set_id(id);
		vlan_interface_binding response[] = (vlan_interface_binding[]) obj.get_resources(service);
		return response;
	}
1105273
def _ip_ifaces():
    '''
    
    '''
    tmp = {}
    ret = {}
    if_ = None
    at_ = None
    out = __salt__['cmd.run']('ip a')
    for line in out.splitlines():
        if not line.startswith(' '):
            comps = line.split(':')
            if_ = comps[1].strip()
            opts_comps = comps[2].strip().split()
            flags = opts_comps.pop(0).lstrip('<').rstrip('>').split(',')
            opts_iter = iter(opts_comps)
            ret[if_] = {
                'flags': flags,
                'options': dict(list(zip(opts_iter, opts_iter)))
            }
        else:
            if line.strip().startswith('link'):
                comps = iter(line.strip().split())
                ret[if_]['link_layer'] = dict(list(zip(comps, comps)))
            elif line.strip().startswith('inet'):
                comps = line.strip().split()
                at_ = comps[0]
                if len(comps) % 2 != 0:
                    last = comps.pop()
                    comps[-1] += ' {0}'.format(last)
                ifi = iter(comps)
                ret[if_][at_] = dict(list(zip(ifi, ifi)))
            else:
                comps = line.strip().split()
                ifi = iter(comps)
                ret[if_][at_].update(dict(list(zip(ifi, ifi))))
    return ret
103863
def get_addr(iface='lo0', iface_type='link'):
    
    if platform.system() in ['Darwin', 'Linux']:
        if iface_type == 'link':
            _AF_FAMILY = psutil.AF_LINK
        elif iface_type in ['inet', 'inet6']:
            _AF_FAMILY = getattr(socket, 'AF_{}'.format(iface_type.upper()))
        else:
            raise SystemError('Not valid address FAMILY')
    else:
        raise SystemExit('Unsupported System. Only Mac/Linux Supported')

    addrs = psutil.net_if_addrs()
    for n in addrs[iface]:
        if n.family == _AF_FAMILY:
            return n.address