Browse Source

New api to get policy edge cluster nsx node ids

Change-Id: I6881782d0fc8ea5fb2d1423dc514a10bb2aa482e
tags/16.0.3
asarfaty 3 weeks ago
committed by Adit Sarfaty
parent
commit
3ee4671388
2 changed files with 23 additions and 0 deletions
  1. +15
    -0
      vmware_nsxlib/tests/unit/v3/policy/test_resources.py
  2. +8
    -0
      vmware_nsxlib/v3/policy/core_resources.py

+ 15
- 0
vmware_nsxlib/tests/unit/v3/policy/test_resources.py View File

@@ -2646,6 +2646,21 @@ class TestPolicyEdgeCluster(NsxPolicyLibTestCase):
self.assert_called_with_def(api_call, expected_def)
self.assertEqual([node_id], result)

def test_get_nodes_nsx_ids(self):
obj_id = '111'
node_id = 'node1'
node_nsx_id = 'nsx1'
with mock.patch.object(
self.policy_api, "list",
return_value={'results': [{'id': node_id,
'nsx_id': node_nsx_id}]}) as api_call:
result = self.resourceApi.get_edge_node_nsx_ids(
obj_id, tenant=TEST_TENANT)
expected_def = core_defs.EdgeClusterNodeDef(
ec_id=obj_id, tenant=TEST_TENANT)
self.assert_called_with_def(api_call, expected_def)
self.assertEqual([node_nsx_id], result)


class TestPolicyMetadataProxy(NsxPolicyLibTestCase):



+ 8
- 0
vmware_nsxlib/v3/policy/core_resources.py View File

@@ -3937,6 +3937,14 @@ class NsxPolicyEdgeClusterApi(NsxPolicyResourceBase):
nodes = self._list(nodes_def)
return [node['id'] for node in nodes]

def get_edge_node_nsx_ids(self, ec_id,
ep_id=constants.DEFAULT_ENFORCEMENT_POINT,
tenant=constants.POLICY_INFRA_TENANT):
nodes_def = core_defs.EdgeClusterNodeDef(
ep_id=ep_id, ec_id=ec_id, tenant=tenant)
nodes = self._list(nodes_def)
return [node.get('nsx_id', node['id']) for node in nodes]


class NsxPolicyMetadataProxyApi(NsxPolicyResourceBase):
# Currently this is used as a ready only Api


Loading…
Cancel
Save