Пример #1
0
 def add_ha_port(self, context, router_id, network_id, tenant_id):
     # NOTE(kevinbenton): we have to block any ongoing transactions because
     # our exception handling will try to delete the port using the normal
     # core plugin API. If this function is called inside of a transaction
     # the exception will mangle the state, cause the delete call to fail,
     # and end up relying on the DB rollback to remove the port instead of
     # proper delete_port call.
     if context.session.is_active:
         raise RuntimeError(_('add_ha_port cannot be called inside of a '
                              'transaction.'))
     args = {'tenant_id': '',
             'network_id': network_id,
             'admin_state_up': True,
             'device_id': router_id,
             'device_owner': constants.DEVICE_OWNER_ROUTER_HA_INTF,
             'name': n_const.HA_PORT_NAME % tenant_id}
     creation = functools.partial(p_utils.create_port, self._core_plugin,
                                  context, {'port': args})
     content = functools.partial(self._create_ha_port_binding, context,
                                 router_id)
     deletion = functools.partial(self._core_plugin.delete_port, context,
                                  l3_port_check=False)
     port, bindings = common_db_mixin.safe_creation(context, creation,
                                                    deletion, content,
                                                    transaction=False)
     return bindings
Пример #2
0
    def _create_ha_network(self, context, tenant_id):
        admin_ctx = context.elevated()

        args = {'network':
                {'name': n_const.HA_NETWORK_NAME % tenant_id,
                 'tenant_id': '',
                 'shared': False,
                 'admin_state_up': True}}
        self._add_ha_network_settings(args['network'])
        creation = functools.partial(p_utils.create_network,
                                     self._core_plugin, admin_ctx, args)
        content = functools.partial(self._create_ha_network_tenant_binding,
                                    admin_ctx, tenant_id)
        deletion = functools.partial(self._core_plugin.delete_network,
                                     admin_ctx)

        network, ha_network = common_db_mixin.safe_creation(
            context, creation, deletion, content, transaction=False)
        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
Пример #3
0
 def add_ha_port(self, context, router_id, network_id, tenant_id):
     # NOTE(kevinbenton): we have to block any ongoing transactions because
     # our exception handling will try to delete the port using the normal
     # core plugin API. If this function is called inside of a transaction
     # the exception will mangle the state, cause the delete call to fail,
     # and end up relying on the DB rollback to remove the port instead of
     # proper delete_port call.
     if context.session.is_active:
         raise RuntimeError(
             _('add_ha_port cannot be called inside of a '
               'transaction.'))
     args = {
         'tenant_id': '',
         'network_id': network_id,
         'admin_state_up': True,
         'device_id': router_id,
         'device_owner': constants.DEVICE_OWNER_ROUTER_HA_INTF,
         'name': constants.HA_PORT_NAME % tenant_id
     }
     creation = functools.partial(p_utils.create_port, self._core_plugin,
                                  context, {'port': args})
     content = functools.partial(self._create_ha_port_binding, context,
                                 router_id)
     deletion = functools.partial(self._core_plugin.delete_port,
                                  context,
                                  l3_port_check=False)
     port, bindings = common_db_mixin.safe_creation(context,
                                                    creation,
                                                    deletion,
                                                    content,
                                                    transaction=False)
     return bindings
Пример #4
0
    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'])
        creation = functools.partial(p_utils.create_network, self._core_plugin,
                                     admin_ctx, args)
        content = functools.partial(self._create_ha_network_tenant_binding,
                                    admin_ctx, tenant_id)
        deletion = functools.partial(self._core_plugin.delete_network,
                                     admin_ctx)

        network, ha_network = common_db_mixin.safe_creation(context,
                                                            creation,
                                                            deletion,
                                                            content,
                                                            transaction=False)
        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
Пример #5
0
    def add_ha_port(self, context, router_id, network_id, tenant_id):
        args = {'tenant_id': '',
                'network_id': network_id,
                'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
                'mac_address': attributes.ATTR_NOT_SPECIFIED,
                'admin_state_up': True,
                'device_id': router_id,
                'device_owner': constants.DEVICE_OWNER_ROUTER_HA_INTF,
                'name': constants.HA_PORT_NAME % tenant_id}

        creation = functools.partial(self._core_plugin.create_port,
                                     context, {'port': args})
        content = functools.partial(self._create_ha_port_binding, context,
                                    router_id)
        deletion = functools.partial(self._core_plugin.delete_port, context,
                                     l3_port_check=False)
        port, bindings = common_db_mixin.safe_creation(context, creation,
                                                       deletion, content)
        return bindings
Пример #6
0
    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"])
        creation = functools.partial(p_utils.create_network, self._core_plugin, admin_ctx, args)
        content = functools.partial(self._create_ha_network_tenant_binding, admin_ctx, tenant_id)
        deletion = functools.partial(self._core_plugin.delete_network, admin_ctx)

        network, ha_network = common_db_mixin.safe_creation(context, creation, deletion, content)
        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