def delete_port_chain(self, context, portchain_id): pc = self.get_port_chain(context, portchain_id) pc_context = sfc_ctx.PortChainContext(self, context, pc) try: self.driver_manager.delete_port_chain(pc_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error(_LE("Delete port chain failed, portchain '%s'"), portchain_id) # TODO(qijing): unsync in case deleted in driver but fail in database with context.session.begin(subtransactions=True): pc = self.get_port_chain(context, portchain_id) pc_context = sfc_ctx.PortChainContext(self, context, pc) super(SfcPlugin, self).delete_port_chain(context, portchain_id) self.driver_manager.delete_port_chain_precommit(pc_context) self.driver_manager.delete_port_chain_postcommit(pc_context)
def delete_port_chain(self, context, portchain_id): pc = self.get_port_chain(context, portchain_id) pc_context = sfc_ctx.PortChainContext(self, context, pc) try: self.driver_manager.delete_port_chain(pc_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error("Delete port chain failed, portchain '%s'", portchain_id) # TODO(qijing): unsync in case deleted in driver but fail in database with db_api.CONTEXT_WRITER.using(context): pc = self.get_port_chain(context, portchain_id) pc_context = sfc_ctx.PortChainContext(self, context, pc) super(SfcPlugin, self).delete_port_chain(context, portchain_id) self.driver_manager.delete_port_chain_precommit(pc_context) self.driver_manager.delete_port_chain_postcommit(pc_context)
def update_port_pair_group_precommit(self, context, remap=False): self._validate_port_pair_group(context) # Remap Port Chain if needed if remap or self._should_regenerate_ppg(context): for chain in self._get_chains_by_ppg_id(context._plugin_context, context.current['id']): c_ctx = sfc_ctx.PortChainContext(context._plugin, context._plugin_context, chain, chain) self.update_port_chain_precommit(c_ctx, remap=True)
def create_port_chain(self, context, port_chain): port_chain_db = super(SfcPlugin, self).create_port_chain(context, port_chain) portchain_db_context = sfc_ctx.PortChainContext( self, context, port_chain_db) try: self.driver_manager.create_port_chain(portchain_db_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error( _LE("Create port chain failed, " "deleting port_chain '%s'"), port_chain_db['id']) self.delete_port_chain(context, port_chain_db['id']) return port_chain_db
def update_port_chain(self, context, portchain_id, port_chain): original_portchain = self.get_port_chain(context, portchain_id) updated_portchain = super(SfcPlugin, self).update_port_chain( context, portchain_id, port_chain) portchain_db_context = sfc_ctx.PortChainContext( self, context, updated_portchain, original_portchain=original_portchain) try: self.driver_manager.update_port_chain(portchain_db_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error(_LE("Update port chain failed, port_chain '%s'"), updated_portchain['id']) # TODO(qijing): should we rollback the database update here? return updated_portchain
def create_port_chain(self, context, port_chain): with db_api.CONTEXT_WRITER.using(context): port_chain_db = super(SfcPlugin, self).create_port_chain( context, port_chain) portchain_db_context = sfc_ctx.PortChainContext( self, context, port_chain_db) self.driver_manager.create_port_chain_precommit( portchain_db_context) try: self.driver_manager.create_port_chain_postcommit( portchain_db_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error("Create port chain failed, " "deleting port_chain '%s'", port_chain_db['id']) self.delete_port_chain(context, port_chain_db['id']) return port_chain_db