def lsn_port_get(self, context, network_id, subnet_id, raise_on_err=True): try: obj = lsn_db.lsn_port_get_for_subnet( context, subnet_id, raise_on_err=raise_on_err) return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None) except p_exc.LsnPortNotFound: with excutils.save_and_reraise_exception() as ctxt: ctxt.reraise = False if self.sync_on_missing: lsn_id, lsn_port_id = ( super(PersistentLsnManager, self).lsn_port_get( context, network_id, subnet_id, raise_on_err=raise_on_err)) mac_addr = lsn_api.lsn_port_info_get( self.cluster, lsn_id, lsn_port_id)['mac_address'] self.lsn_port_save( context, lsn_port_id, subnet_id, mac_addr, lsn_id) return (lsn_id, lsn_port_id) if raise_on_err: ctxt.reraise = True
def test_lsn_port_get_for_subnet(self): lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id) lsn_db.lsn_port_add_for_lsn(self.ctx, self.lsn_port_id, self.subnet_id, self.mac_addr, self.lsn_id) result = lsn_db.lsn_port_get_for_subnet(self.ctx, self.subnet_id) self.assertEqual(self.subnet_id, result.sub_id)