Class: Ubuntu
- Inherits:
-
Object
- Object
- Ubuntu
- Defined in:
- lib/ubuntu_ami/version.rb,
lib/ubuntu_ami.rb
Overview
- Author
-
Joshua Timberman (<[email protected]>)
- Description
-
Retrieves AMI information from Canonical’s AMI release list.
- Copyright
-
2011, Joshua Timberman
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Classes: Ami
Instance Attribute Summary collapse
-
#release_name ⇒ Object
readonly
Returns the value of attribute release_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#amis ⇒ Object
Map the output from Canonical’s image list.
-
#content ⇒ Object
Reads the URL for processing.
-
#initialize(release_name) ⇒ Ubuntu
constructor
A new instance of Ubuntu.
-
#url ⇒ Object
The URL of Canonical’s current released AMIs for the given release.
Constructor Details
#initialize(release_name) ⇒ Ubuntu
Returns a new instance of Ubuntu.
33 34 35 |
# File 'lib/ubuntu_ami.rb', line 33 def initialize(release_name) @release_name = release_name end |
Instance Attribute Details
#release_name ⇒ Object (readonly)
Returns the value of attribute release_name.
22 23 24 |
# File 'lib/ubuntu_ami.rb', line 22 def release_name @release_name end |
Class Method Details
.instance_for_release(release_name) ⇒ Object
28 29 30 31 |
# File 'lib/ubuntu_ami.rb', line 28 def self.instance_for_release(release_name) @releases ||= {} @releases[release_name] ||= new(release_name) end |
.release(release_name) ⇒ Object
24 25 26 |
# File 'lib/ubuntu_ami.rb', line 24 def self.release(release_name) instance_for_release(release_name) end |
Instance Method Details
#amis ⇒ Object
Map the output from Canonical’s image list.
Returns
- Array
-
An array of Ubuntu::Ami objects.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ubuntu_ami.rb', line 41 def amis content.map do |line| Ami.new( line.split[7], line.split[4], line.split[5], line.split[6], line.split[8..9].last) end end |
#content ⇒ Object
Reads the URL for processing.
Exception
Raises an exception if the release name was not specified or was not found.
68 69 70 71 72 73 74 |
# File 'lib/ubuntu_ami.rb', line 68 def content begin @content ||= open(url).read.split("\n") rescue raise "Could not find AMI list for distro release '#{release_name}', did you specify it correctly? (e.g., 'lucid')" end end |
#url ⇒ Object
The URL of Canonical’s current released AMIs for the given release.
Visit “uec-images.ubuntu.com/query” to get a list of available releases.
Returns
- String
-
The full URL to the released AMIs.
60 61 62 |
# File 'lib/ubuntu_ami.rb', line 60 def url "http://uec-images.ubuntu.com/query/#{release_name}/server/released.current.txt" end |