diff --git a/vmware_nsx/plugins/nsx_p/availability_zones.py b/vmware_nsx/plugins/nsx_p/availability_zones.py index 59f8310ed2..edcc849bd1 100644 --- a/vmware_nsx/plugins/nsx_p/availability_zones.py +++ b/vmware_nsx/plugins/nsx_p/availability_zones.py @@ -34,6 +34,10 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone): def get_az_opts(self): return config.get_nsxp_az_opts(self.name) + def init_from_config_section(self, az_name): + super(NsxPAvailabilityZone, self).init_from_config_section(az_name) + #TODO(asarfaty): Add nsx-p specific configs here + def init_defaults(self): # use the default configuration self.metadata_proxy = cfg.CONF.nsx_p.metadata_proxy @@ -134,7 +138,7 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone): self._edge_cluster_uuid = self._init_default_resource( nsxpolicy, nsxpolicy.edge_cluster, 'edge_cluster', - auto_config=True, is_mandatory=False, + auto_config=False, is_mandatory=False, search_scope=search_scope) self.use_policy_md = False diff --git a/vmware_nsx/plugins/nsx_v3/availability_zones.py b/vmware_nsx/plugins/nsx_v3/availability_zones.py index 101ec85e94..ea1f6108d0 100644 --- a/vmware_nsx/plugins/nsx_v3/availability_zones.py +++ b/vmware_nsx/plugins/nsx_v3/availability_zones.py @@ -41,10 +41,6 @@ class NsxV3AvailabilityZone(v3_az.NsxV3AvailabilityZone): if switching_profiles: self.switching_profiles = switching_profiles - edge_cluster = az_info.get('edge_cluster') - if edge_cluster: - self.edge_cluster = edge_cluster - dhcp_relay_service = az_info.get('dhcp_relay_service') if dhcp_relay_service: self.dhcp_relay_service = dhcp_relay_service diff --git a/vmware_nsx/tests/unit/nsx_p/test_availability_zones.py b/vmware_nsx/tests/unit/nsx_p/test_availability_zones.py index c61f54cb37..b009122dc1 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_availability_zones.py +++ b/vmware_nsx/tests/unit/nsx_p/test_availability_zones.py @@ -29,7 +29,7 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase): super(NsxPAvailabilityZonesTestCase, self).setUp() self.az_name = "zone1" self.group_name = "az:%s" % self.az_name - config.register_nsxv3_azs(cfg.CONF, [self.az_name]) + config.register_nsxp_azs(cfg.CONF, [self.az_name]) self.global_md_proxy = uuidutils.generate_uuid() cfg.CONF.set_override( "metadata_proxy", self.global_md_proxy, group="nsx_p") @@ -42,6 +42,7 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase): cfg.CONF.set_override("nameservers", ["10.1.1.1"], group="nsx_p") cfg.CONF.set_override( "default_tier0_router", "uuidrtr1", group="nsx_p") + cfg.CONF.set_override("edge_cluster", "ec1", group="nsx_p") def _config_az(self, metadata_proxy="metadata_proxy1", @@ -51,7 +52,8 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase): nameservers=["20.1.1.1"], default_overlay_tz='otz', default_vlan_tz='vtz', - default_tier0_router="uuidrtr2"): + default_tier0_router="uuidrtr2", + edge_cluster="ec2"): if metadata_proxy is not None: cfg.CONF.set_override("metadata_proxy", metadata_proxy, group=self.group_name) @@ -77,6 +79,9 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase): if default_tier0_router is not None: cfg.CONF.set_override("default_tier0_router", default_tier0_router, group=self.group_name) + if edge_cluster is not None: + cfg.CONF.set_override("edge_cluster", edge_cluster, + group=self.group_name) def test_simple_availability_zone(self): self._config_az() @@ -90,6 +95,7 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase): self.assertEqual("otz", az.default_overlay_tz) self.assertEqual("vtz", az.default_vlan_tz) self.assertEqual("uuidrtr2", az.default_tier0_router) + self.assertEqual("ec2", az.edge_cluster) def test_missing_group_section(self): self.assertRaises( diff --git a/vmware_nsx/tests/unit/nsx_v3/test_availability_zones.py b/vmware_nsx/tests/unit/nsx_v3/test_availability_zones.py index a2e41ad338..eb65684f0d 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_availability_zones.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_availability_zones.py @@ -44,6 +44,7 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase): cfg.CONF.set_override("dhcp_relay_service", "service1", group="nsx_v3") cfg.CONF.set_override( "default_tier0_router", "uuidrtr1", group="nsx_v3") + cfg.CONF.set_override("edge_cluster", "ec1", group="nsx_v3") def _config_az(self, metadata_proxy="metadata_proxy1", @@ -55,7 +56,8 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase): default_vlan_tz='vtz', switching_profiles=["uuid2"], dhcp_relay_service="service2", - default_tier0_router="uuidrtr2"): + default_tier0_router="uuidrtr2", + edge_cluster="ec2"): if metadata_proxy is not None: cfg.CONF.set_override("metadata_proxy", metadata_proxy, group=self.group_name) @@ -87,6 +89,9 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase): if default_tier0_router is not None: cfg.CONF.set_override("default_tier0_router", default_tier0_router, group=self.group_name) + if edge_cluster is not None: + cfg.CONF.set_override("edge_cluster", edge_cluster, + group=self.group_name) def test_simple_availability_zone(self): self._config_az() @@ -102,6 +107,7 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase): self.assertEqual(["uuid2"], az.switching_profiles) self.assertEqual("service2", az.dhcp_relay_service) self.assertEqual("uuidrtr2", az.default_tier0_router) + self.assertEqual("ec2", az.edge_cluster) def test_missing_group_section(self): self.assertRaises(