Skip to Content
Learning MCollective
book

Learning MCollective

by Jo Rhett
August 2014
Intermediate to advanced
284 pages
5h 24m
English
O'Reilly Media, Inc.
Content preview from Learning MCollective

Chapter 22. Collecting Responses

One of the features that makes MCollective truly unique is the ability to send requests from one client and to process the responses with a different client or listener, as shown in Figure 22-1.

Request responses return via a custom queue to a Listener
Figure 22-1. A separate listener to process results from requests

Create a Listener

The first thing we’ll do here is to create a listener. What I’ll introduce to you here is a working listener from which you can debug any problem. You can also copy it and add new functionality. I put my listeners in the $libdir directory just like every other plugin, but that’s not required:

$ cat /usr/libexec/mcollective/mcollective/listener/debugger.rb # Parse options, load config, and start an MCollective client. require 'mcollective' optparser = MCollective::Optionparser.new options = optparser.parse config = MCollective::Config.instance config.loadconfig(options[:config]) MCollective::PluginManager["security_plugin"].initiated_by = :client connector = MCollective::PluginManager['connector_plugin'] connector.connect # Get pretty-print and the Log object require 'pp' Log = MCollective::Log # Get a reply queue name from command line, default to "debugger" replyqueue = ARGV[0] || 'debugger' queuename = '/queue/mcollective.reply.' + replyqueue # Subscribe to the queue connector.connection.subscribe( queuename, {}, "$$".to_i ) # consume all the items in the queue... loop ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Russell Rules

Russell Rules

Bill Russell
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
How You Play the Game

How You Play the Game

Jerry Colangelo, Len Sherman

Publisher Resources

ISBN: 9781491945681Errata