Returns a virtual network's ID from the given virtual network's name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_vn_id opennebula name=my-vn-name
975765
def get_vn_id(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_vn_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_vn_id function requires a name.'
        )

    try:
        ret = list_vns()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The VN \'{0}\' could not be found.'.format(name)
        )

    return ret
653624
def get_vm_ip(name=None, session=None, call=None):
    '''
    

    '''
    if call == 'function':
        raise SaltCloudException(
            'This function must be called with -a or --action.'
        )
    if session is None:
        log.debug('New session being created')
        session = _get_session()
    vm = _get_vm(name, session=session)
    ret = None
    # -- try to get ip from vif
    vifs = session.xenapi.VM.get_VIFs(vm)
    if vifs is not None:
        for vif in vifs:
            if session.xenapi.VIF.get_ipv4_addresses(vif):
                cidr = session.xenapi.VIF.get_ipv4_addresses(vif).pop()
                ret, subnet = cidr.split('/')
                log.debug(
                    'VM vif returned for instance: %s ip: %s', name, ret)
                return ret
    # -- try to get ip from get tools metrics
    vgm = session.xenapi.VM.get_guest_metrics(vm)
    try:
        net = session.xenapi.VM_guest_metrics.get_networks(vgm)
        if "0/ip" in net.keys():
            log.debug(
                'VM guest metrics returned for instance: %s 0/ip: %s',
                name, net["0/ip"]
            )
            ret = net["0/ip"]
    # except Exception as ex:
    except XenAPI.Failure:
        log.info('Could not get vm metrics at this time')
    return ret
1225269
def get_ref_id(self):

        
        if self.ref_key == 'NETWORK':
            return self.network_id
        elif self.ref_key == 'NODE':
            return self.node_id
        elif self.ref_key == 'LINK':
            return self.link_id
        elif self.ref_key == 'GROUP':
            return self.group_id
        elif self.ref_key == 'SCENARIO':
            return self.scenario_id
        elif self.ref_key == 'PROJECT':
            return self.project_id
941011
def get_by_id(self, id_networkv6):
        

        uri = 'api/networkv4/%s/' % id_networkv6
        return super(ApiNetworkIPv6, self).get(uri)
1090578
def port_id_from_name(port_name, device_id, nodes):
        
        port_id = None
        for node in nodes:
            if device_id == node['id']:
                for port in node['ports']:
                    if port_name == port['name']:
                        port_id = port['id']
                        break
                break
        return port_id
525938
def vlan_id(self):
        
        nicid = self.nicid
        if nicid:
            v = nicid.split('.')
            if len(v) > 1:
                return nicid.split('.')[1]
404402
def get_network_by_id(self, net_id):
        """"""

        for elem in self.networks:
            if elem.id == net_id:
                return elem
        return None
1153985
def hostname():
    '''
    
    '''
    # This is going to need some work
    # Provides:
    #   fqdn
    #   host
    #   localhost
    #   domain
    global __FQDN__
    grains = {}

    if salt.utils.platform.is_proxy():
        return grains

    grains['localhost'] = socket.gethostname()
    if __FQDN__ is None:
        __FQDN__ = salt.utils.network.get_fqhostname()

    # On some distros (notably FreeBSD) if there is no hostname set
    # salt.utils.network.get_fqhostname() will return None.
    # In this case we punt and log a message at error level, but force the
    # hostname and domain to be localhost.localdomain
    # Otherwise we would stacktrace below
    if __FQDN__ is None:   # still!
        log.error('Having trouble getting a hostname.  Does this machine have its hostname and domain set properly?')
        __FQDN__ = 'localhost.localdomain'

    grains['fqdn'] = __FQDN__
    (grains['host'], grains['domain']) = grains['fqdn'].partition('.')[::2]
    return grains
410994
def get_network(self, name, batch_size=None, callback=None):
        '''

        '''
        network_proto = nnabla_pb2.Network()
        network_proto.CopyFrom(self.network_dict[name])
        return NnpNetwork(network_proto, self._params, batch_size, callback=callback)
524208
def network_get(auth=None, **kwargs):
    '''
    

    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.get_network(**kwargs)
327258
def is_local_router_id_greater(self):
        
        from ryu.services.protocols.bgp.utils.bgp import from_inet_ptoi

        if not self.state == BGP_FSM_OPEN_CONFIRM:
            raise BgpProtocolException(desc='Can access remote router id only'
                                            ' after open message is received')
        remote_id = self.recv_open_msg.bgp_identifier
        local_id = self.sent_open_msg.bgp_identifier
        return from_inet_ptoi(local_id) > from_inet_ptoi(remote_id)
698171
def get_ip_on_network(self, network_name):
        
        return self.get_scenario_host_ip_on_network(
            scenario_role_name=self.cons3rt_role_name,
            network_name=network_name
        )
1075173
def get_port_name_from_id(node_id, port_id, nodes):
        
        port_name = ''
        for node in nodes:
            if node['id'] == node_id:
                for port in node['ports']:
                    if port['id'] == port_id:
                        port_name = port['name']
                        break
        return port_name
659124
def get_host_id(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_host_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_host_id function requires a name.'
        )

    try:
        ret = avail_locations()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The host \'{0}\' could not be found'.format(name)
        )

    return ret
832855
def get_subnet_nwk_excl(self, tenant_id, excl_list, excl_part=False):
        
        net_list = self.get_network_by_tenant(tenant_id)
        ret_subnet_list = []
        for net in net_list:
            if excl_part:
                name = net.get('name')
                part = name.partition('::')[2]
                if part:
                    continue
            subnet_lst = self.get_subnets_for_net(net.get('id'))
            for subnet_elem in subnet_lst:
                subnet = subnet_elem.get('cidr').split('/')[0]
                subnet_and_mask = subnet_elem.get('cidr')
                if subnet not in excl_list:
                    ret_subnet_list.append(subnet_and_mask)
        return ret_subnet_list
789111
def load_vm_uuid_by_name(self, si, vcenter_data_model, vm_name):
        
        path = VMLocation.combine([vcenter_data_model.default_datacenter, vm_name])
        paths = path.split('/')
        name = paths[len(paths) - 1]
        path = VMLocation.combine(paths[:len(paths) - 1])
        vm = self.pv_service.find_vm_by_name(si, path, name)
        if not vm:
            raise ValueError('Could not find the vm in the given path: {0}/{1}'.format(path, name))

        if isinstance(vm, vim.VirtualMachine):
            return vm.config.uuid

        raise ValueError('The given object is not a vm: {0}/{1}'.format(path, name))
179544
def get_network_interface_id(name, region=None, key=None, keyid=None,
                             profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    r = {}
    try:
        enis = conn.get_all_network_interfaces(filters={'tag:Name': name})
        if not enis:
            r['error'] = {'message': 'No ENIs found.'}
        elif len(enis) > 1:
            r['error'] = {'message': 'Name specified is tagged on multiple ENIs.'}
        else:
            eni = enis[0]
            r['result'] = eni.id
    except boto.exception.EC2ResponseError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r