1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8 <title>Class: MCollective::DDL::Base</title>
10 <link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
12 <script src="../../js/jquery.js" type="text/javascript"
13 charset="utf-8"></script>
14 <script src="../../js/thickbox-compressed.js" type="text/javascript"
15 charset="utf-8"></script>
16 <script src="../../js/quicksearch.js" type="text/javascript"
17 charset="utf-8"></script>
18 <script src="../../js/darkfish.js" type="text/javascript"
19 charset="utf-8"></script>
25 <div id="file-metadata">
26 <div id="file-list-section" class="section">
27 <h3 class="section-header">In Files</h3>
28 <div class="section-body">
31 <li><a href="../../lib/mcollective/ddl/base_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/ddl/base.rb">lib/mcollective/ddl/base.rb</a></li>
41 <div id="class-metadata">
45 <div id="parent-class-section" class="section">
46 <h3 class="section-header">Parent</h3>
48 <p class="link"><a href="../../Object.html">Object</a></p>
53 <!-- Namespace Contents -->
56 <!-- Method Quickref -->
58 <div id="method-list-section" class="section">
59 <h3 class="section-header">Methods</h3>
60 <ul class="link-list">
62 <li><a href="#M000278">::new</a></li>
64 <li><a href="#M000283">#findddlfile</a></li>
66 <li><a href="#M000279">#help</a></li>
68 <li><a href="#M000289">#input</a></li>
70 <li><a href="#M000282">#loadddlfile</a></li>
72 <li><a href="#M000292">#metadata</a></li>
74 <li><a href="#M000290">#output</a></li>
76 <li><a href="#M000291">#requires</a></li>
78 <li><a href="#M000281">#template_for_plugintype</a></li>
80 <li><a href="#M000280">#usage</a></li>
82 <li><a href="#M000288">#validate_input_argument</a></li>
84 <li><a href="#M000286">#validate_requirements</a></li>
90 <!-- Included Modules -->
92 <div id="includes-section" class="section">
93 <h3 class="section-header">Included Modules</h3>
94 <ul class="link-list">
97 <li><a class="include" href="../Connector.html">MCollective::Connector</a></li>
105 <div id="project-metadata">
108 <div id="fileindex-section" class="section project-section">
109 <h3 class="section-header">Files</h3>
112 <li class="file"><a href="../../COPYING.html">COPYING</a></li>
114 <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
116 <li class="file"><a href="../../README.html">README</a></li>
118 <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
120 <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
122 <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
124 <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
126 <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
128 <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
130 <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
132 <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
134 <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
136 <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
138 <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
140 <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
142 <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
144 <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
146 <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
148 <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
150 <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
156 <div id="classindex-section" class="section project-section">
157 <h3 class="section-header">Class Index
158 <span class="search-toggle"><img src="../../images/find.png"
159 height="16" width="16" alt="[+]"
160 title="show/hide quicksearch" /></span></h3>
161 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
163 <legend>Quicksearch</legend>
164 <input type="text" name="quicksearch" value=""
165 class="quicksearch-field" />
169 <ul class="link-list">
171 <li><a href="../../MCollective.html">MCollective</a></li>
173 <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
175 <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
177 <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
179 <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
181 <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
183 <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
185 <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
187 <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
189 <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
191 <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
193 <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
195 <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
197 <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
199 <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
201 <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
203 <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
205 <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
207 <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
209 <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
211 <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
213 <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
215 <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
217 <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
219 <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
221 <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
223 <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
225 <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
227 <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
229 <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
231 <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
233 <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
235 <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
237 <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
239 <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
241 <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
243 <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
245 <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
247 <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
249 <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
251 <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
253 <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
255 <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
257 <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
259 <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
261 <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
263 <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
265 <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
267 <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
269 <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
271 <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
273 <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
275 <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
277 <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
279 <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
281 <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
283 <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
285 <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
287 <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
289 <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
291 <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
293 <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
295 <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
297 <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
299 <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
301 <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
303 <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
305 <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
307 <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
309 <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
311 <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
313 <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
315 <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
317 <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
319 <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
321 <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
323 <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
325 <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
327 <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
329 <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
331 <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
333 <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
335 <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
337 <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
339 <li><a href="../../Array.html">Array</a></li>
341 <li><a href="../../Dir.html">Dir</a></li>
343 <li><a href="../../Object.html">Object</a></li>
345 <li><a href="../../String.html">String</a></li>
347 <li><a href="../../Symbol.html">Symbol</a></li>
350 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
357 <div id="documentation">
358 <h1 class="class">MCollective::DDL::Base</h1>
360 <div id="description">
362 The base class for all kinds of <a href="../DDL.html">DDL</a> files. <a
363 href="../DDL.html">DDL</a> files when run gets parsed and builds up a hash
364 of the basic primitive types, ideally restricted so it can be converted to
365 JSON though today there are some Ruby Symbols in them which might be fixed
369 The Hash being built should be stored in @entities, the format is generally
370 not prescribed but there’s a definite feel to how <a
371 href="../DDL.html">DDL</a> files look so study the agent and discovery ones
372 to see how the structure applies to very different use cases.
375 For every plugin type you should have a single word name - that corresponds
376 to the directory in the libdir where these plugins live. If you need
377 anything above and beyond ‘metadata’ in your plugin <a
378 href="../DDL.html">DDL</a> then add a PlugintypeDDL class here and add your
379 specific behaviors to those.
389 <div id="attribute-method-details" class="method-section section">
390 <h3 class="section-header">Attributes</h3>
393 <div id="meta-attribute-method" class="method-detail">
396 <div class="method-heading attribute-method-heading">
397 <span class="method-name">meta</span><span
398 class="attribute-access-type">[R]</span>
401 <div class="method-description">
403 <p class="missing-docs">(Not documented)</p>
408 <div id="entities-attribute-method" class="method-detail">
409 <a name="entities"></a>
411 <div class="method-heading attribute-method-heading">
412 <span class="method-name">entities</span><span
413 class="attribute-access-type">[R]</span>
416 <div class="method-description">
418 <p class="missing-docs">(Not documented)</p>
423 <div id="pluginname-attribute-method" class="method-detail">
424 <a name="pluginname"></a>
426 <div class="method-heading attribute-method-heading">
427 <span class="method-name">pluginname</span><span
428 class="attribute-access-type">[R]</span>
431 <div class="method-description">
433 <p class="missing-docs">(Not documented)</p>
438 <div id="plugintype-attribute-method" class="method-detail">
439 <a name="plugintype"></a>
441 <div class="method-heading attribute-method-heading">
442 <span class="method-name">plugintype</span><span
443 class="attribute-access-type">[R]</span>
446 <div class="method-description">
448 <p class="missing-docs">(Not documented)</p>
453 <div id="usage-attribute-method" class="method-detail">
456 <div class="method-heading attribute-method-heading">
457 <span class="method-name">usage</span><span
458 class="attribute-access-type">[R]</span>
461 <div class="method-description">
463 <p class="missing-docs">(Not documented)</p>
468 <div id="requirements-attribute-method" class="method-detail">
469 <a name="requirements"></a>
471 <div class="method-heading attribute-method-heading">
472 <span class="method-name">requirements</span><span
473 class="attribute-access-type">[R]</span>
476 <div class="method-description">
478 <p class="missing-docs">(Not documented)</p>
488 <div id="public-class-method-details" class="method-section section">
489 <h3 class="section-header">Public Class Methods</h3>
492 <div id="new-method" class="method-detail ">
493 <a name="M000278"></a>
495 <div class="method-heading">
497 <span class="method-name">new</span><span
498 class="method-args">(plugin, plugintype=:agent, loadddl=true)</span>
499 <span class="method-click-advice">click to toggle source</span>
503 <div class="method-description">
505 <p class="missing-docs">(Not documented)</p>
509 <div class="method-source-code"
512 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 24</span>
513 24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">plugin</span>, <span class="ruby-identifier">plugintype</span>=<span class="ruby-identifier">:agent</span>, <span class="ruby-identifier">loadddl</span>=<span class="ruby-keyword kw">true</span>)
514 25: <span class="ruby-ivar">@entities</span> = {}
515 26: <span class="ruby-ivar">@meta</span> = {}
516 27: <span class="ruby-ivar">@usage</span> = <span class="ruby-value str">""</span>
517 28: <span class="ruby-ivar">@config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
518 29: <span class="ruby-ivar">@pluginname</span> = <span class="ruby-identifier">plugin</span>
519 30: <span class="ruby-ivar">@plugintype</span> = <span class="ruby-identifier">plugintype</span>.<span class="ruby-identifier">to_sym</span>
520 31: <span class="ruby-ivar">@requirements</span> = {}
522 33: <span class="ruby-identifier">loadddlfile</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">loadddl</span>
523 34: <span class="ruby-keyword kw">end</span></pre>
534 <div id="public-instance-method-details" class="method-section section">
535 <h3 class="section-header">Public Instance Methods</h3>
538 <div id="findddlfile-method" class="method-detail ">
539 <a name="M000283"></a>
541 <div class="method-heading">
543 <span class="method-name">findddlfile</span><span
544 class="method-args">(ddlname=nil, ddltype=nil)</span>
545 <span class="method-click-advice">click to toggle source</span>
549 <div class="method-description">
551 <p class="missing-docs">(Not documented)</p>
555 <div class="method-source-code"
556 id="findddlfile-source">
558 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 89</span>
559 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">findddlfile</span>(<span class="ruby-identifier">ddlname</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">ddltype</span>=<span class="ruby-keyword kw">nil</span>)
560 90: <span class="ruby-identifier">ddlname</span> = <span class="ruby-ivar">@pluginname</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ddlname</span>
561 91: <span class="ruby-identifier">ddltype</span> = <span class="ruby-ivar">@plugintype</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ddltype</span>
563 93: <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">libdir</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">libdir</span><span class="ruby-operator">|</span>
564 94: <span class="ruby-identifier">ddlfile</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>([<span class="ruby-identifier">libdir</span>, <span class="ruby-value str">"mcollective"</span>, <span class="ruby-identifier">ddltype</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-node">"#{ddlname}.ddl"</span>])
565 95: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">ddlfile</span>)
566 96: <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC18</span>, <span class="ruby-value str">"Found %{ddlname} ddl at %{ddlfile}"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:ddlname</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ddlname</span>, <span class="ruby-identifier">:ddlfile</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ddlfile</span>)
567 97: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ddlfile</span>
568 98: <span class="ruby-keyword kw">end</span>
569 99: <span class="ruby-keyword kw">end</span>
570 100: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
571 101: <span class="ruby-keyword kw">end</span></pre>
580 <div id="help-method" class="method-detail ">
581 <a name="M000279"></a>
583 <div class="method-heading">
585 <span class="method-name">help</span><span
586 class="method-args">(template=nil)</span>
587 <span class="method-click-advice">click to toggle source</span>
591 <div class="method-description">
594 Generates help using the template based on the data created with metadata
598 If no template name is provided one will be chosen based on the plugin
599 type. If the provided template path is not absolute then the template will
600 be loaded either from the config dir and if that does not exist, default to
606 <div class="method-source-code"
609 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 44</span>
610 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">help</span>(<span class="ruby-identifier">template</span>=<span class="ruby-keyword kw">nil</span>)
611 45: <span class="ruby-identifier">template</span> = <span class="ruby-identifier">template_for_plugintype</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">template</span>
612 46: <span class="ruby-identifier">template</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">templatepath</span>(<span class="ruby-identifier">template</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">absolute_path?</span>(<span class="ruby-identifier">template</span>)
614 48: <span class="ruby-identifier">template</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">template</span>)
615 49: <span class="ruby-identifier">meta</span> = <span class="ruby-ivar">@meta</span>
616 50: <span class="ruby-identifier">entities</span> = <span class="ruby-ivar">@entities</span>
618 52: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">template</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"metadata-help.erb"</span>
619 53: <span class="ruby-identifier">metadata_template</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">templatepath</span>(<span class="ruby-value str">"metadata-help.erb"</span>)
620 54: <span class="ruby-identifier">metadata_template</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">metadata_template</span>)
621 55: <span class="ruby-identifier">metastring</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">metadata_template</span>, <span class="ruby-value">0</span>, <span class="ruby-value str">'%'</span>)
622 56: <span class="ruby-identifier">metastring</span> = <span class="ruby-identifier">metastring</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
623 57: <span class="ruby-keyword kw">end</span>
625 59: <span class="ruby-identifier">erb</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">template</span>, <span class="ruby-value">0</span>, <span class="ruby-value str">'%'</span>)
626 60: <span class="ruby-identifier">erb</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
627 61: <span class="ruby-keyword kw">end</span></pre>
636 <div id="input-method" class="method-detail ">
637 <a name="M000289"></a>
639 <div class="method-heading">
641 <span class="method-name">input</span><span
642 class="method-args">(argument, properties)</span>
643 <span class="method-click-advice">click to toggle source</span>
647 <div class="method-description">
650 Registers an input argument for a given action
653 See the documentation for action for how to use this
658 <div class="method-source-code"
661 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 153</span>
662 153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">input</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">properties</span>)
663 154: <span class="ruby-identifier">raise_code</span>(<span class="ruby-identifier">:PLMC22</span>, <span class="ruby-value str">"Cannot determine what entity input '%{entity}' belongs to"</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">:entity</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@current_entity</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@current_entity</span>
665 156: <span class="ruby-identifier">entity</span> = <span class="ruby-ivar">@current_entity</span>
667 158: [<span class="ruby-identifier">:prompt</span>, <span class="ruby-identifier">:description</span>, <span class="ruby-identifier">:type</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
668 159: <span class="ruby-identifier">raise_code</span>(<span class="ruby-identifier">:PLMC23</span>, <span class="ruby-value str">"Input needs a :%{property} property"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:property</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">arg</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">arg</span>)
669 160: <span class="ruby-keyword kw">end</span>
671 162: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">entity</span>][<span class="ruby-identifier">:input</span>][<span class="ruby-identifier">argument</span>] = {<span class="ruby-identifier">:prompt</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:prompt</span>],
672 163: <span class="ruby-identifier">:description</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:description</span>],
673 164: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:type</span>],
674 165: <span class="ruby-identifier">:default</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:default</span>],
675 166: <span class="ruby-identifier">:optional</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:optional</span>]}
677 168: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:type</span>]
678 169: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:string</span>
679 170: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Input type :string needs a :validation argument"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:validation</span>)
680 171: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Input type :string needs a :maxlength argument"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:maxlength</span>)
682 173: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">entity</span>][<span class="ruby-identifier">:input</span>][<span class="ruby-identifier">argument</span>][<span class="ruby-identifier">:validation</span>] = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:validation</span>]
683 174: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">entity</span>][<span class="ruby-identifier">:input</span>][<span class="ruby-identifier">argument</span>][<span class="ruby-identifier">:maxlength</span>] = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:maxlength</span>]
685 176: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:list</span>
686 177: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Input type :list needs a :list argument"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:list</span>)
688 179: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">entity</span>][<span class="ruby-identifier">:input</span>][<span class="ruby-identifier">argument</span>][<span class="ruby-identifier">:list</span>] = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:list</span>]
689 180: <span class="ruby-keyword kw">end</span>
690 181: <span class="ruby-keyword kw">end</span></pre>
699 <div id="loadddlfile-method" class="method-detail ">
700 <a name="M000282"></a>
702 <div class="method-heading">
704 <span class="method-name">loadddlfile</span><span
705 class="method-args">()</span>
706 <span class="method-click-advice">click to toggle source</span>
710 <div class="method-description">
712 <p class="missing-docs">(Not documented)</p>
716 <div class="method-source-code"
717 id="loadddlfile-source">
719 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 81</span>
720 81: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">loadddlfile</span>
721 82: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ddlfile</span> = <span class="ruby-identifier">findddlfile</span>
722 83: <span class="ruby-identifier">instance_eval</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">ddlfile</span>), <span class="ruby-identifier">ddlfile</span>, <span class="ruby-value">1</span>)
723 84: <span class="ruby-keyword kw">else</span>
724 85: <span class="ruby-identifier">raise_code</span>(<span class="ruby-identifier">:PLMC40</span>, <span class="ruby-value str">"Can't find DDL for %{type} plugin '%{name}'"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@plugintype</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@pluginname</span>)
725 86: <span class="ruby-keyword kw">end</span>
726 87: <span class="ruby-keyword kw">end</span></pre>
735 <div id="metadata-method" class="method-detail ">
736 <a name="M000292"></a>
738 <div class="method-heading">
740 <span class="method-name">metadata</span><span
741 class="method-args">(meta)</span>
742 <span class="method-click-advice">click to toggle source</span>
746 <div class="method-description">
749 Registers meta data for the introspection hash
754 <div class="method-source-code"
755 id="metadata-source">
757 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 215</span>
758 215: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">metadata</span>(<span class="ruby-identifier">meta</span>)
759 216: [<span class="ruby-identifier">:name</span>, <span class="ruby-identifier">:description</span>, <span class="ruby-identifier">:author</span>, <span class="ruby-identifier">:license</span>, <span class="ruby-identifier">:version</span>, <span class="ruby-identifier">:url</span>, <span class="ruby-identifier">:timeout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
760 217: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Metadata needs a :#{arg} property"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">meta</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">arg</span>)
761 218: <span class="ruby-keyword kw">end</span>
763 220: <span class="ruby-ivar">@meta</span> = <span class="ruby-identifier">meta</span>
764 221: <span class="ruby-keyword kw">end</span></pre>
773 <div id="output-method" class="method-detail ">
774 <a name="M000290"></a>
776 <div class="method-heading">
778 <span class="method-name">output</span><span
779 class="method-args">(argument, properties)</span>
780 <span class="method-click-advice">click to toggle source</span>
784 <div class="method-description">
787 Registers an output argument for a given action
790 See the documentation for action for how to use this
795 <div class="method-source-code"
798 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 186</span>
799 186: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">properties</span>)
800 187: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Cannot figure out what action input #{argument} belongs to"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@current_entity</span>
801 188: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Output #{argument} needs a description argument"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:description</span>)
802 189: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Output #{argument} needs a display_as argument"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:display_as</span>)
804 191: <span class="ruby-identifier">action</span> = <span class="ruby-ivar">@current_entity</span>
806 193: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">action</span>][<span class="ruby-identifier">:output</span>][<span class="ruby-identifier">argument</span>] = {<span class="ruby-identifier">:description</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:description</span>],
807 194: <span class="ruby-identifier">:display_as</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:display_as</span>],
808 195: <span class="ruby-identifier">:default</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:default</span>]}
809 196: <span class="ruby-keyword kw">end</span></pre>
818 <div id="requires-method" class="method-detail ">
819 <a name="M000291"></a>
821 <div class="method-heading">
823 <span class="method-name">requires</span><span
824 class="method-args">(requirement)</span>
825 <span class="method-click-advice">click to toggle source</span>
829 <div class="method-description">
831 <p class="missing-docs">(Not documented)</p>
835 <div class="method-source-code"
836 id="requires-source">
838 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 198</span>
839 198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">requires</span>(<span class="ruby-identifier">requirement</span>)
840 199: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Requirement should be a hash in the form :item => 'requirement'"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">requirement</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
842 201: <span class="ruby-identifier">valid_requirements</span> = [<span class="ruby-identifier">:mcollective</span>]
844 203: <span class="ruby-identifier">requirement</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
845 204: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_requirements</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
846 205: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Requirement %s is not a valid requirement, only %s is supported"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">valid_requirements</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">", "</span>)]
847 206: <span class="ruby-keyword kw">end</span>
849 208: <span class="ruby-ivar">@requirements</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">requirement</span>[<span class="ruby-identifier">key</span>]
850 209: <span class="ruby-keyword kw">end</span>
852 211: <span class="ruby-identifier">validate_requirements</span>
853 212: <span class="ruby-keyword kw">end</span></pre>
862 <div id="template-for-plugintype-method" class="method-detail ">
863 <a name="M000281"></a>
865 <div class="method-heading">
867 <span class="method-name">template_for_plugintype</span><span
868 class="method-args">()</span>
869 <span class="method-click-advice">click to toggle source</span>
873 <div class="method-description">
875 <p class="missing-docs">(Not documented)</p>
879 <div class="method-source-code"
880 id="template-for-plugintype-source">
882 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 67</span>
883 67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">template_for_plugintype</span>
884 68: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@plugintype</span>
885 69: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:agent</span>
886 70: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">"rpc-help.erb"</span>
887 71: <span class="ruby-keyword kw">else</span>
888 72: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">templatepath</span>(<span class="ruby-node">"#{@plugintype}-help.erb"</span>))
889 73: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{@plugintype}-help.erb"</span>
890 74: <span class="ruby-keyword kw">else</span>
891 75: <span class="ruby-comment cmt"># Default help template gets loaded if plugintype-help does not exist.</span>
892 76: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">"metadata-help.erb"</span>
893 77: <span class="ruby-keyword kw">end</span>
894 78: <span class="ruby-keyword kw">end</span>
895 79: <span class="ruby-keyword kw">end</span></pre>
904 <div id="usage-method" class="method-detail ">
905 <a name="M000280"></a>
907 <div class="method-heading">
909 <span class="method-name">usage</span><span
910 class="method-args">(usage_text)</span>
911 <span class="method-click-advice">click to toggle source</span>
915 <div class="method-description">
917 <p class="missing-docs">(Not documented)</p>
921 <div class="method-source-code"
924 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 63</span>
925 63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">usage_text</span>)
926 64: <span class="ruby-ivar">@usage</span> = <span class="ruby-identifier">usage_text</span>
927 65: <span class="ruby-keyword kw">end</span></pre>
936 <div id="validate-input-argument-method" class="method-detail ">
937 <a name="M000288"></a>
939 <div class="method-heading">
941 <span class="method-name">validate_input_argument</span><span
942 class="method-args">(input, key, argument)</span>
943 <span class="method-click-advice">click to toggle source</span>
947 <div class="method-description">
950 validate strings, lists and booleans, we’ll add more types of
951 validators when all the use cases are clear
954 only does validation for arguments actually given, since some might be
955 optional. We validate the presense of the argument earlier so this is a
956 safe assumption, just to skip them.
959 :string can have maxlength and regex. A maxlength of 0 will bypasss checks
960 :list has a array of valid values
965 <div class="method-source-code"
966 id="validate-input-argument-source">
968 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 127</span>
969 127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_input_argument</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">argument</span>)
970 128: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">load_validators</span>
972 130: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:type</span>]
973 131: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:string</span>
974 132: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">:string</span>)
976 134: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">length</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:maxlength</span>].<span class="ruby-identifier">to_i</span>)
978 136: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:validation</span>])
980 138: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:list</span>
981 139: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:list</span>])
983 141: <span class="ruby-keyword kw">else</span>
984 142: <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:type</span>])
985 143: <span class="ruby-keyword kw">end</span>
987 145: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
988 146: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
989 147: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC21</span>, <span class="ruby-value str">"Cannot validate input '%{input}': %{error}"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:input</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>)
990 148: <span class="ruby-keyword kw">end</span></pre>
999 <div id="validate-requirements-method" class="method-detail ">
1000 <a name="M000286"></a>
1002 <div class="method-heading">
1004 <span class="method-name">validate_requirements</span><span
1005 class="method-args">()</span>
1006 <span class="method-click-advice">click to toggle source</span>
1010 <div class="method-description">
1012 <p class="missing-docs">(Not documented)</p>
1016 <div class="method-source-code"
1017 id="validate-requirements-source">
1019 <span class="ruby-comment cmt"># File lib/mcollective/ddl/base.rb, line 103</span>
1020 103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_requirements</span>
1021 104: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">requirement</span> = <span class="ruby-ivar">@requirements</span>[<span class="ruby-identifier">:mcollective</span>]
1022 105: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">mcollective_version</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"@DEVELOPMENT_VERSION@"</span>
1023 106: <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC19</span>, <span class="ruby-value str">"DDL requirements validation being skipped in development"</span>, <span class="ruby-identifier">:warn</span>)
1024 107: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
1025 108: <span class="ruby-keyword kw">end</span>
1027 110: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">versioncmp</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">mcollective_version</span>, <span class="ruby-identifier">requirement</span>) <span class="ruby-operator"><</span> <span class="ruby-value">0</span>
1028 111: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC20</span>, <span class="ruby-value str">"%{type} plugin '%{name}' requires MCollective version %{requirement} or newer"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@plugintype</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">capitalize</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@pluginname</span>, <span class="ruby-identifier">:requirement</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">requirement</span>)
1029 112: <span class="ruby-keyword kw">end</span>
1030 113: <span class="ruby-keyword kw">end</span>
1032 115: <span class="ruby-keyword kw">true</span>
1033 116: <span class="ruby-keyword kw">end</span></pre>
1048 <div id="rdoc-debugging-section-dump" class="debugging-section">
1050 <p>Disabled; run with --debug to generate this.</p>
1054 <div id="validator-badges">
1055 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1056 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
1057 Rdoc Generator</a> 1.1.6</small>.</p>