Use project-id instead of tenant -id in nsxlib
Change-Id: If4782a11b74d72bcfda520fc1bd8eaddf464f5ec
This commit is contained in:
parent
fc6dcf073c
commit
76b47c2bb7
|
@ -57,7 +57,7 @@ class TestSwitchingProfileTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||
tags = [
|
||||
{
|
||||
'scope': 'os-project-id',
|
||||
'tag': 'tenant-1'
|
||||
'tag': 'project-1'
|
||||
},
|
||||
{
|
||||
'scope': 'os-api-version',
|
||||
|
@ -83,7 +83,7 @@ class TestSwitchingProfileTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||
tags = [
|
||||
{
|
||||
'scope': 'os-project-id',
|
||||
'tag': 'tenant-1'
|
||||
'tag': 'project-1'
|
||||
},
|
||||
{
|
||||
'scope': 'os-api-version',
|
||||
|
@ -113,7 +113,7 @@ class TestSwitchingProfileTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||
tags = [
|
||||
{
|
||||
'scope': 'os-project-id',
|
||||
'tag': 'tenant-1'
|
||||
'tag': 'project-1'
|
||||
},
|
||||
{
|
||||
'scope': 'os-api-version',
|
||||
|
@ -158,7 +158,7 @@ class TestSwitchingProfileTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||
tags = [
|
||||
{
|
||||
'scope': 'os-project-id',
|
||||
'tag': 'tenant-1'
|
||||
'tag': 'project-1'
|
||||
},
|
||||
{
|
||||
'scope': 'os-api-version',
|
||||
|
|
|
@ -24,12 +24,12 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
def test_build_v3_tags_payload(self):
|
||||
result = self.nsxlib.build_v3_tags_payload(
|
||||
{'id': 'fake_id',
|
||||
'tenant_id': 'fake_tenant_id'},
|
||||
'project_id': 'fake_proj_id'},
|
||||
resource_type='os-net-id',
|
||||
project_name='fake_tenant_name')
|
||||
project_name='fake_proj_name')
|
||||
expected = [{'scope': 'os-net-id', 'tag': 'fake_id'},
|
||||
{'scope': 'os-project-id', 'tag': 'fake_tenant_id'},
|
||||
{'scope': 'os-project-name', 'tag': 'fake_tenant_name'},
|
||||
{'scope': 'os-project-id', 'tag': 'fake_proj_id'},
|
||||
{'scope': 'os-project-name', 'tag': 'fake_proj_name'},
|
||||
{'scope': 'os-api-version',
|
||||
'tag': nsxlib_testcase.PLUGIN_VER}]
|
||||
self.assertEqual(expected, result)
|
||||
|
@ -37,11 +37,11 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
def test_build_v3_tags_payload_internal(self):
|
||||
result = self.nsxlib.build_v3_tags_payload(
|
||||
{'id': 'fake_id',
|
||||
'tenant_id': 'fake_tenant_id'},
|
||||
'project_id': 'fake_proj_id'},
|
||||
resource_type='os-net-id',
|
||||
project_name=None)
|
||||
expected = [{'scope': 'os-net-id', 'tag': 'fake_id'},
|
||||
{'scope': 'os-project-id', 'tag': 'fake_tenant_id'},
|
||||
{'scope': 'os-project-id', 'tag': 'fake_proj_id'},
|
||||
{'scope': 'os-project-name',
|
||||
'tag': nsxlib_testcase.PLUGIN_TAG},
|
||||
{'scope': 'os-api-version',
|
||||
|
@ -52,7 +52,7 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
self.assertRaises(n_exc.InvalidInput,
|
||||
self.nsxlib.build_v3_tags_payload,
|
||||
{'id': 'fake_id',
|
||||
'tenant_id': 'fake_tenant_id'},
|
||||
'project_id': 'fake_proj_id'},
|
||||
resource_type='os-longer-maldini-rocks-id',
|
||||
project_name='fake')
|
||||
|
||||
|
@ -67,7 +67,7 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
def test_is_internal_resource(self):
|
||||
project_tag = self.nsxlib.build_v3_tags_payload(
|
||||
{'id': 'fake_id',
|
||||
'tenant_id': 'fake_tenant_id'},
|
||||
'project_id': 'fake_proj_id'},
|
||||
resource_type='os-net-id',
|
||||
project_name=None)
|
||||
internal_tag = self.nsxlib.build_v3_api_version_tag()
|
||||
|
@ -93,7 +93,7 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
def test_build_v3_tags_max_length_payload(self):
|
||||
result = self.nsxlib.build_v3_tags_payload(
|
||||
{'id': 'X' * 255,
|
||||
'tenant_id': 'X' * 255},
|
||||
'project_id': 'X' * 255},
|
||||
resource_type='os-net-id',
|
||||
project_name='X' * 255)
|
||||
expected = [{'scope': 'os-net-id', 'tag': 'X' * 40},
|
||||
|
|
|
@ -203,15 +203,16 @@ class NsxLibApiBase(object):
|
|||
# There may be cases when the plugin creates the port, for example DHCP
|
||||
if not project_name:
|
||||
project_name = self.nsxlib_config.plugin_tag
|
||||
tenant_id = resource.get('tenant_id', '')
|
||||
# If tenant_id is present in resource and set to None, explicitly set
|
||||
# the tenant_id in tags as ''.
|
||||
if tenant_id is None:
|
||||
tenant_id = ''
|
||||
project_id = (resource.get('project_id', '') or
|
||||
resource.get('tenant_id', ''))
|
||||
# If project_id is present in resource and set to None, explicitly set
|
||||
# the project_id in tags as ''.
|
||||
if project_id is None:
|
||||
project_id = ''
|
||||
return [{'scope': resource_type,
|
||||
'tag': resource.get('id', '')[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-project-id',
|
||||
'tag': tenant_id[:MAX_TAG_LEN]},
|
||||
'tag': project_id[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-project-name',
|
||||
'tag': project_name[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-api-version',
|
||||
|
|
Loading…
Reference in New Issue