ubuntu_ami 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,22 +31,66 @@ module KnifePlugins
31
31
 
32
32
  banner "knife ec2 amis ubuntu DISTRO [TYPE] (options)"
33
33
 
34
+ # Substitutes dashes for underscores in region portion of type for
35
+ # nice display. Replaces "1" as implied for most regions.
36
+ #
37
+ # === Parameters
38
+ # region<String>:: comes from Ubuntu::Ami#region
39
+ #
40
+ # === Returns
41
+ # String:: e.g., us_east_small or us_east_small_ebs
34
42
  def region_fix(region)
35
43
  region.gsub(/-1/,'').gsub(/-/,'_')
36
44
  end
37
45
 
46
+ # Indicates whether a particular image has EBS root volume.
47
+ #
48
+ # === Parameters
49
+ # store<String>:: comes from Ubuntu::Ami#root_store
50
+ #
51
+ # === Returns
52
+ # String:: "_ebs" if the #root_store is EBS, otherwise empty.
38
53
  def disk_store(store)
39
54
  store =~ /ebs/ ? "_ebs" : ''
40
55
  end
41
56
 
57
+ # Indicates whether the architecture type is a large or small AMI.
58
+ #
59
+ # === Parameters
60
+ # arch<String>:: Values can be amd64, x86_64, large, or begin with
61
+ # "64". Intended to be from Ubuntu::Ami#arch, but this method
62
+ # move to Ubuntu directly.
63
+ #
64
+ # === Returns
65
+ # String:: For 64 bit architectures (Ubuntu::Ami#arch #=> amd64),
66
+ # this will return "large". Otherwise, it returns "small".
42
67
  def size_of(arch)
43
68
  String(arch) =~ /(amd64|x86_64|large|^64)/ ? "large" : "small"
44
69
  end
45
70
 
71
+ # Makes a nice string for the type of AMI to display, including
72
+ # the region, architecture size and whether the AMI has EBS root
73
+ # store.
74
+ #
75
+ # === Parameters
76
+ # region<String>:: from Ubuntu::Ami#region
77
+ # arch<String>:: from Ubuntu::Ami#arch
78
+ # root_store<String>:: from Ubuntu::Ami#root_store
79
+ #
80
+ # === Returns
81
+ # String:: The region, arch and root_store (if EBS) concatenated
82
+ # with underscore (_).
46
83
  def build_type(region, arch, root_store)
47
84
  "#{region_fix(region)}_#{size_of(arch)}#{disk_store(root_store)}"
48
85
  end
49
86
 
87
+ # Iterates over the AMIs available for the specified distro.
88
+ #
89
+ # === Parameters
90
+ # distro<String>:: Release name of the distro to display.
91
+ #
92
+ # === Returns
93
+ # Hash:: Keys are the AMI type, values are the AMI ID.
50
94
  def list_amis(distro)
51
95
  amis = Hash.new
52
96
  Ubuntu.release(distro).amis.each do |ami|
@@ -55,6 +99,8 @@ module KnifePlugins
55
99
  amis
56
100
  end
57
101
 
102
+ # Runs the plugin. If TYPE (name_args[1]) is passed, then select a
103
+ # specified type, based on #build_type, above.
58
104
  def run
59
105
  distro = name_args[0]
60
106
  type = name_args[1]
@@ -34,6 +34,10 @@ class Ubuntu
34
34
  @release_name = release_name
35
35
  end
36
36
 
37
+ # Map the output from Canonical's image list.
38
+ #
39
+ # === Returns
40
+ # Array:: An array of Ubuntu::Ami objects.
37
41
  def amis
38
42
  content.map do |line|
39
43
  Ami.new(
@@ -45,10 +49,22 @@ class Ubuntu
45
49
  end
46
50
  end
47
51
 
52
+ # The URL of Canonical's current released AMIs for the given
53
+ # release.
54
+ #
55
+ # Visit "http://uec-images.ubuntu.com/query" to get a list of
56
+ # available releases.
57
+ #
58
+ # === Returns
59
+ # String:: The full URL to the released AMIs.
48
60
  def url
49
61
  "http://uec-images.ubuntu.com/query/#{release_name}/server/released.current.txt"
50
62
  end
51
63
 
64
+ # Reads the URL for processing.
65
+ # === Exception
66
+ # Raises an exception if the release name was not specified or was
67
+ # not found.
52
68
  def content
53
69
  begin
54
70
  @content ||= open(url).read.split("\n")
@@ -57,6 +73,7 @@ class Ubuntu
57
73
  end
58
74
  end
59
75
 
76
+ # Provides accessors for the properties of the AMI list.
60
77
  class Ami
61
78
  attr_reader :name, :root_store, :arch, :region, :virtualization_type
62
79
 
@@ -17,6 +17,6 @@
17
17
 
18
18
  class Ubuntu
19
19
  class Ami
20
- VERSION = '0.4.0'
20
+ VERSION = '0.4.1'
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubuntu_ami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,13 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-11 00:00:00.000000000Z
12
+ date: 2013-02-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Retrieves AMI information from Canonical's Ubuntu release list.
14
+ description: Retrieves AMI information from Canonical's Ubuntu release list.Also provides
15
+ a knife plugin to retrieve the list.
15
16
  email: joshua@opscode.com
16
17
  executables: []
17
18
  extensions: []
18
- extra_rdoc_files: []
19
+ extra_rdoc_files:
20
+ - README.md
21
+ - LICENSE
19
22
  files:
20
23
  - LICENSE
21
24
  - README.md
@@ -42,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
45
  version: '0'
43
46
  requirements: []
44
47
  rubyforge_project:
45
- rubygems_version: 1.8.10
48
+ rubygems_version: 1.8.23
46
49
  signing_key:
47
50
  specification_version: 3
48
51
  summary: Retrieves AMI information from Canonical's Ubuntu release list.