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
334 views

Use task specific credential​s in advanced scripts

Jump to solution

Hi,

I am leveraging on HPNA Advanced Script (Perl ) while executing "Command Scripts " for certain changes but i am not sure how to use task specifc credentails while running the advanced scripts.

In the below script Opsware::NAS::Connect connects to HPNA using $tc_user_username$ and then

$con->connect( $device ) implicitly uses "Standard Device Credentials" but i want to use task specific credentials.

 

==

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

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

$con->login();
$con->connect( $device ) or die "Failed to connect.";

 

I have restricted the "Command Scripts" to run only via "Use Task Specifc Credentials" under task "Device Credentials Options" but how can the script access these variables to connect to the device ?

0 Likes
1 Solution

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

Hi,

 

In NA 10.11 request from support a hotfix including interactive login feature for Connect.pm

connect (-devuser x, -devpass y, $tc_device_ip)

 

Without the updated connect pm module, while using -login you will have to implement prompt handling and a form of retrieving the device user/pwd to connect.

 

Kind regards,

Marius

 

 

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

View solution in original post

0 Likes
3 Replies
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi,

You might have 2 options here.

1. in NA 10.11 request from support a hotfix including interactive login feature for Connect.pm

connect (-devuser x, -devpass y, $tc_device_ip)

Below the list of options including prompts.

item B<connect>-E<gt>( I<%OPTIONS>, I<$device_ip>, I<$prompt_regex> )

Connect to a NA-managed device by giving the IP address and a optional
regular expression that will match the device's command-line prompt.

B<OPTIONS>

=over 8

=item B<-devuser> => I<"User-Name">

Supply a valid user name, the same name you would use to log into
the device.

=item B<-devpass> => I<"Password">

Supply the password for the user given with the B<-devuser> option above.

=item B<-devuserprompt> => I<"Regexp">

Supply the login username prompt.
Can be Regexp, "/regex/", or "regex".
Defaults to 'Login:'.

=item B<-devpassprompt> => I<Regexp>

Supply the login password prompt.
Can be Regexp, "/regex/", or "regex".
Defaults to 'Password:'.

---

The $devuser and $devpass you pull as user defined variables ($devuser$, $devpass$) that can be initialized at task execution in webui.

 

Option 2.

a. You create command scripts for the commands you need to pass on the device.

b. Your script will call

- mod authentication (-loc db) to add device specific credentials

- run command script, capture output by taskid, etc

- mod authentication or del authentication (-loc db) for the device.

The idea is to bypass the connect() call in your script.

 

Best regards,

Marius

 

 

Marius Herculea
HP SW Technical Consultant

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

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

Hello  Mherculea ,

Thanks for the updates. i do notice that CLI API for 'connect' has a option to use -login which bypasses single singon

==

NA>help connect

NAME
     connect - Connect to a device.

SYNOPSIS
     connect [-login] [-method <telnet|ssh|ssh1|ssh2|rlogin>] [-override] [-info                                                                                                                                                             ]
     [-ignoreptyerrors] <hostname> [<port>]

DESCRIPTION
     Connect to a device through the system's Proxy Interface via telnet, ssh, o                                                                                                                                                             r
     rlogin. If you are connected to a device through a console server, you may
     hit ctrl-\ to return to the the system shell after logging out of the
     device.

     -login
          Bypass single sign-on and instead take the user to the device login pr       

==

is this option not available in perl api while using connect ?  connect(-deviceid,-login) ?

                                                                                                                  

             

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

Hi,

 

In NA 10.11 request from support a hotfix including interactive login feature for Connect.pm

connect (-devuser x, -devpass y, $tc_device_ip)

 

Without the updated connect pm module, while using -login you will have to implement prompt handling and a form of retrieving the device user/pwd to connect.

 

Kind regards,

Marius

 

 

Marius Herculea
HP SW Technical Consultant

Cloud and Automation Professional Services

View solution in original post

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.