Skip to content

Commit cd1204b

Browse files
Jayesh Seshadriandyao1
authored andcommitted
OPSAPS-31990 Add dfsServices to the python API
Added list_dfs_services to endpoints/cluster.py's ApiCluster, to match API addition in OPSAPS-31495. Testing: - new unit test - verified with manual test against CM via a simple test script: --- from cm_api.api_client import ApiResource api=ApiResource("nightly-1.vpc.cloudera.com", username="foo", password="bar") cluster=api.get_cluster("Cluster 1") apiList=cluster.list_dfs_services(view="export") print ("%s" %(apiList)) --- (cherry picked from commit adef14d) (cherry picked from commit e40c6259f119cc9067db9d03b092ad0e72ac5f14)
1 parent 2ea63bf commit cd1204b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

python/src/cm_api/endpoints/clusters.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,15 @@ def export(self, export_auto_config=False):
620620

621621
return self._get("export", ApiClusterTemplate, False,
622622
params=dict(exportAutoConfig=export_auto_config), api_version=12)
623+
624+
def list_dfs_services(self, view=None):
625+
"""
626+
List available DFS (distributed file system) services in a cluster.
627+
@param view: View to materialize
628+
@return: List of available distributed file system services in the cluster.
629+
@since: API v12
630+
"""
631+
if view:
632+
return self._get_resource_root().get("%s/%s?view=%s" % (self._path(), 'dfsServices', view))
633+
else:
634+
return self._get_resource_root().get("%s/%s" % (self._path(), 'dfsServices'))

python/src/cm_api_tests/test_clusters.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,18 @@ def test_export_cluster_template(self):
114114
params=dict(exportAutoConfig=True),
115115
retdata=ApiClusterTemplate(resource).to_json_dict())
116116
cluster.export(export_auto_config=True)
117+
118+
def test_list_dfs_services(self):
119+
resource = utils.MockResource(self)
120+
cluster = ApiCluster(resource, name="foo")
121+
data = None
122+
resource.expect("GET", "/clusters/foo/dfsServices",
123+
data=data,
124+
retdata={ 'name' : 'foo'})
125+
cluster.list_dfs_services()
126+
127+
data = None
128+
resource.expect("GET", "/clusters/foo/dfsServices?view=EXPORT",
129+
data=data,
130+
retdata={ 'name' : 'foo'})
131+
cluster.list_dfs_services(view="EXPORT")

0 commit comments

Comments
 (0)