Merge "Support policy edge cluster nodes getter"
This commit is contained in:
commit
eee5406118
vmware_nsxlib
@ -2388,6 +2388,19 @@ class TestPolicyEdgeCluster(NsxPolicyLibTestCase):
|
|||||||
self.assert_called_with_def(api_call, expected_def)
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
self.assertEqual([], result)
|
self.assertEqual([], result)
|
||||||
|
|
||||||
|
def test_get_nodes(self):
|
||||||
|
obj_id = '111'
|
||||||
|
node_id = 'node1'
|
||||||
|
with mock.patch.object(
|
||||||
|
self.policy_api, "list",
|
||||||
|
return_value={'results': [{'id': node_id}]}) as api_call:
|
||||||
|
result = self.resourceApi.get_edge_node_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_id], result)
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyTier1(NsxPolicyLibTestCase):
|
class TestPolicyTier1(NsxPolicyLibTestCase):
|
||||||
|
|
||||||
|
@ -1493,6 +1493,25 @@ class EdgeClusterDef(ResourceDef):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class EdgeClusterNodeDef(ResourceDef):
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_pattern(self):
|
||||||
|
return (EDGE_CLUSTER_PATTERN + '%s/edge-nodes/')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_ids(self):
|
||||||
|
return ('tenant', 'ep_id', 'ec_id', 'node_id')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resource_type():
|
||||||
|
return 'PolicyEdgeNode'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resource_use_cache():
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Currently assumes one deployment point per id
|
# Currently assumes one deployment point per id
|
||||||
class DeploymentMapDef(ResourceDef):
|
class DeploymentMapDef(ResourceDef):
|
||||||
|
|
||||||
|
@ -3394,6 +3394,14 @@ class NsxPolicyEdgeClusterApi(NsxPolicyResourceBase):
|
|||||||
ep_id=ep_id, ec_id=ec_id, tenant=tenant)
|
ep_id=ep_id, ec_id=ec_id, tenant=tenant)
|
||||||
return ec_def.get_resource_full_path()
|
return ec_def.get_resource_full_path()
|
||||||
|
|
||||||
|
def get_edge_node_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['id'] for node in nodes]
|
||||||
|
|
||||||
|
|
||||||
class NsxPolicyDeploymentMapApi(NsxPolicyResourceBase):
|
class NsxPolicyDeploymentMapApi(NsxPolicyResourceBase):
|
||||||
"""NSX Policy Deployment Map."""
|
"""NSX Policy Deployment Map."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user