Author: arkurth
Date: Thu Jun 30 17:06:54 2011
New Revision: 1141626
URL: http://svn.apache.org/viewvc?rev=1141626&view=rev
Log:
VCL-428
Updated get_*_info subroutines in utils.pm so they all return a hash reference.
Added code so that the retrieved data is cached so that the same data does not
need to be retrieved multiple times from the database.
Updated get_request_info to call the individual get_user_info,
get_computer_info, etc subroutines rather than constructing a massive, single
query.
Updated DataStruction.pm to handle the differences in the format of the data
hash.
Added utils.pm::get_user_group_member_info subroutine. This will eventually
replace getusergroupmembers.
Updated all calls in other files to get_*_info subroutines which had expected a
hash to be returned. They now expect a hash reference.
VCL-450
Added ability to configure a specific location where persistent vmdk files are
saved via the vmprofile.virtualdiskpath column.
Other
Removed hostname subroutine from utils.pm. Replaced calls with the
Sys::Hostname function.
Added counter to database_select subroutine to count the number of times it is
called and from where. This info is displayed in the log file when a process
terminates.
Added '-o UserKnownHostsFile = /dev/null' argument to run_ssh_command. Also
added check for 'connection reset' errors so that this condition is attempted
again.
Updated utils.pm::xmlrpc_call to generate more debugging info if an error
occurs.
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm
incubator/vcl/trunk/managementnode/lib/VCL/blockrequest.pm
incubator/vcl/trunk/managementnode/lib/VCL/image.pm
incubator/vcl/trunk/managementnode/lib/VCL/new.pm
incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Thu Jun 30
17:06:54 2011
@@ -229,22 +229,21 @@ $SUBROUTINE_MAPPINGS{computer_provisioni
$SUBROUTINE_MAPPINGS{computer_provisioning_module_perl_package} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{provisioning}{module}{perlpackage}';
$SUBROUTINE_MAPPINGS{vmhost_computer_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{computerid}';
-$SUBROUTINE_MAPPINGS{vmhost_hostname} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{hostname}';
+$SUBROUTINE_MAPPINGS{vmhost_hostname} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{computer}{hostname}';
$SUBROUTINE_MAPPINGS{vmhost_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{id}';
-$SUBROUTINE_MAPPINGS{vmhost_image_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{imageid}';
-$SUBROUTINE_MAPPINGS{vmhost_image_name} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{imagename}';
-$SUBROUTINE_MAPPINGS{vmhost_ram} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{RAM}';
-$SUBROUTINE_MAPPINGS{vmhost_state} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{state}';
-#$SUBROUTINE_MAPPINGS{vmhost_type} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{type}';
+$SUBROUTINE_MAPPINGS{vmhost_image_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{imageid}';
+$SUBROUTINE_MAPPINGS{vmhost_image_name} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{image}{name}';
+$SUBROUTINE_MAPPINGS{vmhost_ram} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{computer}{RAM}';
+$SUBROUTINE_MAPPINGS{vmhost_state} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{computer}{state}{name}';
+#$SUBROUTINE_MAPPINGS{vmhost_type} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{computer}{type}';
$SUBROUTINE_MAPPINGS{vmhost_kernal_nic} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmkernalnic}';
$SUBROUTINE_MAPPINGS{vmhost_vm_limit} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmlimit}';
$SUBROUTINE_MAPPINGS{vmhost_profile_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofileid}';
-$SUBROUTINE_MAPPINGS{vmhost_type} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{type}';
-#$SUBROUTINE_MAPPINGS{vmhost_type_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmtypeid}';
+#$SUBROUTINE_MAPPINGS{vmhost_type_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmtype}{vmtypeid}';
$SUBROUTINE_MAPPINGS{vmhost_profile_repository_path} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{repositorypath}';
$SUBROUTINE_MAPPINGS{vmhost_profile_datastore_path} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{datastorepath}';
-$SUBROUTINE_MAPPINGS{vmhost_profile_datastorepath_4vmx} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{datastorepath4vmx}';
+$SUBROUTINE_MAPPINGS{vmhost_profile_virtual_disk_path} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{virtualdiskpath}';
#$SUBROUTINE_MAPPINGS{vmhost_profile_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{id}';
$SUBROUTINE_MAPPINGS{vmhost_profile_image_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{imageid}';
$SUBROUTINE_MAPPINGS{vmhost_profile_name} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{profilename}';
@@ -261,6 +260,7 @@ $SUBROUTINE_MAPPINGS{vmhost_profile_eth1
#$SUBROUTINE_MAPPINGS{vmhost_typeid} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{vmtypeid}';
$SUBROUTINE_MAPPINGS{vmhost_type_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{vmtype}{id}';
+$SUBROUTINE_MAPPINGS{vmhost_type} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{vmtype}{name}';
$SUBROUTINE_MAPPINGS{vmhost_type_name} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{vmprofile}{vmtype}{name}';
$SUBROUTINE_MAPPINGS{computer_currentimage_architecture} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{architecture}';
@@ -268,7 +268,6 @@ $SUBROUTINE_MAPPINGS{computer_currentima
$SUBROUTINE_MAPPINGS{computer_currentimage_forcheckout} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{forcheckout}';
$SUBROUTINE_MAPPINGS{computer_currentimage_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{id}';
$SUBROUTINE_MAPPINGS{computer_currentimage_imagemetaid} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{imagemetaid}';
-$SUBROUTINE_MAPPINGS{computer_currentimage_imagetypeid} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{imagetypeid}';
$SUBROUTINE_MAPPINGS{computer_currentimage_lastupdate} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{lastupdate}';
$SUBROUTINE_MAPPINGS{computer_currentimage_maxconcurrent} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{maxconcurrent}';
$SUBROUTINE_MAPPINGS{computer_currentimage_maxinitialtime} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{maxinitialtime}';
@@ -302,7 +301,6 @@ $SUBROUTINE_MAPPINGS{computer_nextimage_
$SUBROUTINE_MAPPINGS{computer_nextimage_forcheckout} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{forcheckout}';
$SUBROUTINE_MAPPINGS{computer_nextimage_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{id}';
$SUBROUTINE_MAPPINGS{computer_nextimage_imagemetaid} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{imagemetaid}';
-$SUBROUTINE_MAPPINGS{computer_nextimage_imagetypeid} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{imagetypeid}';
$SUBROUTINE_MAPPINGS{computer_nextimage_lastupdate} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{lastupdate}';
$SUBROUTINE_MAPPINGS{computer_nextimage_maxconcurrent} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{maxconcurrent}';
$SUBROUTINE_MAPPINGS{computer_nextimage_maxinitialtime} =
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{nextimage}{maxinitialtime}';
@@ -483,6 +481,8 @@ $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{subroutine_mappings} = '\%SUBROUTINE_MAPPINGS';
+
##############################################################################
=head1 OBJECT ATTRIBUTES
@@ -613,11 +613,6 @@ sub _initialize : Init {
# Get the computer info if the computer_id argument was specified and
add it to this object
if ($computer_id) {
- my $vmhost_info_save;
- if
(defined($self->request_data->{reservation}{$self->reservation_id}{computer}{vmhost}))
{
- $vmhost_info_save =
$self->request_data->{reservation}{$self->reservation_id}{computer}{vmhost};
- }
-
notify($ERRORS{'DEBUG'}, 0, "computer ID argument was
specified, retrieving data for computer ID: " . $self->computer_id);
my $computer_info = get_computer_info($self->computer_id);
if (!$computer_info) {
@@ -628,28 +623,22 @@ sub _initialize : Init {
return;
}
- # Check if the new computer info doesn't contain VM host info
but the original data does
- # Add the VM host info to the new hash so that it's available
- if (!$computer_info->{computer}{vmhost} && $vmhost_info_save) {
- $computer_info->{computer}{vmhost} = $vmhost_info_save;
- }
-
-
$self->request_data->{reservation}{$self->reservation_id}{computer} =
$computer_info->{computer};
+
$self->request_data->{reservation}{$self->reservation_id}{computer} =
$computer_info;
}
# If either the computer ID, image ID, or imagerevision ID arguments
are specified, retrieve appropriate image and imagerevision data
if ($imagerevision_id || $image_id || $computer_id) {
- my %imagerevision_info;
+ my $imagerevision_info;
if ($imagerevision_id) {
notify($ERRORS{'DEBUG'}, 0, "imagerevision ID argument
was specified: $imagerevision_id, DataStructure object will contain image
information for this imagerevision ID: $imagerevision_id");
- %imagerevision_info =
get_imagerevision_info($imagerevision_id);
+ $imagerevision_info =
get_imagerevision_info($imagerevision_id);
}
elsif ($image_id) {
notify($ERRORS{'DEBUG'}, 0, "image ID argument was
specified: $image_id, DataStructure object will contain image information for
the production imagerevision of this image");
- %imagerevision_info =
get_production_imagerevision_info($image_id);
+ $imagerevision_info =
get_production_imagerevision_info($image_id);
}
elsif ($computer_id) {
@@ -660,29 +649,29 @@ sub _initialize : Init {
Exception::Class::Base->throw( error =>
"DataStructure object could not be initialized, computer's current
imagerevision ID could not be retrieved from the current DataStructure data:\n"
. format_data($self->get_request_data));
return;
}
- %imagerevision_info =
get_imagerevision_info($imagerevision_id);
+ $imagerevision_info =
get_imagerevision_info($imagerevision_id);
}
- if (%imagerevision_info) {
- $imagerevision_id = $imagerevision_info{id};
+ if ($imagerevision_info) {
+ $imagerevision_id = $imagerevision_info->{id};
notify($ERRORS{'DEBUG'}, 0, "retrieved data for
imagerevision ID: $imagerevision_id");
-
$self->request_data->{reservation}{$self->reservation_id}{imagerevision} =
\%imagerevision_info;
+
$self->request_data->{reservation}{$self->reservation_id}{imagerevision} =
$imagerevision_info;
}
else {
Exception::Class::Base->throw( error => "DataStructure
object could not be initialized, failed to retrieve imagerevision data: ");
return;
}
- $image_id = $imagerevision_info{imageid};
+ $image_id = $imagerevision_info->{imageid};
if (!defined($image_id)) {
- Exception::Class::Base->throw( error => "DataStructure
object could not be initialized, failed to retrieve image ID from the
imagerevision data retrieved for imagerevision ID $imagerevision_id:\n" .
format_data(\%imagerevision_info));
+ Exception::Class::Base->throw( error => "DataStructure
object could not be initialized, failed to retrieve image ID from the
imagerevision data retrieved for imagerevision ID $imagerevision_id:\n" .
format_data($imagerevision_info));
return;
}
- my %image_info = get_image_info($image_id);
- if (%image_info) {
+ my $image_info = get_image_info($image_id);
+ if ($image_info) {
notify($ERRORS{'DEBUG'}, 0, "retrieved data for image
ID: $image_id");
-
$self->request_data->{reservation}{$self->reservation_id}{image} = \%image_info;
+
$self->request_data->{reservation}{$self->reservation_id}{image} = $image_info;
}
else {
Exception::Class::Base->throw( error => "DataStructure
object could not be initialized, failed to retrieve data for image ID: " .
$self->image_id);
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module.pm Thu Jun 30 17:06:54
2011
@@ -1131,7 +1131,7 @@ sub setup_test_rpc_xml {
my $digest = sha1_hex("$XMLRPC_PASS$salt");
if ($passhash eq $digest) {
- print "OK: verfied xmlrpc_pass value
configured in $CONF_FILE_PATH is correct\n";
+ print "OK: verfied xmlrpc_pass value is
the correct password for $XMLRPC_USER\n";
}
else {
print "PROBLEM: xmlrpc_pass value
configured in $CONF_FILE_PATH is not correct\n";
@@ -1163,9 +1163,9 @@ sub setup_test_rpc_xml {
$xmlrpc_function,
);
- my $result = xmlrpc_call(@xmlrpc_arguments);
- if ($result) {
- print "SUCCESS: RPC-XML access is configured correctly\n";
+ my $response = xmlrpc_call(@xmlrpc_arguments);
+ if ($response && $response->value) {
+ print "SUCCESS: RPC-XML access is configured correctly\n" .
format_data($response->value) . "\n";
return;
}
@@ -1175,7 +1175,7 @@ sub setup_test_rpc_xml {
return;
}
- print "FAILURE: RPC-XML access is not configured correctly:
$ENV{rpc_xml_error}\n\n";
+ print "FAILURE: RPC-XML access is not configured correctly, error
message:\n$ENV{rpc_xml_error}\n\n";
if ($ENV{rpc_xml_error} =~ /access denied/i) {
# Affiliation not correct
@@ -1218,7 +1218,7 @@ sub setup_set_local_account_password {
my $local_user_info = get_local_user_info();
- print "Select an local VCL user account:\n";
+ print "Select a local VCL user account:\n";
my $user_id = setup_get_hash_choice($local_user_info, 'unityid');
return if (!defined($user_id));
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm Thu Jun 30 17:06:54
2011
@@ -1032,8 +1032,6 @@ sub _get_public_interface_name_helper {
return;
}
-print "\n\n" . '.' x 100 . "\n\n";
-
my ($interface_name_1, $interface_name_2, $condition) = @_;
if (!$interface_name_1 || !$interface_name_2) {
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
---
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
(original)
+++
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
Thu Jun 30 17:06:54 2011
@@ -169,7 +169,7 @@ sub _run_vim_cmd {
my $command = "$self->{vim_cmd} $vim_arguments";
my $attempt = 0;
- my $attempt_limit = 3;
+ my $attempt_limit = 5;
my $wait_seconds = 2;
while ($attempt++ < $attempt_limit) {
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
---
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
(original)
+++
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
Thu Jun 30 17:06:54 2011
@@ -405,7 +405,7 @@ sub load {
}
# Power on the VM
- if (!$self->api->vm_power_on($vmx_file_path)) {
+ if (!$self->power_on($vmx_file_path)) {
notify($ERRORS{'WARNING'}, 0, "failed to power on VM
$computer_name on VM host: $vmhost_hostname");
return;
}
@@ -634,7 +634,7 @@ sub capture {
if (!$virtual_disk_type) {
notify($ERRORS{'WARNING'}, 0, "failed to
determine the virtual disk type of the vmdk being captured:
$vmdk_file_path_renamed");
}
- elsif ($virtual_disk_type =~ /sparse/) {
+ elsif ($virtual_disk_type =~ /sparse/i) {
# Virtual disk is sparse, get a list of the
vmdk file paths
notify($ERRORS{'DEBUG'}, 0, "vmdk can be copied
directly from VM host $vmhost_hostname to the image repository because the
virtual disk type is sparse: $virtual_disk_type");
@vmdk_copy_paths =
$self->vmhost_os->find_files($vmdk_directory_path_renamed, '*.vmdk');
@@ -706,7 +706,7 @@ sub capture {
# Attempt to power the VM back on
# This saves a step when troubleshooting the
problem
notify($ERRORS{'DEBUG'}, 0, "attempting to
power the VM back on so that it can be captured again");
-
$self->api->vm_power_on($vmx_file_path_original);
+ $self->power_on($vmx_file_path_original);
}
else {
if ($self->rename_vmdk($vmdk_file_path_renamed,
$vmdk_file_path_original)) {
@@ -718,7 +718,7 @@ sub capture {
# Attempt to power the VM back on
# This saves a step when
troubleshooting the problem
notify($ERRORS{'DEBUG'}, 0, "attempting
to power the VM back on so that it can be captured again");
-
$self->api->vm_power_on($vmx_file_path_original);
+
$self->power_on($vmx_file_path_original);
}
else {
notify($ERRORS{'WARNING'}, 0, "failed
to rename the vmdk files back to the original name after copying to the
repository failed: '$vmdk_file_path_renamed' --> '$vmdk_file_path_original'");
@@ -1241,7 +1241,7 @@ sub get_vmhost_datastructure {
# This acts as a test to make sure the DataStructure object is working
my $vmhost_computer_node_name = $vmhost_data->get_computer_node_name();
if (!$vmhost_computer_node_name) {
- notify($ERRORS{'WARNING'}, 0, "unable to determine VM host node
name from DataStructure object created for VM host");
+ notify($ERRORS{'WARNING'}, 0, "unable to determine VM host node
name from DataStructure object created for VM host\n");
return;
}
@@ -2447,8 +2447,8 @@ sub reclaim_vmhost_disk_space {
my $vmdk_directory_name =
$self->_get_file_name($vmdk_directory_path);
$vmdk_directories->{$vmdk_directory_path}{directory_name} =
$vmdk_directory_name;
- my %imagerevision_info =
get_imagerevision_info($vmdk_directory_name);
- if (!%imagerevision_info) {
+ my $imagerevision_info =
get_imagerevision_info($vmdk_directory_name);
+ if (!$imagerevision_info) {
notify($ERRORS{'WARNING'}, 0, "failed
to retrieve info for the image revision matching the vmdk directory name:
'$vmdk_directory_name'");
$vmdk_directories->{$vmdk_directory_path}{deletable} = 0;
next;
@@ -2456,19 +2456,19 @@ sub reclaim_vmhost_disk_space {
else {
#notify($ERRORS{'DEBUG'}, 0, "retrieved
info for the image revision matching the vmdk directory name:
'$vmdk_directory_name'\n" . format_data(\%imagerevision_info));
-
$vmdk_directories->{$vmdk_directory_path}{image_id} =
$imagerevision_info{imageid};
-
$vmdk_directories->{$vmdk_directory_path}{imagerevision_id} =
$imagerevision_info{id};
-
$vmdk_directories->{$vmdk_directory_path}{image_deleted} =
$imagerevision_info{deleted};
-
$vmdk_directories->{$vmdk_directory_path}{imagerevision_production} =
$imagerevision_info{production};
+
$vmdk_directories->{$vmdk_directory_path}{image_id} =
$imagerevision_info->{imageid};
+
$vmdk_directories->{$vmdk_directory_path}{imagerevision_id} =
$imagerevision_info->{id};
+
$vmdk_directories->{$vmdk_directory_path}{image_deleted} =
$imagerevision_info->{deleted};
+
$vmdk_directories->{$vmdk_directory_path}{imagerevision_production} =
$imagerevision_info->{production};
- my %image_info =
get_image_info($imagerevision_info{imageid});
- if (!%image_info) {
- notify($ERRORS{'WARNING'}, 0,
"failed to retrieve info for the image ID contained in the image revision info:
$imagerevision_info{imageid}");
+ my $image_info =
get_image_info($imagerevision_info->{imageid});
+ if (!$image_info) {
+ notify($ERRORS{'WARNING'}, 0,
"failed to retrieve info for the image ID contained in the image revision info:
$imagerevision_info->{imageid}");
}
else {
- #notify($ERRORS{'DEBUG'}, 0,
"retrieved info for the image ID contained in the image revision info:
$imagerevision_info{imageid}\n" . format_data(\%image_info));
+ #notify($ERRORS{'DEBUG'}, 0,
"retrieved info for the image ID contained in the image revision info:
$imagerevision_info->{imageid}\n" . format_data($image_info));
# Use the 'or' operator to set
the 'deleted' key so this value is set to 1 if either the image revision or
image has deleted=1
-
$vmdk_directories->{$vmdk_directory_path}{image_deleted} |=
$image_info{deleted};
+
$vmdk_directories->{$vmdk_directory_path}{image_deleted} |=
$image_info->{deleted};
}
}
@@ -3214,10 +3214,86 @@ sub get_vmdk_base_directory_path {
}
}
- # Get the vmprofile.datastorepath
- $vmdk_base_directory_path =
$self->data->get_vmhost_profile_datastore_path();
- if (!$vmdk_base_directory_path) {
- notify($ERRORS{'WARNING'}, 0, "unable to determine the vmdk
base directory path, failed to retrieve either the datastore path for the VM
profile");
+ if ($self->is_vm_persistent()) {
+ return $self->get_vmdk_base_directory_path_persistent();
+ }
+ else {
+ return $self->get_vmdk_base_directory_path_nonpersistent();
+ }
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_vmdk_base_directory_path_nonpersistent
+
+ Parameters :
+ Returns : string
+ Description :
+
+=cut
+
+sub get_vmdk_base_directory_path_nonpersistent {
+ my $self = shift;
+ if (ref($self) !~ /vmware/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
+ return;
+ }
+
+ my $vmdk_base_directory_path;
+
+ # Get the vmprofile.datastore
+ if ($vmdk_base_directory_path =
$self->data->get_vmhost_profile_datastore_path()) {
+ notify($ERRORS{'DEBUG'}, 0, "using VM profile datastore path as
the vmdk base directory path: $vmdk_base_directory_path");
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine the vmdk
base directory path, failed to retrieve the datastore path for the VM profile");
+ return;
+ }
+
+ # Convert the path to a normal path
+ # The path configured in the VM profile may be:
+ # -normal absolute path: /vmfs/volumes/vcl-datastore
+ # -datastore path: [vcl-datastore]
+ # -datastore name: vcl-datastore
+ my $vmdk_base_directory_normal_path =
$self->_get_normal_path($vmdk_base_directory_path);
+ if ($vmdk_base_directory_normal_path) {
+ return $vmdk_base_directory_normal_path;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine the
nonpersistent vmdk base directory path, failed to convert datastore path
configured in the VM profile to a normal path: $vmdk_base_directory_path");
+ return;
+ }
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_vmdk_base_directory_path_persistent
+
+ Parameters :
+ Returns : string
+ Description :
+
+=cut
+
+sub get_vmdk_base_directory_path_persistent {
+ my $self = shift;
+ if (ref($self) !~ /vmware/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
+ return;
+ }
+
+ my $vmdk_base_directory_path;
+
+ # Get the vmprofile.virtualdiskpath
+ # If virtualdiskpath isn't set, try to use the datastore path
+ if ($vmdk_base_directory_path =
$self->data->get_vmhost_profile_virtual_disk_path()) {
+ notify($ERRORS{'DEBUG'}, 0, "using VM profile virtual disk path
as the vmdk base directory path: $vmdk_base_directory_path");
+ }
+ elsif ($vmdk_base_directory_path =
$self->data->get_vmhost_profile_datastore_path()) {
+ notify($ERRORS{'DEBUG'}, 0, "using VM profile datastore path as
the vmdk base directory path: $vmdk_base_directory_path");
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine the vmdk
base directory path, failed to retrieve either the virtual disk or datastore
path for the VM profile");
return;
}
@@ -3231,7 +3307,7 @@ sub get_vmdk_base_directory_path {
return $vmdk_base_directory_normal_path;
}
else {
- notify($ERRORS{'WARNING'}, 0, "unable to determine the vmdk
base directory path, failed to convert path configured in the VM profile to a
normal path: $vmdk_base_directory_path");
+ notify($ERRORS{'WARNING'}, 0, "unable to determine the
nonpersistent vmdk base directory path, failed to convert path configured in
the VM profile to a normal path: $vmdk_base_directory_path");
return;
}
}
@@ -3403,8 +3479,7 @@ sub get_vmdk_directory_path_persistent {
}
# Get the vmdk base directory path
- # Pass '1' to the subroutine to specify that the path should be
retrieved directly from the vmprofile table
- my $vmdk_base_directory_path = $self->get_vmdk_base_directory_path(1);
+ my $vmdk_base_directory_path =
$self->get_vmdk_base_directory_path_persistent();
if (!$vmdk_base_directory_path) {
notify($ERRORS{'WARNING'}, 0, "unable to determine the
nonpersistent vmdk base directory path, failed to retrieve datastore path for
the VM profile");
return;
@@ -3439,7 +3514,7 @@ sub get_vmdk_directory_path_nonpersisten
# Get the vmdk base directory path
# Pass '1' to the subroutine to specify that the path should be
retrieved directly from the vmprofile table
- my $vmdk_base_directory_path = $self->get_vmdk_base_directory_path(1);
+ my $vmdk_base_directory_path =
$self->get_vmdk_base_directory_path_nonpersistent();
if (!$vmdk_base_directory_path) {
notify($ERRORS{'WARNING'}, 0, "unable to determine the
nonpersistent vmdk base directory path, failed to retrieve datastore path for
the VM profile");
return;
@@ -4252,18 +4327,17 @@ sub get_vm_virtual_hardware_version {
if ($vmx_key =~ /virtualHW\.version/i) {
$hardware_version =
$reference_vmx_file_info->{$vmx_key};
notify($ERRORS{'DEBUG'}, 0, "retrieved VM
virtual hardware version from reference vmx file: $hardware_version");
- return $hardware_version;
}
}
notify($ERRORS{'DEBUG'}, 0, "unable to retrieve VM virtual
hardware version from reference vmx file, 'virtualHW.version' key does not
exist");
}
- if ($self->api->can("get_virtual_disk_hardware_version")) {
+ if (!$hardware_version &&
$self->api->can("get_virtual_disk_hardware_version")) {
$hardware_version =
$self->api->get_virtual_disk_hardware_version($self->get_vmdk_file_path());
notify($ERRORS{'DEBUG'}, 0, "retrieved hardware version from
api object: $hardware_version");
}
- else {
+ elsif (!$hardware_version) {
$hardware_version =
$self->get_vmdk_parameter_value('virtualHWVersion');
notify($ERRORS{'DEBUG'}, 0, "retrieved hardware version stored
in the vmdk file: $hardware_version");
}
@@ -5062,7 +5136,33 @@ sub copy_vmdk {
notify($ERRORS{'CRITICAL'}, 0, "failed to copy virtual
disk, no space is left on the destination device on VM host $vmhost_name:
'$destination_directory_path'\ncommand: '$command'\noutput:\n" . join("\n",
@$output));
return;
}
- elsif (grep(/Failed to clone disk/, @$output) || !grep(/(100\%
done|success)/, @$output)) {
+
+ elsif (grep(/needs.*repair/i, @$output)) {
+ # The source disk needs to be repaired. Try option -x
+ notify($ERRORS{'WARNING'}, 0, "virtual disk needs to be
repaired, output:\n" . join("\n", @$output));
+
+ my $vdisk_repair_command = "vmkfstools -x repair
\"$source_vmdk_file_path\"";
+ notify($ERRORS{'DEBUG'}, 0, "attempting to repair
virtual disk using vmkfstools: '$source_vmdk_file_path'");
+
+ my ($vdisk_repair_exit_status, $vdisk_repair_output) =
$self->vmhost_os->execute($vdisk_repair_command);
+ if (!defined($vdisk_repair_output)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to run
command to repair the virtual disk: '$vdisk_repair_command'");
+ }
+ elsif (grep(/(successfully repaired|no errors)/i,
@$vdisk_repair_output)) {
+ notify($ERRORS{'DEBUG'}, 0, "repaired virtual
disk using vmkfstools, output:\n" . join("\n", @$vdisk_repair_output));
+
+ # Attempt to run the copy command again
+ notify($ERRORS{'DEBUG'}, 0, "making a 2nd
attempt to copy virtual disk using vmkfstools after the source was
repaired:\n'$source_vmdk_file_path' --> '$destination_vmdk_file_path'");
+ $start_time = time;
+ ($exit_status, $output) =
$self->vmhost_os->execute($command);
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to repair
the virtual disk on VM host $vmhost_name, output:\n" . join("\n",
@$vdisk_repair_output));
+ return;
+ }
+ }
+
+ if (grep(/Failed to clone disk/, @$output) || !grep(/(100\%
done|success)/, @$output)) {
notify($ERRORS{'WARNING'}, 0, "failed to copy virtual
disk\ncommand: '$command'\noutput:\n" . join("\n", @$output));
}
else {
@@ -5096,7 +5196,7 @@ sub copy_vmdk {
notify($ERRORS{'DEBUG'}, 0, "attempting to
repair virtual disk using vmware-vdiskmanager: '$source_vmdk_file_path'");
my ($vdisk_repair_exit_status,
$vdisk_repair_output) = $self->vmhost_os->execute($vdisk_repair_command);
- if (!defined($output)) {
+ if (!defined($vdisk_repair_output)) {
notify($ERRORS{'WARNING'}, 0, "failed
to run command to repair the virtual disk: '$vdisk_repair_command'");
}
elsif (grep(/(has been successfully repaired|no
errors)/i, @$vdisk_repair_output)) {
@@ -5512,16 +5612,29 @@ sub power_on {
return;
}
+ my $vmhost_hostname = $self->data->get_vmhost_hostname() || return;
+
# Get the vmx file path
# Use the argument if one was supplied
my $vmx_file_path = shift || $self->get_vmx_file_path();
if (!$vmx_file_path) {
- notify($ERRORS{'WARNING'}, 0, "vmx file path argument was not
specified and default vmx file path could not be determined");
+ notify($ERRORS{'WARNING'}, 0, "vmx file path argument was not
specified and default vmx file path could not be determined");
return;
}
$vmx_file_path = normalize_file_path($vmx_file_path);
- return $self->api->vm_power_on($vmx_file_path);
+ #my $power_on_throttle_delay_seconds = 2;
+ #my $power_on_semaphore_id = "$vmhost_hostname-power-on";
+ #my $power_on_semaphore = $self->get_semaphore($power_on_semaphore_id,
(60 * 100), (int(rand(10)))) || return;
+
+ if ($self->api->vm_power_on($vmx_file_path)) {
+ #notify($ERRORS{'OK'}, 0, "powered on $vmx_file_path, sleeping
$power_on_throttle_delay_seconds seconds before releasing
$power_on_semaphore_id semaphore to throttle VMs being powered on");
+ #sleep $power_on_throttle_delay_seconds;
+ return 1;
+ }
+ else {
+ return;
+ }
}
#/////////////////////////////////////////////////////////////////////////////
@@ -5580,8 +5693,8 @@ sub power_reset {
$vmx_file_path = normalize_file_path($vmx_file_path);
# Power off and then power on the VM
- $self->api->vm_power_off($vmx_file_path);
- return$self->api->vm_power_on($vmx_file_path);
+ $self->power_off($vmx_file_path);
+ return$self->power_on($vmx_file_path);
}
#/////////////////////////////////////////////////////////////////////////////
@@ -6498,12 +6611,15 @@ sub _check_datastore_paths {
'get_vmx_file_path',
'get_vmdk_base_directory_path',
+
'get_vmdk_directory_path',
'get_vmdk_file_path',
+ 'get_vmdk_base_directory_path_nonpersistent',
'get_vmdk_directory_path_nonpersistent',
'get_vmdk_file_path_nonpersistent',
+ 'get_vmdk_base_directory_path_persistent',
'get_vmdk_directory_path_persistent',
'get_vmdk_file_path_persistent',
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm Thu Jun 30
17:06:54 2011
@@ -851,6 +851,23 @@ sub DESTROY {
else {
notify($ERRORS{'DEBUG'}, 0, "state process created unknown
number of database handles, \$ENV{dbh_count} is undefined");
}
+
+ if (defined $ENV{database_select_count}) {
+ notify($ERRORS{'DEBUG'}, 0, "number of database select queries:
$ENV{database_select_count}");
+ }
+
+ if (defined $ENV{database_select_row_count}) {
+ notify($ERRORS{'DEBUG'}, 0, "number of database select rows
returned: $ENV{database_select_row_count}");
+ }
+ if (defined $ENV{database_select_field_count}) {
+ notify($ERRORS{'DEBUG'}, 0, "number of database select fields
returned: $ENV{database_select_field_count}");
+ }
+
+ for my $key (sort keys %ENV) {
+ if ($key =~ /^db_/) {
+ print "$key: $ENV{$key}\n";
+ }
+ }
# Close the database handle
if (defined $ENV{dbh}) {
Modified: incubator/vcl/trunk/managementnode/lib/VCL/blockrequest.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/blockrequest.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/blockrequest.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/blockrequest.pm Thu Jun 30
17:06:54 2011
@@ -119,7 +119,8 @@ sub initialize {
sub process {
my $self = shift;
-
+ my ($package, $filename, $line) = caller;
+
# Retrieve data from the data structure
my $blockrequest_id = $self->data->get_blockrequest_id();
my $blockrequest_mode = $self->data->get_blockrequest_mode();
@@ -131,13 +132,14 @@ sub process {
my $blocktime_start = $self->data->get_blocktime_start();
my $blocktime_end = $self->data->get_blocktime_end();
my $blockrequest_name = $self->data->get_blockrequest_name();
- my $blockrequest_owner_id =
$self->data->get_blockrequest_owner_id();
- my $block_group_name =
$self->data->get_blockrequest_group_name();
+ my $blockrequest_owner_id =
$self->data->get_blockrequest_owner_id();
+ my $block_group_id =
$self->data->get_blockrequest_group_id();
+ my $block_group_name =
$self->data->get_blockrequest_group_name();
# Get user info
my $user_info;
- my %image_info;
- my $image_prettyname;
+ my $image_info;
+ my $image_prettyname;
my $owner_affiliation_helpaddress;
my $owner_email;
@@ -147,10 +149,10 @@ sub process {
}
#Get image info
- if(%image_info = get_image_info($blockrequest_image_id)){
- $image_prettyname = $image_info{prettyname};
+ if ($image_info = get_image_info($blockrequest_image_id)){
+ $image_prettyname = $image_info->{prettyname};
- }
+ }
#Set local timer
my $localtimer = convert_to_epoch_seconds();
@@ -245,7 +247,7 @@ sub process {
if($allocated < $blockrequest_number_machines){
$subject = "VCL Block allocation warning for
$blockrequest_name";
- $mailstring .= <<"EOF";
+ $mailstring .= << "EOF";
WARNING - The block allocation for $blockrequest_name was not successfully
processed for the following session.
REASON: machines allocated were less than requested
@@ -410,7 +412,9 @@ sub process_block_time {
sub update_blockTimes_processing {
my ($blockTimes_id, $processing) = @_;
-
+
+ my ($package, $filename, $line, $sub) = caller(0);
+
# Check the arguments
if (!defined($blockTimes_id)) {
notify($ERRORS{'WARNING'}, 0, "blockTimes ID was not
specified");
@@ -534,7 +538,9 @@ sub udpate_block_request_status {
sub clear_blockTimes {
my ($blockTimes_id) = @_;
-
+
+ my ($package, $filename, $line, $sub) = caller(0);
+
# Check the arguments
if (!defined($blockTimes_id)) {
notify($ERRORS{'WARNING'}, 0, "blockTimes ID was not
specified");
@@ -572,7 +578,9 @@ sub clear_blockTimes {
sub clear_blockComputers {
my ($blockTimes_id) = @_;
-
+
+ my ($package, $filename, $line, $sub) = caller(0);
+
# Check the arguments
if (!defined($blockTimes_id)) {
notify($ERRORS{'WARNING'}, 0, "blockTimes ID was not
specified");
Modified: incubator/vcl/trunk/managementnode/lib/VCL/image.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/image.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/image.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/image.pm Thu Jun 30 17:06:54 2011
@@ -559,7 +559,7 @@ sub setup_capture_base_image {
# Get information from the database for all of the computers
found
for my $computer_id (@computer_ids) {
- $computer_info{$computer_id} =
get_computer_info($computer_id)->{computer};
+ $computer_info{$computer_id} =
get_computer_info($computer_id);
if (!$computer_info{$computer_id}) {
print "ERROR: unable to retrieve information
for computer ID: $computer_id\n";
return;
Modified: incubator/vcl/trunk/managementnode/lib/VCL/new.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1141626&r1=1141625&r2=1141626&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/new.pm Thu Jun 30 17:06:54 2011
@@ -133,17 +133,17 @@ sub process {
notify($ERRORS{'OK'}, 0, "request_state_name is not new");
if(is_inblockrequest($computer_id)){
notify($ERRORS{'OK'}, 0, "computer_id $computer_id is
in blockrequest");
- my %imagerev_info =
get_production_imagerevision_info($image_id);
- unless($imagerevision_id == $imagerev_info{id}){
- notify($ERRORS{'OK'}, 0, "imagerevision_id does
not match imagerevision_id= $imagerevision_id imagerev_info
$imagerev_info{id}");
-
$self->data->set_imagerevision_id($imagerev_info{id});
-
$self->data->set_sublog_imagerevisionid($imagerev_info{id});
-
$self->data->set_image_name($imagerev_info{imagename});
-
$self->data->set_imagerevision_revision($imagerev_info{revision});
+ my $imagerev_info =
get_production_imagerevision_info($image_id);
+ unless($imagerevision_id == $imagerev_info->{id}){
+ notify($ERRORS{'OK'}, 0, "imagerevision_id does
not match imagerevision_id= $imagerevision_id imagerev_info
$imagerev_info->{id}");
+
$self->data->set_imagerevision_id($imagerev_info->{id});
+
$self->data->set_sublog_imagerevisionid($imagerev_info->{id});
+
$self->data->set_image_name($imagerev_info->{imagename});
+
$self->data->set_imagerevision_revision($imagerev_info->{revision});
#reset variables in this scope
- $imagerevision_id = $imagerev_info{id};
- $image_name = $imagerev_info{imagename};
+ $imagerevision_id = $imagerev_info->{id};
+ $image_name = $imagerev_info->{imagename};
}
}
}