V and D: make security group logging more robust

Prevent exceptions

Change-Id: I1a318347f92d6d793768dd20d653c872a3f75da3
(cherry picked from commit 8960282459)
This commit is contained in:
Gary Kotton 2018-01-21 01:53:27 -08:00 committed by garyk
parent a64c821955
commit c9e0278f8a
2 changed files with 2 additions and 2 deletions

View File

@ -526,7 +526,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# If the section/sg is already logged, then no action is
# required.
for sg in [sg for sg in self.get_security_groups(context)
if sg[sg_logging.LOGGING] is False]:
if sg.get(sg_logging.LOGGING) is False]:
if sg.get(sg_policy.POLICY):
# Logging is not relevant with a policy
continue

View File

@ -656,7 +656,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
fields=['id',
sg_logging.LOGGING])
for sg in [sg for sg in secgroups
if sg[sg_logging.LOGGING] is False]:
if sg.get(sg_logging.LOGGING) is False]:
nsgroup_id, section_id = nsx_db.get_sg_mappings(
context.session, sg['id'])
try: