V and D: make security group logging more robust

Prevent exceptions

Change-Id: I1a318347f92d6d793768dd20d653c872a3f75da3
(cherry picked from commit 8960282459)
(cherry picked from commit c9e0278f8a)
This commit is contained in:
Gary Kotton 2018-01-21 01:53:27 -08:00 committed by garyk
parent c1628f674c
commit 152b21f526
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

@ -495,7 +495,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: