Created on 06-04-2019 02:08 PM - edited 09-16-2022 07:25 AM
I am using the Python client API (cm_client) to create batch processes for replicaiton schedules.
What I would like to do is list the command details for a specific replication schedule, specifically the subcommands (as described in the documentation - https://www.cloudera.com/documentation/enterprise/5-8-x/topics/cm_dg_view_running_recent_commands.ht...)
Is there any such API GET call that retrieves the Command Details in the Running Commands dialog box?
Thank you for any help you can provide.
Created 06-05-2019 08:07 PM
Hi @Cloudman ,
Thanks for your detail explaination. I have checked with expert in house and it looks like this could be a API limitation/design? Basically the /commands/ for the replication doesn't expose info for the sub-commands in the API.
For example, If you run an HDFS replication you'd see the parent command=id = "969" and for each child command_id = parent. But for restarting a service you'd get a parent and child commands.
# For example replication http://cm-host:7180/api/v19/commands/969/ { "id": 969, "name": "HdfsReplicationCommand", "startTime": "2019-06-05T22:25:11.248Z", "endTime": "2019-06-05T22:29:58.629Z", "active": false, "success": true, "resultMessage": "HDFS replication command succeeded.", "resultDataUrl": "http://cm-host:7180/cmf/command/969/download", "serviceRef": { "clusterName": "Cluster 1", "serviceName": "hdfs" }, "children": { "items": [ ] <<<<<===== no child, although the child tasks are visible in UI CM> All Recent Commands or replication history. }, "canRetry": false }
# For example restart service http://cm-host:7180/api/v19/commands/950/ { "id": 950, "name": "Restart", "startTime": "2019-05-30T23:02:18.071Z", "endTime": "2019-05-30T23:02:43.880Z", "active": false, "success": true, "resultMessage": "Successfully restarted service.", "serviceRef": { "serviceName": "mgmt" }, "children": { <<<<<<<<========== CHILD COMMANDS "items": [ { "id": 951, <<<<<<<< CHILD COMMANDS "name": "Stop", "startTime": "2019-05-30T23:02:18.072Z", "endTime": "2019-05-30T23:02:20.310Z", "active": false, "success": true, "resultMessage": "Successfully stopped service.", "serviceRef": { "serviceName": "mgmt" } }, { "id": 953, <<<<<<<< CHILD COMMANDS "name": "Start", "startTime": "2019-05-30T23:02:20.319Z", "endTime": "2019-05-30T23:02:43.879Z", "active": false, "success": true, "resultMessage": "Successfully started service.", "serviceRef": { "serviceName": "mgmt" } } ] }, "canRetry": false }
I have opened an internal jira #OPSAPS-51023 to see whether we can enhance this in future releases.
Thanks and hope this helps,
Li
Li Wang, Technical Solution Manager
Created 06-04-2019 10:19 PM
Hi @Cloudman ,
Welcome to Cloudera community! May I know what CM API version you are using? I feel below maybe the doc you are looking for:
CM 5.8.x:
CM 6.2.x:
Hope this helps,
Li
Li Wang, Technical Solution Manager
Created 06-05-2019 06:28 AM
Thank you for your response. I am using CM 6.0 with cm_client. The read_history command returns a list of commands triggered by the schedule. This same data can be viewed from the Replication History page of a specific replication schedule. From this page you can select the > arrow which displays a summary section consisted of duration, started at, etc. Now click the Command Details. This will bring you to a new page that shows the subcommands. I want to know if there is any API call to retrieve these subcommands.
With the API call you suggested, I can get a list of commands for a specific replication schedule. I can use the id field (commandid), for this API call (https://dflbda1ea03.itg.ti.com:7183/static/apidocs/path__commands_-commandId-.html😞
Which returns detailed information on an asychronos command. Unfortunately, this information contains no information about the subcommands triggered by this command. Is this possible to get using the CM API? Please advise, thank you.
Created 06-05-2019 08:07 PM
Hi @Cloudman ,
Thanks for your detail explaination. I have checked with expert in house and it looks like this could be a API limitation/design? Basically the /commands/ for the replication doesn't expose info for the sub-commands in the API.
For example, If you run an HDFS replication you'd see the parent command=id = "969" and for each child command_id = parent. But for restarting a service you'd get a parent and child commands.
# For example replication http://cm-host:7180/api/v19/commands/969/ { "id": 969, "name": "HdfsReplicationCommand", "startTime": "2019-06-05T22:25:11.248Z", "endTime": "2019-06-05T22:29:58.629Z", "active": false, "success": true, "resultMessage": "HDFS replication command succeeded.", "resultDataUrl": "http://cm-host:7180/cmf/command/969/download", "serviceRef": { "clusterName": "Cluster 1", "serviceName": "hdfs" }, "children": { "items": [ ] <<<<<===== no child, although the child tasks are visible in UI CM> All Recent Commands or replication history. }, "canRetry": false }
# For example restart service http://cm-host:7180/api/v19/commands/950/ { "id": 950, "name": "Restart", "startTime": "2019-05-30T23:02:18.071Z", "endTime": "2019-05-30T23:02:43.880Z", "active": false, "success": true, "resultMessage": "Successfully restarted service.", "serviceRef": { "serviceName": "mgmt" }, "children": { <<<<<<<<========== CHILD COMMANDS "items": [ { "id": 951, <<<<<<<< CHILD COMMANDS "name": "Stop", "startTime": "2019-05-30T23:02:18.072Z", "endTime": "2019-05-30T23:02:20.310Z", "active": false, "success": true, "resultMessage": "Successfully stopped service.", "serviceRef": { "serviceName": "mgmt" } }, { "id": 953, <<<<<<<< CHILD COMMANDS "name": "Start", "startTime": "2019-05-30T23:02:20.319Z", "endTime": "2019-05-30T23:02:43.879Z", "active": false, "success": true, "resultMessage": "Successfully started service.", "serviceRef": { "serviceName": "mgmt" } } ] }, "canRetry": false }
I have opened an internal jira #OPSAPS-51023 to see whether we can enhance this in future releases.
Thanks and hope this helps,
Li
Li Wang, Technical Solution Manager
Created 06-06-2019 07:26 AM
Thank you so much for your prudent response. It is unfortunate that the API does not provide subcommands for each command and I can see no workaround to this at the moment. I appreciate all the help you have provided.