-
-
Save yevgenko/407133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## from libcloud.types import Provider | |
## from libcloud.providers import get_driver | |
require 'fog/types' | |
require 'fog/providers' | |
## EC2 = get_driver(Provider.EC2) | |
## Slicehost = get_driver(Provider.SLICEHOST) | |
## Rackspace = get_driver(Provider.RACKSPACE) | |
EC2 = Fog::Provider.new(:ec2) # syntax 1 | |
Slicehost = Fog::Provider.new :slicehost # syntax 1 | |
Rackspace = Fog::Provider::Rackspace.new # syntax 2 | |
## drivers = [ EC2('access key id', 'secret key'), | |
## Slicehost('api key'), | |
## Rackspace('username', 'api key') ] | |
drivers = [ EC2.new('access key id', 'secret key'), | |
Slicehost.new('api key'), | |
Rackspace.new('username', 'api key') ] | |
## nodes = [ driver.list_nodes() for driver in drivers ] | |
nodes = drivers.collect { |drv| drv.list_nodes() } | |
p nodes | |
# [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>, | |
# <Node: provider=Slicehost, status=REBOOT, name=korine, ip=6.7.8.9.10>, | |
# ... ] | |
# grab the node named "test" | |
## node = filter(lambda x: x.name == 'test', nodes)[0] | |
node = nodes.find { |nd| nd.name =~ /test/ } | |
# reboot "test" | |
## node.reboot() | |
node.reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment