Class: PEBuild::Cap::Facts::Windows

Inherits:
Base
  • Object
show all
Defined in:
lib/pe_build/cap/facts/windows.rb

Overview

Facts implementation for Windows guests

Since:

  • 0.13.0

Instance Attribute Summary

Attributes inherited from Base

#machine

Instance Method Summary collapse

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

#architectureString

Returns the native architecture of the OS

Looks at the default pointer size for integers and returns x86 or x64.

Returns:

  • (String)

    An architecture, such as i386 or x86_64.

See Also:

Since:

  • 0.13.0



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_infoHash

Returns info about the OS type

Currently returns family as Windows.

Returns:

  • (Hash)

    A hash containing the family of the operating system and, optionally, the name.

See Also:

Since:

  • 0.13.0



22
23
24
25
26
# File 'lib/pe_build/cap/facts/windows.rb', line 22

def os_info
  {
    'family'  => 'Windows',
  }
end

#release_infoHash

Returns info about the OS version

Queries WMI and generates a full version.

Returns:

  • (Hash)

    A hash containing the full version strying of the operating system and, optionally, the minor and major release versions.

See Also:

Since:

  • 0.13.0



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