{"id":1269,"date":"2010-02-03T21:44:44","date_gmt":"2010-02-03T20:44:44","guid":{"rendered":"http:\/\/www.devco.net\/?p=1269"},"modified":"2010-08-17T12:16:13","modified_gmt":"2010-08-17T11:16:13","slug":"mcollective_agent_introspection","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2010\/02\/03\/mcollective_agent_introspection.php","title":{"rendered":"MCollective Agent Introspection"},"content":{"rendered":"
With the new SimpleRPC system in MCollective<\/a> we have a simple interface to creating agents. The way to call an agent would be:<\/p>\n <\/code><\/p>\n This is all fine and well and easy enough, however it requires you to know a lot. You need to know there’s a status<\/em> action and you need to know it expects a service<\/em> argument, not great.<\/p>\n I’m busy adding the ability for an agent to register its metadata and interface so that 3rd party tools can dynamically generate useful interfaces.<\/p>\n A sample registration for service agent is:<\/p>\n <\/code><\/p>\n This includes all the meta data, versions, timeouts, validation of inputs, prompts and help text for every input argument.<\/p>\n Using this we can now generate dynamic UI’s, and do something like JavaDoc generated documentation. I’ve recorded a little video demonstrating a proof of concept Text UI<\/a> that uses this data to generate a UI dynamically. This is ripe for integration into tools like Foreman<\/a> and Puppet Dashboard<\/a>.<\/p>\n<\/p>\n
\r\n$ mc-rpc service status service=httpd\r\n<\/pre>\n
<\/p>\n
\r\nregister_meta(:name => \"SimpleRPC Service Agent\",\r\n :description => \"Agent to manage services using the Puppet service provider\",\r\n :author => \"R.I.Pienaar\",\r\n :license => \"GPLv2\",\r\n :version => 1.1,\r\n :url => \"http:\/\/mcollective-plugins.googlecode.com\/\",\r\n :timeout => 60)\r\n\r\n[\"start\", \"stop\", \"restart\", \"status\"].each do |action|\r\n register_input(:action => action,\r\n :name => \"service\",\r\n :prompt => \"Service Name\",\r\n :description => \"The service to #{action}\",\r\n :type => :string,\r\n :validation => '^[a-zA-Z\\-_\\d]+$',\r\n :maxlength => 30):\r\n<\/pre>\n