Author: arkurth
Date: Tue May 30 18:40:41 2017
New Revision: 1796911

URL: http://svn.apache.org/viewvc?rev=1796911&view=rev
Log:
VCL-1052
Removed check for vmprofile.vmdisk = dedicated and repository path not 
configured in VMware.pm::capture.  Added logic to 
VMware.pm::reclaim_vmhost_disk_space to prevent possibility of images being 
deleted if the repository is not configured.

Other
Added caching of return values in the following subroutines since the results 
are static for a given host:
* VIM_SSH.pm::get_config_option_descriptor_info
* VIM_SSH.pm::get_highest_vm_hardware_version_key
* VIM_SSH.pm::get_config_option_info
* VIM_SSH.pm::get_config_option_guest_os_info
* VIM_SSH.pm::get_supported_guest_os_ids

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

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm?rev=1796911&r1=1796910&r2=1796911&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm 
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm Tue 
May 30 18:40:41 2017
@@ -2561,6 +2561,8 @@ sub get_config_option_descriptor_info {
                return;
        }
        
+       return $self->{config_option_descriptor_info} if 
$self->{config_option_descriptor_info};
+       
        my $vim_cmd_arguments = "solo/querycfgoptdesc";
        my ($exit_status, $output) = $self->_run_vim_cmd($vim_cmd_arguments);
        return if !$output;
@@ -2593,6 +2595,7 @@ sub get_config_option_descriptor_info {
        }
        
        #notify($ERRORS{'DEBUG'}, 0, "retrieved config option descriptor 
info:\n" . format_data($config_option_descriptor_info));
+       $self->{config_option_descriptor_info} = $config_option_descriptor_info;
        return $config_option_descriptor_info;
 }
 
@@ -2616,6 +2619,8 @@ sub get_highest_vm_hardware_version_key
                return;
        }
        
+       return $self->{highest_vm_hardware_version_key} if 
defined($self->{highest_vm_hardware_version_key});
+       
        my $vmhost_hostname = $self->data->get_vmhost_hostname();
        
        my $config_option_descriptor_info = 
$self->get_config_option_descriptor_info();
@@ -2631,6 +2636,7 @@ sub get_highest_vm_hardware_version_key
        }
        
        notify($ERRORS{'DEBUG'}, 0, "determined highest VM hardware version 
supported on $vmhost_hostname: $highest_vm_hardware_version_key");
+       $self->{highest_vm_hardware_version_key} = 
$highest_vm_hardware_version_key;
        return $highest_vm_hardware_version_key;
 }
 
@@ -2672,6 +2678,8 @@ sub get_config_option_info {
                return;
        }
        
+       return $self->{config_option_info}{$key} if 
defined($self->{config_option_info}{$key});
+       
        my $vim_cmd_arguments = "solo/querycfgopt $key";
        my ($exit_status, $output) = $self->_run_vim_cmd($vim_cmd_arguments);
        return if !$output;
@@ -2687,6 +2695,7 @@ sub get_config_option_info {
                return;
        }
        
+       $self->{config_option_info}{$key} = $result->{'vim.vm.ConfigOption'};
        return $result->{'vim.vm.ConfigOption'};
 }
 
@@ -2726,6 +2735,8 @@ sub get_config_option_guest_os_info {
                return;
        }
        
+       return $self->{config_option_guest_os_info}{$key} if 
defined($self->{config_option_guest_os_info}{$key});
+       
        my $config_option_info = $self->get_config_option_info($key) || return;
        
        my $guest_os_descriptor_array_ref = 
$config_option_info->{guestOSDescriptor};
@@ -2751,6 +2762,7 @@ sub get_config_option_guest_os_info {
        }
        
        #notify($ERRORS{'DEBUG'}, 0, "retrieved config option guest OS info:\n" 
. format_data($config_option_guest_os_info));
+       $self->{config_option_guest_os_info}{$key} = 
$config_option_guest_os_info;
        return $config_option_guest_os_info;
 }
 
@@ -2785,6 +2797,8 @@ sub get_supported_guest_os_ids {
                }
        }
        
+       return @{$self->{supported_guest_os_ids}{$vm_hardware_version_key}} if 
defined($self->{supported_guest_os_ids}{$vm_hardware_version_key});
+       
        my $config_option_info = 
$self->get_config_option_info($vm_hardware_version_key) || return;
        
        my $guest_os_descriptor_array_ref = 
$config_option_info->{guestOSDescriptor};
@@ -2817,6 +2831,7 @@ sub get_supported_guest_os_ids {
        }
        
        notify($ERRORS{'DEBUG'}, 0, "retrieved supported guest OS names on 
$vmhost_hostname, VM hardware version: $vm_hardware_version_key: " . join(",", 
@supported_guest_os_ids));
+       $self->{supported_guest_os_ids}{$vm_hardware_version_key} = 
\@supported_guest_os_ids;
        return @supported_guest_os_ids;
 }
 

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=1796911&r1=1796910&r2=1796911&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 30 18:40:41 2017
@@ -57,6 +57,8 @@ use 5.008000;
 use strict;
 use warnings;
 use diagnostics;
+no warnings 'redefine';
+
 use English qw(-no_match_vars);
 use IO::File;
 use Fcntl qw(:DEFAULT :flock);
@@ -830,12 +832,6 @@ sub capture {
        my $vmdk_base_directory_path_shared = 
$self->get_vmdk_base_directory_path_shared();
        my $repository_mounted_on_vmhost = 
$self->is_repository_mounted_on_vmhost();
        
-       # Make sure the VM profile repository path is configured if the VM 
profile disk type is local
-       if ($vmprofile_vmdisk =~ /(local|dedicated)/ && 
!$self->get_repository_vmdk_base_directory_path()) {
-               notify($ERRORS{'CRITICAL'}, 0, "disk type is set to 
'$vmprofile_vmdisk' but the repository path is NOT configured for VM profile 
'$vmprofile_name', this configuration is not allowed because it may result in 
vmdk directories being deleted without a backup copy saved in the image 
repository");
-               return;
-       }
-       
        # Determine the vmx file path actively being used by the VM
        my $vmx_file_path_original = $self->get_active_vmx_file_path();
        if (!$vmx_file_path_original) {
@@ -2708,9 +2704,15 @@ sub reclaim_vmhost_disk_space {
                notify($ERRORS{'DEBUG'}, 0, "VM $vmx_file_name can be deleted");
        }
        
-       if ($vmhost_profile_vmdisk =~ /(local|dedicated)/) {
+       if ($vmhost_profile_vmdisk !~ /(local|dedicated)/) {
+               notify($ERRORS{'OK'}, 0, "VM disk mode is 
'$vmhost_profile_vmdisk', no image directories will be deleted from 
$vmdk_base_directory_path");
+       }
+       elsif (!$self->get_repository_vmdk_base_directory_path()) {
+               notify($ERRORS{'OK'}, 0, "VM disk mode is 
'$vmhost_profile_vmdisk' but repository path is NOT configured, no image 
directories will be deleted from $vmdk_base_directory_path");
+       }
+       else {
+               notify($ERRORS{'DEBUG'}, 0, "VM disk mode is 
'$vmhost_profile_vmdisk' and repository path is configured, checking if any 
image directories can be deleted from $vmdk_base_directory_path");
                for my $vmdk_directory_path (sort keys %$vmdk_directories) {
-                       
                        $vmdk_directories->{$vmdk_directory_path}{deletable} = 
1;
                        for my $vmx_file_path (keys 
%{$vmdk_directories->{$vmdk_directory_path}{vmx_file_paths}}) {
                                
$vmdk_directories->{$vmdk_directory_path}{deletable} &= 
$vmx_files->{$vmx_file_path}{deletable};
@@ -2865,7 +2867,7 @@ sub reclaim_vmhost_disk_space {
                        "vmdk volume potentially available space: " . 
get_file_size_info_string($vmdk_potential_available_space)
                );
        }
-       
+
        my @delete_stage_order = (
                ['vmdk', 'image_deleted', '1'],
                ['vmx', 'registered', '0'],


Reply via email to