[T0API] Added SCOPE parameter in static route
In setting T0 static route, a scope parameter is needed. This patch fixes the problem with previous implementation by adding the scope field in static route definition Issue: # Jira: # Signed-off-by: Rongrong_Miao <rmiao@vmware.com> Change-Id: I9b6e579e8e57e13cb1ba9e797c7348e23e3aaa8f
This commit is contained in:
parent
f0d39ed978
commit
d8596e784e
@ -6934,6 +6934,7 @@ class TestPolicyTier0StaticRoute(NsxPolicyLibTestCase):
|
||||
static_route_id = '222'
|
||||
network = '1.1.1.1/24'
|
||||
nexthop = '2.2.2.2'
|
||||
scope = 'ContainerT0'
|
||||
|
||||
with mock.patch.object(self.policy_api,
|
||||
"create_or_update") as api_call:
|
||||
@ -6943,7 +6944,9 @@ class TestPolicyTier0StaticRoute(NsxPolicyLibTestCase):
|
||||
description=description,
|
||||
network=network,
|
||||
next_hop=nexthop,
|
||||
tenant=TEST_TENANT)
|
||||
tenant=TEST_TENANT,
|
||||
scope=scope
|
||||
)
|
||||
|
||||
expected_def = core_defs.Tier0StaticRoute(
|
||||
tier0_id=tier0_id,
|
||||
@ -6952,7 +6955,9 @@ class TestPolicyTier0StaticRoute(NsxPolicyLibTestCase):
|
||||
description=description,
|
||||
network=network,
|
||||
next_hop=nexthop,
|
||||
tenant=TEST_TENANT)
|
||||
tenant=TEST_TENANT,
|
||||
scope=scope
|
||||
)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
|
@ -740,8 +740,17 @@ class RouterStaticRoute(ResourceDef):
|
||||
|
||||
# next hops
|
||||
if self.has_attr('next_hop'):
|
||||
next_hops = []
|
||||
param_dict = dict()
|
||||
next_hop = self.get_attr('next_hop')
|
||||
next_hops = [{'ip_address': next_hop}]
|
||||
param_dict['ip_address'] = next_hop
|
||||
|
||||
# scope parameter
|
||||
if self.has_attr('scope'):
|
||||
scope_path = self.get_attr('scope')
|
||||
param_dict['scope'] = [scope_path]
|
||||
|
||||
next_hops.append(param_dict)
|
||||
self._set_attr_if_specified(body, 'next_hop',
|
||||
body_attr='next_hops',
|
||||
value=next_hops)
|
||||
|
@ -2012,7 +2012,8 @@ class NSXPolicyTier0StaticRouteApi(NsxPolicyResourceBase):
|
||||
network=IGNORE,
|
||||
next_hop=IGNORE,
|
||||
tags=IGNORE,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
scope=IGNORE):
|
||||
static_route_id = self._init_obj_uuid(static_route_id)
|
||||
static_route_def = self._init_def(tier0_id=tier0_id,
|
||||
static_route_id=static_route_id,
|
||||
@ -2021,7 +2022,8 @@ class NSXPolicyTier0StaticRouteApi(NsxPolicyResourceBase):
|
||||
network=network,
|
||||
next_hop=next_hop,
|
||||
tags=tags,
|
||||
tenant=tenant)
|
||||
tenant=tenant,
|
||||
scope=scope)
|
||||
self._create_or_store(static_route_def)
|
||||
return static_route_id
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user