Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Using an asynchronous task | Creating UCS File

Julio_Navarro
Cirrostratus
Cirrostratus

Hi,

I am trying the following REST URL to create a task to generate a UCS File:

Method: Post
URI: mgmt/tm/task/sys/ucs/
Body: { "command": "save",    "name": "UCS01" }

So, I get back:

{
  "_taskId": 1563464422689504,
  "_taskState": "STARTED",
  "_taskTimeInStateMs": 0,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504/result?ver=12.1.3.4",
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504?ver=12.1.3.4"
}

Now, when I do check the status:

Method: Get
URI: /mgmt/tm/task/sys/ucs/1563464422689504

I gel back:

{
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504?ver=12.1.3.4",
  "_taskId": 1563464422689504,
  "_taskState": "COMPLETED",
  "_taskTimeInStateMs": 5000,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504/result?ver=12.1.3.4"
}

When I go to /var/local/ucs, I don't see the UCS created.

** Maybe I am missing something. Please advise **

----------- If I don't use the "task" option, then it will worked. But I would like to use the task option to take advantage of asynchronous tasks ----

Thank you

1 ACCEPTED SOLUTION

Jason_Adams
F5 Employee
F5 Employee

 ; to close the loop on this one, it appears that you the part that was missing in your request is the -X PUT request, to set the state to 'VALIDATING'

 

# curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "code":202,
    "message":"Task will execute asynchronously.",
    "errorStack":[]
}

That is the request which is necessary to cause any task to begin processing. Until then, the task is waiting for any number of additional tasks to be added together.

View solution in original post

6 REPLIES 6

cjunior
Nacreous
Nacreous

Hi,

Tested on v15.0.0 looks OK for me.

What BIG-IP version are you trying to?

curl -k -u admin:admin  -X POST -H 'Content-Type: application/json'  -d '{ "command": "save", "name": "UCS01" }' https://localhost/mgmt/tm/task/sys/ucs
 
{
  "_taskId": 1563470408202544,
  "_taskState": "STARTED",
  "_taskTimeInStateMs": 0,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544/result?ver=15.0.0",
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544?ver=15.0.0"
}
curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563470408202544
 
{
  "code": 202,
  "message": "Task will execute asynchronously.",
  "errorStack": []
}
curl -k -u admin:admin  https://localhost/mgmt/tm/task/sys/ucs/1563470408202544
 
{
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544?ver=15.0.0",
  "_taskId": 1563470408202544,
  "_taskState": "COMPLETED",
  "_taskTimeInStateMs": 13000,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544/result?ver=15.0.0"
}
# ls -la /var/local/ucs
total 484520
drwxr-xr-x. 3 root root      4096 Jul 18 14:29 .
drwxr-xr-x. 9 root root      4096 Jun 28 12:23 ..
-rw-r--r--. 1 root root 195341011 Jun 28 12:23 config.ucs
-r--r--r--. 1 root root       114 May 10 05:57 cs_backup_rotate.conf
drwxr-xr-x. 2 root root      4096 Jun 28 12:43 tmp
-rw-r--r--. 1 root root 300789664 Jul 18 14:15 UCS01.ucs
 

 

 

 

Hi, we are on version 12.1.3.4

Buddy, It works for me on v12.1.3.4.

# curl -k -u admin:admin  -X POST -H 'Content-Type: application/json'  -d '{ "command": "save", "name": "UCS01" }' https://localhost/mgmt/tm/task/sys/ucs
{
    "_taskId":1563478591515657,
    "_taskState":"STARTED",
    "_taskTimeInStateMs":0,
    "_taskResultLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657/result?ver=12.1.3.4",
    "selfLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4"
}
 
# curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "code":202,
    "message":"Task will execute asynchronously.",
    "errorStack":[]
}
 
# curl -k -u admin:admin  https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "selfLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4",
    "_taskId":1563478591515657,
    "_taskState":"COMPLETED",
    "_taskTimeInStateMs":10000,
    "_taskResultLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657/result?ver=12.1.3.4"
}
 
 
# ls -la /var/local/ucs
total 3976
drwxr-xr-x. 3 root root    4096 2019-07-18 12:37 .
drwxr-xr-x. 9 root root    4096 2019-07-18 12:20 ..
-r--r--r--. 1 root root     114 2018-04-10 13:52 cs_backup_rotate.conf
drwxr-xr-x. 2 root root    4096 2019-07-18 12:22 tmp
-rw-r--r--. 1 root root 4049809 2019-07-18 12:37 UCS01.ucs

So, if you can save UCS from another way, we can't confirm issues during save the file.

It sounds strange to me 😞

Jason_Adams
F5 Employee
F5 Employee

 ; to close the loop on this one, it appears that you the part that was missing in your request is the -X PUT request, to set the state to 'VALIDATING'

 

# curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "code":202,
    "message":"Task will execute asynchronously.",
    "errorStack":[]
}

That is the request which is necessary to cause any task to begin processing. Until then, the task is waiting for any number of additional tasks to be added together.

And you are right! Thank you.

Hello

It looks like I need somebody's help to determine what could be wrong with my script.

I am re-writing all the logic using PowerShell, but the idea is the same - to create a task, to start the task, to check if the task state is COMPLETED and then to download the result.

Here is what I am facing:

step1, to create a task:

_taskId            : 1684506387897122
_taskState         : STARTED
_taskTimeInStateMs : 0
_taskResultLink    : https://localhost/mgmt/tm/task/sys/ucs/1684506387897122/result?ver=16.1.3.4
selfLink           : https://localhost/mgmt/tm/task/sys/ucs/1684506387897122?ver=16.1.3.4

step2, to start the task

code       : 202
message    : Task will execute asynchronously.
errorStack : {}

step3, getting status (the request hags for ~30 seconds):

Invoke-RestMethod : {"code":400,"message":"remoteSender:10.0.3.138, method:GET ","referer":"10.0.3.138","restOperationId":15296221,"kind":":resterrorresponse"}

If I request status for the 2nd time, I can get (sometimes) task COMPLETED, or I can get a "Task not found" error. My question is why do sometimes tasks disappear?