def _provision_tenant_private_network(self, context, tenant_id): """Create a tenant private network/subnets.""" network = None try: network_args = { 'name': 'auto_allocated_network', 'admin_state_up': True, 'tenant_id': tenant_id, 'shared': False } network = p_utils.create_network( self.core_plugin, context, {'network': network_args}) subnets = [] for pool in self._get_supported_subnetpools(context): subnet_args = { 'name': 'auto_allocated_subnet_v%s' % pool['ip_version'], 'network_id': network['id'], 'tenant_id': tenant_id, 'ip_version': pool['ip_version'], 'subnetpool_id': pool['id'], } subnets.append(p_utils.create_subnet( self.core_plugin, context, {'subnet': subnet_args})) return subnets except (ValueError, n_exc.BadRequest, n_exc.NotFound): LOG.error(_LE("Unable to auto allocate topology for tenant " "%s due to missing requirements, e.g. default " "or shared subnetpools"), tenant_id) if network: self._cleanup(context, network['id']) raise exceptions.AutoAllocationFailure( reason=_("Unable to provide tenant private network"))
def _create_ha_network(self, context, tenant_id): admin_ctx = context.elevated() args = {'network': {'name': constants.HA_NETWORK_NAME % tenant_id, 'tenant_id': '', 'shared': False, 'admin_state_up': True}} self._add_ha_network_settings(args['network']) network = p_utils.create_network(self._core_plugin, admin_ctx, args) try: ha_network = self._create_ha_network_tenant_binding(admin_ctx, tenant_id, network['id']) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network['id']) try: self._create_ha_subnet(admin_ctx, network['id'], tenant_id) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network['id']) return ha_network
def _create_ha_network(self, context, tenant_id): admin_ctx = context.elevated() args = { 'network': { 'name': constants.HA_NETWORK_NAME % tenant_id, 'tenant_id': '', 'shared': False, 'admin_state_up': True } } self._add_ha_network_settings(args['network']) network = p_utils.create_network(self._core_plugin, admin_ctx, args) try: ha_network = self._create_ha_network_tenant_binding( admin_ctx, tenant_id, network['id']) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network['id']) try: self._create_ha_subnet(admin_ctx, network['id'], tenant_id) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network['id']) return ha_network
def _create_ha_network(self, context, tenant_id): admin_ctx = context.elevated() args = { "network": { "name": constants.HA_NETWORK_NAME % tenant_id, "tenant_id": "", "shared": False, "admin_state_up": True, } } self._add_ha_network_settings(args["network"]) network = p_utils.create_network(self._core_plugin, admin_ctx, args) try: ha_network = self._create_ha_network_tenant_binding(admin_ctx, tenant_id, network["id"]) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network["id"]) try: self._create_ha_subnet(admin_ctx, network["id"], tenant_id) except Exception: with excutils.save_and_reraise_exception(): self._core_plugin.delete_network(admin_ctx, network["id"]) return ha_network
def _provision_tenant_private_network(self, context, tenant_id): """Create a tenant private network/subnets. CCloud specific: use specific cidr range instead of default subnetpool """ network = None try: network_args = { 'name': 'auto_allocated_network', 'admin_state_up': False, 'tenant_id': tenant_id, 'shared': False } network = p_utils.create_network(self.core_plugin, context, {'network': network_args}) subnets = [] subnet_args = { 'name': 'auto_allocated_subnet_v4', 'network_id': network['id'], 'tenant_id': tenant_id, 'ip_version': 4, 'cidr': '10.180.0.0/24', } subnets.append( p_utils.create_subnet(self.core_plugin, context, {'subnet': subnet_args})) return subnets except (c_exc.SubnetAllocationError, ValueError, n_exc.BadRequest, n_exc.NotFound) as e: LOG.error( "Unable to auto allocate topology for tenant " "%(tenant_id)s due to missing or unmet " "requirements. Reason: %(reason)s", { 'tenant_id': tenant_id, 'reason': e }) if network: self._cleanup(context, network['id']) raise exceptions.AutoAllocationFailure( reason=_("Unable to provide tenant private network")) except Exception as e: network_id = network['id'] if network else None raise exceptions.UnknownProvisioningError(e, network_id=network_id)
def _provision_tenant_private_network(self, context, tenant_id): """Create a tenant private network/subnets.""" network = None try: network_args = { 'name': 'auto_allocated_network', 'admin_state_up': False, 'tenant_id': tenant_id, 'shared': False } network = p_utils.create_network( self.core_plugin, context, {'network': network_args}) subnets = [] for pool in self._get_supported_subnetpools(context): subnet_args = { 'name': 'auto_allocated_subnet_v%s' % pool['ip_version'], 'network_id': network['id'], 'tenant_id': tenant_id, 'ip_version': pool['ip_version'], 'subnetpool_id': pool['id'], } subnets.append(p_utils.create_subnet( self.core_plugin, context, {'subnet': subnet_args})) return subnets except (c_exc.SubnetAllocationError, ValueError, n_exc.BadRequest, n_exc.NotFound) as e: LOG.error(_LE("Unable to auto allocate topology for tenant " "%(tenant_id)s due to missing or unmet " "requirements. Reason: %(reason)s"), {'tenant_id': tenant_id, 'reason': e}) if network: self._cleanup(context, network['id']) raise exceptions.AutoAllocationFailure( reason=_("Unable to provide tenant private network")) except Exception as e: network_id = network['id'] if network else None raise exceptions.UnknownProvisioningError(e, network_id=network_id)
def _provision_tenant_private_network(self, context, tenant_id): """Create a tenant private network/subnets.""" network = None try: network_args = { "name": "auto_allocated_network", "admin_state_up": False, "tenant_id": tenant_id, "shared": False, } network = p_utils.create_network(self.core_plugin, context, {"network": network_args}) subnets = [] for pool in self._get_supported_subnetpools(context): subnet_args = { "name": "auto_allocated_subnet_v%s" % pool["ip_version"], "network_id": network["id"], "tenant_id": tenant_id, "ip_version": pool["ip_version"], "subnetpool_id": pool["id"], } subnets.append(p_utils.create_subnet(self.core_plugin, context, {"subnet": subnet_args})) return subnets except (c_exc.SubnetAllocationError, ValueError, n_exc.BadRequest, n_exc.NotFound) as e: LOG.error( _LE( "Unable to auto allocate topology for tenant " "%(tenant_id)s due to missing or unmet " "requirements. Reason: %(reason)s" ), {"tenant_id": tenant_id, "reason": e}, ) if network: self._cleanup(context, network["id"]) raise exceptions.AutoAllocationFailure(reason=_("Unable to provide tenant private network")) except Exception as e: network_id = network["id"] if network else None raise exceptions.UnknownProvisioningError(e, network_id=network_id)