mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[stormondemand] fix some minor problems. Add a README.md file to describe how to use the storm on demand APIs
This commit is contained in:
parent
de6e6c6c6d
commit
bba488a31b
7 changed files with 80 additions and 16 deletions
49
lib/fog/storm_on_demand/README.md
Normal file
49
lib/fog/storm_on_demand/README.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# StormOnDemand services examples
|
||||
|
||||
This storm_on_demand directory provides code for all storm on demand cloud APIs. All of the APIs are seperated into Compute, Network, Storage, DNS, Monitoring, Account, Billing, Support and Billing services.
|
||||
|
||||
|
||||
## Use a service
|
||||
Before using APIs of a service, you need to create a service object first. Take Compute for instance:
|
||||
|
||||
c = Fog::Compute.new :provider => :stormondemand,
|
||||
:storm_on_demand_username => 'username',
|
||||
:storm_on_demand_password => 'password'
|
||||
Now, you can call API methods for Compute service. For instance:
|
||||
|
||||
c.servers.all
|
||||
this will list all servers for the current account.
|
||||
|
||||
## Call an API method
|
||||
According to Fog, a high level interface is provided through collections, such as images and servers. Each collection has a corresponding model, such as image and server.
|
||||
|
||||
APIs like create, list or details reside in the collections. For instance:
|
||||
|
||||
server = c.servers.create :config_id => conf.id,
|
||||
:template => tpl.name,
|
||||
:domain => 'example.com',
|
||||
:password => 'rootpassword'
|
||||
Other APIs for specific cloud object will reside in a model. For instance:
|
||||
|
||||
server.reboot :force => 1
|
||||
|
||||
All APIs' parameters are the same with the [Storm On Demand API Doc](https://www.stormondemand.com/api/docs/v1/).
|
||||
|
||||
#### (p.s. In order to conform to Fog's CRUD operations, some API methods are changed. For instance, 'list' methods are now 'all', 'details' methods are now 'get')
|
||||
|
||||
|
||||
## Use a Token
|
||||
If you want to use a token instead of password for API calls, instead of creating a new service like Compute, you should create a new Account first and get the token. Then create a new Compute/Network/Storage with the token.
|
||||
|
||||
account = Fog::Account.new :provider => :stormondemand,
|
||||
:storm_on_demand_username => 'username',
|
||||
:storm_on_demand_password => 'password'
|
||||
# create a new token
|
||||
token = account.tokens.create
|
||||
# use the token instead of a password
|
||||
net = Fog::Network.new :provider => :stormondemand,
|
||||
:storm_on_demand_username = 'username',
|
||||
:storm_on_demand_password = token.token
|
||||
|
||||
# if you want to expire the token
|
||||
token.expire
|
|
@ -18,6 +18,7 @@ module Fog
|
|||
model :record
|
||||
collection :records
|
||||
model :reverse
|
||||
collection :reverses
|
||||
model :zone
|
||||
collection :zones
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ module Fog
|
|||
|
||||
def update(options={})
|
||||
requires :identity
|
||||
img = service.update_image({:id => identity}.merge!(options)).body
|
||||
new(img)
|
||||
service.update_image({:id => identity}.merge!(options)).body
|
||||
end
|
||||
|
||||
def restore(options={})
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
|
||||
def resolve
|
||||
requires :identity
|
||||
service.resolve_notification(:id => identity)
|
||||
service.resolve_notification(:id => identity).body
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -62,18 +62,19 @@ module Fog
|
|||
|
||||
def history(options={})
|
||||
requires :identity
|
||||
res = service.server_history({:uniq_id => identity}.merge!(options))
|
||||
params = {:uniq_id => identity}.merge!(options)
|
||||
res = service.server_history(params).body
|
||||
res['items']
|
||||
end
|
||||
|
||||
def shutdown(options={})
|
||||
requires :identity
|
||||
service.shutdown_server({:uniq_id => identity}.merge!(options))
|
||||
service.shutdown_server({:uniq_id => identity}.merge!(options)).body
|
||||
end
|
||||
|
||||
def start
|
||||
reqwuires :identity
|
||||
service.start_server({:uniq_id => identity})
|
||||
service.start_server({:uniq_id => identity}).body
|
||||
end
|
||||
|
||||
def status
|
||||
|
@ -83,8 +84,7 @@ module Fog
|
|||
|
||||
def update(options)
|
||||
requires :identity
|
||||
s = service.update_server({:uniq_id => identity}.merge!(options))
|
||||
load(s)
|
||||
service.update_server({:uniq_id => identity}.merge!(options)).body
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,14 +9,6 @@ module Fog
|
|||
super
|
||||
end
|
||||
|
||||
def destroy(options)
|
||||
service.delete_reverse(options).body
|
||||
end
|
||||
|
||||
def update(options)
|
||||
service.update_reverse(options).body
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
23
lib/fog/storm_on_demand/models/dns/reverses.rb
Normal file
23
lib/fog/storm_on_demand/models/dns/reverses.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'fog/core/colletion'
|
||||
require 'fog/storm_on_demand/models/dns/reverse'
|
||||
|
||||
module Fog
|
||||
module DNS
|
||||
class StormOnDemand
|
||||
|
||||
class Reverses < Fog::Collection
|
||||
model Fog::DNS::StormOnDemand::Reverse
|
||||
|
||||
def destroy(options)
|
||||
service.delete_reverse(options).body
|
||||
end
|
||||
|
||||
def update(options)
|
||||
service.update_reverse(options).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue