Returns a dict object of all Vlans in the running-config

        Returns:
            A dict object of Vlan attributes
505622
def getall(self):
        
        vlans_re = re.compile(r'(?<=^vlan\s)(\d+)', re.M)

        response = dict()
        for vid in vlans_re.findall(self.config):
            response[vid] = self.get(vid)
        return response
63652
def virtual_interface_list(self, name):
        '''
        
        '''
        nt_ks = self.compute_conn
        nets = nt_ks.virtual_interfaces.list(self._server_uuid_from_name(name))
        return [network.__dict__ for network in nets]
829170
def connection(self):
        
        return {'host': self.host, 'namespace': self.namespace, 'username': self.username, 'password': self.password}
83177
def _parse_settings_vlan(opts, iface):

    '''
    
    '''
    vlan = {}
    if 'reorder_hdr' in opts:
        if opts['reorder_hdr'] in _CONFIG_TRUE + _CONFIG_FALSE:
            vlan.update({'reorder_hdr': opts['reorder_hdr']})
        else:
            valid = _CONFIG_TRUE + _CONFIG_FALSE
            _raise_error_iface(iface, 'reorder_hdr', valid)

    if 'vlan_id' in opts:
        if opts['vlan_id'] > 0:
            vlan.update({'vlan_id': opts['vlan_id']})
        else:
            _raise_error_iface(iface, 'vlan_id', 'Positive integer')

    if 'phys_dev' in opts:
        if opts['phys_dev']:
            vlan.update({'phys_dev': opts['phys_dev']})
        else:
            _raise_error_iface(iface, 'phys_dev', 'Non-empty string')

    return vlan
1353135
def get_vlan(self, vlan_id):
        
        return self.vlan.getObject(id=vlan_id, mask=DEFAULT_GET_VLAN_MASK)
852772
def get_nexusvm_bindings(vlan_id, instance_id):
    """"""
    LOG.debug("get_nexusvm_bindings() called")
    return _lookup_all_nexus_bindings(instance_id=instance_id,
                                      vlan_id=vlan_id)
1297202
def config_dict(config):
    
    return dict(
        (key, getattr(config, key))
        for key in config.values
    )
1141047
def to_dict(self):
        
        return {
            'hostname': self.hostname,
            'port': self.port,
            'transport': self.transport,
            'virtual_host': self.virtual_host
        }
1165792
def get_config(self):
        
        if not self._config:
            namespace = {}
            if os.path.exists(self.config_path):
                execfile(self.config_path, namespace)
            self._config = namespace.get('config') or Configuration()
        return self._config
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
281010
def get_config(self, retrieve="all"):
        """"""
        get_startup = retrieve == "all" or retrieve == "startup"
        get_running = retrieve == "all" or retrieve == "running"
        get_candidate = (retrieve == "all" or retrieve == "candidate") and self.config_session

        if retrieve == "all":
            commands = ['show startup-config',
                        'show running-config']

            if self.config_session:
                commands.append('show session-config named {}'.format(self.config_session))

            output = self.device.run_commands(commands, encoding="text")
            return {
                'startup': py23_compat.text_type(output[0]['output']) if get_startup else u"",
                'running': py23_compat.text_type(output[1]['output']) if get_running else u"",
                'candidate': py23_compat.text_type(output[2]['output']) if get_candidate else u"",
            }
        elif get_startup or get_running:
            commands = ['show {}-config'.format(retrieve)]
            output = self.device.run_commands(commands, encoding="text")
            return {
                'startup': py23_compat.text_type(output[0]['output']) if get_startup else u"",
                'running': py23_compat.text_type(output[0]['output']) if get_running else u"",
                'candidate': "",
            }
        elif get_candidate:
            commands = ['show session-config named {}'.format(self.config_session)]
            output = self.device.run_commands(commands, encoding="text")
            return {
                'startup': "",
                'running': "",
                'candidate': py23_compat.text_type(output[0]['output']),
            }
        elif retrieve == "candidate":
            # If we get here it means that we want the candidate but there is none.
            return {
                'startup': "",
                'running': "",
                'candidate': "",
            }
        else:
            raise Exception("Wrong retrieve filter: {}".format(retrieve))
1329058
def get_default_config(self):
        
        config = super(NetworkCollector, self).get_default_config()
        config.update({
            'path':         'network',
            'interfaces':   ['eth', 'bond', 'em', 'p1p', 'eno', 'enp', 'ens',
                             'enx'],
            'byte_unit':    ['bit', 'byte'],
            'greedy':       'true',
        })
        return config
1316088
def _get_socket_paths(self):
        
        socket_pattern = os.path.join(self.config['socket_path'],
                                      (self.config['socket_prefix'] +
                                       '*.' + self.config['socket_ext']))
        return glob.glob(socket_pattern)
407178
def get_configuration():
    
    root = getLogger()
    name_levels = [('', logging.getLevelName(root.level))]
    name_levels.extend(
        (name, logging.getLevelName(logger.level))
        for name, logger
        in root.manager.loggerDict.items()
        if hasattr(logger, 'level')
    )

    config_string = ','.join('%s:%s' % x for x in name_levels)

    return dict(config_string=config_string, log_json=SLogger.manager.log_json)
546713
def _get_running_config(self, split=True):
        
        conn = self._get_connection()
        config = conn.get_config(source="running")
        if config:
            root = ET.fromstring(config._raw)
            running_config = root[0][0]
            if split is True:
                rgx = re.compile("\r*\n+")
                ioscfg = rgx.split(running_config.text)
            else:
                ioscfg = running_config.text
            return ioscfg
608346
def get_subnet_dict():
  """"""
  subnet_dict = {}
  vpc = get_vpc()
  for subnet in vpc.subnets.all():
    zone = subnet.availability_zone
    assert zone not in subnet_dict, "More than one subnet in %s, why?" % (zone,)
    subnet_dict[zone] = subnet
  return subnet_dict
788393
def ips(self):
        
        if self._ips is None:
            self._ips = {}
            default_net = extract_data_from_inspect("default", self.net_settings)
            if default_net:
                self._ips["default"] = default_net
            # this can be None
            networks = self.inspect_data["NetworkSettings"]["Networks"]
            if networks:
                for network_name, network_data in networks.items():
                    self._ips[network_name] = extract_data_from_inspect(network_name, network_data)

        return self._ips