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 server APIs

This commit is contained in:
Eric Wong 2013-05-21 21:01:23 +08:00
parent a9a9ad49cd
commit 4e2a7aa453
15 changed files with 133 additions and 19 deletions

View file

@ -35,6 +35,11 @@ module Fog
request :get_server
request :create_server
request :resize_server
request :server_history
request :shutdown_server
request :start_server
request :server_status
request :update_server
request :remove_balancer_node
request :add_balancer_node

View file

@ -8,6 +8,7 @@ module Fog
identity :uniq_id
attribute :accnt
attribute :active
attribute :backup_enabled
attribute :backup_plan
attribute :backup_quota
@ -20,11 +21,10 @@ module Fog
attribute :ip
attribute :ip_count
attribute :manage_level
attribute :subaccnt
attribute :template
attribute :template_description
attribute :type
attribute :zone
attribute :active
attr_writer :password
@ -32,11 +32,6 @@ module Fog
super
end
def create(options)
data = service.create_server(options).body['servers']
load(data)
end
def destroy
requires :identity
service.delete_server(:uniq_id => identity)
@ -47,9 +42,9 @@ module Fog
active == 1
end
def reboot
def reboot(options={})
requires :identity
service.reboot_server(:uniq_id => identity)
service.reboot_server({:uniq_id => identity}.merge!(options))
true
end
@ -58,11 +53,40 @@ module Fog
service.clone_server({:uniq_id => identity}.merge!(options))
true
end
def resize(options)
requires :identity
service.resize_server({:uniq_id => identity}.merge!(options))
true
end
def history(options={})
requires :identity
res = service.server_history({:uniq_id => identity}.merge!(options))
res[:items]
end
def shutdown(options={})
requires :identity
service.shutdown_server({:uniq_id => identity}.merge!(options))
end
def start
reqwuires :identity
service.start_server({:uniq_id => identity})
end
def status
requires :identity
service.server_status({:uniq_id => identity}).body
end
def update(options)
requires :identity
s = service.update_server({:uniq_id => identity}.merge!(options))
load(s)
end
end
end

View file

@ -9,8 +9,8 @@ module Fog
model Fog::Compute::StormOnDemand::Server
def all
data = service.list_servers.body['items']
def all(options={})
data = service.list_servers(options).body['items']
load(data)
end
@ -19,6 +19,11 @@ module Fog
new(server)
end
def create(options)
server = service.create_server(options).body
new(server)
end
end
end

View file

@ -5,7 +5,7 @@ module Fog
def clone_server(options = {})
request(
:path => "/storm/server/clone",
:path => "/Storm/Server/clone",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -5,7 +5,7 @@ module Fog
def create_server(options = {})
request(
:path => "/storm/server/create",
:path => "/Storm/Server/create",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -5,7 +5,7 @@ module Fog
def delete_server(options = {})
request(
:path => "/storm/server/destroy",
:path => "/Storm/Server/destroy",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -5,7 +5,7 @@ module Fog
def get_server(options = {})
request(
:path => "/storm/server/details",
:path => "/Storm/Server/details",
:body => Fog::JSON.encode({:params => options})
)
end

View file

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

View file

@ -5,7 +5,7 @@ module Fog
def reboot_server(options = {})
request(
:path => "/storm/server/reboot",
:path => "/Storm/Server/reboot",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -5,7 +5,7 @@ module Fog
def resize_server(options = {})
request(
:path => "/storm/server/resize",
:path => "/Storm/Server/resize",
:body => Fog::JSON.encode({:params => options})
)
end

View file

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

View file

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

View file

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

View file

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

View file

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