Skip to content

Commit

Permalink
svc-monitor: Avoid NoneType Error in snat_agent.py
Browse files Browse the repository at this point in the history
The method cleanup_snat_instance in svc_monitor/snat_agent.py
can be called with lr_id == None from audit_snat_instances.

If that happens, the Python interpreter crashes since line 282
performs a string concatenation of 'rt_' and None, which does not work.

The proper thing to do in cleanup_snat_instance, when lr_id == None,
seems to be to set rt_obj = None.

Why this state has appeared, if errornous, which I do not know, is IMO
secondary to the code being executable by the interpreter.

Change-Id: I2cf31f956d8992354cc1635c04bc3c807f1db38a
Signed-off-by: Martin Millnert <martin@millnert.se>
Closes-Bug: #1549755
Closes-Bug: #1549637
  • Loading branch information
Millnert authored and rrugge committed Feb 25, 2016
1 parent f97ea9f commit 9ddfbf0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/config/svc-monitor/svc_monitor/snat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,17 @@ def cleanup_snat_instance(self, lr_id, si_id):
return

# Get route table for default route it it exists
rt_name = 'rt_' + lr_id
rt_fq_name = si_obj.get_fq_name()[0:2] + [rt_name]
try:
rt_obj = self._vnc_lib.route_table_read(
fq_name=rt_fq_name,
fields=['virtual_network_back_refs'])
except vnc_exc.NoIdError:
if lr_id is None:
rt_obj = None
else:
rt_name = 'rt_' + lr_id
rt_fq_name = si_obj.get_fq_name()[0:2] + [rt_name]
try:
rt_obj = self._vnc_lib.route_table_read(
fq_name=rt_fq_name,
fields=['virtual_network_back_refs'])
except vnc_exc.NoIdError:
rt_obj = None

# Delete route table
if rt_obj:
Expand Down

0 comments on commit 9ddfbf0

Please sign in to comment.