Class: PEBuild::Cap::Facts::Windows
- Defined in:
- lib/pe_build/cap/facts/windows.rb
Overview
Facts implementation for Windows guests
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#architecture ⇒ String
Returns the native architecture of the OS.
-
#os_info ⇒ Hash
Returns info about the OS type.
-
#release_info ⇒ Hash
Returns info about the OS version.
Methods inherited from Base
#basic_facts, #initialize, #load_facts, pebuild_facts, #puppet_path
Constructor Details
This class inherits a constructor from PEBuild::Cap::Facts::Base
Instance Method Details
#architecture ⇒ String
Returns the native architecture of the OS
Looks at the default pointer size for integers and returns x86
or x64
.
13 14 15 |
# File 'lib/pe_build/cap/facts/windows.rb', line 13 def architecture sudo('if ([System.IntPtr]::Size -eq 4) { "x86" } else { "x64" }')[:stdout] end |
#os_info ⇒ Hash
Returns info about the OS type
Currently returns family
as Windows
.
22 23 24 25 26 |
# File 'lib/pe_build/cap/facts/windows.rb', line 22 def os_info { 'family' => 'Windows', } end |
#release_info ⇒ Hash
Returns info about the OS version
Queries WMI and generates a full
version.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pe_build/cap/facts/windows.rb', line 33 def release_info version = sudo('(Get-WmiObject -Class Win32_OperatingSystem).Version')[:stdout] producttype = sudo('(Get-WmiObject -Class Win32_OperatingSystem).Producttype')[:stdout] # Cribbed from Facter 2.4. # # NOTE: Currently doesn't support XP/Server 2003 or Windows 10. name = case version when /^6\.3/ producttype == 1 ? "8.1" : "2012 R2" when /^6\.2/ producttype == 1 ? "8" : "2012" when /^6\.1/ producttype == 1 ? "7" : "2008 R2" when /^6\.0/ producttype == 1 ? "Vista" : "2008" else version # Default to the raw version number. end { 'full' => name } end |