Skip to content

Instantly share code, notes, and snippets.

@MaxMartin
Created March 29, 2013 17:44
Show Gist options
  • Save MaxMartin/5272354 to your computer and use it in GitHub Desktop.
Save MaxMartin/5272354 to your computer and use it in GitHub Desktop.
Using Zweikopf to invoke mcollective from Clojure
root@master:/home/vagrant/zweikopf# lein repl
REPL started; server listening on localhost port 24747
user=> (require '(zweikopf [core :as zc]))
nil
user=> (zc/init-ruby-context)
#'zweikopf.core/ruby-runtime
user=> (zc/ruby-eval "$: << '/usr/lib/ruby/vendor_ruby'")
#<RubyArray ["/home/vagrant/zweikopf/test", "/home/vagrant/zweikopf/test-resources", "/home/vagrant/zweikopf/src", "/home/vagrant/zweikopf/classes", "/home/vagrant/zweikopf/resources", "/home/vagrant/zweikopf/lib/jruby-complete-1.7.1.jar", "/home/vagrant/zweikopf/lib/clojure-1.4.0.jar", "file:/home/vagrant/zweikopf/lib/jruby-complete-1.7.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby", "file:/home/vagrant/zweikopf/lib/jruby-complete-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared", "file:/home/vagrant/zweikopf/lib/jruby-complete-1.7.1.jar!/META-INF/jruby.home/lib/ruby/1.9", "/usr/lib/ruby/vendor_ruby"]>
user=> (zc/ruby-require "mcollective")
#<RubyBoolean true>
user=> (zc/ruby-eval "extend MCollective::RPC")
#<RubyObject main>
user=> (def mc (zc/ruby-eval "self.rpcclient('patch')"))
#'user/mc
user=> (def response (zc/call-ruby mc checkupdates))
3 / 3#'user/response
user=> (def zeroth-result (zc/clojurize (zc/call-ruby (nth response 0) results)))
#'user/zeroth-result
user=> (keys zeroth-result)
(:sender :statuscode :statusmsg :data)
user=> (:sender zeroth-result)
"agent1.vagrant.internal"
etc....
@MaxMartin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment