]> git.uio.no Git - perl-UiO.git/commitdiff
Added support for passwd file as a parameter
authorRagnar Hongset <ragnahon@hongset.uio.no>
Tue, 13 Aug 2013 07:38:04 +0000 (09:38 +0200)
committerRagnar Hongset <ragnahon@hongset.uio.no>
Tue, 13 Aug 2013 07:38:04 +0000 (09:38 +0200)
lib/UiO/SELF/virtcred.pm

index a88efa875a160bb6930ab21c71722996adc665d5..b6623bcfc374084da971bed69b2d8affac63c72e 100644 (file)
@@ -18,26 +18,11 @@ use UiO::virtcred;
 
 =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
 
@@ -107,26 +92,29 @@ use Exporter();
 $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;
 }