def create_network_segment(self, network, network_profile, vsm_ip=None):
        body = {'publishName': network['id'],
                'description': network['name'],
                'id': network['id'],
                'tenantId': network['tenant_id'],
                'mode': 'access',
                'segmentType': network_profile['segment_type'],
                'networkSegmentPool': network_profile['id']}
        # Override tenantId if network is shared
        if network['shared']:
            body['tenantId'] = '0'
        if network[providernet.NETWORK_TYPE] == p_const.TYPE_VLAN:
            body['vlan'] = network[providernet.SEGMENTATION_ID]
        elif network[providernet.NETWORK_TYPE] == p_const.TYPE_VXLAN:
            # Create a bridge domain on VSM
            bd_name = network['id'] + n1kv_const.BRIDGE_DOMAIN_SUFFIX
            self.create_bridge_domain(network, network_profile, vsm_ip=vsm_ip)
            body['bridgeDomain'] = bd_name
        try:
            return self._post(self.network_segment_path % network['id'],
                              body=body, vsm_ip=vsm_ip)
        except(n1kv_exc.VSMError, n1kv_exc.VSMConnectionFailed):
            with excutils.save_and_reraise_exception():
                # Clean up the bridge domain from the VSM for VXLAN networks.
                # Reraise the exception so that caller method executes further
                # clean up.
                if network[providernet.NETWORK_TYPE] == p_const.TYPE_VXLAN:
                    self.delete_bridge_domain(bd_name, vsm_ip=vsm_ip)
Create a network segment on the VSM.
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/plugins/ml2/drivers/cisco/n1kv/n1kv_client.py/Client.create_network_segment