Skip to content

Commit 0f03d39

Browse files
gitmfoxPhilip Langdale
authored and
Philip Langdale
committed
[services] OPSAPS-12686 Add python client binding for Migrate Roles command
This commit adds a python client binding for the Migrate Roles command. This command is available from the hosts endpoint.
1 parent 64d8c81 commit 0f03d39

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

python/src/cm_api/endpoints/hosts.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,52 @@ def exit_maintenance_mode(self):
180180
self._update(get_host(self._get_resource_root(), self.hostId))
181181
return cmd
182182

183+
def migrate_roles(self, role_names_to_migrate, target_host_id,
184+
clear_stale_role_data):
185+
"""
186+
Migrate roles from this host to a different host.
187+
188+
Currently, this command applies only to HDFS NameNode, JournalNode,
189+
and Failover Controller roles. In order to migrate these roles:
190+
191+
- HDFS High Availability must be enabled, using quorum-based storage.
192+
- HDFS must not be configured to use a federated nameservice.
193+
194+
I{B{Migrating a NameNode role requires cluster downtime.}} HDFS, along
195+
with all of its dependent services, will be stopped at the beginning
196+
of the migration process, and restarted at its conclusion.
197+
198+
If the active NameNode is selected for migration, a manual failover
199+
will be performed before the role is migrated. The role will remain in
200+
standby mode after the migration is complete.
201+
202+
When migrating a NameNode role, the co-located Failover Controller
203+
role must be migrated as well. The Failover Controller role name must
204+
be included in the list of role names to migrate specified in the
205+
arguments to this command (it will not be included implicitly). This
206+
command does not allow a Failover Controller role to be moved by itself,
207+
although it is possible to move a JournalNode independently.
208+
209+
@param role_names_to_migrate: list of role names to migrate.
210+
@param target_host_id: the id of the host to which the roles
211+
should be migrated.
212+
@param clear_stale_role_data: true to delete existing stale role data,
213+
if any. For example, when migrating a
214+
NameNode, if the target host has stale
215+
data in the NameNode data directories
216+
(possibly because a NameNode role was
217+
previously located there), this stale
218+
data will be deleted before migrating
219+
the role.
220+
@return: Reference to the submitted command.
221+
@since: API v10
222+
"""
223+
args = dict(
224+
roleNamesToMigrate = role_names_to_migrate,
225+
targetHostId = target_host_id,
226+
clearStaleRoleData = clear_stale_role_data)
227+
return self._cmd('migrateRoles', data=args, api_version=10)
228+
183229
def set_rack_id(self, rackId):
184230
"""
185231
Update the rack ID of this host.

0 commit comments

Comments
 (0)