commit ce08951fd8b0562ac47f51c826048dd1b6e0d790
Author: Martin Matuska <martin@matuska.org>
Date:   Tue Apr 22 14:08:57 2014 +0200

    fixes #4380 [vSphere] allow selection of guest OS
    
    (cherry picked from commit 507ebfd570c63d39a0a3876b762abd7e5ea038e4)

diff --git a/app/models/compute_resources/foreman/model/vmware.rb b/app/models/compute_resources/foreman/model/vmware.rb
index b509f4115..ce41c9b1b 100644
--- a/app/models/compute_resources/foreman/model/vmware.rb
+++ b/app/models/compute_resources/foreman/model/vmware.rb
@@ -83,6 +83,128 @@ module Foreman::Model
       }
     end
 
+   # vSphere guest OS type descriptions
+   # list fetched from RbVmomi::VIM::VirtualMachineGuestOsIdentifier.values
+   def guest_types_descriptions
+      {
+        "dosGuest" => "Microsoft MS-DOS",
+        "win31Guest" => "Microsoft Windows 3.1",
+        "win95Guest" => "Microsoft Windows 95",
+        "win98Guest" => "Microsoft Windows 98",
+        "winMeGuest" => "Microsoft Windows Millenium Edition",
+        "winNTGuest" => "Microsoft Windows NT",
+        "win2000ProGuest" => "Microsoft Windows 2000 Professional",
+        "win2000ServGuest" => "Microsoft Windows 2000 Server",
+        "win2000AdvServGuest" => "Microsoft Windows 2000 Advanced Server",
+        "winXPHomeGuest" => "Microsoft Windows XP Home Edition",
+        "winXPProGuest" => "Microsoft Windows XP Professional (32-bit)",
+        "winXPPro64Guest" => "Microsoft Windows XP Professional (64-bit)",
+        "winNetWebGuest" => "Microsoft Windows Server 2003 Web Edition (32-bit)",
+        "winNetStandardGuest" => "Microsoft Windows Server 2003 Standard Edition (32-bit)",
+        "winNetEnterpriseGuest" => "Microsoft Windows Server 2003 Enterprise Edition (32-bit)",
+        "winNetDatacenterGuest" => "Microsoft Windows Server 2003 Datacenter Edition (32-bit)",
+        "winNetBusinessGuest" => "Microsoft Windows Small Business Server 2003",
+        "winNetStandard64Guest" => "Microsoft Windows Server 2003 Standard Edition (64-bit)",
+        "winNetEnterprise64Guest" => "Microsoft Windows Server 2003 Enterprise Edition (64-bit)",
+        "winLonghornGuest" => "Microsoft Windows Longhorn (32-bit)",
+        "winLonghorn64Guest" => "Microsoft Windows Longhorn (64-bit)",
+        "winNetDatacenter64Guest" => "Microsoft Windows Server 2003 Datacenter Edition (64-bit)",
+        "winVistaGuest" => "Microsoft Windows Vista (32-bit)",
+        "winVista64Guest" => "Microsoft Windows Vista (64-bit)",
+        "windows7Guest" => "Microsoft Windows 7 (32-bit)",
+        "windows7_64Guest" => "Microsoft Windows 7 (64-bit)",
+        "windows7Server64Guest" => "Microsoft Windows Server 2008 R2 (64-bit)",
+        "windows8Guest" => "Microsoft Windows 8 (32-bit)",
+        "windows8_64Guest" => "Microsoft Windows 8 (64-bit)",
+        "windows8Server64Guest" => "Microsoft Windows Server 2012 (64-bit)",
+        "freebsd64Guest" => "FreeBSD (64-bit)",
+        "freebsdGuest" => "FreeBSD (32-bit)",
+        "redhatGuest" => "Red Hat Linux 2.1",
+        "rhel2Guest" => "Red Hat Enterprise Linux 2.1",
+        "rhel3Guest" => "Red Hat Enterprise Linux 3 (32-bit)",
+        "rhel3_64Guest" => "Red Hat Enterprise Linux 3 (64-bit)",
+        "rhel4Guest" => "Red Hat Enterprise Linux 4 (32-bit)",
+        "rhel4_64Guest" => "Red Hat Enterprise Linux 4 (64-bit)",
+        "rhel5Guest" => "Red Hat Enterprise Linux 5 (32-bit)",
+        "rhel5_64Guest" => "Red Hat Enterprise Linux 5 (64-bit)",
+        "rhel6Guest" => "Red Hat Enterprise Linux 6 (32-bit)",
+        "rhel6_64Guest" => "Red Hat Enterprise Linux 6 (64-bit)",
+        "centosGuest" => "CentOS 4/5/6 (32-bit)",
+        "centos64Guest" => "CentOS 4/5/6 (64-bit)",
+        "oracleLinux64Guest" => "Oracle Linux 4/5/6 (64-bit)",
+        "oracleLinuxGuest" => "Oracle Linux 4/5/6 (32-bit)",
+        "suseGuest" => "Suse Linux (32-bit)",
+        "suse64Guest" => "Suse Linux (64-bit)",
+        "slesGuest" => "Novell SUSE Linux Enterprise 8/9 (32-bit)",
+        "sles64Guest" => "Novell SUSE Linux Enterprise 8/9 (64-bit)",
+        "sles10Guest" => "Novell SUSE Linux Enterprise 10 (32-bit)",
+        "sles10_64Guest" => "Novell SUSE Linux Enterprise 10 (64-bit)",
+        "sles11Guest" => "Novell SUSE Linux Enterprise 11 (32-bit)",
+        "sles11_64Guest" => "Novell SUSE Linux Enterprise 11 (64-bit)",
+        "nld9Guest" => "Novell Linux Desktop 9",
+        "oesGuest" => "Novell Open Enterprise Server",
+        "sjdsGuest" => "Sun Java Desktop System",
+        "mandrivaGuest" => "Mandriva Linux (32-bit)",
+        "mandriva64Guest" => "Mandriva Linux (64-bit)",
+        "turboLinuxGuest" => "Turbolinux (32-bit)",
+        "turboLinux64Guest" => "Turbolinux (64-bit)",
+        "ubuntu64Guest" => "Ubuntu Linux (64-bit)",
+        "ubuntuGuest" => "Ubuntu Linux (32-bit)",
+        "debian4Guest" => "Debian GNU/Linux 4 (32-bit)",
+        "debian4_64Guest" => "Debian GNU/Linux 5 (64-bit)",
+        "debian5Guest" => "Debian GNU/Linux 5 (32-bit)",
+        "debian5_64Guest" => "Debian GNU/Linux 5 (64-bit)",
+        "debian6Guest" => "Debian GNU/Linux 6 (32-bit)",
+        "debian6_64Guest" => "Debian GNU/Linux 6 (64-bit)",
+        "asianux3Guest" => "Asianux Server 3 (32-bit)",
+        "asianux3_64Guest" => "Asianux Server 3 (64-bit)",
+        "asianux4Guest" => "Asianux Server 4 (32-bit)",
+        "asianux4_64Guest" => "Asianux Server 4 (64-bit)",
+        "opensuseGuest" => "OpenSUSE Linux (32-bit)",
+        "opensuse64Guest" => "OpenSUSE Linux (64-bit)",
+        "other24xLinuxGuest" => "Other 2.4.x Linux (32-bit)",
+        "other26xLinuxGuest" => "Other 2.6.x Linux (32-bit)",
+        "otherLinuxGuest" => "Other Linux (32-bit)",
+        "other24xLinux64Guest" => "Other 2.4.x Linux (64-bit)",
+        "other26xLinux64Guest" => "Other 2.6.x Linux (64-bit)",
+        "otherLinux64Guest" => "Other Linux (64-bit)",
+        "solaris6Guest" => "Sun Microsystems Solaris 6",
+        "solaris7Guest" => "Sun Microsystems Solaris 7",
+        "solaris8Guest" => "Sun Microsystems Solaris 8",
+        "solaris9Guest" => "Sun Microsystems Solaris 9",
+        "solaris10Guest" => "Oracle Solaris 10 (32-bit)",
+        "solaris10_64Guest" => "Oracle Solaris 10 (64-bit)",
+        "solaris11_64Guest" => "Oracle Solaris 11 (64-bit)",
+        "os2Guest" => "IBM OS/2",
+        "eComStationGuest" => "Serenity Systems eComStation 1.x",
+        "eComStation2Guest" => "Serenity Systems eComStation 2.0",
+        "netware4Guest" => "Novell NetWare 4",
+        "netware5Guest" => "Novell NetWare 5.1",
+        "netware6Guest" => "Novell NetWare 6.x",
+        "openServer5Guest" => "SCO OpenServer 5",
+        "openServer6Guest" => "SCO OpenServer 6",
+        "unixWare7Guest" => "SCO UnixWare 7",
+        "darwinGuest" => "Apple Mac OS X 10.5 (32-bit)",
+        "darwin64Guest" => "Apple Mac OS X 10.5 (64-bit)",
+        "darwin10Guest" => "Apple Mac OS X 10.6 (32-bit)",
+        "darwin10_64Guest" => "Apple Mac OS X 10.6 (64-bit)",
+        "darwin11Guest" => "Apple Mac OS X 10.7 (32-bit)",
+        "darwin11_64Guest" => "Apple Mac OS X 10.7 (64-bit)",
+        "vmkernelGuest" => "VMWare ESX 4.x",
+        "vmkernel5Guest" => "VMWare ESXi 5.x",
+        "otherGuest" => "Other (32-bit)",
+        "otherGuest64" => "Other (64-bit)"
+      }
+    end
+
+    def guest_types
+      types = { }
+      RbVmomi::VIM::VirtualMachineGuestOsIdentifier.values.compact.each do |v|
+        types[v] = guest_types_descriptions.has_key?(v) ? guest_types_descriptions[v] : v
+      end
+      types
+    end
+
     def scsi_controller_default_type
       "VirtualLsiLogicController"
     end
diff --git a/app/views/compute_resources_vms/form/_vmware.html.erb b/app/views/compute_resources_vms/form/_vmware.html.erb
index 1de2ebf09..9a492e338 100644
--- a/app/views/compute_resources_vms/form/_vmware.html.erb
+++ b/app/views/compute_resources_vms/form/_vmware.html.erb
@@ -6,6 +6,7 @@
 <%= selectable_f f, :cluster, compute_resource.clusters, { }, :class => "col-md-2", :disabled => !new, :label => _('Cluster') %>
 <%# selectable_f f, :resource_pool, compute_resource.resource_pools, { }, :class => "col-md-2", :disabled => !new %>
 <%= select_f f, :path, compute_resource.folders, :path, :to_label , {}, { :label => _("Folder"), :class => "col-md-2", :disabled => !new } %>
+<%= select_f f, :guest_id, compute_resource.guest_types, :first, :last, {}, { :label => _("Guest OS"), :class => "col-md-2", :disabled => !new } %>
 
 <!--interfaces-->
 <div class="children_fields">
