06-27-2018 02:41 PM - edited 03-01-2019 06:27 AM
Hello,
I want to send many objects from UCS Director (Workflow or Custom Workflow Tasks) to my web Site ( Lang PHP).
I tested this request from Rest Client (ARC), but the returned result is ==> "serviceresult: 600" (this is the service request number).
I would like to retrieve the data on the same request, for exemple after invoking Worflow "Proviosnning VM Vmware", I want to recover the data ( like ip address, Vm Name, ...) so i can store in my database.
Thx,
Rami Khili
06-27-2018 02:53 PM
If I understand you correctly you want to retrieve the information per SR _ID.
Show a list of SRs:
http://10.52.249.103/app/api/rest?opName=userAPIGetServiceRequests&opData=
1. {
2. "Service_Request_ID": 115,
3. "Request_Type": "Create VM",
4. "Initiating_User": "demouser",
5. "Group": "DemoGroup",
6. "Catalog_Workflow_Name": "Provision VMware VM",
7. "Initiator_Comments": "",
8. "Request_Time": "Sep 10, 2014 09:39:49 UTC",
9. "Request_Status": "Failed",
10. "Rollback_Type": "",
11. "Catalog": "No"
12. },
Get details of an individual SR:
http://10.52.249.103/app/api/rest?opName=userAPIGetServiceRequestDetails&opData=
1. {
2. "serviceResult":
3. {
4. "requestId": 115,
5. "requestType": 0,
6. "initiatingUser": "demouser",
7. "groupName": "DemoGroup",
8. "requestTime": 1410341989314,
9. "comments": "",
10. "provisionQuantity": 1,
11. "provisionCatalog": "Windows 2008 R2",
12. "provisionVDCName": "CUIC-DEPLOYED-02",
13. "provisionDurationHours": -1
14. },
15. "serviceError": null,
16. "serviceName": "InfraMgr",
17. "opName": "userAPIGetServiceRequestDetails"
18. }
Get SR log:
http://10.52.249.103/app/api/rest?opName=userAPIGetServiceRequestWorkFlow&opData=
1. {
2. "stepId": "Initiated by demouser",
3. "executionStatus": 3,
4. "statusMessage": null,
5. "handlerId": 4,
6. "startedTime": -1,
7. "completedTime": 1410341983118,
8. "validTill": -1,
9. "startAfter": -1
10. },
11. {
12. "stepId": "VM Provision Inputs",
13. "executionStatus": 3,
14. "statusMessage": "",
15. "handlerId": 12,
16. "startedTime": -1,
17. "completedTime": 1410341989488,
18. "validTill": -1,
19. "startAfter": -1
20. },
21. {
22. "stepId": "Budget Allocation",
23. "executionStatus": 3,
24. "statusMessage": "Budget watch is not requested by the group.",
25. "handlerId": 12,
26. "startedTime": -1,
27. "completedTime": 1410341995265,
28. "validTill": -1,
29. "startAfter": -1
30. },
06-27-2018 03:31 PM
Thank you, but when i execute this simple exepmle :
loadLibrary("JSON-JS-Module/JSON-JS-ModuleLibrary");
importPackage(com.cloupia.model.cIM);
importPackage(java.util);
importPackage(java.lang);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(com.cloupia.lib.util);
var test = "{'name':'1'}";
var resultObj = JSON2.parse(test);
logger.addInfo("result= "+resultObj );
output.return_a = resultObj;
I got this error:
{
"serviceResponse": null,
"serviceError": "REMOTE_SERVICE_EXCEPTION: The JsonDeserializer IntegerTypeAdapter failed to deserialized json object "return_test" given the type int",
"serviceName": "InfraMgr",
"opName": "userAPIGetServiceRequestDetails"
}
I want to retrieve resultObj.
06-28-2018 04:31 AM
Take a look at this posting
https://communities.cisco.com/docs/DOC-58243
06-28-2018 06:57 AM
Hi Gelbrich,
Thank you for your answer,
I followed the link, but I have no return ( jsonData ) from ucs director. !! he only returns SR in the "serviceResult"
{
"serviceResult": 685,
"serviceError": null,
"serviceName": "InfraMgr",
"opName": "userAPISubmitWorkflowServiceRequest"
}
what is the function in opname ? userAPIGetWorkflowServiceRequest, userAPISubmitWorkflowServiceRequest, ??
here is my code:
Code 1:
importPackage(com.cloupia.model.cIM);
importPackage(java.util);
importPackage(java.lang);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(com.cloupia.lib.util);
importPackage(com.cloupia.lib.util);
var jsonData = '{"pool":"test-http-pool","description":"My test virtual server","name":"test-http-virtual","mask":"255.255.255.255","profiles":[{"name":"http","kind":"ltm:virtual:profile"},{"name":"tcp","kind":"ltm:virtual:profile"}],"ipProtocol":"tcp","sourceAddressTranslation":{"type":"automap"},"kind":"tm:ltm:virtual:virtualstate","destination":"1.1.1.3:80"}';
var data = JSON.getJsonElement(jsonData,null);
Code 2 :
importPackage(java.util);
importPackage(com.cloupia.lib.util);
var map = new HashMap ();
map.put ("nom", "test-http-virtual");
var data = JSON.javaToJsonString (carte, map.getClass ());
I need to recover the variable jsonData
Thank you in advance
06-28-2018 09:12 AM
I just ran this…
https://172.16.50.51/app/api/rest?opName=userAPIGetServiceRequestWorkFlow&opData=
And the result was this:
{ "serviceResult":{"requestId":3330,"workflowCreated":1530201600207,"submittedTime":1530201600530,"cancelledTime":-1,"cancelledByUser":null,"adminStatus":1,"executionStatus":3,"futureStartTime":1530201600207,"entries":[{"stepId":"Initiated by admin","executionStatus":3,"statusMessage":null,"handlerId":4,"startedTime":-1,"completedTime":1530201603658,"validTill":-1,"startAfter":-1},{"stepId":"RESTfulwebServiceAccess","executionStatus":3,"statusMessage":"","handlerId":12,"startedTime":-1,"completedTime":1530201607831,"validTill":-1,"startAfter":-1},{"stepId":"Parse_Temp","executionStatus":3,"statusMessage":"","handlerId":12,"startedTime":-1,"completedTime":1530201610050,"validTill":-1,"startAfter":-1},{"stepId":"kelvin_to_fahrenheit","executionStatus":3,"statusMessage":"","handlerId":12,"startedTime":-1,"completedTime":1530201616094,"validTill":-1,"startAfter":-1},{"stepId":"Child workflow (GlobalVariables_UPDATE_put_API_Global_var)","executionStatus":3,"statusMessage":"Completed action","handlerId":12,"startedTime":-1,"completedTime":1530201642451,"validTill":-1,"startAfter":-1},{"stepId":"Complete","executionStatus":3,"statusMessage":"Completed successfully.","handlerId":13,"startedTime":-1,"completedTime":1530201642833,"validTill":-1,"startAfter":-1}]}, "serviceError":null, "serviceName":"InfraMgr", "opName":"userAPIGetServiceRequestWorkFlow" }
06-28-2018 10:38 AM
1) In your request you have invoked the workflow first then you have retrieved the workflow data ===> I need to invoke the workflow and retrieve the data at the same time
2) The data in serviceResult is information about the workflow and this is not the case ==> I need the output of the workflow in serviceResult
06-28-2018 11:19 AM
Invoking workflow and getting information on the running workflow would be two separate events.
Infact the checking for workflow status would probably be in a loop with a wait status (~20sec) to see the status of the workflow.
When evoking a workflow it will only return the SR_ID nothing more.
https://communities.cisco.com/docs/DOC-55973
The SR ID is returned and with that number you would have to make further API calls to see status.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide