1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #500 from leehuffman/bluebox-archive

[bluebox|compute] Create and destroy images
This commit is contained in:
Wesley Beary 2011-09-07 13:52:00 -07:00
commit 729a62fb1e
4 changed files with 72 additions and 2 deletions

View file

@ -25,6 +25,8 @@ module Fog
request :get_products
request :get_template
request :get_templates
request :create_template
request :destroy_template
request :reboot_block
class Mock

View file

@ -7,11 +7,26 @@ module Fog
class Image < Fog::Model
identity :id
attribute :block_id
attribute :description
attribute :public
attribute :created_at, :aliases => 'created'
def save
requires :block_id
data = connection.create_template(block_id, attributes)
true
end
def destroy
requires :id
data = connection.destroy_template(id)
true
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Compute
class Bluebox
class Real
# Create a template from block
#
# ==== Parameters
# * block_id<~Integer> - Id of block to create template from
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO
def create_template(block_id, options={})
request(
:expects => 200,
:method => 'POST',
:path => "api/block_templates.json",
:query => {'id' => block_id}.merge!(options)
)
end
end
end
end
end

View file

@ -0,0 +1,26 @@
module Fog
module Compute
class Bluebox
class Real
# Create a template from block
#
# ==== Parameters
# * id<~Integer> - Id of image to destroy
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO
def destroy_template(id)
request(
:expects => 200,
:method => 'DELETE',
:path => "api/block_templates/#{id}.json"
)
end
end
end
end
end