Class: RackspaceCloud::Image
- Inherits:
-
Object
- Object
- RackspaceCloud::Image
- Defined in:
- lib/rackspace_cloud/image.rb
Constant Summary collapse
- MAX_RACKSPACE_IMAGE_ID =
the highest id in use by a standard rackspace image (vs. a user backup)
10
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#rackspace_id ⇒ Object
readonly
Returns the value of attribute rackspace_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(base, image_json) ⇒ Image
constructor
A new instance of Image.
- #refresh ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize(base, image_json) ⇒ Image
Returns a new instance of Image.
18 19 20 21 |
# File 'lib/rackspace_cloud/image.rb', line 18 def initialize(base, image_json) @base = base populate(image_json) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def base @base end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def created @created end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def name @name end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def progress @progress end |
#rackspace_id ⇒ Object (readonly)
Returns the value of attribute rackspace_id.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def rackspace_id @rackspace_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def status @status end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
6 7 8 |
# File 'lib/rackspace_cloud/image.rb', line 6 def updated @updated end |
Class Method Details
.create_from_server(server, name = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rackspace_cloud/image.rb', line 9 def create_from_server(server, name=nil) name ||= (server) image_json = server.base.request("/images", :method => :post, :data => {'image' => {'name' => name, 'serverId' => @rackspace_id}})['image'] new_image = RackspaceCloud::Image.new(image_json) @images[new_image.rackspace_id] = new_image new_image end |
Instance Method Details
#delete ⇒ Object
23 24 25 26 |
# File 'lib/rackspace_cloud/image.rb', line 23 def delete raise RuntimeError, "Can't delete Rackspace standard images" if @rackspace_id <= MAX_RACKSPACE_IMAGE_ID @base.request("/images/#{@rackspace_id}", :method => :delete) end |
#refresh ⇒ Object
32 33 34 35 |
# File 'lib/rackspace_cloud/image.rb', line 32 def refresh populate(@base.request("/images/#{@rackspace_id}")['image']) self end |
#to_i ⇒ Object
28 29 30 |
# File 'lib/rackspace_cloud/image.rb', line 28 def to_i @rackspace_id end |