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:
commit
729a62fb1e
4 changed files with 72 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
27
lib/fog/bluebox/requests/compute/create_template.rb
Normal file
27
lib/fog/bluebox/requests/compute/create_template.rb
Normal 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
|
26
lib/fog/bluebox/requests/compute/destroy_template.rb
Normal file
26
lib/fog/bluebox/requests/compute/destroy_template.rb
Normal 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
|
Loading…
Reference in a new issue