Welcome Serena Central users!
The migration of the Serena Central community is happening today. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Bobin Thomas Regular Contributor.
Regular Contributor.
667 views

Getting multiple device password in Advanced Script

Hi all,

I am trying to write a script to achieve below task using Python Advanced Script :

1. Run command script on a device A
2. Execute a command on A and get list of devices associated to A ( Say, device B, device C .... )
3. Login in associated devices ( Say, device B, device C .... )
4. Execute a command and get output from ( Say, device B, device C .... ).

Issue :

I am getting password for device A where advanced script is running via variable "$tc_device_password$".
Later when my script need to device B and device C, it seems $tc_device_password$ is not working as password. It seems $tc_device_password$ is specific password only for the device at which advanced script is running.

How can I get password for device B, device C etc ?
If there is not way to get password for other device than which adv script is running , then another option is run the command script on HPNA server as use <connect device> , In that case, 

1. What need to be the device to be selected in advanced script wizard while running the advanced script ?

2. How can i execute HPNA commands like  "connect <device>" using python script in advanced script?

 

ANy pointers greatly appreciated.

 

Regards

Bobin

 

 

0 Likes
6 Replies
Chris_Powers Acclaimed Contributor.
Acclaimed Contributor.

Re: Getting multiple device password in Advanced Script

OK, you say you setup an advanced script so based on that, you should have something with these lines (or similar):

use Opsware::NAS::Connect;

my($host, $port, $user, $pass) = ('localhost','$tc_proxy_telnet_port$','$tc_user_username$','$tc_user_password$');

my $con = Opsware::NAS::Connect->new(-user => $user, -pass => $pass, -host => $host, -port => $port);

This should do what you're asking for, it'll connect to each device that the script is told to run on using the needed credentials.  

I'm guessing that all your devices are working in NA?  Snapshots are good / current (credentials are working)?  

If you run a basic script on these devices, any issues there?  

-Chris

0 Likes
Bobin Thomas Regular Contributor.
Regular Contributor.

Re: Getting multiple device password in Advanced Script

Hi Chris,

Thanks for the quick response. I will try new method of login. My problem is, in my example,

Device A only I am running script, srcipt is not running on Device B and C. B's and C's IP i get from device A show output and I have to connect using same script.

Currently using Python pexpect.

1. Connect to A using pexpect spawn (using $tc_user_username$','$tc_user_password$')
2. Get B and C IP from A
3. Connect to B and C using another pexpect spawn. But I cannot use $tc_user_username$','$tc_user_password$' as these variable contains still A's username and password.

 

0 Likes
Chris_Powers Acclaimed Contributor.
Acclaimed Contributor.

Re: Getting multiple device password in Advanced Script

OK, if you want NA to log in, then you could do a few things but sorry, not the easiest way to go....

The script that calls device A and ends up getting the other devices that you need NA to do something to, would call yet another script inside that first script..

So, something like:

script A

    Connects to device A

         does whatever it does

         collects a list of other devices, B, C, D

         runs script B (and script A will pass devices B, C, D to script B).  

                      This will connect to B, C, D and I believe this gets treated as a new / separate connect and therefore should have those device credentials avaialble.    

There may be a different way to go about this, but inside NA, this was the first thing I thought of.  

-Chris

0 Likes
Bobin Thomas Regular Contributor.
Regular Contributor.

Re: Getting multiple device password in Advanced Script

Hi Chris,

That option looks like promising. I am a beginner in HPNA.
Can you please tell me in python command script how can call another command script.
Say like, I will
1) Create advance script 'Y' for running on Devices 'B', 'C' etc and print output 'P'
2) Create another advance script 'X' for running on Device 'A', which will get IP for Device B,C etc
3) Then on Script 'X', call/run Script 'Y' to run on Device B,C etc
4) Script X receives output 'P' from Script Y

How can I do Step#3 and #4 if my Script X is in python ?

Thanks
Bobin

0 Likes
Bobin Thomas Regular Contributor.
Regular Contributor.

Re: Getting multiple device password in Advanced Script

Hi Chris,

 

Any update on how to run another "Advanced Script" from a Python written Advanced Script ?

Regards

Bobin

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Getting multiple device password in Advanced Script

Hi @Bobin Thomas,

you will need to use the run_script option for python either using the api.wsdl.soappy or the http://192.168.0.112/soap?wsdl

I havent dig very deep on python, but these are the options for a call on the run_script

ns0:run_scriptInputParms(ns0:run_scriptInputParms)
ns0:run_scriptInputParms(ns0:run_scriptInputParms)
ns0:run_scriptInputParms(sessionid: xsd:string, runmode: xsd:string, linebyline: xsd:string, stoponfailure: xsd:string, ip: xsd:string, start: xsd:string, taskname: xsd:string, priority: xsd:int, sync: xsd:string, script: xsd:string, mode: xsd:string, disablesessionlogging: xsd:string, postsnapshot: xsd:string, comment: xsd:string, presnapshot: xsd:string, rep: xsd:string, nowait: xsd:string, group: xsd:string, host: xsd:string, fqdn: xsd:string, deviceid: xsd:int)
run_script(parameters: ns0:run_scriptInputParms, _soapheaders={header: ns0:RequestHeader}) -> Result: ns0:Result
run_script(parameters: ns0:run_scriptInputParms, _soapheaders={header: ns0:RequestHeader}) -> Result: ns0:Result

Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
Tags (2)
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.