Class: Kitchen::Driver::Aws::StandardPlatform::Windows

Inherits:
Kitchen::Driver::Aws::StandardPlatform show all
Defined in:
lib/kitchen/driver/aws/standard_platform/windows.rb

Overview

Constant Summary

Constants inherited from Kitchen::Driver::Aws::StandardPlatform

SUPPORTED_ARCHITECTURES

Instance Attribute Summary

Attributes inherited from Kitchen::Driver::Aws::StandardPlatform

#architecture, #driver, #name, #version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Kitchen::Driver::Aws::StandardPlatform

#find_image, from_platform_string, #initialize, platforms, #to_s

Constructor Details

This class inherits a constructor from Kitchen::Driver::Aws::StandardPlatform

Class Method Details

.from_image(driver, image) ⇒ Object


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/kitchen/driver/aws/standard_platform/windows.rb', line 72

def self.from_image(driver, image)
  if image.name =~ /Windows/i
    # 2008 R2 SP2
    if image.name =~ /(\b\d+)\W*(r\d+)?/i
      major, revision = (Regexp.last_match || [])[1], (Regexp.last_match || [])[2]
      if image.name =~ /(sp\d+|rtm)/i
        service_pack = (Regexp.last_match || [])[1]
      end
      revision = revision.downcase if revision
      service_pack ||= "rtm"
      service_pack = service_pack.downcase
      version = "#{major}#{revision}#{service_pack}"
    end

    new(driver, "windows", version, image.architecture)
  end
end

Instance Method Details

#image_searchObject

Figure out the right set of names to search for:

“windows” -> [nil, nil, nil]

Windows_Server-*-R*_RTM-, Windows_Server-*-R*_SP*-,
Windows_Server-*-RTM-, Windows_Server-*-SP*-,
Windows_Server-*-

“windows-2012” -> [2012, 0, nil]

Windows_Server-2012-RTM-, Windows_Server-2012-SP*-

“windows-2012r2” -> [2012, 2, nil]

Windows_Server-2012-R2_RTM-, Windows_Server-2012-R2_SP*-

“windows-2012sp1” -> [2012, 0, 1]

Windows_Server-2012-SP1-

“windows-2012rtm” -> [2012, 0, 0]

Windows_Server-2012-RTM-

“windows-2012r2sp1” -> [2012, 2, 1]

Windows_Server-2012-R2_SP1-

“windows-2012r2rtm” -> [2012, 2, 0]

Windows_Server-2012-R2_RTM-

“windows-2016” -> [2016, 0, nil]

Windows_Server-2016-

“windows-2019” -> [2019, 0, nil]

Windows_Server-2019-

54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/aws/standard_platform/windows.rb', line 54

def image_search
  search = {
    "owner-alias" => "amazon",
    "name" => windows_name_filter,
  }
  search["architecture"] = architecture if architecture
  search
end

#sort_by_version(images) ⇒ Object


63
64
65
66
67
68
69
70
# File 'lib/kitchen/driver/aws/standard_platform/windows.rb', line 63

def sort_by_version(images)
  # 2008r2rtm -> [ img1, img2, img3 ]
  # 2012r2sp1 -> [ img4, img5 ]
  # ...
  images.group_by { |image| self.class.from_image(driver, image).windows_version_parts }
    .sort_by { |version, _platform_images| version }
    .reverse.flat_map { |_version, platform_images| platform_images }
end

#usernameString

default username for this platform's ami

Returns:

  • (String)

28
29
30
# File 'lib/kitchen/driver/aws/standard_platform/windows.rb', line 28

def username
  "administrator"
end