mcollective 代理参数定义

mcollective agent parameter definition

以下ddl

action 'ant', :description => "Runs ant in the application directory" do
  input :application,
      :prompt      => "Application(s)",
      :description => "Application's instance name(s)",
      :type        => :string,
      :validation  => '^[a-z0-9_,\-]+$',
      :maxlength   => 500,
      :optional    => false

可以在代理内部使用获取命令行参数application

  # entry point for the ant target
  action 'ant' do
    # find eligible applications
    applications = request[:application].split(',').select{|a| valid_application?(a) }

command命令可以用mco <agentname> -a applicationname1,applicationname2等开头。发出 mco <agentname> --help 给我:

$ mco ehyp --help
Manage an <internal> application
Application Options
    -a, --application APPLICATION    Application to manage

我没有在 -a--applicationrequest[:application] 之间找到 "link"。在哪里定义了如何解释这些命令行开关?

它在MCollective::Application中定义 你定义:

option :application,
     :description => 'Application to manage',
     :arguments   => ['-a', '--application APPLICATION'],
     :required    => true

option :destination,
     :description => 'Ant target ("destination") to call',
     :arguments   => ['-d', '--destination TARGET'],
     :required    => true