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

[stormondemand|compute] Add all template APIs

This commit is contained in:
Eric Wong 2013-05-21 21:11:06 +08:00
parent 4e2a7aa453
commit 297d2be06c
6 changed files with 50 additions and 5 deletions

View file

@ -58,6 +58,8 @@ module Fog
request :get_config_details request :get_config_details
request :list_templates request :list_templates
request :get_template_details
request :restore_template
request :list_images request :list_images
request :create_image request :create_image

View file

@ -7,16 +7,22 @@ module Fog
class Template < Fog::Model class Template < Fog::Model
identity :id identity :id
attribute :name attribute :name
attribute :deprecated
attribute :description attribute :description
attribute :manage_level attribute :manage_level
attribute :os attribute :os
attribute :price attribute :zone_availability
end end
def initialize(attributes={}) def initialize(attributes={})
super super
end end
def restore(options)
requires :identity
service.restore_template({:id => identity}.merge!(options))
end
end end
end end
end end

View file

@ -9,11 +9,16 @@ module Fog
model Fog::Compute::StormOnDemand::Template model Fog::Compute::StormOnDemand::Template
def all def all(options={})
data = service.list_templates.body['items'] data = service.list_templates(options).body['items']
load(data) load(data)
end end
def get(template_id)
tpl = service.get_template_details(:id => template_id).body
new(tpl)
end
end end
end end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_template_details(options={})
request(
:path => '/Storm/Template/details',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -5,8 +5,8 @@ module Fog
def list_templates(options = {}) def list_templates(options = {})
request( request(
:path => "/server/template/list", :path => "/Storm/Template/list",
:body => Fog::JSON.encode(options) :body => Fog::JSON.encode(:params => options)
) )
end end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def restore_template(options={})
request(
:path => '/Storm/Template/restore',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end