Skip to content

Commit 21eb5f1

Browse files
author
Francis Pang
committed
[recommission] OPSAPS-36382 Python API changes to support recommssion with start
Added to api endpoints hosts_recommission_with_start() and recommission_with_start() for api_version >= 15. These endpoints will start decommissioned roles before doing the recommission.
1 parent ff41c6c commit 21eb5f1

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

python/src/cm_api/endpoints/cms.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ def hosts_recommission(self, host_names):
245245
"""
246246
return self._cmd('hostsRecommission', data=host_names)
247247

248+
def hosts_recommission_with_start(self, host_names):
249+
"""
250+
Recommission the specified hosts by recommissioning the slave roles.
251+
This command will start the roles before recommissioning.
252+
253+
Warning: Evolving. This method may change in the future and does not
254+
offer standard compatibility guarantees.
255+
Do not use without guidance from Cloudera.
256+
257+
Currently, only HDFS DataNodes will be started by this command.
258+
259+
@param host_names: List of names of hosts to be recommissioned.
260+
@return: Information about the submitted command.
261+
@since: API v15
262+
"""
263+
return self._cmd('hostsRecommissionWithStart', data=host_names, api_version=15)
264+
248265
def hosts_start_roles(self, host_names):
249266
"""
250267
Start all the roles on the specified hosts.

python/src/cm_api/endpoints/services.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,21 @@ def recommission(self, *role_names):
849849
"""
850850
return self._cmd('recommission', data=role_names)
851851

852+
def recommission_with_start(self, *role_names):
853+
"""
854+
Recommission roles in a service. Roles are started before recommissioning.
855+
856+
Warning: Evolving. This method may change in the future and does not offer
857+
standard compatibility guarantees.
858+
Only support by HDFS.
859+
Do not use without guidance from Cloudera.
860+
861+
@param role_names: Names of the roles to recommission.
862+
@return: Reference to the submitted command.
863+
@since: API v15
864+
"""
865+
return self._cmd('recommissionWithStart', data=role_names, api_version=15)
866+
852867
def deploy_client_config(self, *role_names):
853868
"""
854869
Deploys client configuration to the hosts where roles are running.

python/src/cm_api_tests/test_cms.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ def test_host_commission(self):
128128
retdata={})
129129
cms.hosts_recommission([ "host1", "host2" ])
130130

131+
def test_host_commission_with_start(self):
132+
resource = utils.MockResource(self)
133+
cms = ClouderaManager(resource)
134+
135+
resource.expect("POST", "/cm/commands/hostsDecommission",
136+
data=[ "host1", "host2" ],
137+
retdata={})
138+
cms.hosts_decommission([ "host1", "host2" ])
139+
140+
resource.expect("POST", "/cm/commands/hostsRecommissionWithStart",
141+
data=[ "host1", "host2" ],
142+
retdata={})
143+
cms.hosts_recommission_with_start([ "host1", "host2" ])
144+
131145
def test_get_licensed_feature_usage(self):
132146
resource = utils.MockResource(self)
133147
cms = ClouderaManager(resource)

0 commit comments

Comments
 (0)