a72433d2f8
Following work on reorganising the requires, there was an inconsistent approach to where service wrappers are required. (Fog::Compute...) Since they should be standardised and shared across providers (although they really aren't yet) they have been moved to `fog-core` gem. Each provider has their own `lib/fog/{provider}/core` files that is required by each of their services. These files should all require `fog/core` which already required most or these. So this removes the extra cases to concentrate them in core. |
||
---|---|---|
.. | ||
models | ||
requests | ||
account.rb | ||
billing.rb | ||
compute.rb | ||
core.rb | ||
dns.rb | ||
monitoring.rb | ||
network.rb | ||
README.md | ||
shared.rb | ||
storage.rb | ||
support.rb | ||
vpn.rb |
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.
(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