BasicObject
# File ext/mc-irb, line 168 def agent_filter(*args) @agent.agent_filter(*args) print_filter end
Build the rdoc documentation.
# File install.rb, line 248 def build_rdoc(files) return unless $haverdoc begin r = RDoc::RDoc.new r.document(["--main", "MCollective", "--line-numbers"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" end end
# File install.rb, line 65 def check_prereqs PREREQS.each do |pre| begin require pre rescue LoadError puts "Could not load #{pre} Ruby library; cannot install" exit(-1) end end end
# File ext/mc-irb, line 174 def class_filter(*args) @agent.class_filter(*args) print_filter end
# File ext/mc-irb, line 40 def consolize &block yield IRB.setup(nil) irb = IRB::Irb.new IRB.conf[:MAIN_CONTEXT] = irb.context irb.context.evaluate("require 'irb/completion'", 0) begin require 'bond' Bond.start Bond.complete(:method => "rpc") do |e| begin if e.argument == 1 if e.arguments.last == "?" puts "\n\nActions for #{@agent_name}:\n" @agent.ddl.actions.each do |action| puts "%20s - %s" % [ ":#{action}", @agent.ddl.action_interface(action)[:description] ] end print "\n" + e.line end @agent.ddl.actions elsif e.argument > 1 action = eval(e.arguments[0]).to_s ddl = @agent.ddl.action_interface(action) if e.arguments.last == "?" puts "\n\nArguments for #{action}:\n" ddl[:input].keys.each do |input| puts "%20s - %s" % [ ":#{input}", ddl[:input][input][:description] ] end print "\n" + e.line end [ddl[:input].keys, :verbose].flatten end rescue Exception [] end end rescue Exception end trap("SIGINT") do irb.signal_handle end catch(:IRB_EXIT) do irb.eval_input end end
# File install.rb, line 86 def do_bins(bins, target, strip = 's?bin/') Dir.mkdir(target) unless File.directory? target bins.each do |bf| obf = bf.gsub(/#{strip}/, '') install_binfile(bf, obf, target) end end
# File install.rb, line 76 def do_configs(configs, target, strip = 'etc/') Dir.mkdir(target) unless File.directory? target configs.each do |cf| ocf = File.join(target, cf.gsub(Regexp.new(strip), '')) oc = File.dirname(ocf) makedirs(oc, {:mode => 0755, :verbose => true}) install(cf, ocf, {:mode => 0644, :preserve => true, :verbose => true}) end end
# File install.rb, line 94 def do_libs(libs, target, strip = 'lib/') libs.each do |lf| olf = File.join(target, lf.sub(/^#{strip}/, '')) op = File.dirname(olf) if File.directory?(lf) makedirs(olf, {:mode => 0755, :verbose => true}) else makedirs(op, {:mode => 0755, :verbose => true}) install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true}) end end end
# File ext/mc-irb, line 162 def fact_filter(*args) @agent.fact_filter(*args) print_filter end
# File install.rb, line 57 def glob(list) g = list.map { |i| Dir.glob(i) } g.flatten! g.compact! g.uniq! g end
# File ext/mc-irb, line 156 def identity_filter(*args) @agent.identity_filter(*args) print_filter end
Install file(s) from ./bin to RbConfig::CONFIG. Patch it on the way to insert a #! line; on a Unix install, the command is named as expected
# File install.rb, line 263 def install_binfile(from, op_file, target) tmp_file = Tempfile.new('mcollective-binfile') if InstallOptions.ruby ruby = InstallOptions.ruby else ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end File.open(from) do |ip| File.open(tmp_file.path, "w") do |op| op.puts "#!#{ruby}" contents = ip.readlines contents.shift if contents[0] =~ /^#!/ op.write contents.join end end install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true) tmp_file.unlink end
# File spec/monkey_patches/instance_variable_defined.rb, line 3 def instance_variable_defined?(meth) instance_variables.include?(meth) end
# File ext/packaging/spec/spec_helper.rb, line 11 def load_task(name) return false if (@loaded ||= {})[name] load File.join(SPECDIR, '..', 'tasks', name) @loaded[name] = true end
# File ext/mc-irb, line 196 def mc? puts Available Commands: rpc - Performs an RPC request reset - Resets the discovered knowledge discover - Performs a new discovery showing hosts that was found newagent - Switches to a new agent mchelp - The DDL created help for the agent Filter Commands: Filter arguments should be enclosed in "your.host.com" if they are strings else use /your.host/ to match Regular expressions identity_filter [identity] - Sets an identity filter fact_filter [factname], [factvalue] - Sets a fact filter class_filter [classname] - Sets a class filter agent_filter [agentname] - Sets an agent filter reset_filter - Resets to the filter to blank print_filter - Displays current filter Available Variables: @agent_name - The name of the active agent @agent - The active RPC client Completions: While doing an RPC request, press ?<tab> for a list of actions or arguments, do simple :<tab> to get completion on action names and arguments without description of each true end
# File ext/mc-irb, line 97 def mchelp system("mc-rpc --agent-help #{@agent_name}|less") true end
# File ext/mc-irb, line 143 def newagent(agent) @agent_name = agent @options[:filter]["agent"] = [] @agent = rpcclient(@agent_name, :options => @options) discover @agent.progress = true print_filter end
Prepare the file installation.
# File install.rb, line 110 def prepare_installation InstallOptions.configs = true # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true else InstallOptions.rdoc = false end ARGV.options do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.separator "" opts.on('--[no-]rdoc', 'Creation of RDoc output.', 'Default is create rdoc.') do |onrdoc| InstallOptions.rdoc = onrdoc end opts.on('--[no-]configs', 'Installation of config files', 'Default is install configs.') do |onconfigs| InstallOptions.configs = onconfigs end opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/mcollective') do |configdir| InstallOptions.configdir = configdir end opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides RbConfig::CONFIG["sbindir"]') do |sbindir| InstallOptions.sbindir = sbindir end opts.on('--ruby[=OPTIONAL]', 'Ruby interpreter to use with installation', 'overrides ruby used to call install.rb') do |ruby| InstallOptions.ruby = ruby end opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir| InstallOptions.sitelibdir = sitelibdir end opts.on('--plugindir[=OPTIONAL]', 'Installation directory for plugins', 'Default /usr/libexec/mcollective') do |plugindir| InstallOptions.plugindir = plugindir end opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| InstallOptions.rdoc = false InstallOptions.ri = false InstallOptions.configs = true end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| InstallOptions.rdoc = true InstallOptions.ri = true InstallOptions.configs = true end opts.separator("") opts.on_tail('--help', "Shows this help text.") do $stderr.puts opts exit end opts.parse! end version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".") libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version) # Mac OS X 10.5 and higher declare bindir # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin # which is not generally where people expect executables to be installed # These settings are appropriate defaults for all OS X versions. if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ RbConfig::CONFIG['bindir'] = "/usr/bin" RbConfig::CONFIG['sbindir'] = "/usr/sbin" end if InstallOptions.configdir configdir = InstallOptions.configdir else configdir = "/etc/mcollective" end if InstallOptions.bindir bindir = InstallOptions.bindir else bindir = RbConfig::CONFIG['bindir'] end if InstallOptions.sbindir sbindir = InstallOptions.sbindir else sbindir = RbConfig::CONFIG['sbindir'] end if InstallOptions.sitelibdir sitelibdir = InstallOptions.sitelibdir else sitelibdir = RbConfig::CONFIG["sitelibdir"] if sitelibdir.nil? sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } if sitelibdir.nil? sitelibdir = File.join(libdir, "site_ruby") elsif sitelibdir !~ Regexp.quote(version) sitelibdir = File.join(sitelibdir, version) end end end if InstallOptions.plugindir plugindir = InstallOptions.plugindir else plugindir = "/usr/libexec/mcollective" end if InstallOptions.destdir destdir = InstallOptions.destdir else destdir = '' end configdir = File.join(destdir, configdir) bindir = File.join(destdir, bindir) sbindir = File.join(destdir, sbindir) sitelibdir = File.join(destdir, sitelibdir) plugindir = File.join(destdir, plugindir) makedirs(configdir) if InstallOptions.configs makedirs(bindir) makedirs(sbindir) makedirs(sitelibdir) makedirs(plugindir) InstallOptions.sitelibdir = sitelibdir InstallOptions.configdir = configdir InstallOptions.bindir = bindir InstallOptions.sbindir = sbindir InstallOptions.plugindir = plugindir end
# File ext/mc-irb, line 133 def print_filter puts "Active Filter matched #{discover.size} hosts:" puts "\tIdentity: #{@agent.filter['identity'].pretty_inspect}" puts "\t Classes: #{@agent.filter['cf_class'].pretty_inspect}" puts "\t Facts: #{@agent.filter['fact'].pretty_inspect}" puts "\t Agents: #{@agent.filter['agent'].pretty_inspect}" discover.size > 0 ? true : false end
# File ext/mc-irb, line 180 def reset_filter @agent.reset_filter print_filter end
# File ext/mc-irb, line 102 def rpc(method_name, *args, &block) unless block_given? if args.size > 0 args = args.first else args = {} end if args[:verbose] args.delete(:verbose) printrpc(@agent.send(method_name, args), :verbose => true) printrpcstats else printrpc @agent.send(method_name, args) printrpcstats end else @agent.send(method_name, args.first).each do |resp| yield resp end printrpcstats end true rescue MCollective::DDLValidationError => e puts "Request did not pass DDL validation: #{e}" end
# File ext/stompclient, line 92 def showhelp puts("List of commands:") puts("\n\t- subscribe /(topic|queue)/foo subscribes to topic of queue 'foo'") puts("\t- /(topic|queue|/foo bar sends msg 'bar' to topic of queue 'foo'") puts("\t- quit|exit|q|^d exit") puts("\t- detail show/dont show time and topic a msg was received on") puts("\t- help show this help") end
Generated with the Darkfish Rdoc Generator 2.