def delete_port_pair(self, context, portpair_id): portpair = self.get_port_pair(context, portpair_id) portpair_context = sfc_ctx.PortPairContext(self, context, portpair) try: self.driver_manager.delete_port_pair(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error(_LE("Delete port pair failed, port_pair '%s'"), portpair_id) with context.session.begin(subtransactions=True): portpair = self.get_port_pair(context, portpair_id) portpair_context = sfc_ctx.PortPairContext(self, context, portpair) super(SfcPlugin, self).delete_port_pair(context, portpair_id) self.driver_manager.delete_port_pair_precommit(portpair_context) self.driver_manager.delete_port_pair_postcommit(portpair_context)
def delete_port_pair(self, context, portpair_id): portpair = self.get_port_pair(context, portpair_id) portpair_context = sfc_ctx.PortPairContext(self, context, portpair) try: self.driver_manager.delete_port_pair(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error("Delete port pair failed, port_pair '%s'", portpair_id) with db_api.context_manager.writer.using(context): portpair = self.get_port_pair(context, portpair_id) portpair_context = sfc_ctx.PortPairContext(self, context, portpair) super(SfcPlugin, self).delete_port_pair(context, portpair_id) self.driver_manager.delete_port_pair_precommit(portpair_context) self.driver_manager.delete_port_pair_postcommit(portpair_context)
def create_port_pair(self, context, port_pair): portpair_db = super(SfcPlugin, self).create_port_pair(context, port_pair) portpair_context = sfc_ctx.PortPairContext(self, context, portpair_db) try: self.driver_manager.create_port_pair(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error( _LE("Create port pair failed, " "deleting port_pair '%s'"), portpair_db['id']) self.delete_port_pair(context, portpair_db['id']) return portpair_db
def update_port_pair(self, context, portpair_id, port_pair): original_portpair = self.get_port_pair(context, portpair_id) updated_portpair = super(SfcPlugin, self).update_port_pair( context, portpair_id, port_pair) portpair_context = sfc_ctx.PortPairContext( self, context, updated_portpair, original_portpair=original_portpair) try: self.driver_manager.update_port_pair(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error(_LE("Update port pair failed, port_pair '%s'"), updated_portpair['id']) return updated_portpair
def update_port_pair(self, context, portpair_id, port_pair): with db_api.CONTEXT_WRITER.using(context): original_portpair = self.get_port_pair(context, portpair_id) updated_portpair = super(SfcPlugin, self).update_port_pair( context, portpair_id, port_pair) portpair_context = sfc_ctx.PortPairContext( self, context, updated_portpair, original_portpair=original_portpair) self.driver_manager.update_port_pair_precommit(portpair_context) try: self.driver_manager.update_port_pair_postcommit(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error("Update port pair failed, port_pair '%s'", updated_portpair['id']) return updated_portpair
def _handle_port_bound(self, rtype, event, trigger, driver_context, **kwargs): if event == events.PRECOMMIT_UPDATE: context = driver_context p_ctx = driver_context._plugin_context c_host = context.host o_host = context.original_host if c_host and (c_host != o_host): pps = self.sfc_plugin.get_port_pairs( p_ctx, filters={'ingress': [driver_context.current['id']]}) pps.extend( self.sfc_plugin.get_port_pairs( p_ctx, filters={'egress': [driver_context.current['id']]})) for pp in pps: d_ctx = sfc_ctx.PortPairContext(context._plugin, p_ctx, pp, pp) self.update_port_pair_precommit(d_ctx, remap=True)
def create_port_pair(self, context, port_pair): with db_api.CONTEXT_WRITER.using(context): portpair_db = super(SfcPlugin, self).create_port_pair( context, port_pair) portpair_context = sfc_ctx.PortPairContext( self, context, portpair_db) self.driver_manager.create_port_pair_precommit(portpair_context) try: self.driver_manager.create_port_pair_postcommit(portpair_context) except sfc_exc.SfcDriverError as e: LOG.exception(e) with excutils.save_and_reraise_exception(): LOG.error("Create port pair failed, " "deleting port_pair '%s'", portpair_db['id']) self.delete_port_pair(context, portpair_db['id']) return portpair_db
def _get_ctx(self, cls, kwargs): return sfc_ctx.PortPairContext( self.sfc_plugin, self.ctx, kwargs, )