Class: Chef::ReservedNames::Win32::Version

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

Constant Summary collapse

WIN_VERSIONS =
{
  "Windows Server 2025" => { major: 10, minor: 0, callable: lambda { |product_type, _suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 26100 } },
  "Windows Server 2022" => { major: 10, minor: 0, callable: lambda { |product_type, _suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 20348 && build_number < 26100 } },
  "Windows Server 2019" => { major: 10, minor: 0, callable: lambda { |product_type, _suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 17763 && build_number < 20348 } },
  "Windows 11" => { major: 10, minor: 0, callable: lambda { |product_type, _suite_mask, build_number| product_type == VER_NT_WORKSTATION && build_number >= 22000 } },
  "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, _suite_mask, build_number| product_type == VER_NT_WORKSTATION && build_number >= 19044 && build_number < 22000 } },
  "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 API::System

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

Constants included from API

API::WIN32_EPOC_MINUS_POSIX_EPOC

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API

extended, #make_uint64, #safe_attach_function, #wtime_to_time

Methods included from API::Macros

#FAILED, #HIBYTE, #HIWORD, #HRESULT_CODE, #HRESULT_FACILITY, #HRESULT_FROM_NT, #HRESULT_FROM_WIN32, #HRESULT_SEVERITY, #IS_ERROR, #LOBYTE, #LOWORD, #LocalDiscard, #MAKELONG, #MAKEWORD, #MAKE_HRESULT, #MAKE_SCODE, #SUCCEEDED

Constructor Details

#initialize ⇒ Version

Returns a new instance of Version.



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/chef/win32/version.rb', line 73

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_number ⇒ Object (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_version ⇒ Object (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_version ⇒ Object (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)


115
116
117
# File 'lib/chef/win32/version.rb', line 115

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