[NSX-V] Ensure binding exists before assigning lswitch_id

When fetching router bindings, make sure the binding exists
before accessing its properties

Change-Id: I6e1a4af530394444f5513df1f606d8bc62cc7c2d
This commit is contained in:
Salvatore Orlando 2019-02-05 13:42:35 -08:00
parent a92b6c88c8
commit c8768e34da
1 changed files with 5 additions and 2 deletions

View File

@ -1590,8 +1590,11 @@ class EdgeManager(object):
raise nsx_exc.NsxPluginException(err_msg=error)
def get_plr_by_tlr_id(self, context, router_id):
lswitch_id = nsxv_db.get_nsxv_router_binding(
context.session, router_id).lswitch_id
lswitch_id = None
binding = nsxv_db.get_nsxv_router_binding(
context.session, router_id)
if binding:
lswitch_id = binding.lswitch_id
if lswitch_id:
edge_vnic_bindings = nsxv_db.get_edge_vnic_bindings_by_int_lswitch(
context.session, lswitch_id)