Fix availability zones unit tests
+ some cleanup in v3/p/common availability zones code. Change-Id: I8b5475e0e92ad3fbddc56ac1ee416146d0dfb2f7
This commit is contained in:
parent
e796a00e40
commit
df2dc98c8f
@ -34,6 +34,10 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||||||
def get_az_opts(self):
|
def get_az_opts(self):
|
||||||
return config.get_nsxp_az_opts(self.name)
|
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):
|
def init_defaults(self):
|
||||||
# use the default configuration
|
# use the default configuration
|
||||||
self.metadata_proxy = cfg.CONF.nsx_p.metadata_proxy
|
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(
|
self._edge_cluster_uuid = self._init_default_resource(
|
||||||
nsxpolicy, nsxpolicy.edge_cluster, 'edge_cluster',
|
nsxpolicy, nsxpolicy.edge_cluster, 'edge_cluster',
|
||||||
auto_config=True, is_mandatory=False,
|
auto_config=False, is_mandatory=False,
|
||||||
search_scope=search_scope)
|
search_scope=search_scope)
|
||||||
|
|
||||||
self.use_policy_md = False
|
self.use_policy_md = False
|
||||||
|
@ -41,10 +41,6 @@ class NsxV3AvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||||||
if switching_profiles:
|
if switching_profiles:
|
||||||
self.switching_profiles = 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')
|
dhcp_relay_service = az_info.get('dhcp_relay_service')
|
||||||
if dhcp_relay_service:
|
if dhcp_relay_service:
|
||||||
self.dhcp_relay_service = dhcp_relay_service
|
self.dhcp_relay_service = dhcp_relay_service
|
||||||
|
@ -29,7 +29,7 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
super(NsxPAvailabilityZonesTestCase, self).setUp()
|
super(NsxPAvailabilityZonesTestCase, self).setUp()
|
||||||
self.az_name = "zone1"
|
self.az_name = "zone1"
|
||||||
self.group_name = "az:%s" % self.az_name
|
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()
|
self.global_md_proxy = uuidutils.generate_uuid()
|
||||||
cfg.CONF.set_override(
|
cfg.CONF.set_override(
|
||||||
"metadata_proxy", self.global_md_proxy, group="nsx_p")
|
"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("nameservers", ["10.1.1.1"], group="nsx_p")
|
||||||
cfg.CONF.set_override(
|
cfg.CONF.set_override(
|
||||||
"default_tier0_router", "uuidrtr1", group="nsx_p")
|
"default_tier0_router", "uuidrtr1", group="nsx_p")
|
||||||
|
cfg.CONF.set_override("edge_cluster", "ec1", group="nsx_p")
|
||||||
|
|
||||||
def _config_az(self,
|
def _config_az(self,
|
||||||
metadata_proxy="metadata_proxy1",
|
metadata_proxy="metadata_proxy1",
|
||||||
@ -51,7 +52,8 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
nameservers=["20.1.1.1"],
|
nameservers=["20.1.1.1"],
|
||||||
default_overlay_tz='otz',
|
default_overlay_tz='otz',
|
||||||
default_vlan_tz='vtz',
|
default_vlan_tz='vtz',
|
||||||
default_tier0_router="uuidrtr2"):
|
default_tier0_router="uuidrtr2",
|
||||||
|
edge_cluster="ec2"):
|
||||||
if metadata_proxy is not None:
|
if metadata_proxy is not None:
|
||||||
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
||||||
group=self.group_name)
|
group=self.group_name)
|
||||||
@ -77,6 +79,9 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
if default_tier0_router is not None:
|
if default_tier0_router is not None:
|
||||||
cfg.CONF.set_override("default_tier0_router", default_tier0_router,
|
cfg.CONF.set_override("default_tier0_router", default_tier0_router,
|
||||||
group=self.group_name)
|
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):
|
def test_simple_availability_zone(self):
|
||||||
self._config_az()
|
self._config_az()
|
||||||
@ -90,6 +95,7 @@ class NsxPAvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
self.assertEqual("otz", az.default_overlay_tz)
|
self.assertEqual("otz", az.default_overlay_tz)
|
||||||
self.assertEqual("vtz", az.default_vlan_tz)
|
self.assertEqual("vtz", az.default_vlan_tz)
|
||||||
self.assertEqual("uuidrtr2", az.default_tier0_router)
|
self.assertEqual("uuidrtr2", az.default_tier0_router)
|
||||||
|
self.assertEqual("ec2", az.edge_cluster)
|
||||||
|
|
||||||
def test_missing_group_section(self):
|
def test_missing_group_section(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
@ -44,6 +44,7 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
cfg.CONF.set_override("dhcp_relay_service", "service1", group="nsx_v3")
|
cfg.CONF.set_override("dhcp_relay_service", "service1", group="nsx_v3")
|
||||||
cfg.CONF.set_override(
|
cfg.CONF.set_override(
|
||||||
"default_tier0_router", "uuidrtr1", group="nsx_v3")
|
"default_tier0_router", "uuidrtr1", group="nsx_v3")
|
||||||
|
cfg.CONF.set_override("edge_cluster", "ec1", group="nsx_v3")
|
||||||
|
|
||||||
def _config_az(self,
|
def _config_az(self,
|
||||||
metadata_proxy="metadata_proxy1",
|
metadata_proxy="metadata_proxy1",
|
||||||
@ -55,7 +56,8 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
default_vlan_tz='vtz',
|
default_vlan_tz='vtz',
|
||||||
switching_profiles=["uuid2"],
|
switching_profiles=["uuid2"],
|
||||||
dhcp_relay_service="service2",
|
dhcp_relay_service="service2",
|
||||||
default_tier0_router="uuidrtr2"):
|
default_tier0_router="uuidrtr2",
|
||||||
|
edge_cluster="ec2"):
|
||||||
if metadata_proxy is not None:
|
if metadata_proxy is not None:
|
||||||
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
||||||
group=self.group_name)
|
group=self.group_name)
|
||||||
@ -87,6 +89,9 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
if default_tier0_router is not None:
|
if default_tier0_router is not None:
|
||||||
cfg.CONF.set_override("default_tier0_router", default_tier0_router,
|
cfg.CONF.set_override("default_tier0_router", default_tier0_router,
|
||||||
group=self.group_name)
|
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):
|
def test_simple_availability_zone(self):
|
||||||
self._config_az()
|
self._config_az()
|
||||||
@ -102,6 +107,7 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
self.assertEqual(["uuid2"], az.switching_profiles)
|
self.assertEqual(["uuid2"], az.switching_profiles)
|
||||||
self.assertEqual("service2", az.dhcp_relay_service)
|
self.assertEqual("service2", az.dhcp_relay_service)
|
||||||
self.assertEqual("uuidrtr2", az.default_tier0_router)
|
self.assertEqual("uuidrtr2", az.default_tier0_router)
|
||||||
|
self.assertEqual("ec2", az.edge_cluster)
|
||||||
|
|
||||||
def test_missing_group_section(self):
|
def test_missing_group_section(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
Loading…
Reference in New Issue
Block a user