ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins. Read more for important details.
ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins.Read more for important details.
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class
552 views

pass task id to another task

Jump to solution

Hello Experts,

 

I have a perl script which is executed via HPNA task under Advanced Script ( Perl ) , the task is executed against multiple devices .

I want to execute another task ( Advanced Script) after the above tasks completes on all the devices and need to access the data from the first task  ( Need to know the task id to pull the hosts on which the script was executed )

 

1. Task 1 = Execute the script on 10 devices .

2. Once the above task completes trigger Task 2 [ I want to pass the Task id of Task 1 as a parameter to Task 2 so that programatically i can reterive the device names and action accordingly ]

 

0 Likes
1 Solution

Accepted Solutions
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi 

 

There are multiple ways to do this. via NA only.

Here is one To be run as external task.

 

1. Get your devices in a specific group.

2. You script 

Import NA perl modules Connect and Client


2.1 run command script - on the group (async mode). This is task A. The command will return the parent task id.
2.2 while task duration is NULL. wait. You can find this with show task -id taks_id_step2.1.
2.3 break while when duration is not null. Parent task has finished.
2.4. List child tasks list task -parentid taks_id_step2.2 For each shild taskid. list taks -id X. Get the device hostname. Create a file on filesystem [Hostname]-[ParentTaskID]-[optionallyAtimestamp]
2.5. Zip all files *ParentTaskID*. Send

 

Best Regards

 

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

View solution in original post

0 Likes
6 Replies
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

To better answer you question i need more data.

Your need is

a. Execute task A on all devices, then when it finishes on all devices execute task B (while identifigin the device and taskid map for A) 

or 

b. For each device, execute task A and when it finishes on this device only, proceed to B?

I assume it`s option b.

 

Also, can you please give a detailed example of what you retrieve viathe taskID A ?

Kind regards,

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi Marius,

I am looking for the below option

a. Execute task A on all devices, then when it finishes on all devices execute task B (while identifigin the device and taskid map for A) 

Example .

1. Task A - Executes Task on 10 Devices and write the output to respective files . ( 10 files in this case )

2.Task B - Once the Task A completes on all the devices i need to zip and mail all the files , names of the files will be the device ip or hostnames .  So inorder for me to know the devices on which the task has been executed we would need the task id from the task A to execute   (show_task id => xxx ) and iterate throughthe results

0 Likes
Absent Member.. Absent Member..
Absent Member..

Hi Drupan,

We have completed similar tasks as you described using a combination of HPNA and HPOO.  I have found a combination of utilizing both products helps accomplish these multi-step tasks much easier and cleaner.  For your example, HPOO can capture the NA task ID and utilize it as a variable in a different operation in the HPOO workflow. 

I know it may sound like I am trying to sell you on another HPOO product, but our experience in utilizing both products had been very successful. 

- David

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi David,

Appreciate your feedback.  Trying to see how we can leverage on the exiting HPNA product  as HPOO is again not be fesable option as of now .

I am sure there must be an option via in advanced scripts .

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi 

 

There are multiple ways to do this. via NA only.

Here is one To be run as external task.

 

1. Get your devices in a specific group.

2. You script 

Import NA perl modules Connect and Client


2.1 run command script - on the group (async mode). This is task A. The command will return the parent task id.
2.2 while task duration is NULL. wait. You can find this with show task -id taks_id_step2.1.
2.3 break while when duration is not null. Parent task has finished.
2.4. List child tasks list task -parentid taks_id_step2.2 For each shild taskid. list taks -id X. Get the device hostname. Create a file on filesystem [Hostname]-[ParentTaskID]-[optionallyAtimestamp]
2.5. Zip all files *ParentTaskID*. Send

 

Best Regards

 

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

View solution in original post

0 Likes
Commander Commander
Commander

Excellent solution, Marius.

I just did something like this. 

Thanks,

Srikanth

techsatish
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.