Skip to content

Instantly share code, notes, and snippets.

@maguec
Created April 13, 2012 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maguec/2380478 to your computer and use it in GitHub Desktop.
Save maguec/2380478 to your computer and use it in GitHub Desktop.
simple client for a wrapped command
#!/usr/bin/env ruby
require 'rubygems' if RUBY_VERSION < "1.9"
require 'mcollective'
include MCollective::RPC
args = {}
action=""
options = rpcoptions do |parser, options|
parser.on('-K', '--targ TARGET', 'Target to test against') do |v|
args[:target] = v
end
parser.on('-S', '--action ACTION', 'action') do |v|
action = v
end
end
mc = rpcclient("wrapit", :options => options)
#mc.fact_filter "servertype", "/myservertype/"
mc.timeout = 10
mc.progress = false
mc.send(action, args).each do |resp|
if resp[:statusmsg] == "OK"
puts resp[:sender]
puts resp[:data][:info]
else
puts "ERROR:"
p resp
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment