Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class
1049 views

HPNA : Use task specific credentials in advanced scripts

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.";

==

hpna_advanced.JPGI 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
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

Cloud and Automation Professional Services

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

The does not answer the question of how to utilize the task specific credentials. It would appear to be a bug that the $tc_device_username$ and $tc_device_password$ are not being set.

The purposed solution of prompting the user for a second set of credentials for set $devusr$ and $devpass$ is undesirable since the script will update the password in the clear and it will be in the clear in any log files, not to mention the redundancy of having to type in the credentials twice.

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

Hi Larry / Marlus,

 

What would be a good solution in this case then ?  its more of a bug as you mentioned , there must be a way for user specific task to be passed to the advanced script as it helps to track the user who made the changes . 

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.