Set default ipv6 ndra profile instead of empty value
Change-Id: I2d61ce9443ea0ee407efec286682cc3267fadf34
This commit is contained in:
parent
60eaa86892
commit
03fd42824e
|
@ -366,17 +366,52 @@ class TestPolicyTier1(policy_testcase.TestPolicyApi):
|
|||
nat=True,
|
||||
lb_vip=False,
|
||||
lb_snat=False)
|
||||
ipv6_ndra_profile_id = '111'
|
||||
tier1_def = policy.Tier1Def(
|
||||
tier1_id=tier1_id,
|
||||
name=name, description=description,
|
||||
route_advertisement=route_adv,
|
||||
tier0=tier0_id)
|
||||
tier0=tier0_id,
|
||||
ipv6_ndra_profile_id=ipv6_ndra_profile_id)
|
||||
expected_data = {"id": "%s" % tier1_id,
|
||||
"resource_type": "Tier1",
|
||||
"description": "%s" % description,
|
||||
"display_name": "%s" % name,
|
||||
"tier0_path": "/infra/tier-0s/%s" % tier0_id,
|
||||
"route_advertisement_types": route_adv.get_obj_dict()}
|
||||
"route_advertisement_types": route_adv.get_obj_dict(),
|
||||
"ipv6_profile_paths": ["/infra/ipv6-ndra-profiles/"
|
||||
"%s" % ipv6_ndra_profile_id]}
|
||||
self.policy_api.create_or_update(tier1_def)
|
||||
tier1_path = tier1_def.get_resource_path()
|
||||
self.assert_json_call('PATCH', self.client,
|
||||
tier1_path,
|
||||
data=expected_data)
|
||||
|
||||
def test_create_no_ipv6_profile(self):
|
||||
name = 'test'
|
||||
description = 'desc'
|
||||
tier0_id = '000'
|
||||
tier1_id = '111'
|
||||
route_adv = policy.RouteAdvertisement(static_routes=True,
|
||||
subnets=True,
|
||||
nat=True,
|
||||
lb_vip=False,
|
||||
lb_snat=False)
|
||||
ipv6_ndra_profile_id = None
|
||||
tier1_def = policy.Tier1Def(
|
||||
tier1_id=tier1_id,
|
||||
name=name, description=description,
|
||||
route_advertisement=route_adv,
|
||||
tier0=tier0_id,
|
||||
ipv6_ndra_profile_id=ipv6_ndra_profile_id)
|
||||
expected_data = {"id": "%s" % tier1_id,
|
||||
"resource_type": "Tier1",
|
||||
"description": "%s" % description,
|
||||
"display_name": "%s" % name,
|
||||
"tier0_path": "/infra/tier-0s/%s" % tier0_id,
|
||||
"route_advertisement_types": route_adv.get_obj_dict(),
|
||||
"ipv6_profile_paths": ["/infra/ipv6-ndra-profiles/"
|
||||
"default"]}
|
||||
self.policy_api.create_or_update(tier1_def)
|
||||
tier1_path = tier1_def.get_resource_path()
|
||||
self.assert_json_call('PATCH', self.client,
|
||||
|
|
|
@ -2561,6 +2561,7 @@ class TestPolicyTier1(NsxPolicyLibTestCase):
|
|||
route_adv = self.resourceApi.build_route_advertisement(
|
||||
lb_vip=True,
|
||||
lb_snat=True)
|
||||
ipv6_profile_id = '222'
|
||||
|
||||
with mock.patch.object(self.policy_api,
|
||||
"create_or_update") as api_call:
|
||||
|
@ -2570,6 +2571,7 @@ class TestPolicyTier1(NsxPolicyLibTestCase):
|
|||
force_whitelisting=True,
|
||||
route_advertisement=route_adv,
|
||||
pool_allocation=pool_alloc_type,
|
||||
ipv6_ndra_profile_id=ipv6_profile_id,
|
||||
tenant=TEST_TENANT)
|
||||
|
||||
expected_def = core_defs.Tier1Def(
|
||||
|
@ -2582,6 +2584,42 @@ class TestPolicyTier1(NsxPolicyLibTestCase):
|
|||
failover_mode=constants.NON_PREEMPTIVE,
|
||||
route_advertisement=route_adv,
|
||||
pool_allocation=pool_alloc_type,
|
||||
ipv6_ndra_profile_id=ipv6_profile_id,
|
||||
tenant=TEST_TENANT)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
def test_create_no_ipv6_profile(self):
|
||||
name = 'test'
|
||||
description = 'desc'
|
||||
tier0_id = '111'
|
||||
pool_alloc_type = 'LB_SMALL'
|
||||
route_adv = self.resourceApi.build_route_advertisement(
|
||||
lb_vip=True,
|
||||
lb_snat=True)
|
||||
|
||||
with mock.patch.object(self.policy_api,
|
||||
"create_or_update") as api_call:
|
||||
result = self.resourceApi.create_or_overwrite(
|
||||
name, description=description,
|
||||
tier0=tier0_id,
|
||||
force_whitelisting=True,
|
||||
route_advertisement=route_adv,
|
||||
pool_allocation=pool_alloc_type,
|
||||
ipv6_ndra_profile_id=None,
|
||||
tenant=TEST_TENANT)
|
||||
|
||||
expected_def = core_defs.Tier1Def(
|
||||
nsx_version=self.policy_lib.get_version(),
|
||||
tier1_id=mock.ANY,
|
||||
name=name,
|
||||
description=description,
|
||||
tier0=tier0_id,
|
||||
force_whitelisting=True,
|
||||
failover_mode=constants.NON_PREEMPTIVE,
|
||||
route_advertisement=route_adv,
|
||||
pool_allocation=pool_alloc_type,
|
||||
ipv6_ndra_profile_id=None,
|
||||
tenant=TEST_TENANT)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertIsNotNone(result)
|
||||
|
|
|
@ -377,13 +377,19 @@ class RouterDef(ResourceDef):
|
|||
value=paths)
|
||||
|
||||
if self.has_attr('ipv6_ndra_profile_id'):
|
||||
paths = ""
|
||||
if self.get_attr('ipv6_ndra_profile_id'):
|
||||
ndra_profile = Ipv6NdraProfileDef(
|
||||
profile_id=self.get_attr('ipv6_ndra_profile_id'),
|
||||
tenant=self.get_tenant())
|
||||
paths = [ndra_profile.get_resource_full_path()]
|
||||
else:
|
||||
# Set it to the default profile
|
||||
# This will allow removing the old profile,
|
||||
# as the NSX does not support empty value.
|
||||
ndra_profile = Ipv6NdraProfileDef(
|
||||
profile_id=Ipv6NdraProfileDef.default_profile(),
|
||||
tenant=self.get_tenant())
|
||||
|
||||
paths = [ndra_profile.get_resource_full_path()]
|
||||
self._set_attr_if_specified(body, 'ipv6_ndra_profile_id',
|
||||
body_attr='ipv6_profile_paths',
|
||||
value=paths)
|
||||
|
@ -594,13 +600,19 @@ class Tier1InterfaceDef(ResourceDef):
|
|||
value=path)
|
||||
|
||||
if self.has_attr('ipv6_ndra_profile_id'):
|
||||
paths = ""
|
||||
if self.get_attr('ipv6_ndra_profile_id'):
|
||||
ndra_profile = Ipv6NdraProfileDef(
|
||||
profile_id=self.get_attr('ipv6_ndra_profile_id'),
|
||||
tenant=self.get_tenant())
|
||||
paths = [ndra_profile.get_resource_full_path()]
|
||||
else:
|
||||
# Set it to the default profile
|
||||
# This will allow removing the old profile,
|
||||
# as the NSX does not support empty value.
|
||||
ndra_profile = Ipv6NdraProfileDef(
|
||||
profile_id=Ipv6NdraProfileDef.default_profile(),
|
||||
tenant=self.get_tenant())
|
||||
|
||||
paths = [ndra_profile.get_resource_full_path()]
|
||||
self._set_attr_if_specified(body, 'ipv6_ndra_profile_id',
|
||||
body_attr='ipv6_profile_paths',
|
||||
value=paths)
|
||||
|
@ -2109,6 +2121,10 @@ class Ipv6NdraProfileDef(ResourceDef):
|
|||
def resource_type():
|
||||
return 'Ipv6NdraProfile'
|
||||
|
||||
@staticmethod
|
||||
def default_profile():
|
||||
return 'default'
|
||||
|
||||
def path_defs(self):
|
||||
return (TenantDef,)
|
||||
|
||||
|
|
Loading…
Reference in New Issue