Class: ReservedNames::Win32::Version

Inherits:
Object
  • Object
show all
Extended by:
Chef::ReservedNames::Win32::API::System
Includes:
Chef::ReservedNames::Win32::API::Macros, Chef::ReservedNames::Win32::API::System
Defined in:
lib/chef/win32/version.rb

Constant Summary collapse

WIN_VERSIONS =
{
  "Windows Server 2019" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 17763 } },
  "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
  "Windows Server 2016" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number <= 14393 } },
  "Windows 8.1" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
  "Windows Server 2012 R2" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION } },
  "Windows 8" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
  "Windows Server 2012" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION } },
  "Windows 7" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
  "Windows Server 2008 R2" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION } },
  "Windows Server 2008" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION } },
  "Windows Vista" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
  "Windows Server 2003 R2" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask, build_number| get_system_metrics(SM_SERVERR2) != 0 } },
  "Windows Home Server" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask, build_number| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
  "Windows Server 2003" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask, build_number| get_system_metrics(SM_SERVERR2) == 0 } },
  "Windows XP" => { major: 5, minor: 1 },
  "Windows 2000" => { major: 5, minor: 0 },
}.freeze

Constants included from Chef::ReservedNames::Win32::API::System

Chef::ReservedNames::Win32::API::System::PRODUCT_BUSINESS, Chef::ReservedNames::Win32::API::System::PRODUCT_BUSINESS_N, Chef::ReservedNames::Win32::API::System::PRODUCT_CLUSTER_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_CORE, Chef::ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_CORE_V, Chef::ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_V, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_E, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_N, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_CORE, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_CORE_V, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_IA64, Chef::ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_V, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC_E, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC_N, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_E, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_N, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_HOME_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_HYPERV, Chef::ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT, Chef::ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING, Chef::ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY, Chef::ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL, Chef::ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL_E, Chef::ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL_N, Chef::ReservedNames::Win32::API::System::PRODUCT_SB_SOLUTION_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_SERVER_FOR_SMALLBUSINESS, Chef::ReservedNames::Win32::API::System::PRODUCT_SERVER_FOR_SMALLBUSINESS_V, Chef::ReservedNames::Win32::API::System::PRODUCT_SERVER_FOUNDATION, Chef::ReservedNames::Win32::API::System::PRODUCT_SMALLBUSINESS_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_SOLUTION_EMBEDDEDSERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_CORE, Chef::ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_CORE_V, Chef::ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_V, Chef::ReservedNames::Win32::API::System::PRODUCT_STARTER, Chef::ReservedNames::Win32::API::System::PRODUCT_STARTER_E, Chef::ReservedNames::Win32::API::System::PRODUCT_STARTER_N, Chef::ReservedNames::Win32::API::System::PRODUCT_STORAGE_ENTERPRISE_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_STORAGE_EXPRESS_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_STORAGE_STANDARD_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_STORAGE_WORKGROUP_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_ULTIMATE, Chef::ReservedNames::Win32::API::System::PRODUCT_ULTIMATE_E, Chef::ReservedNames::Win32::API::System::PRODUCT_ULTIMATE_N, Chef::ReservedNames::Win32::API::System::PRODUCT_UNDEFINED, Chef::ReservedNames::Win32::API::System::PRODUCT_WEB_SERVER, Chef::ReservedNames::Win32::API::System::PRODUCT_WEB_SERVER_CORE, Chef::ReservedNames::Win32::API::System::SM_SERVERR2, Chef::ReservedNames::Win32::API::System::VER_NT_DOMAIN_CONTROLLER, Chef::ReservedNames::Win32::API::System::VER_NT_SERVER, Chef::ReservedNames::Win32::API::System::VER_NT_WORKSTATION, Chef::ReservedNames::Win32::API::System::VER_SUITE_BACKOFFICE, Chef::ReservedNames::Win32::API::System::VER_SUITE_BLADE, Chef::ReservedNames::Win32::API::System::VER_SUITE_COMPUTE_SERVER, Chef::ReservedNames::Win32::API::System::VER_SUITE_DATACENTER, Chef::ReservedNames::Win32::API::System::VER_SUITE_EMBEDDEDNT, Chef::ReservedNames::Win32::API::System::VER_SUITE_ENTERPRISE, Chef::ReservedNames::Win32::API::System::VER_SUITE_PERSONAL, Chef::ReservedNames::Win32::API::System::VER_SUITE_SINGLEUSERTS, Chef::ReservedNames::Win32::API::System::VER_SUITE_SMALLBUSINESS, Chef::ReservedNames::Win32::API::System::VER_SUITE_SMALLBUSINESS_RESTRICTED, Chef::ReservedNames::Win32::API::System::VER_SUITE_STORAGE_SERVER, Chef::ReservedNames::Win32::API::System::VER_SUITE_TERMINAL, Chef::ReservedNames::Win32::API::System::VER_SUITE_WH_SERVER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVersion

Returns a new instance of Version.



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chef/win32/version.rb', line 70

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
  @sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version)
end

Instance Attribute Details

#build_numberObject (readonly)

Returns the value of attribute build_number.



33
34
35
# File 'lib/chef/win32/version.rb', line 33

def build_number
  @build_number
end

#major_versionObject (readonly)

Returns the value of attribute major_version.



33
34
35
# File 'lib/chef/win32/version.rb', line 33

def major_version
  @major_version
end

#minor_versionObject (readonly)

Returns the value of attribute minor_version.



33
34
35
# File 'lib/chef/win32/version.rb', line 33

def minor_version
  @minor_version
end

Instance Method Details

#win_10_creators_or_higher?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/chef/win32/version.rb', line 112

def win_10_creators_or_higher?
  windows_10? && build_number >= 15063
end