Skip to main content
Cloudman
Silver ⭐️⭐️
June 4, 2019
Solved

Retrieve Command Details from cm_client

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.html#concept_ktn_xsf_4l__section_s5d_kqf_4l) 

 

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.

lwang
lwangAnswer
Platinum ⭐️
June 6, 2019

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

4 replies

lwang
Platinum ⭐️
Platinum ⭐️
June 5, 2019
Cloudman
CloudmanAuthor
Silver ⭐️⭐️
June 5, 2019

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😞

 

/api/v19/commands/{commandId}

 

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.

Translate
lwang
Platinum ⭐️
lwangAnswer
Platinum ⭐️
June 6, 2019

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

Translate
Li Wang, Technical Solution Manager