Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'rubygems'
- require 'English'
- require 'trollop'
- require 'fog'
- require 'awesome_print'
- opts = Trollop::options do
- version "1.0"
- banner <<-EOS
- #{File.basename($0)} wrapper around fog to allow actions to be sent to instances
- Usage:
- #{File.basename($0)} [options]
- where [options] are:
- EOS
- opt :provider , "Cloud provider to use" , :default => "AWS"
- opt :instance , "Instance", :required => true, :type => :string
- opt :action , "Action to perform (start stop terminate", :default => 'describe_instances'
- end
- # create a connection
- connection = Fog::Compute.new({
- :provider => opts[:provider],
- })
- command="#{opts[:action]}('instance-id' => #{opts[:instance]})"
- puts connection.send(command.to_sym)
Advertisement
Add Comment
Please, Sign In to add comment