NSX-V3| Fix AZ when native dhcp is disabled

When native dhcp is disabled, the default availability zone is defined,
but the profile ids can be None. Avoid crashing in this case.

Change-Id: If16b9e31fe6b9b983f58bbb90d4293081f9f8b22
This commit is contained in:
Adit Sarfaty 2017-03-27 09:15:16 +03:00
parent 6228a06399
commit 826b9eb1b2
1 changed files with 19 additions and 9 deletions

View File

@ -86,17 +86,27 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
def translate_configured_names_to_uuids(self, nsxlib): def translate_configured_names_to_uuids(self, nsxlib):
# Mandatory configurations (in AZ or inherited from global values) # Mandatory configurations (in AZ or inherited from global values)
dhcp_id = nsxlib.native_dhcp_profile.get_id_by_name_or_id( # Unless this is the default AZ, and metadata is disabled.
self.dhcp_profile) if self.dhcp_profile:
self._native_dhcp_profile_uuid = dhcp_id dhcp_id = nsxlib.native_dhcp_profile.get_id_by_name_or_id(
self.dhcp_profile)
self._native_dhcp_profile_uuid = dhcp_id
else:
self._native_dhcp_profile_uuid = None
proxy_id = nsxlib.native_md_proxy.get_id_by_name_or_id( if self.metadata_proxy:
self.metadata_proxy) proxy_id = nsxlib.native_md_proxy.get_id_by_name_or_id(
self._native_md_proxy_uuid = proxy_id self.metadata_proxy)
self._native_md_proxy_uuid = proxy_id
else:
self._native_md_proxy_uuid = None
tz_id = nsxlib.transport_zone.get_id_by_name_or_id( if self.default_overlay_tz:
self.default_overlay_tz) tz_id = nsxlib.transport_zone.get_id_by_name_or_id(
self._default_overlay_tz_uuid = tz_id self.default_overlay_tz)
self._default_overlay_tz_uuid = tz_id
else:
self._default_overlay_tz_uuid = None
# Optional configurations (may be None) # Optional configurations (may be None)
if self.default_vlan_tz: if self.default_vlan_tz: