vcl-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arku...@apache.org
Subject svn commit: r1787263 - in /vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware: VIM_SSH.pm VMware.pm
Date Thu, 16 Mar 2017 22:31:46 GMT
Author: arkurth
Date: Thu Mar 16 22:31:45 2017
New Revision: 1787263

URL: http://svn.apache.org/viewvc?rev=1787263&view=rev
Log:
VCL-1010
Added Windows 10 and 2016 keys to %VM_OS_CONFIGURATION in VMware.pm.

VCL-1026
Updated the default values in %VM_OS_CONFIGURATION from WinXPPro to windows7 and other to
otherlinux. Also changed the associated default NIC and storage models to the recommended
defaults for the corresponding guestOS choice.

Added code to VMware.pm::capture to attempt to retrieve the OS product name and architecture
from the running VM before being shutting down. These values are added to the VM's .vmx file
after it is powered off, which in turn winds up in the reference .vmx file.

Added VIM_SSH.pm::get_highest_vm_hardware_version_key. It queries the host's capabilities
and determines the highest VM virtual hardware version supported.

Added VIM_SSH.pm::get_supported_guest_os_ids. It also queries the host's capabilities and
generates a list of valid guestOS values. This is used to verify a particular guestOS is supported.
If not, a lesser default is used.

Updated VMware.pm::get_vm_virtual_hardware_version to call the API module's get_highest_vm_hardware_version_key
subroutine if implemented. This is used to select the host's latest supported version.

Reworked VMware.pm::get_vm_guest_os to attempt to get both the guestOS and newly added OS
product name comment from the reference .vmx. If the product name was retrieved, it attempts
to figure out the best guest OS from it. If not, it resorts to the guestOS value from the
captured computer. If all else fails, the default value from %VM_OS_CONFIGURATION is used.


Other
Updated experimental code to support VMware ESXi's built-in VNC server in VMware.pm::node_status
and prepare_vmx. All of this code is commented out.

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=1787263&r1=1787262&r2=1787263&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 Thu Mar 16 22:31:45
2017
@@ -205,16 +205,6 @@ sub _run_vim_cmd {
 			$semaphore = $self->get_semaphore($vmhost_computer_name, 120, 1) || next ATTEMPT;
 		}
 		
-		#	my $semaphore_id = "$vmhost_computer_name";
-		#	if ($self->does_semaphore_exist($semaphore_id)) {
-		#		
-		#		notify($ERRORS{'DEBUG'}, 0, "blocked by another process controlling $vmhost_computer_name,
sleeping for 10 seconds");
-		#		sleep_uninterrupted(10);
-		#		my $wait_message = "blocked by another process controlling $vmhost_computer_name";
-		#		$self->code_loop_timeout(sub{!$self->does_semaphore_exist(@_)}, [$semaphore_id],
$wait_message, 140, 5);
-		#	}
-		#}
-		
 		# The following error is somewhat common if several processes are adding/removing VMs at
the same time:
 		# (vmodl.fault.ManagedObjectNotFound) {
 		#	 dynamicType = <unset>,
@@ -228,6 +218,14 @@ sub _run_vim_cmd {
 		$self->{vim_cmd_calls}++;
 		#notify($ERRORS{'DEBUG'}, 0, "vim-cmd call count: $self->{vim_cmd_calls} ($vim_arguments)");
 		
+		#my $register_semaphore;
+		#if ($command =~ /(getallvms|register)/) {
+		#	$register_semaphore = $self->get_semaphore($vmhost_computer_name, 120, 1);
+		#	if (!$register_semaphore) {
+		#		next ATTEMPT;
+		#	}
+		#}
+		
 		my ($exit_status, $output) = $self->vmhost_os->execute({
 			'command' => $command,
 			'display_output' => 0,
@@ -2600,12 +2598,64 @@ sub get_config_option_descriptor_info {
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 get_highest_vm_hardware_version_key
+
+ Parameters  : none
+ Returns     : string
+ Description : Each VMware VM has a hardware version. The versions supported on
+               the host depends on the version of VMware. This subroutine
+               returns the highest supported version and returns an integer. For
+               example vmx-11 is returned for ESXi 6.0.
+
+=cut
+
+sub get_highest_vm_hardware_version_key {
+	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;
+	}
+	
+	my $vmhost_hostname = $self->data->get_vmhost_hostname();
+	
+	my $config_option_descriptor_info = $self->get_config_option_descriptor_info();
+	
+	my $highest_vm_hardware_version_number;
+	my $highest_vm_hardware_version_key;
+	for my $version_key (sort keys %$config_option_descriptor_info) {
+		my ($version_number) = $version_key =~ /-(\d+)$/g;
+		if (!$highest_vm_hardware_version_number || $highest_vm_hardware_version_number < $version_number)
{
+			$highest_vm_hardware_version_number = $version_number;
+			$highest_vm_hardware_version_key = $version_key;
+		}
+	}
+	
+	notify($ERRORS{'DEBUG'}, 0, "determined highest VM hardware version supported on $vmhost_hostname:
$highest_vm_hardware_version_key");
+	return $highest_vm_hardware_version_key;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 get_config_option_info
 
  Parameters  : $key
  Returns     : hash reference
  Description : Retrieves info about the VM configuration options available for a
-               particular hardware version key (ex: vmx-09).
+					particular hardware version key (ex: vmx-09). A hash reference is
+					returned with the following keys:
+                  {
+                     capabilities = {},
+                     datastore = {},
+                     defaultDevice = [],
+                     description = '',
+                     guestOSDefaultIndex = '',
+                     guestOSDescriptor = [],
+                     hardwareOptions = {},
+                     supportedMonitorType = [],
+                     supportedOvfEnvironmentTransport = '',
+                     supportedOvfInstallTransport = '',
+                     version = '',
+                  },
 
 =cut
 
@@ -2706,126 +2756,206 @@ sub get_config_option_guest_os_info {
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 get_supported_guest_os_ids
+
+ Parameters  : $vm_hardware_version_key (optional)
+ Returns     : array
+ Description : Retrieves the names of the supported guestOS values for the VM
+               hardware version specified by the argument (example: vmx-11). If
+               no argument is supplied, the host's highest supported hardware
+               version is used.
+
+=cut
+
+sub get_supported_guest_os_ids {
+	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;
+	}
+	
+	my $vmhost_hostname = $self->data->get_vmhost_hostname();
+	
+	my $vm_hardware_version_key = shift;
+	if (!defined($vm_hardware_version_key)) {
+		$vm_hardware_version_key = $self->get_highest_vm_hardware_version_key();
+		if (!defined($vm_hardware_version_key)) {
+			notify($ERRORS{'WARNING'}, 0, "failed to determine supported guest OS names on $vmhost_hostname,
VM hardware version key argument was not provided and highest supported VM hardware version
could not be determiend");
+			return;
+		}
+	}
+	
+	my $config_option_info = $self->get_config_option_info($vm_hardware_version_key) || return;
+	
+	my $guest_os_descriptor_array_ref = $config_option_info->{guestOSDescriptor};
+	if (!defined($guest_os_descriptor_array_ref)) {
+		notify($ERRORS{'WARNING'}, 0, "failed to retrieve config option guest OS info, config option
info does not contain a 'guestOSDescriptor' key:\n" . format_hash_keys($config_option_info));
+		return;
+	}
+	
+	my $type = ref($guest_os_descriptor_array_ref);
+	if (!$type || $type ne 'ARRAY') {
+		notify($ERRORS{'WARNING'}, 0, "failed to retrieve config option guest OS info for '$vm_hardware_version_key',
guestOSDescriptor value is not an array reference:\n" . format_data($guest_os_descriptor_array_ref));
+		return;
+	}
+	
+	my @supported_guest_os_ids;
+	for my $guest_os_descriptor (@$guest_os_descriptor_array_ref) {
+		my $guest_os_id = $guest_os_descriptor->{id};
+		
+		# Every name includes "Guest" at the end but this is not in the valid guestOS values
+		$guest_os_id =~ s/Guest//;
+		
+		# Windows server OS's: windows7Server --> windows7srv
+		$guest_os_id =~ s/(windows.+)Server/$1srv/;
+		
+		# windows7_64 --> windows7-64
+		# windows8srv64 --> windows8srv-64
+		$guest_os_id =~ s/_?(64)/-$1/g;
+		
+		push @supported_guest_os_ids, $guest_os_id;
+	}
+	
+	notify($ERRORS{'DEBUG'}, 0, "retrieved supported guest OS names on $vmhost_hostname, VM
hardware version: $vm_hardware_version_key: " . join(",", @supported_guest_os_ids));
+	return @supported_guest_os_ids;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 _print_compatible_guest_os_hardware_versions
 
  Parameters  : $print_code (optional)
  Returns     : true
  Description : Used for development/testing only. Prints list of possible
                guestOS values.
-               asianux3Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               asianux3_64Guest                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               asianux4Guest                                   vmx-08 vmx-09 vmx-10 vmx-11
-               asianux4_64Guest                                vmx-08 vmx-09 vmx-10 vmx-11
-               asianux5_64Guest                                                     vmx-11
-               centos64Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               centosGuest                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               coreos64Guest                                                        vmx-11
-               darwin10Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               darwin10_64Guest                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               darwin11Guest                                   vmx-08 vmx-09 vmx-10 vmx-11
-               darwin11_64Guest                                vmx-08 vmx-09 vmx-10 vmx-11
-               darwin12_64Guest                                       vmx-09 vmx-10 vmx-11
-               darwin13_64Guest                                              vmx-10 vmx-11
-               darwin14_64Guest                                                     vmx-11
-               darwin64Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               darwinGuest                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               debian4Guest                             vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               debian4_64Guest                          vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               debian5Guest                             vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               debian5_64Guest                          vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               debian6Guest                                    vmx-08 vmx-09 vmx-10 vmx-11
-               debian6_64Guest                                 vmx-08 vmx-09 vmx-10 vmx-11
-               debian7Guest                                                  vmx-10 vmx-11
-               debian7_64Guest                                               vmx-10 vmx-11
-               debian8Guest                                                         vmx-11
-               debian8_64Guest                                                      vmx-11
-               dosGuest                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               eComStation2Guest                               vmx-08 vmx-09 vmx-10 vmx-11
-               eComStationGuest                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               fedora64Guest                                                        vmx-11
-               fedoraGuest                                                          vmx-11
-               freebsd64Guest                           vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               freebsdGuest                             vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               netware5Guest              vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               netware6Guest              vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               oesGuest                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               openServer5Guest                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               openServer6Guest                                vmx-08 vmx-09 vmx-10 vmx-11
-               opensuse64Guest                                                      vmx-11
-               opensuseGuest                                                        vmx-11
-               oracleLinux64Guest                       vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               oracleLinuxGuest                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               os2Guest                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               other24xLinux64Guest                     vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               other24xLinuxGuest                       vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               other26xLinux64Guest                     vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               other26xLinuxGuest                       vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               other3xLinux64Guest                                           vmx-10 vmx-11
-               other3xLinuxGuest                                             vmx-10 vmx-11
-               otherGuest                 vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               otherGuest64                      vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               otherLinux64Guest                 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               otherLinuxGuest            vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel2Guest                        vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel3Guest                        vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel3_64Guest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel4Guest                        vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel4_64Guest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel5Guest                        vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel5_64Guest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel6Guest                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel6_64Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               rhel7Guest                                             vmx-09 vmx-10
-               rhel7_64Guest                                          vmx-09 vmx-10 vmx-11
-               sles10Guest                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               sles10_64Guest                    vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               sles11Guest                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               sles11_64Guest                    vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               sles12Guest                                            vmx-09 vmx-10
-               sles12_64Guest                                         vmx-09 vmx-10 vmx-11
-               sles64Guest                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               slesGuest                         vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               solaris10Guest                    vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               solaris10_64Guest                 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               solaris11_64Guest                               vmx-08 vmx-09 vmx-10 vmx-11
-               solaris8Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               solaris9Guest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               ubuntu64Guest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               ubuntuGuest                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               unixWare7Guest                           vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               vmkernel5Guest                                  vmx-08 vmx-09 vmx-10 vmx-11
-               vmkernel6Guest                                                       vmx-11
-               vmkernelGuest                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win2000AdvServGuest        vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win2000ProGuest                   vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win2000ServGuest           vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win31Guest                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win95Guest                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               win98Guest                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winLonghorn64Guest                vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winLonghornGuest                  vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNTGuest                 vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetBusinessGuest        vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetDatacenter64Guest           vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetDatacenterGuest      vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetEnterprise64Guest           vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetEnterpriseGuest      vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetStandard64Guest             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetStandardGuest        vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winNetWebGuest             vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winVista64Guest                   vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winVistaGuest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winXPPro64Guest                   vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               winXPProGuest              vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               windows7Guest                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               windows7Server64Guest             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               windows7_64Guest                  vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11
-               windows8Guest                                   vmx-08 vmx-09 vmx-10 vmx-11
-               windows8Server64Guest                           vmx-08 vmx-09 vmx-10 vmx-11
-               windows8_64Guest                                vmx-08 vmx-09 vmx-10 vmx-11
-               windows9Guest                                                 vmx-10 vmx-11
-               windows9Server64Guest                                         vmx-10 vmx-11
-               windows9_64Guest                                              vmx-10 vmx-11
+					asianux3                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					asianux3-64                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					asianux4                                        vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					asianux4-64                                     vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					asianux7-64                                                                        vmx-13
+					centos                                   vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					centos-64                                vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					centos6                                                                            vmx-13
+					centos6-64                                                                         vmx-13
+					centos7-64                                                                         vmx-13
+					coreos-64                                                            vmx-11 vmx-12 vmx-13
+					darwin                                   vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin-64                                vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin10                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin10-64                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin11                                        vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin11-64                                     vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin12-64                                            vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					darwin13-64                                                   vmx-10 vmx-11 vmx-12 vmx-13
+					darwin14-64                                                          vmx-11 vmx-12 vmx-13
+					darwin15-64                                                                 vmx-12 vmx-13
+					darwin16-64                                                                        vmx-13
+					debian10                                                                           vmx-13
+					debian10-64                                                                        vmx-13
+					debian4                                  vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian4-64                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian5                                  vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian5-64                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian6                                  vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian6-64                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					debian7                                                       vmx-10 vmx-11 vmx-12 vmx-13
+					debian7-64                                                    vmx-10 vmx-11 vmx-12 vmx-13
+					debian8                                                              vmx-11 vmx-12 vmx-13
+					debian8-64                                                           vmx-11 vmx-12 vmx-13
+					debian9                                                                            vmx-13
+					debian9-64                                                                         vmx-13
+					dos                                      vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					eComStation                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					eComStation2                                    vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					fedora                                                               vmx-11 vmx-12 vmx-13
+					fedora-64                                                            vmx-11 vmx-12 vmx-13
+					freebsd                                  vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					freebsd-64                               vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					netware5                   vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					netware6                   vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					oes                               vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					openServer5                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					openServer6                                     vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					opensuse                                                             vmx-11 vmx-12 vmx-13
+					opensuse-64                                                          vmx-11 vmx-12 vmx-13
+					oracleLinux                              vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					oracleLinux-64                           vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					oracleLinux6                                                                       vmx-13
+					oracleLinux6-64                                                                    vmx-13
+					oracleLinux7-64                                                                    vmx-13
+					os2                                      vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other                      vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other-64                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other24xLinux                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other24xLinux-64                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other26xLinux                            vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other26xLinux-64                         vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					other3xLinux                                                  vmx-10 vmx-11 vmx-12 vmx-13
+					other3xLinux-64                                               vmx-10 vmx-11 vmx-12 vmx-13
+					otherLinux                 vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					otherLinux-64                     vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel2                             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel3                             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel3-64                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel4                             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel4-64                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel5                             vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel5-64                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel6                                    vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel6-64                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					rhel7                                                  vmx-09 vmx-10
+					rhel7-64                                               vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles                              vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles-64                           vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles10                            vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles10-64                         vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles11                            vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles11-64                         vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					sles12                                                 vmx-09 vmx-10
+					sles12-64                                              vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					solaris10                         vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					solaris10-64                      vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					solaris11-64                                    vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					solaris8                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					solaris9                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					ubuntu                            vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					ubuntu-64                         vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					unixWare7                                vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					vmkernel                                 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					vmkernel5                                       vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					vmkernel6                                                            vmx-11 vmx-12 vmx-13
+					vmkernel65                                                           vmx-11 vmx-12 vmx-13
+					vmwarePhoton-64                                                                    vmx-13
+					win2000AdvServ             vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					win2000Pro                        vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					win2000Serv                vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					win31                                    vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					win95                                    vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					win98                                    vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows7                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows7-64                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows7srv-64                    vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows8                                        vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows8-64                                     vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows8srv-64                                  vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					windows9                                                      vmx-10 vmx-11 vmx-12 vmx-13
+					windows9-64                                                   vmx-10 vmx-11 vmx-12 vmx-13
+					windows9srv-64                                                vmx-10 vmx-11 vmx-12 vmx-13
+					winLonghorn                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winLonghorn-64                    vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetBusiness             vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetDatacenter           vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetDatacenter-64               vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetEnterprise           vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetEnterprise-64               vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetStandard             vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetStandard-64                 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNetWeb                  vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winNT                      vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winVista                          vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winVista-64                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winXPPro                   vmx-03 vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
+					winXPPro-64                       vmx-04 vmx-07 vmx-08 vmx-09 vmx-10 vmx-11 vmx-12 vmx-13
 
 =cut
 
@@ -2842,15 +2972,15 @@ sub _print_compatible_guest_os_hardware_
 	my $config_option_descriptor_info = $self->get_config_option_descriptor_info();
 	
 	for my $version_key (sort keys %$config_option_descriptor_info) {
-		my $config_option_guest_os_info = $self->get_config_option_guest_os_info($version_key);
-		for my $guest_os (keys %$config_option_guest_os_info) {
-			$guest_os_info->{$guest_os}{$version_key} = 1;
+		my @guest_os_ids = $self->get_supported_guest_os_ids($version_key);
+		for my $guest_os_id (@guest_os_ids) {
+			$guest_os_info->{$guest_os_id}{$version_key} = 1;
 		}
 	}
 	
 	my $version_key_count = scalar(keys %$config_option_descriptor_info);
 	
-	for my $guest_os (sort keys %$guest_os_info) {
+	for my $guest_os (sort {lc($a) cmp lc($b)} keys %$guest_os_info) {
 		if ($print_code) {
 			print "'$guest_os' => { ";
 			for my $version_key (sort keys %{$guest_os_info->{$guest_os}}) {

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=1787263&r1=1787262&r2=1787263&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm Thu Mar 16 22:31:45
2017
@@ -152,7 +152,19 @@ our %VM_OS_CONFIGURATION = (
 		"ethernet-virtualDev" => "e1000",
 		"scsi-virtualDev" => "lsiLogic",
 		"cpu_socket_limit" => 2,
+	},
+	"win10-x86" => {
+		"guestOS" => "windows9",
+		"ethernet-virtualDev" => "e1000e",
+		"scsi-virtualDev" => "lsisas1068",
+		"cpu_socket_limit" => 2,
 	}, 
+	"win10-x86_64" => {
+		"guestOS" => "windows9-64",
+		"ethernet-virtualDev" => "e1000",
+		"scsi-virtualDev" => "lsisas1068",
+		"cpu_socket_limit" => 2,
+	},
 	"win2003-x86" => {
 		"guestOS" => "winNetEnterprise",
 		"ethernet-virtualDev" => "vlance",
@@ -183,25 +195,33 @@ our %VM_OS_CONFIGURATION = (
 		"scsi-virtualDev" => "lsisas1068",
 		"cpu_socket_limit" => 64,
 	},
+	"win2016-x86_64" => {
+		"guestOS" => "windows9srv-64",
+		"ethernet-virtualDev" => "e1000e",
+		"scsi-virtualDev" => "lsisas1068",
+		"cpu_socket_limit" => 64,
+	},
+	
 	# Default Windows configuration if Windows version isn't found above:
 	"windows-x86" => {
-		"guestOS" => "winXPPro",
-		"ethernet-virtualDev" => "vlance",
-		"scsi-virtualDev" => "busLogic",
+		"guestOS" => "windows7",
+		"ethernet-virtualDev" => "e1000",
+		"scsi-virtualDev" => "lsisas1068",
 	},
 	"windows-x86_64" => {
-		"guestOS" => "winXPPro-64",
+		"guestOS" => "windows7-64",
 		"ethernet-virtualDev" => "e1000",
-		"scsi-virtualDev" => "lsiLogic",
+		"scsi-virtualDev" => "lsisas1068",
 	},
+	
 	# Default configuration if OS is not Windows or Linux:
 	"default-x86" => {
-		"guestOS" => "other",
-		"ethernet-virtualDev" => "vlance",
-		"scsi-virtualDev" => "busLogic",
+		"guestOS" => "otherlinux",
+		"ethernet-virtualDev" => "e1000",
+		"scsi-virtualDev" => "lsiLogic",
 	},
 	"default-x86_64" => {
-		"guestOS" => "other-64",
+		"guestOS" => "otherlinux-64",
 		"ethernet-virtualDev" => "e1000",
 		"scsi-virtualDev" => "lsiLogic",
 	},
@@ -501,8 +521,65 @@ sub node_status {
 		notify($ERRORS{'DEBUG'}, 0, "request state is '$request_state_name', returning result from
normal node_status checks: '$result'");
 		return $result;
 	}
+	
+	my $vmx_file_path = $self->get_vmx_file_path();
+	if (!$vmx_file_path) {
+		notify($ERRORS{'WARNING'}, 0, "unable to determine vmx file path, returning 'RELOAD'");
+		return 'RELOAD';
+	}
+	
+	#>>>>>>>>>>
+	# Experimental - Support for VMware ESXi's built in VNC server functionality
+	#my $reservation_id = $self->data->get_reservation_id();
+	#my $nathost_id = $self->data->get_nathost_id(0);
+	#if ($nathost_id) {
+	#	my $connect_method_info = get_reservation_connect_method_info($reservation_id);
+	#	
+	#	my $vnc_connect_method_port_id;
+	#	
+	#	for my $connect_method_id (keys %$connect_method_info) {
+	#		my $connect_method_name = $connect_method_info->{$connect_method_id}{name};
+	#		if ($connect_method_name =~ /(VMWare|ESX)/i && $connect_method_name =~ /VNC/i)
{
+	#			my @vnc_connect_method_port_ids = keys(%{$connect_method_info->{$connect_method_id}{connectmethodport}});
+	#			$vnc_connect_method_port_id = $vnc_connect_method_port_ids[0];
+	#			last;
+	#		}
+	#	}
+	#	
+	#	if ($vnc_connect_method_port_id) {
+	#		my $vmx_info = $self->get_vmx_info($vmx_file_path);
+	#		if (!$vmx_info) {
+	#			notify($ERRORS{'WARNING'}, 0, "unable to retrieve vmx file info, returning 'RELOAD'");
+	#			return 'RELOAD';
+	#		}
+	#		
+	#		my $vnc_password = $vmx_info->{'remotedisplay.vnc.password'};
+	#		if (!defined($vnc_password)) {
+	#			notify($ERRORS{'WARNING'}, 0, "VMware VNC connect method enabled, vmx file does NOT
contain VNC password, returning 'RELOAD'");
+	#			return 'RELOAD';
+	#		}
+	#		
+	#		my $vnc_port = $vmx_info->{'remotedisplay.vnc.port'};
+	#		if (!defined($vnc_port)) {
+	#			notify($ERRORS{'WARNING'}, 0, "VMware VNC connect method enabled, vmx file does NOT
contain VNC port, returning 'RELOAD'");
+	#			return 'RELOAD';
+	#		}
+	#		
+	#		if (!$self->data->set_reservation_password($vnc_password) || !update_reservation_password($reservation_id,
$vnc_password)) {
+	#			notify($ERRORS{'WARNING'}, 0, "VMware VNC connect method enabled, failed to override
reservation password, returning 'RELOAD'");
+	#			return 'RELOAD';
+	#		}
+	#		
+	#		if (!insert_natport($reservation_id, $nathost_id, $vnc_connect_method_port_id, $vnc_port))
{
+	#			notify($ERRORS{'WARNING'}, 0, "VMware VNC connect method enabled, failed to override
NAT port, returning 'RELOAD'");
+	#			return 'RELOAD';
+	#		}
+	#	}
+	#}
+	#<<<<<<<<<<
+
 	# If this is not a server request, no additional checks are necessary
-	elsif (!$is_server_request) {
+	if (!$is_server_request) {
 		notify($ERRORS{'DEBUG'}, 0, "this is not a server request, returning result from normal
node_status checks: '$result'");
 		return $result;
 	}
@@ -516,11 +593,7 @@ sub node_status {
 		return 'RELOAD';
 	}
 	
-	my $vmx_file_path = $self->get_vmx_file_path();
-	if (!$vmx_file_path) {
-		notify($ERRORS{'WARNING'}, 0, "unable to determine vmx file path, returning 'RELOAD'");
-		return 'RELOAD';
-	}
+	
 	
 	my @vm_virtual_disk_file_paths = $self->api->get_vm_virtual_disk_file_paths($vmx_file_path);
 	if (!@vm_virtual_disk_file_paths) {
@@ -840,6 +913,11 @@ sub capture {
 	# Set the imagemeta Sysprep value to 0 to prevent Sysprep from being used
 	$self->data->set_imagemeta_sysprep(0);
 	
+	# Attempt to get the name of the OS running on the VM and tag the .vmx file with it
+	# The name will be saved in the reference .vmx file and can be used to select the most appropriate
guest OS when loading future VMs
+	my $os_product_name = $self->os->get_product_name() if $self->os->can("get_product_name");
+	my $os_is_64_bit = $self->os->is_64_bit() if $self->os->can("is_64_bit");
+	
 	# Call the OS module's pre_capture() subroutine if implemented
 	if ($self->os->can("pre_capture") && !$self->os->pre_capture({end_state
=> 'off'})) {
 		notify($ERRORS{'WARNING'}, 0, "failed to complete OS module's pre_capture tasks");
@@ -861,6 +939,11 @@ sub capture {
 		}
 	}
 	
+	# Tag the .vmx with the OS product name and architecture
+	$self->vmhost_os->append_text_file($vmx_file_path_original, "#os_product_name = \"$os_product_name\"")
if (defined($os_product_name));
+	$self->vmhost_os->append_text_file($vmx_file_path_original, "#os_64_bit = \"$os_is_64_bit\"")
if (defined($os_is_64_bit));
+	
+	
 	if ($vmprofile_vmdisk =~ /(local|dedicated)/ && $repository_mounted_on_vmhost) {
 		# See https://issues.apache.org/jira/browse/VCL-633
 		# Don't save copy on VM host's datastore if dedicated, datastore may run out of space
@@ -1700,20 +1783,24 @@ sub prepare_vmx {
 		"workingDir" => "$vmx_directory_path",
 	);
 	
-	#my $reservation_password     = $self->data->get_reservation_password();
-	#if (defined($reservation_password)) {
-	#	my $vnc_port = ($computer_id + 10000);
-	#	notify($ERRORS{'DEBUG'}, 0, "vnc access will be enabled, port: $vnc_port, password: $reservation_password");
-	#	
-	#	%vmx_parameters = (%vmx_parameters, (
-	#		"RemoteDisplay.vnc.enabled" => "TRUE",
-	#		"RemoteDisplay.vnc.password" => $reservation_password,
-	#		"RemoteDisplay.vnc.port" => $vnc_port,
-	#	));
-	#}
-	#else {
-	#	notify($ERRORS{'DEBUG'}, 0, "vnc access will be not be enabled because the reservation
password is not set");
+	#>>>>>>>>>>
+	## Experimental - Support for VMware ESXi's built in VNC server functionality
+	#my $reservation_id = $self->data->get_reservation_id();
+	#my $vnc_password = $self->data->get_reservation_password(0);
+	#if (!defined($vnc_password)) {
+	#	$vnc_password = getpw();
+	#	update_reservation_password($reservation_id, $vnc_password);
+	#	$self->data->set_reservation_password($vnc_password);
 	#}
+	#
+	#my $vnc_port = ($computer_id + 10000);
+	#notify($ERRORS{'DEBUG'}, 0, "vnc access will be enabled, port: $vnc_port, password: $vnc_password");
+	#%vmx_parameters = (%vmx_parameters, (
+	#	"RemoteDisplay.vnc.enabled" => "TRUE",
+	#	"RemoteDisplay.vnc.password" => $vnc_password,
+	#	"RemoteDisplay.vnc.port" => $vnc_port,
+	#));
+	#<<<<<<<<<<
 	
 	# Add the disk adapter parameters to the hash
 	if ($vm_disk_adapter_type =~ /ide/i) {
@@ -4793,6 +4880,18 @@ sub get_vm_virtual_hardware_version {
 	
 	my $hardware_version;
 	
+	# Attempt to get the highest version supported by the VMware host
+	if ($self->api->can('get_highest_vm_hardware_version_key')) {
+		my $hardware_version_key = $self->api->get_highest_vm_hardware_version_key();
+		if ($hardware_version_key) {
+			($hardware_version) = $hardware_version_key =~ /-(\d+)$/g;
+			if ($hardware_version) {
+				notify($ERRORS{'DEBUG'}, 0, "retrieved highest VM hardware version supported on host:
$hardware_version");
+				return $hardware_version;
+			}
+		}
+	}
+	
 	# Attempt to retrieve the type from the reference vmx file for the image
 	my $reference_vmx_file_info = $self->get_reference_vmx_info();
 	if ($reference_vmx_file_info) {
@@ -4977,8 +5076,111 @@ sub get_vm_guest_os {
 		return;
 	}
 	
-	my $vm_os_configuration = $self->get_vm_os_configuration() || return;
-	return $vm_os_configuration->{"guestOS"};
+	# Get the hard-coded default guest OS value
+	my $vm_os_configuration = $self->get_vm_os_configuration() || {};
+	my $default_guest_os = $vm_os_configuration->{'guestOS'} || 'other';
+	
+	my $guest_os_determination = 'default value for image OS';
+	
+	# Attempt to retrieve the guestOS from the reference vmx file for the image
+	my $reference_vmx_file_info = $self->get_reference_vmx_info();
+	if (!$reference_vmx_file_info) {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, reference
.vmx file information could not be retrieved, returning $guest_os_determination: $default_guest_os");
+		return $default_guest_os;
+	}
+	my $refererence_guest_os = $reference_vmx_file_info->{guestos};
+	if ($refererence_guest_os) {
+		notify($ERRORS{'DEBUG'}, 0, "retrieved guestOS value from reference vmx file: $refererence_guest_os");
+		$default_guest_os = $refererence_guest_os;
+		$guest_os_determination = 'value from reference .vmx file';
+	}
+	else {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, guestOS
value could not be retrieved from reference .vmx file, returning $guest_os_determination:
$default_guest_os");
+		return $default_guest_os;
+	}
+	
+	
+	# Get the supported guest OS names from the API object
+	my @supported_guest_os_ids;
+	if ($self->api->can('get_supported_guest_os_ids')) {
+		@supported_guest_os_ids = $self->api->get_supported_guest_os_ids();
+		if (!@supported_guest_os_ids) {
+			notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, failed
to retrieve list of supported guest OS names from the API object, returning $guest_os_determination:
$default_guest_os");
+			return $default_guest_os;
+		}
+	}
+	else {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, API object
does not implement a 'get_supported_guest_os_names' subroutine, returning $guest_os_determination:
$default_guest_os");
+		return $default_guest_os;
+	}
+	
+	# Get the 'os_product_name' value from the reference .vmx file if it exists
+	# This gets added when a VM is loaded if it can be determined from the running OS
+	my $captured_os_product_name = $reference_vmx_file_info->{'os_product_name'};
+	if (!$captured_os_product_name) {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, reference
.vmx file does not contain an 'os_product_name' key, returning $guest_os_determination: $default_guest_os");
+		return $default_guest_os;
+	}
+	
+	my $captured_os_64_bit = $reference_vmx_file_info->{'os_64_bit'} || 1;
+	my $guest_os_64_bit_section = ($captured_os_64_bit ? '-64' : '');
+	
+	# $captured_os_product_name should like like:
+	# CentOS release 6.5 (Final)									: centos-64
+	# Red Hat Enterprise Linux Server release 7.2 (Maipo)	: rhel7-64
+	# Ubuntu 16.04.1 LTS												: ubuntu-64
+	# Windows 7 Enterprise											: windows7-64
+	# Windows 8 Enterprise											: windows8-64
+	# Windows 10 Enterprise											: windows9-64
+	# Windows Server 2008 R2 Datacenter							: windows7srv-64
+	# Windows Server 2012 R2 Datacenter							: windows8srv-64
+	my $image_os_product_patterns = {
+		'^centos[^\d]*[4567]'			=> '"centos'		. $guest_os_64_bit_section . '"',
+		'^(?:red hat|rh)[^\d]*(\d+)'	=> '"rhel$1'		. $guest_os_64_bit_section . '"',
+		'^ubuntu'							=> '"ubuntu' 		. $guest_os_64_bit_section . '"',
+		'^windows[^\d]*(7|8)'			=> '"windows$1'	. $guest_os_64_bit_section . '"',
+		'^windows[^\d]*10'				=> '"windows9'		. $guest_os_64_bit_section . '"',
+		'^windows[^\d]*2008'				=> '"windows7srv'	. $guest_os_64_bit_section . '"',
+		'^windows[^\d]*2012'				=> '"windows8srv'	. $guest_os_64_bit_section . '"',
+		'^windows[^\d]*2016'				=> '"windows9srv'	. $guest_os_64_bit_section . '"',
+	};
+	
+	my $guest_os;
+	for my $image_os_product_pattern (keys %$image_os_product_patterns) {
+		my $guest_os_value = $image_os_product_patterns->{$image_os_product_pattern};
+		if ($captured_os_product_name =~ /$image_os_product_pattern/i) {
+			$guest_os = eval $guest_os_value;
+			
+			notify($ERRORS{'DEBUG'}, 0, "match:\n" .
+				"image OS product : $captured_os_product_name\n" .
+				"pattern          : $image_os_product_pattern\n" .
+				"guest OS value   : $guest_os_value\n" .
+				"guest OS         : $guest_os"
+			);
+			
+			last;
+		}
+		else {
+			notify($ERRORS{'DEBUG'}, 0, "no match:\n" .
+				"image OS product : $captured_os_product_name\n" .
+				"pattern          : $image_os_product_pattern\n" .
+				"guest OS value   : $guest_os_value"
+			);
+		}
+	}
+	
+	if (!defined($guest_os)) {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, did not
find a pattern matching OS product name: $captured_os_product_name, returning $guest_os_determination:
$default_guest_os");
+		return $default_guest_os;
+	}
+	elsif (!grep { $guest_os eq $_ } @supported_guest_os_ids) {
+		notify($ERRORS{'DEBUG'}, 0, "unable to dynamically determine VM guest OS value, '$guest_os'
does not match any supported guest OS names, returning $guest_os_determination: $default_guest_os");
+		return $default_guest_os;
+	}
+	else {
+		notify($ERRORS{'DEBUG'}, 0, "dynamically determined VM guest OS value: '$guest_os'");
+		return $guest_os;
+	}
 }
 
 #/////////////////////////////////////////////////////////////////////////////
@@ -5003,7 +5205,6 @@ sub get_vm_cpu_socket_limit {
 	return $vm_os_configuration->{"cpu_socket_limit"};
 }
 
-
 #/////////////////////////////////////////////////////////////////////////////
 
 =head2 get_vm_ethernet_adapter_type



Mime
View raw message