class Chef::ReservedNames::Win32::Version
Constants
- WIN_VERSIONS
Public Class Methods
new()
click to toggle source
# File lib/chef/win32/version.rb, line 66 def initialize @major_version, @minor_version, @build_number = get_version ver_info = get_version_ex @product_type = ver_info[:w_product_type] @suite_mask = ver_info[:w_suite_mask] @sp_major_version = ver_info[:w_service_pack_major] @sp_minor_version = ver_info[:w_service_pack_minor] # Obtain sku information for the purpose of identifying # datacenter, cluster, and core skus, the latter 2 only # exist in releases after Windows Server 2003 if ! Chef::Platform::windows_server_2003? @sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version) else # The get_product_info API is not supported on Win2k3, # use an alternative to identify datacenter skus @sku = get_datacenter_product_info_windows_server_2003(ver_info) end end
Private Class Methods
get_system_metrics(n_index)
click to toggle source
Ruby implementation of msdn.microsoft.com/en-us/library/ms724833(v=vs.85).aspx msdn.microsoft.com/en-us/library/ms724358(v=vs.85).aspx
# File lib/chef/win32/version.rb, line 39 def self.get_system_metrics(n_index) GetSystemMetrics(n_index) end
method_name_from_marketing_name(marketing_name)
click to toggle source
# File lib/chef/win32/version.rb, line 43 def self.method_name_from_marketing_name(marketing_name) "#{marketing_name.gsub(/\s/, '_').gsub(/\./, '_').downcase}?" # "#{marketing_name.gsub(/\s/, '_').gsub(//, '_').downcase}?" end
Private Instance Methods
get_datacenter_product_info_windows_server_2003(ver_info)
click to toggle source
# File lib/chef/win32/version.rb, line 156 def get_datacenter_product_info_windows_server_2003(ver_info) # The intent is not to get the actual sku, just identify # Windows Server 2003 datacenter sku = (ver_info[:w_suite_mask] & VER_SUITE_DATACENTER) ? PRODUCT_DATACENTER_SERVER : 0 end
get_product_info(major, minor, sp_major, sp_minor)
click to toggle source
# File lib/chef/win32/version.rb, line 150 def get_product_info(major, minor, sp_major, sp_minor) out = FFI::MemoryPointer.new(:uint32) GetProductInfo(major, minor, sp_major, sp_minor, out) out.get_uint(0) end
get_version()
click to toggle source
# File lib/chef/win32/version.rb, line 117 def get_version # Use WMI here because API's like GetVersion return faked # version numbers on Windows Server 2012 R2 and Windows 8.1 -- # WMI always returns the truth. See article at # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx # CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0 # https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db # https://github.com/ruby/ruby/commit/27ed294c7134c0de582007af3c915a635a6506cd WIN32OLE.ole_initialize wmi = WmiLite::Wmi.new os_info = wmi.first_of('Win32_OperatingSystem') os_version = os_info['version'] WIN32OLE.ole_uninitialize # The operating system version is a string in the following form # that can be split into components based on the '.' delimiter: # MajorVersionNumber.MinorVersionNumber.BuildNumber os_version.split('.').collect { | version_string | version_string.to_i } end
get_version_ex()
click to toggle source
# File lib/chef/win32/version.rb, line 141 def get_version_ex lp_version_info = OSVERSIONINFOEX.new lp_version_info[:dw_os_version_info_size] = OSVERSIONINFOEX.size unless GetVersionExW(lp_version_info) Chef::ReservedNames::Win32::Error.raise! end lp_version_info end