You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2014/04/22 18:15:56 UTC

svn commit: r1589196 - in /vcl/trunk/managementnode/lib/VCL: DataStructure.pm Module/OS.pm Module/OS/Linux.pm Module/OS/Windows.pm Module/Provisioning/Lab.pm Module/Provisioning/xCAT.pm inuse.pm reclaim.pm reserved.pm utils.pm

Author: fapeeler
Date: Tue Apr 22 16:15:55 2014
New Revision: 1589196

URL: http://svn.apache.org/r1589196
Log:
VCL-758

Improved functionality for timing variables. Begining steps to allow VCL admins to set different timing values for selected events related to reservations.

- Moved the following from DataStructure to utils to allow for calls from non-objects

get_variable, set_variable, is_variable_set, yaml_deserialize, yaml_serialize

Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/Lab.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
    vcl/trunk/managementnode/lib/VCL/inuse.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/lib/VCL/DataStructure.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Tue Apr 22 16:15:55 2014
@@ -485,6 +485,9 @@ $SUBROUTINE_MAPPINGS{management_node_pre
 $SUBROUTINE_MAPPINGS{management_node_predictive_module_description} = '$ENV{management_node_info}{predictive_description}';
 $SUBROUTINE_MAPPINGS{management_node_predictive_module_perl_package} = '$ENV{management_node_info}{predictive_perlpackage}';
 
+$SUBROUTINE_MAPPINGS{general_inuse_check} = '$ENV{management_node_info}{GENERAL_INUSE_CHECK}';
+$SUBROUTINE_MAPPINGS{server_inuse_check} = '$ENV{management_node_info}{SERVER_INUSE_CHECK}';
+
 $SUBROUTINE_MAPPINGS{subroutine_mappings} = '\%SUBROUTINE_MAPPINGS';
 
 ##############################################################################
@@ -1786,372 +1789,13 @@ sub set_computer_private_ip_address {
 	return 1;
 }
 
-#/////////////////////////////////////////////////////////////////////////////
-
-=head2 is_variable_set
-
- Parameters  : variable name
- Returns     : If variable is set: 1
-               If variable is not set: 0
-               If an error occurred: undefined
- Description : Queries the variable table for the variable with the name
-               specified by the argument. Returns true if the variable is set,
-               false otherwise.
-
-=cut
-
-sub is_variable_set {
-	my $variable_name = shift;
-	
-	# Check if 1st argument is a reference meaning this was called as an object method
-	# If so, ignore 1st reference argument and call shift again
-	if (ref($variable_name)) {
-		$variable_name = shift;
-	}
-	
-	# Check the argument
-	if (!defined($variable_name)) {
-		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
-		return;
-	}
-	
-	# Construct the select statement
-my $select_statement .= <<"EOF";
-SELECT
-variable.value
-FROM
-variable
-WHERE
-variable.name = '$variable_name'
-EOF
-	
-	# Call the database select subroutine
-	my @selected_rows = database_select($select_statement);
-
-	# Check to make 1 sure row was returned
-	if (!@selected_rows){
-		notify($ERRORS{'DEBUG'}, 0, "variable is NOT set: $variable_name");
-		return 0;
-	}
-	elsif (@selected_rows > 1){
-		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', multiple rows exist in the database for variable:\n" . format_data(\@selected_rows));
-		return;
-	}
-	
-	# Get the serialized value from the variable row
-	my $database_value = $selected_rows[0]{value};
-	
-	if (defined($database_value)) {
-		notify($ERRORS{'DEBUG'}, 0, "variable is set: $variable_name");
-		return 1;
-	}
-	else {
-		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', row returned:\n" . format_data(\@selected_rows));
-		return;
-	}
-}
-
-#/////////////////////////////////////////////////////////////////////////////
-
-=head2 get_variable
-
- Parameters  : $variable_name, $show_warnings (optional)
- Returns     : If successful: data stored in the variable table for the variable name specified
-               If failed: false
- Description : Queries the variable table for the variable with the name
-               specified by the argument. Returns the data stored for the
-               variable. Values are deserialized before being returned if the
-               value stored was a reference.
-               
-               Undefined is returned if the variable name does not exist in the
-               variable table. A log message is displayed by default. To
-               suppress the log message, supply the $show_warnings argument with
-               a value of 0.
-
-=cut
-
-sub get_variable {
-	# Check if 1st argument is a reference meaning this was called as an object method
-	# If so, ignore 1st reference argument
-	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
-	
-	# Check the argument
-	my $variable_name = shift;
-	if (!defined($variable_name)) {
-		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
-		return;
-	}
-	
-	my $show_warnings = shift;
-	$show_warnings = 1 unless defined $show_warnings;
-	
-	# Construct the select statement
-my $select_statement .= <<"EOF";
-SELECT
-variable.value,
-variable.serialization
-FROM
-variable
-WHERE
-variable.name = '$variable_name'
-EOF
-	
-	# Call the database select subroutine
-	my @selected_rows = database_select($select_statement);
-
-	# Check to make 1 sure row was returned
-	if (!@selected_rows){
-		notify($ERRORS{'OK'}, 0, "variable '$variable_name' is not set in the database") if $show_warnings;
-		return 0;
-	}
-	elsif (@selected_rows > 1){
-		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', multiple rows exist in the database for variable:\n" . format_data(\@selected_rows));
-		return;
-	}
-	
-	# Get the serialized value from the variable row
-	my $serialization_type = $selected_rows[0]{serialization};
-	my $database_value = $selected_rows[0]{value};
-	my $deserialized_value;
-	
-	# Deserialize the variable value if necessary
-	if ($serialization_type eq 'none') {
-		$deserialized_value = $database_value;
-	}
-	elsif ($serialization_type eq 'yaml') {
-		# Attempt to deserialize the value
-		$deserialized_value = yaml_deserialize($database_value);
-		if (!defined($deserialized_value)) {
-			notify($ERRORS{'WARNING'}, 0, "unable to deserialize variable '$variable_name' using YAML");
-			return;
-		}
-		
-		# Display the data type of the value retrieved from the variable table
-		if (my $deserialized_data_type = ref($deserialized_value)) {
-			notify($ERRORS{'DEBUG'}, 0, "data type of variable '$variable_name': $deserialized_data_type reference");
-		}
-		else {
-			notify($ERRORS{'DEBUG'}, 0, "data type of variable '$variable_name': scalar");
-		}
-	}
-	elsif ($serialization_type eq 'phpserialize') {
-		# TODO: find Perl module to handle PHP serialized data
-		# Add module to list of dependencies
-		# Add code here to call PHP deserialize function
-		notify($ERRORS{'CRITICAL'}, 0, "unable to get value of variable '$variable_name', PHP serialized data is NOT supported yet by the VCL backend, returning null");
-		return;
-	}
-	else {
-		notify($ERRORS{'CRITICAL'}, 0, "unable to get value of variable '$variable_name', serialization type '$serialization_type' is NOT supported by the VCL backend, returning null");
-		return;
-	}
-	
-	notify($ERRORS{'DEBUG'}, 0, "retrieved variable '$variable_name', serialization: $serialization_type");
-	return $deserialized_value;
-}
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 set_variable
-
- Parameters  : variable name, variable value
- Returns     : If successful: true
-               If failed: false
- Description : Inserts or updates a row in the variable table. The variable name
-               and value arguments must be specified.
-               
-               The value can be a simple scalar such as a string or a reference
-               to a complex data structure such as an array of hashes.
-               
-               Simple scalar values are stored in the variable.value column
-               as-is and the variable.serialization column will be set to
-               'none'.
-               
-               References are serialized using YAML before being stored. The
-               variable.value column will contain the YAML representation of the
-               data and the variable.serialization column will be set to 'yaml'.
-               
-               This subroutine will also update the variable.timestamp column.
-               The variable.setby column is automatically set to the filename
-               and line number which called this subroutine.
-
-=cut
-
-sub set_variable {
-	# Check if 1st argument is a reference meaning this was called as an object method
-	# If so, ignore 1st reference argument
-	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
-	
-	my $variable_name = shift;
-	
-	# Get the 2nd argument containing the variable value
-	my $variable_value = shift;
-	
-	# Check the arguments
-	if (!defined($variable_name)) {
-		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
-		return;
-	}
-	elsif (!defined($variable_value)) {
-		notify($ERRORS{'WARNING'}, 0, "variable value argument was not supplied");
-		return;
-	}
-	
-	notify($ERRORS{'DEBUG'}, 0, "attempting to set variable: $variable_name");
-	
-	# Set serialization type to yaml if the value being stored is a reference
-	# Otherwise, a simple scalar is being stored and serialization is not necessary
-	my $serialization_type;
-	if (ref($variable_value)) {
-		$serialization_type = 'yaml';
-	}
-	else {
-		$serialization_type = 'none';
-	}
-	
-	# Construct a string indicating where the variable was set from
-	my @caller = caller(0);
-	(my $calling_file) = $caller[1] =~ /([^\/]*)$/;
-	my $calling_line = $caller[2];
-	my $caller_string = "$calling_file:$calling_line";
-	
-	# Attempt to serialize the value if necessary
-	my $database_value;
-	if ($serialization_type eq 'none') {
-		$database_value = $variable_value;
-	}
-	else {
-		# Attempt to serialize the value using YAML
-		$database_value = yaml_serialize($variable_value);
-		if (!defined($database_value)) {
-			notify($ERRORS{'WARNING'}, 0, "unable to serialize variable '$variable_name' using YAML, value:\n" . format_data($variable_value));
-			return;
-		}
-	}
-	
-	# Escape all backslashes
-	$database_value =~ s/\\/\\\\/g;
-	
-	# Escape all single quote characters with a backslash
-	#   or else the SQL statement will fail becuase it is wrapped in single quotes
-	$database_value =~ s/'/\\'/g;
-	
-	# Assemble an insert statement, if the variable already exists, update the existing row
-	my $insert_statement .= <<"EOF";
-INSERT INTO variable
-(
-name,
-serialization,
-value,
-setby,
-timestamp
-)
-VALUES
-(
-'$variable_name',
-'$serialization_type',
-'$database_value',
-'$caller_string',
-NOW()
-)
-ON DUPLICATE KEY UPDATE
-name=VALUES(name),
-serialization=VALUES(serialization),
-value=VALUES(value),
-setby=VALUES(setby),
-timestamp=VALUES(timestamp)
-EOF
-	
-	# Execute the insert statement, the return value should be the id of the row
-	my $inserted_id = database_execute($insert_statement);
-	if ($inserted_id) {
-		notify($ERRORS{'OK'}, 0, "set variable '$variable_name', variable id: $inserted_id, serialization: $serialization_type");
-	}
-	else {
-		notify($ERRORS{'WARNING'}, 0, "failed to set variable '$variable_name', serialization: $serialization_type");
-		return;
-	}
-	
-	return 1;
-}
-
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 yaml_serialize
-
- Parameters  : Data
- Returns     : If successful: string containing serialized representation of data
-               If failed: false
- Description : 
-
-=cut
-
-sub yaml_serialize {
-	# Check if 1st argument is a reference meaning this was called as an object method
-	# If so, ignore 1st reference argument
-	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
-	
-	# Check to make sure argument was passed
-	my $data_argument = shift;
-	if (!defined($data_argument)) {
-		notify($ERRORS{'WARNING'}, 0, "data argument was not passed");
-		return;
-	}
-	
-	# Attempt to serialize the value using YAML::Dump()
-	# Use eval because Dump() will call die() if it encounters an error
-	my $serialized_data;
-	eval '$serialized_data = YAML::Dump($data_argument)';
-	if ($EVAL_ERROR) {
-		notify($ERRORS{'WARNING'}, 0, "unable to serialize data using YAML::Dump(), data value: $data_argument");
-		return;
-	}
-	
-	# Escape all backslashes
-	$serialized_data =~ s/\\/\\\\/g;
-	
-	# Escape all single quote characters with a backslash
-	#   or else the SQL statement will fail becuase it is wrapped in single quotes
-	$serialized_data =~ s/'/\\'/g;
-	
-	return $serialized_data;
-}
-
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 yaml_deserialize
-
- Parameters  : Data
- Returns     : If successful: data structure
-               If failed: false
- Description : 
-
-=cut
-
-sub yaml_deserialize {
-	# Check if 1st argument is a reference meaning this was called as an object method
-	# If so, ignore 1st reference argument and call shift again
-	my $yaml_data_argument = shift;
-	if (ref($yaml_data_argument)) {
-		$yaml_data_argument = shift;
-	}
-	
-	# Check to make sure argument was passed
-	if (!defined($yaml_data_argument)) {
-		notify($ERRORS{'WARNING'}, 0, "data argument was not passed");
-		return;
-	}
-	
-	my $deserialized_value;
-	eval '$deserialized_value = YAML::Load($yaml_data_argument)';
-	if ($EVAL_ERROR) {
-		notify($ERRORS{'WARNING'}, 0, "unable to deserialize data using YAML::Load(), data value: $yaml_data_argument");
-		return;
-	}
-	
-	return $deserialized_value;
-}
-
 #/////////////////////////////////////////////////////////////////////////////
 
 =head2 get_image_affiliation_name

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Tue Apr 22 16:15:55 2014
@@ -3286,9 +3286,9 @@ sub update_fixedIP_info {
 	my $variable_name = "fixedIPsr" . $server_request_id; 	
    my $server_variable_data;
 
-	if($self->data->is_variable_set($variable_name)){
+	if(is_variable_set($variable_name)){
 		  #fetch variable
-		  $server_variable_data  = $self->data->get_variable($variable_name);
+		  $server_variable_data  = get_variable($variable_name);
 
 		  notify($ERRORS{'DEBUG'}, 0, "data is set for $variable_name" . format_data($server_variable_data));
 			
@@ -3309,6 +3309,54 @@ sub update_fixedIP_info {
 
 }
 
+#/////////////////////////////////////////////////////////////////////////////
+=head2 get_timings
+
+   Parameters  : $self
+   Returns     : hash of timings
+   Description : Check for cached information or pulls from variable table
+   Acceptable variables are:
+      acknowledgetimeout
+      wait_for_connect
+      wait_for_reconnect
+      general_inuse_check
+      server_inuse_check
+      general_end_notice_first
+      general_end_notice_second
+      ignore_connections_gte
+
+=cut
+
+#/////////////////////////////////////////////////////////////////////////////
+
+sub get_timings {
+	my $self = shift;
+	my $variable = shift;
+	my $affiliation_name = $self->data->get_user_affiliation_name(0);
+
+   my %timing_defaults = (
+      acknowledgetimeout => '900',
+      connecttimeout => '900',
+      wait_for_connect => '900',
+      wait_for_reconnect => '900',
+      general_inuse_check => '300',
+      server_inuse_check => '900',
+      general_end_notice_first => '600',
+      general_end_notice_second => '300',
+      ignore_connections_gte => '1440'
+   );
+
+	#Check for affiliation, if nothing return default timings
+   if (!defined($variable) || !(exists($timing_defaults{$variable}))) {
+		notify($ERRORS{'WARNING'}, 0, " input variable is not acceptable, returning 900 as value"); 
+      return '900';
+   }
+
+	my $db_timing_variable_value = get_variable("$variable|$affiliation_name", 0) || get_variable("$variable", 0) || $timing_defaults{$variable} ;
+	return $db_timing_variable_value;
+
+}
+
 #///////////////////////////////////////////////////////////////////////////
 
 1;

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Tue Apr 22 16:15:55 2014
@@ -1023,12 +1023,12 @@ sub synchronize_time {
 	my $variable_name_global = "timesource|global";
 	
 	my $time_source_variable;
-	if ($self->data->is_variable_set($variable_name)) {
-		$time_source_variable = $self->data->get_variable($variable_name);
+	if (is_variable_set($variable_name)) {
+		$time_source_variable = get_variable($variable_name);
 		notify($ERRORS{'DEBUG'}, 0, "retrieved time source variable '$variable_name': $time_source_variable");
 	}
-	elsif ($self->data->is_variable_set($variable_name_global)) {
-		$time_source_variable = $self->data->get_variable($variable_name_global);
+	elsif (is_variable_set($variable_name_global)) {
+		$time_source_variable = get_variable($variable_name_global);
 		notify($ERRORS{'DEBUG'}, 0, "retrieved global time source variable '$variable_name_global': $time_source_variable");
 	}
 	else {
@@ -3029,7 +3029,7 @@ sub check_connection_on_port {
 	
 	my $ret_val = "no";
 	my $command = "netstat -an";
-	my ($status, $output) = $self->execute($command, '', '', 0);
+	my ($status, $output) = $self->execute($command, 0);
 	notify($ERRORS{'DEBUG'}, 0, "checking connections on node $computer_node_name on port $port");
 	foreach my $line (@{$output}) {
 		if ($line =~ /Connection refused|Permission denied/) {

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Tue Apr 22 16:15:55 2014
@@ -8587,14 +8587,14 @@ sub configure_time_synchronization {
 	my $time_source;
    my $variable_name = "timesource|" . $self->data->get_management_node_hostname();
    my $variable_name_global = "timesource|global";
-   if($self->data->is_variable_set($variable_name)){
+   if(is_variable_set($variable_name)){
        #fetch variable
-       $time_source = $self->data->get_variable($variable_name);
+       $time_source = get_variable($variable_name);
        notify($ERRORS{'DEBUG'}, 0, "time_source is $time_source  set for $variable_name");
     }
-    elsif($self->data->is_variable_set($variable_name_global) ) {
+    elsif(is_variable_set($variable_name_global) ) {
        #fetch variable
-       $time_source = $self->data->get_variable($variable_name_global);
+       $time_source = get_variable($variable_name_global);
        notify($ERRORS{'DEBUG'}, 0, "time_source is $time_source  set for $variable_name");
     }
 	 else {
@@ -11720,8 +11720,8 @@ sub check_image {
 		return;
 	}
 	
-	#$self->data->set_variable('ignore_users', 'Administrator,cyg_server,Guest,root,sshd,HelpAssistant,SUPPORT_388945a0,ASPNET');
-	#$self->data->set_variable('disable_users', 'test');
+	#set_variable('ignore_users', 'Administrator,cyg_server,Guest,root,sshd,HelpAssistant,SUPPORT_388945a0,ASPNET');
+	#set_variable('disable_users', 'test');
 	
 	my $imagerevision_id = $self->data->get_imagerevision_id();
 	my $image_name = $self->data->get_image_name();
@@ -11740,12 +11740,12 @@ sub check_image {
 	my $reservation_user_names_regex = join("|", @reservation_user_names);
 
 	# Get list of user names which should be ignored in images (safe, normal users: Administrator, guest...)
-	my $ignore_user_names_variable = $self->data->get_variable('ignore_users') || '';
+	my $ignore_user_names_variable = get_variable('ignore_users') || '';
 	my @ignore_user_names = sort {lc($a) cmp lc($b)} (split(/[,;]+/, $ignore_user_names_variable));
 	my $ignore_user_names_regex = join("|", @ignore_user_names);
 	
 	# Get list of user names which should be disabled in images - known bad, unsafe
-	my $disable_user_names_variable = $self->data->get_variable('disable_users') || '';
+	my $disable_user_names_variable = get_variable('disable_users') || '';
 	my @disable_user_names = sort {lc($a) cmp lc($b)} (split(/[,;]+/, $disable_user_names_variable));
 	my $disable_user_names_regex = join("|", @disable_user_names);
 	

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/Lab.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/Lab.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/Lab.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/Lab.pm Tue Apr 22 16:15:55 2014
@@ -296,6 +296,12 @@ sub node_status {
 	return \%status;
 } ## end sub node_status
 
+
+sub power_reset {
+
+	return 1;
+
+}
 #/////////////////////////////////////////////////////////////////////////////
 
 1;

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Tue Apr 22 16:15:55 2014
@@ -179,7 +179,7 @@ sub load {
 	$self->_edit_nodelist($computer_node_name, $image_name) || return;
 	
 	# Check to see if management node throttle is configured
-	my $throttle_limit = $self->data->get_variable("xcat|throttle|$management_node_hostname", 0) || $self->data->get_variable("$management_node_hostname|xcat|throttle", 0) || $self->data->get_variable("xcat|throttle", 0);
+	my $throttle_limit = get_variable("xcat|throttle|$management_node_hostname", 0) || get_variable("$management_node_hostname|xcat|throttle", 0) || get_variable("xcat|throttle", 0);
 	if (!$throttle_limit || $throttle_limit !~ /^\d+$/) {
 		$throttle_limit = 10;
 		notify($ERRORS{'DEBUG'}, 0, "xCAT load throttle limit variable is NOT set in database: 'xcat|throttle', using default value: $throttle_limit");
@@ -1860,13 +1860,13 @@ sub _rpower {
 	my $command = "$XCAT_ROOT/bin/rpower $computer_node_name $rpower_option";
 	
 	my $rpower_attempt = 0;
-	my $rpower_error_limit = $self->data->get_variable("xcat|rpower_error_limit|$management_node_hostname", 0) || $self->data->get_variable("xcat|rpower_error_limit", 0);
+	my $rpower_error_limit = get_variable("xcat|rpower_error_limit|$management_node_hostname", 0) || get_variable("xcat|rpower_error_limit", 0);
 	if (!$rpower_error_limit || $rpower_error_limit !~ /^\d+$/) {
 		$rpower_error_limit = 3;
 	}
 	
 	my $timeout_error_count = 0;
-	my $timeout_error_limit = $self->data->get_variable("xcat|timeout_error_limit|$management_node_hostname", 0) || $self->data->get_variable("xcat|timeout_error_limit", 0);
+	my $timeout_error_limit = get_variable("xcat|timeout_error_limit|$management_node_hostname", 0) || get_variable("xcat|timeout_error_limit", 0);
 	if (!$timeout_error_limit || $timeout_error_limit !~ /^\d+$/) {
 		$timeout_error_limit = 5;
 	}

Modified: vcl/trunk/managementnode/lib/VCL/inuse.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/inuse.pm Tue Apr 22 16:15:55 2014
@@ -116,7 +116,7 @@ sub process {
 	my $is_parent_reservation   = $self->data->is_parent_reservation();
 	my $computer_id             = $self->data->get_computer_id();
 	my $computer_short_name     = $self->data->get_computer_short_name();
-	my $connect_timeout_seconds = $self->data->get_variable('connecttimeout') || (15 * 60);
+	my $connect_timeout_seconds = $self->os->get_timings('connecttimeout');
 
 	# Make sure connect timeout is long enough
 	# It has to be a bit longer than the ~5 minute period between inuse checks due to cluster reservations
@@ -378,6 +378,8 @@ sub user_connected {
 	my $server_request_id       		= $self->data->get_server_request_id();
 	my $request_duration_epoch_secs	= $self->data->get_request_duration_epoch();
 	my $request_duration_hrs 			= floor($request_duration_epoch_secs / 60 / 60);
+	my $ignore_connections_gte_min	= $self->os->get_timings('ignore_connections_gte');
+	my $ignore_connections_gte			= floor($ignore_connections_gte_min / 60);
 	
 	# Check if user deleted the request
 	$self->state_exit() if is_request_deleted($request_id);
@@ -393,8 +395,8 @@ sub user_connected {
 	}
 	
 	# If duration is >= 24 hrs set as connected and return
-	if($request_duration_hrs >= 24 ) {
-		notify($ERRORS{'OK'}, 0, "duration is $request_duration_hrs hrs . Is >= to 24 hrs, skipping inuse checks");
+	if($request_duration_hrs >= $ignore_connections_gte ) {
+		notify($ERRORS{'OK'}, 0, "reservation duration is $request_duration_hrs hrs is >= to ignore_connections setting $ignore_connections_gte hrs, skipping inuse checks");
 		insertloadlog($reservation_id, $computer_id, "connected", "user connected to $computer_short_name");
 		return 1;
 	}	

Modified: vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reclaim.pm Tue Apr 22 16:15:55 2014
@@ -102,7 +102,7 @@ sub process {
 	# Remove related fixedIPsr variable, if it exists
 	if ($server_request_id) {
  		my $variable_name = "fixedIPsr" . $server_request_id;
- 		if($self->data->is_variable_set($variable_name)){
+ 		if(is_variable_set($variable_name)){
                #Delete from variable table.
                my $delete_sql_statement = "DELETE variable FROM variable WHERE name = '$variable_name' ";
                if (database_execute($delete_sql_statement)) {

Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Tue Apr 22 16:15:55 2014
@@ -101,7 +101,7 @@ sub process {
 	my $computer_short_name         = $self->data->get_computer_short_name();
 	my $is_parent_reservation       = $self->data->is_parent_reservation();
 	my $server_request_id           = $self->data->get_server_request_id();
-	my $acknowledge_timeout_seconds = $self->data->get_variable('acknowledgetimeout') || 900;
+	my $acknowledge_timeout_seconds = $self->os->get_timings('acknowledgetimeout');
 	
 	# Update the log loaded time to now for this request
 	update_log_loaded_time($request_logid);

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1589196&r1=1589195&r2=1589196&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Tue Apr 22 16:15:55 2014
@@ -153,6 +153,7 @@ our @EXPORT = qw(
   get_resource_groups
   get_managable_resource_groups
   get_user_info
+  get_variable
   get_vmhost_assigned_vm_info
   get_vmhost_info
   getnewdbh
@@ -172,6 +173,7 @@ our @EXPORT = qw(
   is_request_imaging
   is_valid_dns_host_name
   is_valid_ip_address
+  is_variable_set
   kill_child_processes
   kill_reservation_process
   known_hosts
@@ -196,6 +198,7 @@ our @EXPORT = qw(
   set_hash_process_id
   set_logfile_path
   set_managementnode_state
+  set_variable
   setnextimage
   setup_confirm
   setup_get_array_choice
@@ -234,6 +237,8 @@ our @EXPORT = qw(
   write_currentimage_txt
   xmlrpc_call
   xml_string_to_hash
+  yaml_deserialize
+  yaml_serialize
   add_imageid_to_newimages
 
   $CONF_FILE_PATH
@@ -1082,8 +1087,9 @@ sub check_time {
 		else {
 			# End time is more than 10 minutes in the future
 			#notify($ERRORS{'DEBUG'}, 0, "reservation will end in more than 10 minutes ($end_diff_minutes)");
+			my $general_inuse_check_time = ($ENV{management_node_info}->{GENERAL_INUSE_CHECK} * -1);
 
-			if ($lastcheck_diff_minutes <= -5) {
+			if ($lastcheck_diff_minutes <= $general_inuse_check_time) {
 				#notify($ERRORS{'DEBUG'}, 0, "reservation was last checked more than 5 minutes ago ($lastcheck_diff_minutes)");
 				return "poll";
 			}
@@ -3155,7 +3161,7 @@ EOF
 		my $user_id = $request_info->{userid};
 		my $user_info = get_user_info($user_id, 0, 1);
 		$request_info->{user} = $user_info;
-		
+
 		my $imagemeta_root_access = $request_info->{reservation}{$reservation_id}{image}{imagemeta}{rootaccess};
 		
 		# Add the request user to the hash, set ROOTACCESS to the value configured in imagemeta
@@ -3182,7 +3188,7 @@ EOF
 		
 		# If server request or duration is greater >= 24 hrs disable user checks
 		if ($request_info->{reservation}{$reservation_id}{serverrequest}{id}) {
-			notify($ERRORS{'DEBUG'}, 0, "server sequest - disabling user checks");
+			notify($ERRORS{'DEBUG'}, 0, "server request - disabling user checks");
 			$request_info->{checkuser} = 0;
 			$request_info->{reservation}{$reservation_id}{serverrequest}{ALLOW_USERS} = $request_info->{user}{unityid};
 		}
@@ -4711,6 +4717,15 @@ AND managementnode.id != $management_nod
 		#notify($ERRORS{'DEBUG'}, 0, "image library sharing functions are disabled");
 	}
 
+	# Get the inuse timing checks for general and server based reservations
+	my $general_inuse_check = get_variable('general_inuse_check') || 300;
+	$management_node_info->{GENERAL_INUSE_CHECK} = round($general_inuse_check / 60);
+	$ENV{management_node_info}{GENERAL_INUSE_CHECK} = $management_node_info->{GENERAL_INUSE_CHECK};
+
+	my $server_inuse_check = get_variable('server_inuse_check') || 300;
+	$management_node_info->{SERVER_INUSE_CHECK} = round($server_inuse_check / 60);
+	$ENV{management_node_info}{SERVER_INUSE_CHECK} = $management_node_info->{SERVER_INUSE_CHECK};
+
 	# Get the OS name
 	my $os_name = lc($^O);
 	$management_node_info->{OSNAME} = $os_name;
@@ -6550,6 +6565,7 @@ sub get_user_info {
 SELECT DISTINCT
 user.*,
 adminlevel.name AS adminlevel_name,
+affiliation.id AS affiliation_id,
 affiliation.name AS affiliation_name,
 affiliation.shibname AS affiliation_shibname,
 affiliation.dataUpdateText AS affiliation_dataUpdateText,
@@ -6688,7 +6704,7 @@ EOF
 	if ($user_login_id =~ /vcladmin/) {
 		$user_info->{STANDALONE} = 1;
 	}
-	
+
 	# Set the user's affiliation sitewwwaddress and help address if not defined or blank
 	if (!$user_info->{affiliation}{sitewwwaddress}) {
 		$user_info->{affiliation}{sitewwwaddress} = 'http://cwiki.apache.org/VCL';
@@ -10456,6 +10472,373 @@ sub get_code_ref_subroutine_name {
 	return $gv->NAME;
 }
 
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 is_variable_set
+
+ Parameters  : variable name
+ Returns     : If variable is set: 1
+               If variable is not set: 0
+               If an error occurred: undefined
+ Description : Queries the variable table for the variable with the name
+               specified by the argument. Returns true if the variable is set,
+               false otherwise.
+
+=cut
+
+sub is_variable_set {
+	my $variable_name = shift;
+	
+	# Check if 1st argument is a reference meaning this was called as an object method
+	# If so, ignore 1st reference argument and call shift again
+	if (ref($variable_name)) {
+		$variable_name = shift;
+	}
+	
+	# Check the argument
+	if (!defined($variable_name)) {
+		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
+		return;
+	}
+	
+	# Construct the select statement
+my $select_statement .= <<"EOF";
+SELECT
+variable.value
+FROM
+variable
+WHERE
+variable.name = '$variable_name'
+EOF
+	
+	# Call the database select subroutine
+	my @selected_rows = database_select($select_statement);
+
+	# Check to make 1 sure row was returned
+	if (!@selected_rows){
+		notify($ERRORS{'DEBUG'}, 0, "variable is NOT set: $variable_name");
+		return 0;
+	}
+	elsif (@selected_rows > 1){
+		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', multiple rows exist in the database for variable:\n" . format_data(\@selected_rows));
+		return;
+	}
+	
+	# Get the serialized value from the variable row
+	my $database_value = $selected_rows[0]{value};
+	
+	if (defined($database_value)) {
+		notify($ERRORS{'DEBUG'}, 0, "variable is set: $variable_name");
+		return 1;
+	}
+	else {
+		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', row returned:\n" . format_data(\@selected_rows));
+		return;
+	}
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_variable
+
+ Parameters  : $variable_name, $show_warnings (optional)
+ Returns     : If successful: data stored in the variable table for the variable name specified
+               If failed: false
+ Description : Queries the variable table for the variable with the name
+               specified by the argument. Returns the data stored for the
+               variable. Values are deserialized before being returned if the
+               value stored was a reference.
+               
+               Undefined is returned if the variable name does not exist in the
+               variable table. A log message is displayed by default. To
+               suppress the log message, supply the $show_warnings argument with
+               a value of 0.
+
+=cut
+
+sub get_variable {
+	# Check if 1st argument is a reference meaning this was called as an object method
+	# If so, ignore 1st reference argument
+	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
+	
+	# Check the argument
+	my $variable_name = shift;
+	if (!defined($variable_name)) {
+		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
+		return;
+	}
+	
+	my $show_warnings = shift;
+	$show_warnings = 1 unless defined $show_warnings;
+	
+	# Construct the select statement
+my $select_statement .= <<"EOF";
+SELECT
+variable.value,
+variable.serialization
+FROM
+variable
+WHERE
+variable.name = '$variable_name'
+EOF
+	
+	# Call the database select subroutine
+	my @selected_rows = database_select($select_statement);
+
+	# Check to make 1 sure row was returned
+	if (!@selected_rows){
+		notify($ERRORS{'OK'}, 0, "variable '$variable_name' is not set in the database") if $show_warnings;
+		return 0;
+	}
+	elsif (@selected_rows > 1){
+		notify($ERRORS{'WARNING'}, 0, "unable to get value of variable '$variable_name', multiple rows exist in the database for variable:\n" . format_data(\@selected_rows));
+		return;
+	}
+	
+	# Get the serialized value from the variable row
+	my $serialization_type = $selected_rows[0]{serialization};
+	my $database_value = $selected_rows[0]{value};
+	my $deserialized_value;
+	
+	# Deserialize the variable value if necessary
+	if ($serialization_type eq 'none') {
+		$deserialized_value = $database_value;
+	}
+	elsif ($serialization_type eq 'yaml') {
+		# Attempt to deserialize the value
+		$deserialized_value = yaml_deserialize($database_value);
+		if (!defined($deserialized_value)) {
+			notify($ERRORS{'WARNING'}, 0, "unable to deserialize variable '$variable_name' using YAML");
+			return;
+		}
+		
+		# Display the data type of the value retrieved from the variable table
+		if (my $deserialized_data_type = ref($deserialized_value)) {
+			notify($ERRORS{'DEBUG'}, 0, "data type of variable '$variable_name': $deserialized_data_type reference");
+		}
+		else {
+			notify($ERRORS{'DEBUG'}, 0, "data type of variable '$variable_name': scalar");
+		}
+	}
+	elsif ($serialization_type eq 'phpserialize') {
+		# TODO: find Perl module to handle PHP serialized data
+		# Add module to list of dependencies
+		# Add code here to call PHP deserialize function
+		notify($ERRORS{'CRITICAL'}, 0, "unable to get value of variable '$variable_name', PHP serialized data is NOT supported yet by the VCL backend, returning null");
+		return;
+	}
+	else {
+		notify($ERRORS{'CRITICAL'}, 0, "unable to get value of variable '$variable_name', serialization type '$serialization_type' is NOT supported by the VCL backend, returning null");
+		return;
+	}
+	
+	notify($ERRORS{'DEBUG'}, 0, "retrieved variable '$variable_name', serialization: $serialization_type");
+	return $deserialized_value;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 yaml_deserialize
+
+ Parameters  : Data
+ Returns     : If successful: data structure
+               If failed: false
+ Description : 
+
+=cut
+
+sub yaml_deserialize {
+	# Check if 1st argument is a reference meaning this was called as an object method
+	# If so, ignore 1st reference argument and call shift again
+	my $yaml_data_argument = shift;
+	if (ref($yaml_data_argument)) {
+		$yaml_data_argument = shift;
+	}
+	
+	# Check to make sure argument was passed
+	if (!defined($yaml_data_argument)) {
+		notify($ERRORS{'WARNING'}, 0, "data argument was not passed");
+		return;
+	}
+	
+	my $deserialized_value;
+	eval '$deserialized_value = YAML::Load($yaml_data_argument)';
+	if ($EVAL_ERROR) {
+		notify($ERRORS{'WARNING'}, 0, "unable to deserialize data using YAML::Load(), data value: $yaml_data_argument");
+		return;
+	}
+	
+	return $deserialized_value;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 set_variable
+
+ Parameters  : variable name, variable value
+ Returns     : If successful: true
+               If failed: false
+ Description : Inserts or updates a row in the variable table. The variable name
+               and value arguments must be specified.
+               
+               The value can be a simple scalar such as a string or a reference
+               to a complex data structure such as an array of hashes.
+               
+               Simple scalar values are stored in the variable.value column
+               as-is and the variable.serialization column will be set to
+               'none'.
+               
+               References are serialized using YAML before being stored. The
+               variable.value column will contain the YAML representation of the
+               data and the variable.serialization column will be set to 'yaml'.
+               
+               This subroutine will also update the variable.timestamp column.
+               The variable.setby column is automatically set to the filename
+               and line number which called this subroutine.
+
+=cut
+
+sub set_variable {
+	# Check if 1st argument is a reference meaning this was called as an object method
+	# If so, ignore 1st reference argument
+	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
+	
+	my $variable_name = shift;
+	
+	# Get the 2nd argument containing the variable value
+	my $variable_value = shift;
+	
+	# Check the arguments
+	if (!defined($variable_name)) {
+		notify($ERRORS{'WARNING'}, 0, "variable name argument was not supplied");
+		return;
+	}
+	elsif (!defined($variable_value)) {
+		notify($ERRORS{'WARNING'}, 0, "variable value argument was not supplied");
+		return;
+	}
+	
+	notify($ERRORS{'DEBUG'}, 0, "attempting to set variable: $variable_name");
+	
+	# Set serialization type to yaml if the value being stored is a reference
+	# Otherwise, a simple scalar is being stored and serialization is not necessary
+	my $serialization_type;
+	if (ref($variable_value)) {
+		$serialization_type = 'yaml';
+	}
+	else {
+		$serialization_type = 'none';
+	}
+	
+	# Construct a string indicating where the variable was set from
+	my @caller = caller(0);
+	(my $calling_file) = $caller[1] =~ /([^\/]*)$/;
+	my $calling_line = $caller[2];
+	my $caller_string = "$calling_file:$calling_line";
+	
+	# Attempt to serialize the value if necessary
+	my $database_value;
+	if ($serialization_type eq 'none') {
+		$database_value = $variable_value;
+	}
+	else {
+		# Attempt to serialize the value using YAML
+		$database_value = yaml_serialize($variable_value);
+		if (!defined($database_value)) {
+			notify($ERRORS{'WARNING'}, 0, "unable to serialize variable '$variable_name' using YAML, value:\n" . format_data($variable_value));
+			return;
+		}
+	}
+	
+	# Escape all backslashes
+	$database_value =~ s/\\/\\\\/g;
+	
+	# Escape all single quote characters with a backslash
+	#   or else the SQL statement will fail becuase it is wrapped in single quotes
+	$database_value =~ s/'/\\'/g;
+	
+	# Assemble an insert statement, if the variable already exists, update the existing row
+	my $insert_statement .= <<"EOF";
+INSERT INTO variable
+(
+name,
+serialization,
+value,
+setby,
+timestamp
+)
+VALUES
+(
+'$variable_name',
+'$serialization_type',
+'$database_value',
+'$caller_string',
+NOW()
+)
+ON DUPLICATE KEY UPDATE
+name=VALUES(name),
+serialization=VALUES(serialization),
+value=VALUES(value),
+setby=VALUES(setby),
+timestamp=VALUES(timestamp)
+EOF
+	
+	# Execute the insert statement, the return value should be the id of the row
+	my $inserted_id = database_execute($insert_statement);
+	if ($inserted_id) {
+		notify($ERRORS{'OK'}, 0, "set variable '$variable_name', variable id: $inserted_id, serialization: $serialization_type");
+	}
+	else {
+		notify($ERRORS{'WARNING'}, 0, "failed to set variable '$variable_name', serialization: $serialization_type");
+		return;
+	}
+	
+	return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 yaml_serialize
+
+ Parameters  : Data
+ Returns     : If successful: string containing serialized representation of data
+               If failed: false
+ Description : 
+
+=cut
+
+sub yaml_serialize {
+	# Check if 1st argument is a reference meaning this was called as an object method
+	# If so, ignore 1st reference argument
+	shift @_ if ($_[0] && ref($_[0]) && ref($_[0]) =~ /VCL/);
+	
+	# Check to make sure argument was passed
+	my $data_argument = shift;
+	if (!defined($data_argument)) {
+		notify($ERRORS{'WARNING'}, 0, "data argument was not passed");
+		return;
+	}
+	
+	# Attempt to serialize the value using YAML::Dump()
+	# Use eval because Dump() will call die() if it encounters an error
+	my $serialized_data;
+	eval '$serialized_data = YAML::Dump($data_argument)';
+	if ($EVAL_ERROR) {
+		notify($ERRORS{'WARNING'}, 0, "unable to serialize data using YAML::Dump(), data value: $data_argument");
+		return;
+	}
+	
+	# Escape all backslashes
+	$serialized_data =~ s/\\/\\\\/g;
+	
+	# Escape all single quote characters with a backslash
+	#   or else the SQL statement will fail becuase it is wrapped in single quotes
+	$serialized_data =~ s/'/\\'/g;
+	
+	return $serialized_data;
+}
+
 #/////////////////////////////////////////////////////////////////////////////
 
 1;