New api to get policy edge cluster nsx node ids

Change-Id: I6881782d0fc8ea5fb2d1423dc514a10bb2aa482e
This commit is contained in:
asarfaty 2020-06-08 10:44:51 +02:00 committed by Adit Sarfaty
parent b1a6528be0
commit 3ee4671388
2 changed files with 23 additions and 0 deletions

View File

@ -2646,6 +2646,21 @@ class TestPolicyEdgeCluster(NsxPolicyLibTestCase):
self.assert_called_with_def(api_call, expected_def) self.assert_called_with_def(api_call, expected_def)
self.assertEqual([node_id], result) 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): class TestPolicyMetadataProxy(NsxPolicyLibTestCase):

View File

@ -3937,6 +3937,14 @@ class NsxPolicyEdgeClusterApi(NsxPolicyResourceBase):
nodes = self._list(nodes_def) nodes = self._list(nodes_def)
return [node['id'] for node in nodes] 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): class NsxPolicyMetadataProxyApi(NsxPolicyResourceBase):
# Currently this is used as a ready only Api # Currently this is used as a ready only Api