Created
April 13, 2012 22:16
-
-
Save maguec/2380478 to your computer and use it in GitHub Desktop.
simple client for a wrapped command
This file contains hidden or 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
#!/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