=head1 B<DESCRIPTION>
-Exports routines for bofh manipulation
+Small module used for reading in user credentials for SELF scripts
=over 4
-<> login
-
-<> logout
-
-<> run_command
-
-<> list_roles
-
-<> dhcp_assoc
-
-<> host_add
-
-<> add_role
-
-<> get_commands
-
+<> credentials
=back
$VERSION = 1.01;
sub credentials {
+ my ($passwd) = @_;
+
# get credentials for vmware, db and bofh
- open (CRED, "/site/etc/vmware-virtprov-authfile") or die "Not able to open cred file $!\n";
+ open (CRED, $passwd) or die "Not able to open cred file $!\n";
my ($vmPROD, $vmTEST, $vmuser,$vmpasswd, $db, $dbhost, $dbuser, $dbpasswd, $bofh_user, $bofh_pw, $bofh_url);
+ my %cred=();
foreach (<CRED>) {
chomp;
s/"//g;
my ($key, $value) = split(/=/,$_);
- ($vmPROD) = split(/\ /, $value) if ($key eq "vmPROD");
- ($vmTEST) = split(/\ /, $value) if ($key eq "vmTEST");
- ($vmuser) = split(/\ /, $value) if ($key eq "vmuser");
- ($vmpasswd) = split(/\ /, $value) if ($key eq "vmpasswd");
- ($db) = split(/\ /, $value) if ($key eq "db");
- ($dbhost) = split(/\ /, $value) if ($key eq "dbhost");
- ($dbuser) = split(/\ /, $value) if ($key eq "dbuser");
- ($dbpasswd) = split(/\ /, $value) if ($key eq "dbpasswd");
- ($bofh_user) = split(/\ /, $value) if ($key eq "bofh_user");
- ($bofh_pw) = split(/\ /, $value) if ($key eq "bofh_pw");
- ($bofh_url) = split(/\ /, $value) if ($key eq "bofh_url");
+ ($cred{'vmPROD'}) = split(/\ /, $value) if ($key eq "vmPROD");
+ ($cred{'vmTEST'}) = split(/\ /, $value) if ($key eq "vmTEST");
+ ($cred{'vmuser'}) = split(/\ /, $value) if ($key eq "vmuser");
+ ($cred{'vmpasswd'}) = split(/\ /, $value) if ($key eq "vmpasswd");
+ ($cred{'db'}) = split(/\ /, $value) if ($key eq "db");
+ ($cred{'dbhost'}) = split(/\ /, $value) if ($key eq "dbhost");
+ ($cred{'dbuser'}) = split(/\ /, $value) if ($key eq "dbuser");
+ ($cred{'dbpasswd'}) = split(/\ /, $value) if ($key eq "dbpasswd");
+ ($cred{'bofh_user'}) = split(/\ /, $value) if ($key eq "bofh_user");
+ ($cred{'bofh_pw'}) = split(/\ /, $value) if ($key eq "bofh_pw");
+ ($cred{'bofh_url'}) = split(/\ /, $value) if ($key eq "bofh_url");
}
- return ($vmPROD, $vmTEST, $vmuser, $vmpasswd, $db, $dbhost, $dbuser, $dbpasswd, $bofh_user, $bofh_pw, $bofh_url);
+ return %cred;
}