1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/storm_on_demand
2013-05-25 22:48:24 +08:00
..
models [stormondemand] fix some minor problems. Add a README.md file to describe how to use the storm on demand APIs 2013-05-25 22:48:24 +08:00
requests [stormondemand|network] Add a new Network service and move all network code in Compute into Network 2013-05-25 17:29:10 +08:00
account.rb [stormondemand|account] Add Account service and token APIs 2013-05-25 15:16:42 +08:00
billing.rb [stormondemand|billing] Add Billing service and related APIs 2013-05-24 17:29:12 +08:00
compute.rb [stormondemand|network] Add a new Network service and move all network code in Compute into Network 2013-05-25 17:29:10 +08:00
dns.rb [stormondemand] fix some minor problems. Add a README.md file to describe how to use the storm on demand APIs 2013-05-25 22:48:24 +08:00
monitoring.rb [stormondemand|monitoring] Add a new Monitoring service and add/move load/bandwidth/service APIs 2013-05-24 21:11:28 +08:00
network.rb [stormondemand|network] Add a new Network service and move all network code in Compute into Network 2013-05-25 17:29:10 +08:00
README.md [stormondemand] fix some minor problems. Add a README.md file to describe how to use the storm on demand APIs 2013-05-25 22:48:24 +08:00
shared.rb [stormondemand] fix typo bugs and move shared code into shared.rb module 2013-05-24 09:12:44 +08:00
storage.rb [stormondemand] fix typo bugs and move shared code into shared.rb module 2013-05-24 09:12:44 +08:00
support.rb [stormondemand|support] Add Support service and APIs for alert and support tickets 2013-05-25 11:44:34 +08:00
vpn.rb [stormondemand|vpn] Add new VPN service and APIs 2013-05-25 17:02:43 +08:00

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