Ejemplo n.º 1
0
    def update_port_pair_group(self, context, portpairgroup_id,
                               port_pair_group):
        with context.session.begin(subtransactions=True):
            original_portpairgroup = self.get_port_pair_group(
                context, portpairgroup_id)
            updated_portpairgroup = super(SfcPlugin,
                                          self).update_port_pair_group(
                                              context, portpairgroup_id,
                                              port_pair_group)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self,
                context,
                updated_portpairgroup,
                original_portpairgroup=original_portpairgroup)
            self.driver_manager.update_port_pair_group_precommit(
                portpairgroup_context)
        try:
            self.driver_manager.update_port_pair_group_postcommit(
                portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error(
                    _LE("Update port pair group failed, "
                        "port_pair_group '%s'"), updated_portpairgroup['id'])

        return updated_portpairgroup
Ejemplo n.º 2
0
    def update_port_pair_group(
        self, context, portpairgroup_id, port_pair_group
    ):
        with db_api.CONTEXT_WRITER.using(context):
            original_portpairgroup = self.get_port_pair_group(
                context, portpairgroup_id)
            updated_portpairgroup = super(
                SfcPlugin, self).update_port_pair_group(
                context, portpairgroup_id, port_pair_group)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, updated_portpairgroup,
                original_portpairgroup=original_portpairgroup)
            self.driver_manager.update_port_pair_group_precommit(
                portpairgroup_context)
        try:
            self.driver_manager.update_port_pair_group_postcommit(
                portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Update port pair group failed, "
                          "port_pair_group '%s'",
                          updated_portpairgroup['id'])

        return updated_portpairgroup
Ejemplo n.º 3
0
 def update_port_pair_precommit(self, context, remap=False):
     self._validate_port_pair(context)
     p_ctx = context._plugin_context
     # Remap the affected groups if needed.
     if remap or self._should_regenerate_pp(context):
         for group in self._get_groups_by_pair_id(p_ctx,
                                                  context.current['id']):
             # Curr and original are identical, so the same object gets
             # remapped.
             g_ctx = sfc_ctx.PortPairGroupContext(context._plugin, p_ctx,
                                                  group, group)
             self.update_port_pair_group_precommit(g_ctx, remap=True)
Ejemplo n.º 4
0
    def delete_port_pair_group(self, context, portpairgroup_id):
        portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
        portpairgroup_context = sfc_ctx.PortPairGroupContext(
            self, context, portpairgroup)
        try:
            self.driver_manager.delete_port_pair_group(portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error(
                    _LE("Delete port pair group failed, "
                        "port_pair_group '%s'"), portpairgroup_id)

        with context.session.begin(subtransactions=True):
            portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, portpairgroup)
            super(SfcPlugin,
                  self).delete_port_pair_group(context, portpairgroup_id)
            self.driver_manager.delete_port_pair_group_precommit(
                portpairgroup_context)
        self.driver_manager.delete_port_pair_group_postcommit(
            portpairgroup_context)
Ejemplo n.º 5
0
    def delete_port_pair_group(self, context, portpairgroup_id):
        portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
        portpairgroup_context = sfc_ctx.PortPairGroupContext(
            self, context, portpairgroup)
        try:
            self.driver_manager.delete_port_pair_group(portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error(
                    "Delete port pair group failed, "
                    "port_pair_group '%s'", portpairgroup_id)

        with db_api.context_manager.writer.using(context):
            portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, portpairgroup)
            super(SfcPlugin,
                  self).delete_port_pair_group(context, portpairgroup_id)
            self.driver_manager.delete_port_pair_group_precommit(
                portpairgroup_context)
        self.driver_manager.delete_port_pair_group_postcommit(
            portpairgroup_context)
Ejemplo n.º 6
0
    def create_port_pair_group(self, context, port_pair_group):
        portpairgroup_db = super(SfcPlugin, self).create_port_pair_group(
            context, port_pair_group)
        portpairgroup_context = sfc_ctx.PortPairGroupContext(
            self, context, portpairgroup_db)
        try:
            self.driver_manager.create_port_pair_group(portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error(
                    _LE("Create port pair group failed, "
                        "deleting port_pair_group '%s'"),
                    portpairgroup_db['id'])
                self.delete_port_pair_group(context, portpairgroup_db['id'])

        return portpairgroup_db