Class: Kitchen::Driver::Aws::StandardPlatform::Centos

Inherits:
Kitchen::Driver::Aws::StandardPlatform show all
Defined in:
lib/kitchen/driver/aws/standard_platform/centos.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



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

def self.from_image(driver, image)
  if image.name =~ /centos/i
    image.name =~ /\b(\d+(\.\d+)?)\b/i
    new(driver, "centos", (Regexp.last_match || [])[1], image.architecture)
  end
end

Instance Method Details

#image_searchObject



36
37
38
39
40
41
42
43
# File 'lib/kitchen/driver/aws/standard_platform/centos.rb', line 36

def image_search
  search = {
    "owner-alias" => "aws-marketplace",
    "name" => ["CentOS Linux #{version}*", "CentOS-#{version}*-GA-*"],
  }
  search["architecture"] = architecture if architecture
  search
end

#sort_by_version(images) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/kitchen/driver/aws/standard_platform/centos.rb', line 45

def sort_by_version(images)
  # 7.1 -> [ img1, img2, img3 ]
  # 6 -> [ img4, img5 ]
  # ...
  images.group_by { |image| self.class.from_image(driver, image).version }
    .sort_by { |k, _v| (k && k.include?(".") ? k.to_f : "#{k}.999".to_f) }
    .reverse.flat_map { |_k, v| v }
end

#usernameString

default username for this platform’s ami

Returns:

  • (String)


28
29
30
31
32
33
34
# File 'lib/kitchen/driver/aws/standard_platform/centos.rb', line 28

def username
  # Centos 6.x images use root as the username (but the "centos 6"
  # updateable image uses "centos")
  return "root" if version && version.start_with?("6.")

  "centos"
end