Get all the mappings of network resource attributes, NOT ALL THE MAPPINGS
        WITHIN A NETWORK. For that, ``use get_mappings_in_network``. If another network
        is specified, only return the mappings between the two networks.
359837
def get_network_mappings(network_id, network_2_id=None, **kwargs):
    
    qry = db.DBSession.query(ResourceAttrMap).filter(
        or_(
            and_(
                ResourceAttrMap.resource_attr_id_a == ResourceAttr.id,
                ResourceAttr.network_id == network_id),
            and_(
                ResourceAttrMap.resource_attr_id_b == ResourceAttr.id,
                ResourceAttr.network_id == network_id)))

    if network_2_id is not None:
        aliased_ra = aliased(ResourceAttr, name="ra2")
        qry = qry.filter(or_(
            and_(
                ResourceAttrMap.resource_attr_id_a == aliased_ra.id,
                aliased_ra.network_id == network_2_id),
            and_(
                ResourceAttrMap.resource_attr_id_b == aliased_ra.id,
                aliased_ra.network_id == network_2_id)))

    return qry.all()
1358345
def list_networks(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request
        return self.list('networks', self.networks_path, retrieve_all,
                         **_params)
624975
def list_subnets(self, retrieve_all=True, **_params):
        """"""
        return self.list('subnets', self.subnets_path, retrieve_all,
                         **_params)
277698
def get_all_resource_attributes_in_network(attr_id, network_id, **kwargs):
    

    user_id = kwargs.get('user_id')

    try:
        a = db.DBSession.query(Attr).filter(Attr.id == attr_id).one()
    except NoResultFound:
        raise HydraError("Attribute %s not found"%(attr_id,))

    ra_qry = db.DBSession.query(ResourceAttr).filter(
                ResourceAttr.attr_id==attr_id,
                or_(Network.id == network_id,
                Node.network_id==network_id,
                Link.network_id==network_id,
                ResourceGroup.network_id==network_id)
            ).outerjoin('node')\
             .outerjoin('link')\
             .outerjoin('network')\
             .outerjoin('resourcegroup')\
             .options(joinedload_all('node'))\
             .options(joinedload_all('link'))\
             .options(joinedload_all('resourcegroup'))\
             .options(joinedload_all('network'))

    resourceattrs = ra_qry.all()

    json_ra = []
    #Load the metadata too
    for ra in resourceattrs:
        ra_j = JSONObject(ra, extras={'node':JSONObject(ra.node) if ra.node else None,
                                               'link':JSONObject(ra.link) if ra.link else None,
                                               'resourcegroup':JSONObject(ra.resourcegroup) if ra.resourcegroup else None,
                                               'network':JSONObject(ra.network) if ra.network else None})
        
        if ra_j.node is not None:
            ra_j.resource = ra_j.node
        elif ra_j.link is not None:
            ra_j.resource = ra_j.link
        elif ra_j.resourcegroup is not None:
            ra_j.resource = ra_j.resourcegroup
        elif ra.network is not None:
            ra_j.resource = ra_j.network
        
        json_ra.append(ra_j)

    return json_ra
257492
def get_mapping(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.get_mapping(index=self._name, **kwargs)
581237
def predict_mappings(self, mappings):
        
        if self.nat_type not in self.predictable_nats:
            msg = "Can't predict mappings for non-predictable NAT type."
            raise Exception(msg)

        for mapping in mappings:
            mapping["bound"] = mapping["sock"].getsockname()[1]

            if self.nat_type == "preserving":
                mapping["remote"] = mapping["source"]

            if self.nat_type == "delta":
                max_port = 65535
                mapping["remote"] = int(mapping["source"]) + self.delta

                # Overflow or underflow = wrap port around.
                if mapping["remote"] > max_port:
                    mapping["remote"] -= max_port
                if mapping["remote"] < 0:
                    mapping["remote"] = max_port - -mapping["remote"]

                # Unknown error.
                if mapping["remote"] < 1 or mapping["remote"] > max_port:
                    mapping["remote"] = 1
                mapping["remote"] = str(mapping["remote"])

        return mappings
1219230
def _apply_dvs_network_resource_pools(network_resource_pools, resource_dicts):
    '''
    
    '''
    for res_dict in resource_dicts:
        ress = [r for r in network_resource_pools if r.key == res_dict['key']]
        if ress:
            res = ress[0]
        else:
            res = vim.DVSNetworkResourcePoolConfigSpec()
            res.key = res_dict['key']
            res.allocationInfo = \
                    vim.DVSNetworkResourcePoolAllocationInfo()
            network_resource_pools.append(res)
        if res_dict.get('limit'):
            res.allocationInfo.limit = res_dict['limit']
        if res_dict.get('num_shares') and res_dict.get('share_level'):
            if not res.allocationInfo.shares:
                res.allocationInfo.shares = vim.SharesInfo()
            res.allocationInfo.shares.shares = res_dict['num_shares']
            res.allocationInfo.shares.level = \
                    vim.SharesLevel(res_dict['share_level'])
181928
def links(self):
        
        link_dict = {'self': self.resource_uri()}
        for relationship in inspect(  # pylint: disable=maybe-no-member
                self.__class__).relationships:
            if 'collection' not in relationship.key:
                instance = getattr(self, relationship.key)
                if instance:
                    link_dict[str(relationship.key)] = instance.resource_uri()
        return link_dict
736621
def get_network_resource_property_entry(resource, prop):
    

    def get_func(cmd, resource_group_name, resource_name, item_name):
        client = getattr(network_client_factory(cmd.cli_ctx), resource)
        items = getattr(client.get(resource_group_name, resource_name), prop)

        result = next((x for x in items if x.name.lower() == item_name.lower()), None)
        if not result:
            raise CLIError("Item '{}' does not exist on {} '{}'".format(
                item_name, resource, resource_name))
        else:
            return result

    func_name = 'get_network_resource_property_entry_{}_{}'.format(resource, prop)
    setattr(sys.modules[__name__], func_name, get_func)
    return func_name
714005
def networks(self, role="all", full="all"):
        """"""
        if full not in ["all", True, False]:
            raise ValueError(
                "full must be boolean or all, it cannot be {}".format(full)
            )

        if full == "all":
            if role == "all":
                return Network.query.all()
            else:
                return Network.query.filter_by(role=role).all()
        else:
            if role == "all":
                return Network.query.filter_by(full=full).all()
            else:
                return Network.query.filter(
                    and_(Network.role == role, Network.full == full)
                ).all()
1267155
def get_links(network_id, template_id=None, **kwargs):
    
    user_id = kwargs.get('user_id')
    try:
        net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
        net_i.check_read_permission(user_id=user_id)
    except NoResultFound:
        raise ResourceNotFoundError("Network %s not found"%(network_id))

    link_qry = db.DBSession.query(Link).filter(
                                        Link.network_id==network_id,
                                        Link.status=='A').options(
                                            noload('network')
                                        ).options(
                                            joinedload_all('types.templatetype')
                                        ).options(
                                            joinedload_all('attributes.attr')
                                        )

    if template_id is not None:
        link_qry = link_qry.filter(ResourceType.link_id==Link.id,
                                   TemplateType.id==ResourceType.type_id,
                                   TemplateType.template_id==template_id)

    links = link_qry.all()
    return links
418619
def get_network_link(self, mapsource):
        
        return kml_network_link(self.url_formatter.get_map_root_url(mapsource),
                                 name=mapsource.name, visible=False)
64455
def net_query(name: str) -> Constants:
    '''
    '''

    for net_params in networks:
        if name in (net_params.name, net_params.shortname,):
            return net_params

    raise UnsupportedNetwork
474297
def get_all_supplier_properties(self, params=None):
        
        if not params:
            params = {}
        return self._iterate_through_pages(
            get_function=self.get_supplier_properties_per_page,
            resource=SUPPLIER_PROPERTIES,
            **{'params': params}
        )
1179968
def _get_network(self):
        '''
        
        '''
        data = dict()
        data['interfaces'] = salt.utils.network.interfaces()
        data['subnets'] = salt.utils.network.subnets()

        return data
85933
def get_ethernet_networks(self):
        
        network_uris = self.data.get('networkUris')
        networks = []
        if network_uris:
            for uri in network_uris:
                networks.append(self._ethernet_networks.get_by_uri(uri))
        return networks
372884
def clean_networks(networks: Iterable[str] = None) -> Optional[Iterable[str]]:
    
    if not networks:
        return networks
    if not isinstance(networks, list):
        raise TypeError("networks parameter must be a list.")

    result = []
    for n in networks:
        if isinstance(n, str):
            n = {"Target": n}
        result.append(n)
    return result