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 2015/05/12 21:39:45 UTC

svn commit: r1679038 - /vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm

Author: arkurth
Date: Tue May 12 19:39:44 2015
New Revision: 1679038

URL: http://svn.apache.org/r1679038
Log:
VCL-844
Added check to VMware.pm::prepare_vmdk to not attempt to delete an existing dedicated vmdk directory for a VM unless the request state is new or reload.

Added check to migrate_vm so that the migration fails if the VM has multiple virtual disks. Support for this may be added later.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm?rev=1679038&r1=1679037&r2=1679038&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm Tue May 12 19:39:44 2015
@@ -1951,10 +1951,19 @@ sub prepare_vmdk {
 	
 	# If the VM is dedicated, check if the dedicated vmdk already exists on the host, delete it if necessary
 	if ($is_vm_dedicated && $self->vmhost_os->file_exists($host_vmdk_directory_path)) {
-		notify($ERRORS{'WARNING'}, 0, "VM is dedicated and vmdk directory already exists on VM host $vmhost_name: $host_vmdk_directory_path, existing directory will be deleted");
-		if (!$self->vmhost_os->delete_file($host_vmdk_directory_path)) {
-			notify($ERRORS{'WARNING'}, 0, "failed to delete existing dedicated vmdk directory on VM host $vmhost_name: $host_vmdk_directory_path");
-			return;
+		my $request_state_name = $self->data->get_request_state_name(0);
+		if ($request_state_name && $request_state_name =~ /(new|reload)/) {
+			notify($ERRORS{'WARNING'}, 0, "VM is dedicated and vmdk directory already exists on VM host $vmhost_name: $host_vmdk_directory_path, existing directory will be deleted");
+			if (!$self->vmhost_os->delete_file($host_vmdk_directory_path)) {
+				notify($ERRORS{'WARNING'}, 0, "failed to delete existing dedicated vmdk directory on VM host $vmhost_name: $host_vmdk_directory_path");
+				return;
+			}
+		}
+		else {
+			# Don't delete the directory, it may be in use by a VM
+			# Attempting to delete it will likely delete some files but not all, leaving a mess to reconstruct
+			notify($ERRORS{'OK'}, 0, "VM is dedicated and vmdk directory already exists on VM host $vmhost_name: $host_vmdk_directory_path, request state is not new or reload, directory will not be deleted, returning true");
+			return 1;
 		}
 	}
 	
@@ -9264,6 +9273,12 @@ sub migrate_vm {
 		notify($ERRORS{'WARNING'}, 0, "failed to migrate VM, source vmdk file paths could not be retrieved");
 		return;
 	}
+	elsif (scalar(@source_vmdk_file_paths) > 1) {
+		# Don't allow multiple vmdk's for now
+		# TODO: add support for this, need to check if destination has enough space
+		# Also need to check if disks are affected by snapshots. If not, need to copy while VM is suspended
+		notify($ERRORS{'DEBUG'}, 0, "$vm_computer_name contains multiple virtual disks, only the migration of single virtual disk VMs is currently supported");
+	}
 	
 	# VM may have multiple virtual disks
 	my @source_primary_vmdk_file_paths = @{$source_vmdk_file_paths[0]};