def create_mtz_network_subnet(self,
                                  scope_id,
                                  tenant_project_id,
                                  cidr=None,
                                  cidr_offset=0):
        """MTZ networks can only be created by ADMIN

        All tenant network resources will be created by ADMIN.
        """
        networks_client = self.admin_manager.networks_client
        subnets_client = self.admin_manager.subnets_client
        network_name = data_utils.rand_name('mtz-net')
        create_body = {
            'name': network_name,
            'provider:network_type': self.provider_network_type,
            'provider:physical_network': scope_id
        }
        network = HELO.create_network(self,
                                      client=networks_client,
                                      tenant_id=tenant_project_id,
                                      **create_body)
        subnet = HELO.create_subnet(self,
                                    network,
                                    client=subnets_client,
                                    name=network_name,
                                    tenant_id=tenant_project_id,
                                    cidr=cidr,
                                    cidr_offset=cidr_offset)
        lswitch_list = self.vsm.get_all_logical_switches(scope_id)
        lswitch_list = [x for x in lswitch_list if x['name'] == network['id']]
        msg = ("network=%s is not configured by specified vdn_scope_id=%s" %
               (network['id'], scope_id))
        self.assertTrue(len(lswitch_list) == 1, msg=msg)
        return (network['id'], network, subnet)
Beispiel #2
0
 def create_subnet(self,
                   network,
                   client=None,
                   gateway='',
                   cidr=None,
                   mask_bits=None,
                   ip_version=None,
                   cidr_offset=0,
                   allocation_pools=None,
                   dns_nameservers=None,
                   **kwargs):
     subnets_client = client or self.subnets_client
     kwargs.update(client=subnets_client,
                   gateway=gateway,
                   cidr=cidr,
                   cidr_offset=cidr_offset,
                   mask_bits=mask_bits,
                   ip_version=ip_version,
                   allocation_pools=allocation_pools,
                   dns_nameservers=dns_nameservers)
     return HELO.create_subnet(self, network, **kwargs)