Author: fapeeler
Date: Fri Aug  8 18:13:51 2014
New Revision: 1616844

URL: http://svn.apache.org/r1616844
Log:
VCL-684

DataStructure.pm: removed retrieve_user_data


inuse: fixed typo


Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/inuse.pm

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1616844&r1=1616843&r2=1616844&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Fri Aug  8 18:13:51 2014
@@ -1372,164 +1372,6 @@ sub print_subroutines {
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 retrieve_user_data
-
- Parameters  : If subroutine is called as a DataStructure object method an no 
arguments are supplied:
-                  -the user ID stored in the DataStructure object is used
-                                               -the user login ID stored in 
the DataStructure object is used if the user ID is not set
-                                               -if neither the user ID or 
login ID are set in the object, an error message is generated and null is 
returned
-                                       If subroutine is NOT called as an 
object method, either of the following must be passed:
-                                          -user ID containing all digits 
(example: retrieve_user_data(2870))
-                                               -user ID containing all digits 
(example: retrieve_user_data('ibuser'))
-                                               -if an argument is not passed, 
an error message is generated and null is returned
- Returns     : If successful: hash reference containing user data (evaluates 
to true)
-               If failed: undefined (evaluates to false)
- Description : This subroutine attempts to retrieve data for a user.
-               If called as an object method the user data is stored in the 
DataStructure object.
-                                       If called as a class function, the data 
can be utilized by accessing the hash reference returned.
-                                       A populated DataStructure object does 
not need to be created in order to use this subroutine.
-                                       A reservation is not required in order 
to use this subroutine.
-                                       Examples:
-                                       use VCL::DataStructure;
-                                       
-                                       # Called as a class function
-                                       my $user_data = 
VCL::DataStructure::retrieve_user_data(2870);
-                                       foreach my $key (sort 
keys(%{$user_data})) {
-                                               print "key: $key, value: 
$user_data->{$key}\n";
-                                       }
-                                       
-                                       # Called as an object method
-                                       
$self->data->retrieve_user_data('ibuser');
-                                       print $self->data->get_user_id();
-
-=cut
-
-sub retrieve_user_data {
-       my $self;
-       my $argument = shift;
-       
-       # Check if subroutine was called as an object method
-       if (ref($argument) =~ /DataStructure/) {
-               # Subroutine was called as an object method, get next argument
-               $self = $argument;
-               $argument = shift;
-       }
-       
-       # Get a hash containing all of the tables and columns in the database
-       my $database_table_columns = VCL::utils::get_database_table_columns();
-       if (!$database_table_columns) {
-               notify($ERRORS{'WARNING'}, 0, "database table and column names 
could not be retrieved");
-               return;
-       }
-       
-       # Assemble a hash containing table names and aliases to be used in the 
select statement
-       my %tables_to_join = (
-               'user' => 'user',
-               'adminlevel' => 'user_adminlevel',
-               'affiliation' => 'user_affiliation',
-               'IMtype' => 'user_IMtype',
-       );
-       
-       # Assemble the WHERE part of the select statement
-       # The user must be specified by either passing an id or login_id 
argument
-       my $where_clause;
-       if ($argument && $argument =~ /^\d+$/) {
-               # Simple scalar argument was passed containing all digits, 
assume it's the user id
-               $where_clause = "user.id = '$argument'\n";
-       }
-       elsif ($argument) {
-               # Simple scalar argument was passed not consisting of all 
digits, assume it's the user login id
-               $where_clause = "user.unityid = '$argument'\n";
-       }
-       elsif ($self && (my $user_id = $self->get_user_id())) {
-               # Argument was not passed but subroutine was called as a 
DataStructure object method
-               # $self->get_user_id() returned something
-               $where_clause = "user.id = '$user_id'\n";
-       }
-       elsif ($self && (my $user_login_id = $self->get_user_login_id())) {
-               # Argument was not passed but subroutine was called as a 
DataStructure object method
-               # $self->get_user_login_id() returned something
-               $where_clause = "user.unityid = '$user_login_id'\n";
-       }
-       elsif (!$self) {
-               notify($ERRORS{'WARNING'}, 0, "unable to determine which user 
to query, subroutine was not called as an object method and id or login id 
argument was not passed");
-               return;
-       }
-       else {
-               notify($ERRORS{'WARNING'}, 0, "unable to determine which user 
to query, subroutine was called as an object method but get_user_id() and 
get_user_login_id() did not return values");
-               return;
-       }
-       
-       notify($ERRORS{'DEBUG'}, 0, "attempting to retrieve and store data for 
user: $where_clause");
-       
-       # Add the tables to join to the WHERE clause
-       $where_clause .= "AND user.adminlevelid = user_adminlevel.id\n";
-       $where_clause .= "AND user.affiliationid = user_affiliation.id\n";
-       $where_clause .= "AND user.IMtypeid = user_IMtype.id\n";
-       
-       # Loop through the tables which will be joined together and assemble 
the columns part of the select statement
-       # Get the column names for each table
-       # Assemble a line for each column: tablealias_table.column AS 
tablealias_column
-       my $sql_query_columns;
-       foreach my $table_to_join (keys(%tables_to_join)) {
-               my $table_alias = $tables_to_join{$table_to_join};
-               for my $column (@{$database_table_columns->{$table_to_join}}) {
-                       $sql_query_columns .= "$table_alias.$column AS 
$table_alias\_$column,\n";
-               }
-               $sql_query_columns .= "\n";
-       }
-       
-       # Remove the last comma and trailing newlines from the column names 
string
-       $sql_query_columns =~ s/,\n+$//;
-       
-       # Use join to put together the FROM part of the select statement
-       # This generates a string:
-       #    table1 tablealias1,
-       #    table2 tablealias2...
-       my $from_clause = join(",\n", map ("$_ $tables_to_join{$_}", 
keys(%tables_to_join)));
-       
-       # Assemble the select statement
-       my $sql_select_statement = "SELECT 
DISTINCT\n\n$sql_query_columns\n\nFROM\n$from_clause\n\nWHERE\n$where_clause";
-       
-       # Call database_select() to execute the select statement and make sure 
1 row was returned
-       my @select_rows = VCL::utils::database_select($sql_select_statement);
-       if (!scalar @select_rows == 1) {
-               notify($ERRORS{'WARNING'}, 0, "select statement returned " . 
scalar @select_rows . " rows:\n" . join("\n", $sql_select_statement));
-               return;
-       }
-       
-       # $select_rows[0] is a hash reference, the keys are the column names
-       # Loop through the column names and add the data to $self->request_data
-       my $user_data_row = $select_rows[0];
-       my %user_data_hash;
-       foreach my $column_name (sort keys(%{$user_data_row})) {
-               # Get the data value for the column
-               my $user_data_value = $user_data_row->{$column_name};
-               
-               # The column name is in the format: user_affiliation_name
-               # Underscores represent hash depth
-               # Transform the column name: user_affiliation_name --> 
{user}{affiliation}{name}
-               (my $hash_path = "{$column_name}") =~ s/_/}{/g;
-               
-               # Use eval to set the correct data key to the value
-               eval '$user_data_hash' . $hash_path . '= $user_data_value';
-       }
-       
-       # Attempt to get the user ID and login ID from the data that was just 
retrieved
-       my $user_id = $user_data_hash{user}{id};
-       my $user_login_id = $user_data_hash{user}{unityid};
-       if (!$user_id && $user_login_id) {
-               notify($ERRORS{'WARNING'}, 0, "user id and login id could not 
be determined for user data just retrieved");
-               return;
-       }
-       
-       notify($ERRORS{'DEBUG'}, 0, "data has been retrieved for user: 
$user_login_id (id: $user_id)");
-       
-       return $user_data_hash{user};
-}
-
-#/////////////////////////////////////////////////////////////////////////////
-
 =head2 get_log_data
 
  Parameters  : log ID (optional)
@@ -1776,7 +1618,7 @@ sub get_image_affiliation_name {
        }
        
        # Get the data for the user who owns the image
-       my $image_owner_data = $self->retrieve_user_data($image_owner_id);
+       my $image_owner_data = get_user_info($image_owner_id);
        unless ($image_owner_data) {
                notify($ERRORS{'WARNING'}, 0, "unable to retrieve image owner 
data in order to determine image affiliation");
                return;
@@ -1824,7 +1666,7 @@ sub get_image_affiliation_id {
        }
        
        # Get the data for the user who owns the image
-       my $image_owner_data = $self->retrieve_user_data($image_owner_id);
+       my $image_owner_data = get_user_info($image_owner_id);
        unless ($image_owner_data) {
                notify($ERRORS{'WARNING'}, 0, "unable to retrieve image owner 
data in order to determine image affiliation");
                return;

Modified: vcl/trunk/managementnode/lib/VCL/inuse.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1616844&r1=1616843&r2=1616844&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/inuse.pm Fri Aug  8 18:13:51 2014
@@ -523,7 +523,7 @@ EOF
        
        # Send message to machine
        if ($computer_type =~ /blade|virtualmachine/) {
-               sif ($image_os_type =~ /osx/){
+               if ($image_os_type =~ /osx/){
         # Notify via oascript
         notify_via_oascript($computer_short_name, $user_login_id, 
$short_message);
      }


Reply via email to