def create_service_network(self, tenant_name, network, subnet,
                               dhcp_range=True):
        """Create network on the DCNM.

        :param tenant_name: name of tenant the network belongs to
        :param network: network parameters
        :param subnet: subnet parameters of the network
        """
        network_info = {}
        subnet_ip_mask = subnet.cidr.split('/')
        if self._default_md is None:
            self._set_default_mobility_domain()
        vlan_id = '0'
        gw_ip = subnet.gateway_ip
        part_name = network.part_name
        if not part_name:
            part_name = self._part_name

        if network.vlan_id:
            vlan_id = str(network.vlan_id)
            if network.mob_domain_name is not None:
                mob_domain_name = network.mob_domain_name
            else:
                mob_domain_name = self._default_md
        else:
            mob_domain_name = None

        seg_id = str(network.segmentation_id)
        seg_str = "$segmentId=" + seg_id
        cfg_args = [
            seg_str,
            "$netMaskLength=" + subnet_ip_mask[1],
            "$gatewayIpAddress=" + gw_ip,
            "$networkName=" + network.name,
            "$vlanId=" + vlan_id,
            "$vrfName=" + tenant_name + ':' + part_name
        ]
        cfg_args = ';'.join(cfg_args)

        ip_range = ','.join(["%s-%s" % (p['start'], p['end']) for p in
                             subnet.allocation_pools])

        dhcp_scopes = {'ipRange': ip_range,
                       'subnet': subnet.cidr,
                       'gateway': gw_ip}

        network_info = {"vlanId": vlan_id,
                        "mobilityDomainId": mob_domain_name,
                        "profileName": network.config_profile,
                        "networkName": network.name,
                        "configArg": cfg_args,
                        "organizationName": tenant_name,
                        "partitionName": part_name,
                        "description": network.name,
                        "netmaskLength": subnet_ip_mask[1],
                        "gateway": gw_ip}
        if seg_id:
            network_info["segmentId"] = seg_id
        if dhcp_range:
            network_info["dhcpScope"] = dhcp_scopes
        if hasattr(subnet, 'secondary_gw'):
            network_info["secondaryGateway"] = subnet.secondary_gw
        if self._is_iplus:
            # Need to add the vrf name to the network info
            prof = self._config_profile_get(network.config_profile)
            if prof and prof.get('profileSubType') == 'network:universal':
                # For universal profile vrf has to e organization:partition
                network_info["vrfName"] = ':'.join((tenant_name, part_name))
            else:
                # Otherwise, it should be left empty.
                network_info["vrfName"] = ""

        LOG.info("Creating %s network in DCNM.", network_info)

        res = self._create_network(network_info)
        if res and res.status_code in self._resp_ok:
            LOG.info("Created %s network in DCNM.", network_info)
        else:
            LOG.error("Failed to create %s network in DCNM.",
                      network_info)
            raise dexc.DfaClientRequestFailed(reason=self._failure_msg(res))
def create_service_network ( self , tenant_name , network , subnet , dhcp_range = True ) : network_info = { } subnet_ip_mask = subnet . cidr . split ( '/' ) if self . _default_md is None : self . _set_default_mobility_domain ( ) vlan_id = '0' gw_ip = subnet . gateway_ip part_name = network . part_name if not part_name : part_name = self . _part_name if network . vlan_id : vlan_id = str ( network . vlan_id ) if network . mob_domain_name is not None : mob_domain_name = network . mob_domain_name else : mob_domain_name = self . _default_md else : mob_domain_name = None seg_id = str ( network . segmentation_id ) seg_str = "$segmentId=" + seg_id cfg_args = [ seg_str , "$netMaskLength=" + subnet_ip_mask [ 1 ] , "$gatewayIpAddress=" + gw_ip , "$networkName=" + network . name , "$vlanId=" + vlan_id , "$vrfName=" + tenant_name + ':' + part_name ] cfg_args = ';' . join ( cfg_args ) ip_range = ',' . join ( [ "%s-%s" % ( p [ 'start' ] , p [ 'end' ] ) for p in subnet . allocation_pools ] ) dhcp_scopes = { 'ipRange' : ip_range , 'subnet' : subnet . cidr , 'gateway' : gw_ip } network_info = { "vlanId" : vlan_id , "mobilityDomainId" : mob_domain_name , "profileName" : network . config_profile , "networkName" : network . name , "configArg" : cfg_args , "organizationName" : tenant_name , "partitionName" : part_name , "description" : network . name , "netmaskLength" : subnet_ip_mask [ 1 ] , "gateway" : gw_ip } if seg_id : network_info [ "segmentId" ] = seg_id if dhcp_range : network_info [ "dhcpScope" ] = dhcp_scopes if hasattr ( subnet , 'secondary_gw' ) : network_info [ "secondaryGateway" ] = subnet . secondary_gw if self . _is_iplus : prof = self . _config_profile_get ( network . config_profile ) if prof and prof . get ( 'profileSubType' ) == 'network:universal' : network_info [ "vrfName" ] = ':' . join ( ( tenant_name , part_name ) ) else : network_info [ "vrfName" ] = "" LOG . info ( "Creating %s network in DCNM." , network_info ) res = self . _create_network ( network_info ) if res and res . status_code in self . _resp_ok : LOG . info ( "Created %s network in DCNM." , network_info ) else : LOG . error ( "Failed to create %s network in DCNM." , network_info ) raise dexc . DfaClientRequestFailed ( reason = self . _failure_msg ( res ) )
Create network on the DCNM.

        :param tenant_name: name of tenant the network belongs to
        :param network: network parameters
        :param subnet: subnet parameters of the network