Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Retrieve Command Details from cm_client

SOLVED Go to solution

Retrieve Command Details from cm_client

New Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Retrieve Command Details from cm_client

Community Manager

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 Resolution Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

Learn more about the Cloudera Community:

Terms of Service

Community Guidelines

How to use the forum

4 REPLIES 4

Re: Retrieve Command Details from cm_client

Community Manager

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: 

https://cloudera.github.io/cm_api/apidocs/v13/path__clusters_-clusterName-_services_-serviceName-_re...

CM 6.2.x: 

https://archive.cloudera.com/cm6/6.2.0/generic/jar/cm_api/apidocs/resource_ReplicationsResource.html...

 

Hope this helps,

Li

Li Wang, Technical Resolution Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

Learn more about the Cloudera Community:

Terms of Service

Community Guidelines

How to use the forum

Re: Retrieve Command Details from cm_client

New Contributor

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.

Re: Retrieve Command Details from cm_client

Community Manager

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 Resolution Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

Learn more about the Cloudera Community:

Terms of Service

Community Guidelines

How to use the forum

Re: Retrieve Command Details from cm_client

New Contributor

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.