Пример #1
0
 def _save(self, context, tenant_id, network_id, router_id, subnets):
     """Save auto-allocated topology, or revert in case of DB errors."""
     try:
         # NOTE(armax): saving the auto allocated topology in a
         # separate transaction will keep the Neutron DB and the
         # Neutron plugin backend in sync, thus allowing for a
         # more bullet proof cleanup.
         with context.session.begin(subtransactions=True):
             context.session.add(
                 models.AutoAllocatedTopology(
                     tenant_id=tenant_id,
                     network_id=network_id,
                     router_id=router_id))
     except db_exc.DBDuplicateEntry:
         LOG.error(_LE("Multiple auto-allocated networks detected for "
                       "tenant %(tenant)s. Attempting clean up for "
                       "network %(network)s and router %(router)s"),
                   {'tenant': tenant_id,
                    'network': network_id,
                    'router': router_id})
         self._cleanup(
             context, network_id=network_id,
             router_id=router_id, subnets=subnets)
         network_id = self._get_auto_allocated_network(
             context, tenant_id)
     return network_id
Пример #2
0
 def _save(self, context, tenant_id, network_id, router_id, subnets):
     """Save auto-allocated topology, or revert in case of DB errors."""
     try:
         # NOTE(armax): saving the auto allocated topology in a
         # separate transaction will keep the Neutron DB and the
         # Neutron plugin backend in sync, thus allowing for a
         # more bullet proof cleanup. Any other error will have
         # to bubble up.
         with context.session.begin(subtransactions=True):
             context.session.add(
                 models.AutoAllocatedTopology(
                     tenant_id=tenant_id,
                     network_id=network_id,
                     router_id=router_id))
         self.core_plugin.update_network(
             context, network_id,
             {'network': {'admin_state_up': True}})
     except db_exc.DBDuplicateEntry:
         LOG.debug("Multiple auto-allocated networks detected for "
                   "tenant %s. Attempting clean up for network %s "
                   "and router %s.",
                   tenant_id, network_id, router_id)
         self._cleanup(
             context, network_id=network_id,
             router_id=router_id, subnets=subnets)
         network_id = self._get_auto_allocated_network(context, tenant_id)
     except Exception as e:
         raise exceptions.UnknownProvisioningError(
             e, network_id=network_id,
             router_id=router_id, subnets=subnets)
     return network_id