Guest User

Untitled

a guest
Aug 29th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.78 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'rubygems'
  3. require 'English'
  4. require 'trollop'
  5. require 'fog'
  6. require 'awesome_print'
  7.  
  8. opts = Trollop::options do
  9.   version "1.0"
  10.   banner <<-EOS
  11.   #{File.basename($0)} wrapper around fog to allow actions to be sent to instances
  12.  
  13.   Usage:
  14.            #{File.basename($0)} [options]
  15.   where [options] are:
  16.   EOS
  17.   opt :provider , "Cloud provider to use" , :default => "AWS"
  18.   opt :instance , "Instance", :required => true, :type => :string
  19.   opt :action , "Action to perform (start stop terminate", :default => 'describe_instances'
  20. end
  21.  
  22.  
  23. # create a connection
  24. connection = Fog::Compute.new({
  25.   :provider                 => opts[:provider],
  26. })
  27.  
  28. command="#{opts[:action]}('instance-id' => #{opts[:instance]})"
  29. puts connection.send(command.to_sym)
Advertisement
Add Comment
Please, Sign In to add comment