Author: arkurth
Date: Mon Dec 15 22:16:45 2014
New Revision: 1645773

URL: http://svn.apache.org/r1645773
Log:
VCL-428
Changed utils.pm::get_request_info to return a hash reference.

Modified:
    vcl/trunk/managementnode/bin/vcld
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/image.pm
    vcl/trunk/managementnode/lib/VCL/inuse.pm
    vcl/trunk/managementnode/lib/VCL/makeproduction.pm
    vcl/trunk/managementnode/lib/VCL/new.pm
    vcl/trunk/managementnode/lib/VCL/reclaim.pm
    vcl/trunk/managementnode/lib/VCL/reserved.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/bin/vcld
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/bin/vcld?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/bin/vcld (original)
+++ vcl/trunk/managementnode/bin/vcld Mon Dec 15 22:16:45 2014
@@ -224,7 +224,7 @@ sub main () {
                                next REQUEST;
                        }
                        
-                       my %request_info;
+                       my $request_info;
                        
                        
#===========================================================================
                        # Loop through the reservations associated with this 
request
@@ -294,24 +294,24 @@ sub main () {
                                }
                                
                                # Get the full set of database data for this 
request
-                               if (!%request_info) {
-                                       if (%request_info = 
get_request_info($request_id)) {
+                               if (!$request_info) {
+                                       if ($request_info = 
get_request_info($request_id)) {
                                                notify($ERRORS{'DEBUG'}, 
$LOGFILE, "retrieved request information from database");
                                                
                                                # Set request variables that 
may have changed by other processes to their original values
                                                # They may change if this is a 
cluster reservation
-                                               $request_info{state}{name}     
= $request_state_name;
-                                               $request_info{laststate}{name} 
= $request_laststate_name;
-                                               $request_info{preload}         
= $request_preload;
+                                               $request_info->{state}{name}    
 = $request_state_name;
+                                               
$request_info->{laststate}{name} = $request_laststate_name;
+                                               $request_info->{preload}        
 = $request_preload;
                                                
                                                # Add the check_time result to 
the hash
-                                               $request_info{CHECKTIME} = 
$check_time_result;
+                                               $request_info->{CHECKTIME} = 
$check_time_result;
                                                
                                                # Check if preload was returned 
by check_time and that preload flag is 0
                                                # The preload flag will be set 
to 1 by new.pm module after it's done
-                                               if ($check_time_result =~ 
/preload/ && !($request_info{preload})) {
+                                               if ($check_time_result =~ 
/preload/ && !($request_info->{preload})) {
                                                        notify($ERRORS{'OK'}, 
$LOGFILE, "request start time within 25-35 minute window and preload flag is 0, 
processing preload request");
-                                                       
$request_info{PRELOADONLY} = 1;
+                                                       
$request_info->{PRELOADONLY} = 1;
                                                }
                                        }
                                        else {
@@ -321,11 +321,11 @@ sub main () {
                                }
                                
                                # Add the reservation ID to be processed to the 
hash
-                               $request_info{RESERVATIONID} = $reservation_id;
+                               $request_info->{RESERVATIONID} = 
$reservation_id;
                                
                                # Get a new data structure object
                                my $data_structure;
-                               eval {$data_structure = new 
VCL::DataStructure({request_data => \%request_info, reservation_id => 
$reservation_id});};
+                               eval {$data_structure = new 
VCL::DataStructure({request_data => $request_info, reservation_id => 
$reservation_id});};
                                if (my $error = 
Exception::Class::Base->caught()) {
                                        notify($ERRORS{'CRITICAL'}, 0, "unable 
to create DataStructure object" . $error->message);
                                        next RESERVATION;
@@ -344,7 +344,7 @@ sub main () {
                                insertloadlog($reservation_id, $computer_id, 
"begin", "beginning to process, state is $request_state_name");
 
                                # Make a new child process, passing it the 
request/reservation info
-                               make_new_child({request_info => \%request_info, 
data_structure => $data_structure});
+                               make_new_child({request_info => $request_info, 
data_structure => $data_structure});
                        } ## end foreach my $reservation_id (keys 
%{$info{request...
                } ## end foreach my $request_id (keys %{$info{request}})
 

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Mon Dec 15 22:16:45 2014
@@ -947,18 +947,18 @@ sub refresh {
        my $request_laststate_name = $self->get_request_laststate_name();
 
        # Get the full set of database data for this request
-       if (my %request_info = get_request_info($request_id)) {
+       if (my $request_info = get_request_info($request_id)) {
                notify($ERRORS{'DEBUG'}, 0, "retrieved current request 
information from database for request $request_id");
 
                # Set the state names in the newly retrieved hash to their 
original values
-               $request_info{state}{name}     = $request_state_name;
-               $request_info{laststate}{name} = $request_laststate_name;
+               $request_info->{state}{name}     = $request_state_name;
+               $request_info->{laststate}{name} = $request_laststate_name;
 
                # Replace the request data for this DataStructure object
-               $self->refresh_request_data(\%request_info);
+               $self->refresh_request_data($request_info);
                notify($ERRORS{'DEBUG'}, 0, "updated DataStructure object with 
current request information from database");
 
-       } ## end if (my %request_info = get_request_info($request_id...
+       }
        else {
                notify($ERRORS{'WARNING'}, 0, "could not retrieve current 
request information from database");
                return;

Modified: vcl/trunk/managementnode/lib/VCL/image.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/image.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/image.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/image.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::image - Perl module for the VCL ima
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::image object based on the request information
- my $image = VCL::image->new(%request_info);
+ my $image = VCL::image->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/inuse.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/inuse.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::inuse - Perl module for the VCL inu
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info->($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::inuse object based on the request information
- my $inuse = VCL::inuse->new(%request_info);
+ my $inuse = VCL::inuse->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/makeproduction.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/makeproduction.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/makeproduction.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/makeproduction.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::makeproduction - Perl module for th
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info->($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::makeproduction object based on the request information
- my $makeproduction = VCL::makeproduction->new(%request_info);
+ my $makeproduction = VCL::makeproduction->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::new - Perl module for the VCL new s
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info->($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::new object based on the request information
- my $new = VCL::new->new(%request_info);
+ my $new = VCL::new->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reclaim.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::reclaim - Perl module for the VCL r
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::reclaim object based on the request information
- my $reclaim = VCL::reclaim->new(%request_info);
+ my $reclaim = VCL::reclaim->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Mon Dec 15 22:16:45 2014
@@ -32,13 +32,13 @@ VCL::reserved - Perl module for the VCL
  my $reservation_id = 6;
 
  # Call the VCL::utils::get_request_info subroutine to populate a hash
- my %request_info = get_request_info($request_id);
+ my $request_info = get_request_info($request_id);
 
  # Set the reservation ID in the hash
- $request_info{RESERVATIONID} = $reservation_id;
+ $request_info->{RESERVATIONID} = $reservation_id;
 
  # Create a new VCL::reserved object based on the request information
- my $reserved = VCL::reserved->new(%request_info);
+ my $reserved = VCL::reserved->new($request_info);
 
 =head1 DESCRIPTION
 

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1645773&r1=1645772&r2=1645773&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Mon Dec 15 22:16:45 2014
@@ -1766,64 +1766,58 @@ sub is_request_imaging {
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 get_next_image_default
+=head2 get_reservation_accounts
 
  Parameters  : $reservationid
- Returns     : userid,password,affiliation
+ Returns     : 
  Description : Used for server loads, provides list of users for group access
 
 =cut
 
 sub get_reservation_accounts {
-        my ($reservationid) = @_;
-        my ($calling_package, $calling_filename, $calling_line, $calling_sub) 
= caller(0);
-
-        if (!defined($reservationid)) {
-                notify($ERRORS{'WARNING'}, 0, "$calling_sub $calling_package 
missing mandatory variable: reservationid ");
-                return 0;
-        }
-
-        my $select_statement = "
-       SELECT DISTINCT
-       reservationaccounts.userid AS reservationaccounts_userid,
-       reservationaccounts.password AS reservationaccounts_password,
-       affiliation.name AS affiliation_name,
-       user.unityid AS user_name
-       FROM
-       reservationaccounts,
-       affiliation,
-       user
-       WHERE
-       user.id = reservationaccounts.userid AND
-       affiliation.id = user.affiliationid AND
-       reservationaccounts.reservationid = $reservationid
+       my ($reservation_id) = @_;
+       if (!defined($reservation_id)) {
+               notify($ERRORS{'WARNING'}, 0, "reservation ID argument was not 
supplied");
+               return 0;
+       }
+       
+       my $select_statement = "
+               SELECT DISTINCT
+               reservationaccounts.userid AS reservationaccounts_userid,
+               reservationaccounts.password AS reservationaccounts_password,
+               affiliation.name AS affiliation_name,
+               user.unityid AS user_name
+               FROM
+               reservationaccounts,
+               affiliation,
+               user
+               WHERE
+               user.id = reservationaccounts.userid AND
+               affiliation.id = user.affiliationid AND
+               reservationaccounts.reservationid = $reservation_id
        ";
-
-        # Call the database select subroutine
-        # This will return an array of one or more rows based on the select 
statement
-        my @selected_rows = database_select($select_statement);
-
-        my @ret_array;
+       
+       # Call the database select subroutine
+       # This will return an array of one or more rows based on the select 
statement
+       my @selected_rows = database_select($select_statement);
+       
+       my @ret_array;
        my %user_info;
-
-        # Check to make sure 1 or more rows were returned
-        if (scalar @selected_rows > 0) {
+       
+       # Check to make sure 1 or more rows were returned
+       if (scalar @selected_rows > 0) {
                # It contains a hash
-                for (@selected_rows) {
-                        my %reservation_acct= %{$_};
+               for (@selected_rows) {
+                       my %reservation_acct= %{$_};
                        my $userid = 
$reservation_acct{reservationaccounts_userid};
                        $user_info{$userid}{"userid"} = $userid;
                        $user_info{$userid}{"password"} = 
$reservation_acct{reservationaccounts_password};
                        $user_info{$userid}{"affiliation"} = 
$reservation_acct{affiliation_name};
                        $user_info{$userid}{"username"} = 
$reservation_acct{user_name};
                }
-               
                return %user_info;
-
        }
-               
        return ();
-
 }
 
 #/////////////////////////////////////////////////////////////////////////////
@@ -2981,7 +2975,7 @@ sub database_execute {
 =head2  get_request_info
 
  Parameters  : $request_id, $no_cache (optional)
- Returns     : hash
+ Returns     : hash reference
  Description : Retrieves all request/reservation information.
 
 =cut
@@ -3195,7 +3189,7 @@ EOF
        $request_info->{UPDATED}          = '0';
        
        #notify($ERRORS{'DEBUG'}, 0, "retrieved request info:\n" . 
format_data($request_info));
-       return %$request_info;
+       return $request_info;
 }
 
 #/////////////////////////////////////////////////////////////////////////////
@@ -5075,9 +5069,9 @@ EOF
                my $request_id = $row->{request_id};
                my $reservation_id = $row->{reservation_id};
                
-               my %request_info = get_request_info($request_id);
+               my $request_info = get_request_info($request_id);
                
-               if (!%request_info) {
+               if (!$request_info) {
                        # Request may have been deleted in this brief period
                        if (is_request_deleted($request_id)) {
                                notify($ERRORS{'OK'}, 0, "request was deleted 
before request info could be retrieved: $request_id");
@@ -5090,7 +5084,7 @@ EOF
                }
                
                my $data_structure;
-               eval {$data_structure = new VCL::DataStructure({request_data => 
\%request_info, reservation_id => $reservation_id});};
+               eval {$data_structure = new VCL::DataStructure({request_data => 
$request_info, reservation_id => $reservation_id});};
                if (my $exception = Exception::Class::Base->caught()) {
                        notify($ERRORS{'WARNING'}, 0, "unable to create 
DataStructure object" . $exception->message);
                        return;
@@ -6728,6 +6722,7 @@ EOF
        else {
                my $management_node_info = get_management_node_info();
                if ($management_node_info) {
+                       my $user_affiliation_name = 
$user_info->{affiliation}{name};
                        my $not_standalone_list = 
$management_node_info->{NOT_STANDALONE};
                        if (grep(/^$user_affiliation_name$/i, split(/[,;]/, 
$not_standalone_list))) {
                                notify($ERRORS{'DEBUG'}, 0, "non-standalone 
affiliation found for user $user_login_id:\nuser affiliation: 
$user_affiliation_name\nnot standalone list: $not_standalone_list");
@@ -7325,7 +7320,7 @@ sub populate_reservation_natport {
                return;
        }
        
-       my $request_info = {get_reservation_request_info($reservation_id, 0)};
+       my $request_info = get_reservation_request_info($reservation_id, 0);
        my $computer_id = 
$request_info->{reservation}{$reservation_id}{computerid};
        my $computer_name = 
$request_info->{reservation}{$reservation_id}{computer}{SHORTNAME};
        my $imagerevision_id = 
$request_info->{reservation}{$reservation_id}{imagerevision}{id};


Reply via email to