Returns the SubnetId of a SubnetName to use
424484
def _get_subnetname_id(subnetname):
    '''
    
    '''
    params = {'Action': 'DescribeSubnets'}
    for subnet in aws.query(params, location=get_location(),
               provider=get_provider(), opts=__opts__, sigver='4'):
        tags = subnet.get('tagSet', {}).get('item', {})
        if not isinstance(tags, list):
            tags = [tags]
        for tag in tags:
            if tag['key'] == 'Name' and tag['value'] == subnetname:
                log.debug(
                    'AWS Subnet ID of %s is %s',
                    subnetname, subnet['subnetId']
                )
                return subnet['subnetId']
    return None
388688
def json_2_subnet(json_obj):
        
        LOGGER.debug("Subnet.json_2_subnet")
        return Subnet(subnetid=json_obj['subnetID'],
                      name=json_obj['subnetName'],
                      description=json_obj['subnetDescription'],
                      ip=json_obj['subnetIP'],
                      mask=json_obj['subnetMask'],
                      routing_area_id=json_obj['subnetRoutingAreaID'],
                      ip_address_ids=json_obj['subnetIPAddressesID'],
                      subnet_loc_ids=json_obj['subnetLocationsID'],
                      subnet_osi_ids=json_obj['subnetOSInstancesID'])
280614
def subnets_list(resource_group_name, vnet_name, address_prefix = nil)
      list = network_resource_client.subnets.list(resource_group_name, vnet_name)
      !address_prefix.nil? && !list.empty? ? subnets_list_for_specific_address_space(address_prefix, list) : list
    end
920211
def get_network_name(network_id):
        
        if os.environ.get('KEEPER_NETWORK_NAME'):
            logging.debug('keeper network name overridden by an environment variable: {}'.format(
                os.environ.get('KEEPER_NETWORK_NAME')))
            return os.environ.get('KEEPER_NETWORK_NAME')

        return Keeper._network_name_map.get(network_id, Keeper.DEFAULT_NETWORK_NAME)
948741
def mgmt_nw_id(cls):
        """"""
        if cls._mgmt_nw_uuid is None:
            tenant_id = cls.l3_tenant_id()
            if not tenant_id:
                return
            net = bc.get_plugin().get_networks(
                bc.context.get_admin_context(),
                {'tenant_id': [tenant_id],
                 'name': [cfg.CONF.general.management_network]},
                ['id', 'subnets'])
            if len(net) == 1:
                num_subnets = len(net[0]['subnets'])
                if num_subnets == 0:
                    LOG.error('The management network has no subnet. '
                              'Please assign one.')
                    return
                elif num_subnets > 1:
                    LOG.info('The management network has %d subnets. The '
                             'first one will be used.', num_subnets)
                cls._mgmt_nw_uuid = net[0].get('id')
                cls._mgmt_subnet_uuid = net[0]['subnets'][0]
            elif len(net) > 1:
                # Management network must have a unique name.
                LOG.error('The management network for does not have '
                          'unique name. Please ensure that it is.')
            else:
                # Management network has not been created.
                LOG.error('There is no virtual management network. Please '
                          'create one.')
        return cls._mgmt_nw_uuid
869539
def getIPString():
        
        if not(NetInfo.systemip):
            NetInfo.systemip = ",".join(NetInfo.getSystemIps())
        return NetInfo.systemip
1091119
def delete_network_subname(self, sub_name):
        
        try:
            body = {}
            net_list = self.neutronclient.list_networks(body=body)
            for net in net_list:
                if net.get('name').find(sub_name) != -1:
                    self.delete_network_all_subnets(net.get('net_id'))
        except Exception as exc:
            LOG.error("Failed to get network by subname %(name)s, "
                      "Exc %(exc)s",
                      {'name': sub_name, 'exc': str(exc)})
929380
def get_network_by_name(self, nwk_name):
        
        ret_net_lst = []
        try:
            body = {}
            net_list = self.neutronclient.list_networks(body=body)
            net_list = net_list.get('networks')
            for net in net_list:
                if net.get('name') == nwk_name:
                    ret_net_lst.append(net)
        except Exception as exc:
            LOG.error("Failed to get network by name %(name)s, "
                      "Exc %(exc)s",
                      {'name': nwk_name, 'exc': str(exc)})
        return ret_net_lst
889796
def get_subnet_length(mask):
    '''
    
    '''
    if not salt.utils.validate.net.netmask(mask):
        raise SaltInvocationError(
            '\'{0}\' is not a valid netmask'.format(mask)
        )
    return salt.utils.network.get_net_size(mask)
377344
def get_by_id(self, id_networkv4):
        

        uri = 'api/networkv4/%s/' % id_networkv4

        return super(ApiNetworkIPv4, self).get(uri)
107325
def update_subnet(self, subnet, body=None):
        """"""
        return self.put(self.subnet_path % (subnet), body=body)
695686
def vlan_id(self):
        
        nicids = self.nicid.split('-')
        if nicids:
            u = []
            for vlan in nicids:
                if vlan.split('.')[-1] not in u:
                    u.append(vlan.split('.')[-1])
            return '-'.join(u)
82896
def get_out_net_id(cls, tenant_id):
        
        if 'out' not in cls.ip_db_obj:
            LOG.error("Fabric not prepared for tenant %s", tenant_id)
            return None
        db_obj = cls.ip_db_obj.get('out')
        out_subnet_dict = cls.get_out_ip_addr(tenant_id)
        sub = db_obj.get_subnet(out_subnet_dict.get('subnet'))
        return sub.network_id
309534
def _find_usage_subnets(self):
        """"""
        # subnets per VPC
        subnet_to_az = {}
        subnets = defaultdict(int)
        for subnet in self.conn.describe_subnets()['Subnets']:
            subnets[subnet['VpcId']] += 1
            subnet_to_az[subnet['SubnetId']] = subnet['AvailabilityZone']
        for vpc_id in subnets:
            self.limits['Subnets per VPC']._add_current_usage(
                subnets[vpc_id],
                aws_type='AWS::EC2::VPC',
                resource_id=vpc_id
            )
        return subnet_to_az
583435
def get_network_id(self, is_full: bool = False) -> int:
        

        payload = self.generate_json_rpc_payload(RpcMethod.GET_NETWORK_ID)
        response = self.__post(self.__url, payload)
        if is_full:
            return response
        return response['result']
682811
def __get_subnetwork(vm_):
    '''
    
    '''
    ex_subnetwork = config.get_cloud_config_value(
        'subnetwork', vm_, __opts__,
        search_global=False)

    return ex_subnetwork
470210
def allocate_subnet(self, subnet_lst, net_id=None):
        

        session = db.get_session()
        query_str = None
        for sub in subnet_lst:
            sub_que = (self.model.subnet_address != sub)
            if query_str is not None:
                query_str = query_str & sub_que
            else:
                query_str = sub_que
        with session.begin(subtransactions=True):
            select = (session.query(self.model).filter(
                (self.model.allocated == 0) & query_str))

            # Selected segment can be allocated before update by someone else,
            # We retry until update success or DB_MAX_RETRIES retries
            for attempt in range(DB_MAX_RETRIES + 1):
                alloc = select.first()
                if not alloc:
                    LOG.info("No subnet resource available")
                    return
                count = (session.query(self.model).
                         filter_by(subnet_address=alloc.subnet_address,
                         allocated=False).update({"allocated": True,
                                                  "network_id": net_id}))
                if count:
                    return alloc.subnet_address

        LOG.error("ERROR: Failed to allocate subnet for net %(net)s",
                  {'net': net_id})
        return None