Fix LBServiceDef for vpc tenant
Change-Id: Idb6fb2bffdf55ceb59550f742d9cca15b69d3af1 Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
This commit is contained in:
parent
0a75bd5669
commit
14a9b16225
@ -23,6 +23,8 @@ from vmware_nsxlib.v3 import exceptions as nsxlib_exc
|
||||
from vmware_nsxlib.v3 import nsx_constants
|
||||
from vmware_nsxlib.v3.policy import constants
|
||||
from vmware_nsxlib.v3.policy import lb_defs
|
||||
from vmware_nsxlib.v3.policy.lb_defs import VPC_LB_SERVICES_PATH_PATTERN
|
||||
|
||||
TEST_TENANT = 'test'
|
||||
TEST_VPC_TENANT = 'orgs/default/projects/proj-2/vpcs/vpc-1234'
|
||||
|
||||
@ -811,6 +813,37 @@ class TestPolicyLBService(test_resources.NsxPolicyLibTestCase):
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertEqual(obj_id, result)
|
||||
|
||||
def test_create_with_vpc_tenant(self):
|
||||
name = 'd1'
|
||||
description = 'desc'
|
||||
obj_id = '111'
|
||||
size = 'SMALL'
|
||||
connectivity_path = 'path'
|
||||
relax_scale_validation = True
|
||||
with self.mock_create_update() as api_call:
|
||||
result = self.resourceApi.create_or_overwrite(
|
||||
name,
|
||||
lb_service_id=obj_id,
|
||||
description=description,
|
||||
size=size,
|
||||
connectivity_path=connectivity_path,
|
||||
relax_scale_validation=relax_scale_validation,
|
||||
tenant=TEST_VPC_TENANT)
|
||||
expected_def = (
|
||||
lb_defs.LBServiceDef(
|
||||
nsx_version=self.policy_lib.get_version(),
|
||||
lb_service_id=obj_id,
|
||||
name=name,
|
||||
description=description,
|
||||
size=size,
|
||||
connectivity_path=connectivity_path,
|
||||
relax_scale_validation=relax_scale_validation,
|
||||
tenant=TEST_VPC_TENANT))
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertEqual(obj_id, result)
|
||||
self.assertEqual(expected_def.path_pattern,
|
||||
VPC_LB_SERVICES_PATH_PATTERN)
|
||||
|
||||
def test_create_without_id(self):
|
||||
name = 'd1'
|
||||
description = 'desc'
|
||||
@ -1222,7 +1255,7 @@ class TestPolicyLBVirtualServer(test_resources.NsxPolicyLibTestCase):
|
||||
app_profile_path = '/infra/lb-app-profiles/%s' % app_profile_id
|
||||
self.assertEqual(body['application_profile_path'],
|
||||
app_profile_path)
|
||||
lb_service_path = '/%s/lb-services/%s' % (TEST_VPC_TENANT, lbs_id)
|
||||
lb_service_path = '/%s/vpc-lbs/%s' % (TEST_VPC_TENANT, lbs_id)
|
||||
self.assertEqual(body['lb_service_path'],
|
||||
lb_service_path)
|
||||
|
||||
|
@ -26,6 +26,7 @@ LB_VIRTUAL_SERVERS_PATH_PATTERN = TENANTS_PATH_PATTERN + "lb-virtual-servers/"
|
||||
VPC_LB_VIRTUAL_SERVERS_PATH_PATTERN = (TENANTS_PATH_PATTERN +
|
||||
"vpc-lb-virtual-servers/")
|
||||
LB_SERVICES_PATH_PATTERN = TENANTS_PATH_PATTERN + "lb-services/"
|
||||
VPC_LB_SERVICES_PATH_PATTERN = TENANTS_PATH_PATTERN + "vpc-lbs/"
|
||||
LB_POOL_PATH_PATTERN = TENANTS_PATH_PATTERN + "lb-pools/"
|
||||
VPC_LB_POOL_PATH_PATTERN = TENANTS_PATH_PATTERN + "vpc-lb-pools/"
|
||||
LB_APP_PROFILE_PATTERN = TENANTS_PATH_PATTERN + "lb-app-profiles/"
|
||||
@ -437,6 +438,8 @@ class LBServiceDef(ResourceDef):
|
||||
|
||||
@property
|
||||
def path_pattern(self):
|
||||
if self.is_vpc_tenant():
|
||||
return VPC_LB_SERVICES_PATH_PATTERN
|
||||
return LB_SERVICES_PATH_PATTERN
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user