You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2014/02/07 20:59:03 UTC

svn commit: r1565780 - in /vcl/trunk/managementnode/lib/VCL/Module: OS.pm OS/Windows.pm

Author: arkurth
Date: Fri Feb  7 19:59:03 2014
New Revision: 1565780

URL: http://svn.apache.org/r1565780
Log:
VCL-745
Added check to Windows.pm::user_logged_in to use the 'Administrator' username for imaging requests.


VCL-746
Updated Windows.pm::get_service_configuration to copy the reg export text file from the remote computer to the management node and then retrieve its contents locally.
Added OS.pm::copy_file_from subroutine. This is called from get_service_configuration.


Other
Removed duplicate call to update_public_ip_address in Windows.pm::post_load.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/OS.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1565780&r1=1565779&r2=1565780&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Fri Feb  7 19:59:03 2014
@@ -662,7 +662,7 @@ sub is_ssh_responding {
 	if (!$computer_node_name) {
 		$computer_node_name = $self->data->get_computer_node_name();
 	}
-	
+
 	# Try nmap to see if any of the ssh ports are open before attempting to run a test command
 	my $port_22_status = nmap_port($computer_node_name, 22) ? "open" : "closed";
 	my $port_24_status = nmap_port($computer_node_name, 24) ? "open" : "closed";
@@ -2943,15 +2943,63 @@ sub copy_file_to {
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 copy_file_from
+
+ Parameters  : $source_path, $destination_path
+ Returns     : boolean
+ Description : Copies file(s) from the computer to the management node.
+
+=cut
+
+sub copy_file_from {
+	my $self = shift;
+	if (ref($self) !~ /VCL::Module/i) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+		return;
+	}
+	
+	# Get the source and destination arguments
+	my ($source_path, $destination_path) = @_;
+	if (!$source_path || !$destination_path) {
+		notify($ERRORS{'WARNING'}, 0, "source and destination path arguments were not specified");
+		return;
+	}
+	
+	# Get the computer short and hostname
+	my $computer_node_name = $self->data->get_computer_node_name() || return;
+	
+	# Get the destination parent directory path and create the directory
+	my $destination_directory_path = parent_directory_path($destination_path);
+	if (!$destination_directory_path) {
+		notify($ERRORS{'WARNING'}, 0, "unable to determine destination parent directory path: $destination_path");
+		return;
+	}
+	$self->mn_os->create_directory($destination_directory_path) || return;
+	
+	# Get the identity keys used by the management node
+	my $management_node_keys = $self->data->get_management_node_keys() || '';
+	
+	# Run the SCP command
+	if (run_scp_command("$computer_node_name:\"$source_path\"", $destination_path, $management_node_keys)) {
+		notify($ERRORS{'DEBUG'}, 0, "copied file from $computer_node_name to management node: $computer_node_name:'$source_path' --> '$destination_path'");
+	}
+	else {
+		notify($ERRORS{'WARNING'}, 0, "failed to copy file from $computer_node_name to management node: $computer_node_name:'$source_path' --> '$destination_path'");
+		return;
+	}
+	
+	return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 find_files
 
  Parameters  : $base_directory_path, $file_pattern, $search_subdirectories (optional)
  Returns     : array
- Description : Finds files under the base directory path
+ Description : Finds files under the base directory and any subdirectories path
                matching the file pattern. The search is not case sensitive. An
-               array is returned containing matching file paths. Subdirectories
-               are searched by default. An optional $search_subdirectories
-               argument may be specified.
+               array is returned containing matching file paths.
 
 =cut
 
@@ -2988,7 +3036,7 @@ sub find_files {
 	
 	COMMAND: for my $find_command (@find_commands) {
 		# Run the find command
-		my $command = "$find_command \"$base_directory_path\" -iname \"$file_pattern\"";
+		my $command = "$find_command \"$base_directory_path\" -iname \"$file_pattern\" -type f";
 		
 		if (!$search_subdirectories) {
 			$command .= " -maxdepth 1";

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=1565780&r1=1565779&r2=1565780&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Fri Feb  7 19:59:03 2014
@@ -684,16 +684,6 @@ sub post_load {
 
 =item *
 
-	Collect or Set the public IP address
-=cut
-
-   if (!$self->update_public_ip_address()) {
-		notify($ERRORS{'WARNING'}, 0, "failed to update IP address for $computer_node_name");
-		return 0;
-   }
-
-=item *
-
  Set root as the owner of /home/root
 
 =cut
@@ -3968,21 +3958,33 @@ sub get_service_configuration {
 	my $computer_node_name   = $self->data->get_computer_node_name();
 	
 	notify($ERRORS{'DEBUG'}, 0, "retrieving service configuration information from the registry");
+	
 	my $services_key = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services';
+	
 	my $node_reg_file_path = "C:/cygwin/tmp/services_$computer_node_name.reg";
+	my $mn_reg_file_path = "/tmp/vcl/services_$computer_node_name.reg";
+	
+	# Export the registry key to the temp directory on the computer
 	if (!$self->reg_export($services_key, $node_reg_file_path)) {
 		notify($ERRORS{'WARNING'}, 0, "failed to retrieve service credential information from the registry on $computer_node_name");
 		return;
 	}
 	
-	my @reg_file_contents = $self->get_file_contents($node_reg_file_path);
+	# Copy the file to the managment node
+	if (!$self->copy_file_from($node_reg_file_path, $mn_reg_file_path)) {
+		return;
+	}
+	
+	# Get the contents of the file on the managment node
+	my @reg_file_contents = $self->mn_os->get_file_contents($mn_reg_file_path);
 	if (!@reg_file_contents) {
 		notify($ERRORS{'WARNING'}, 0, "failed to retrieve contents of file on $computer_node_name containing exported service credential information from the registry: $node_reg_file_path");
 		return;
 	}
 	
-	# Delete the registry file
+	# Delete the registry files
 	$self->delete_file($node_reg_file_path);
+	$self->mn_os->delete_file($mn_reg_file_path);
 	
 	my $service_configuration;
 	my $service_name;
@@ -3997,6 +3999,7 @@ sub get_service_configuration {
 		}
 	}
 	
+	#notify($ERRORS{'DEBUG'}, 0, "retrieved service configuration from $computer_node_name:\n" . format_data($service_configuration));
 	$self->{service_configuration} = $service_configuration;
 	return $self->{service_configuration};
 }
@@ -8957,7 +8960,12 @@ sub user_logged_in {
 	
 	# Check if username argument was passed
 	if (!$username) {
-		$username = $self->data->get_user_login_id();
+		if ($self->data->get_request_forimaging()) {
+			$username = 'Administrator';
+		}
+		else {
+			$username = $self->data->get_user_login_id();
+		}
 	}
 	notify($ERRORS{'DEBUG'}, 0, "checking if $username is logged in to $computer_node_name");
 
@@ -9998,7 +10006,7 @@ sub setup_get_menu {
  Parameters  : none
  Returns     :
  Description : Checks various configuration settings and displays a message to
-               the user if any important settings are not configured.
+					the user if any important settings are not configured.
 
 =cut