Class: Aspera::Cli::Plugins::Console
- Inherits:
-
BasicAuthPlugin
- Object
- Aspera::Cli::Plugin
- BasicAuthPlugin
- Aspera::Cli::Plugins::Console
- Defined in:
- lib/aspera/cli/plugins/console.rb
Constant Summary collapse
- ACTIONS =
[:transfer,:nagios_check]
Constants inherited from Aspera::Cli::Plugin
Aspera::Cli::Plugin::ALL_OPS, Aspera::Cli::Plugin::GLOBAL_OPS, Aspera::Cli::Plugin::INSTANCE_OPS
Instance Method Summary collapse
- #execute_action ⇒ Object
-
#initialize(env) ⇒ Console
constructor
A new instance of Console.
Methods inherited from BasicAuthPlugin
Methods inherited from Aspera::Cli::Plugin
#config, #entity_action, #entity_command, #format, #options, #transfer
Constructor Details
#initialize(env) ⇒ Console
Returns a new instance of Console.
8 9 10 11 12 13 14 15 |
# File 'lib/aspera/cli/plugins/console.rb', line 8 def initialize(env) super(env) self..add_opt_date(:filter_from,"only after date") self..add_opt_date(:filter_to,"only before date") self..set_option(:filter_from,Manager.time_to_string(Time.now - 3*3600)) self..set_option(:filter_to,Manager.time_to_string(Time.now)) self.. end |
Instance Method Details
#execute_action ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aspera/cli/plugins/console.rb', line 19 def execute_action api_console=basic_auth_api('api') command=self..get_next_command(ACTIONS) case command when :nagios_check nagios=Nagios.new begin api_console.read('ssh_keys') nagios.add_ok('console api','accessible') rescue => e nagios.add_critical('console api',e.to_s) end return nagios.result when :transfer command=self..get_next_command([ :current, :smart ]) case command when :smart command=self..get_next_command([:list,:submit]) case command when :list return {:type=>:object_list,:data=>api_console.read('smart_transfers')[:data]} when :submit smart_id = self..get_next_argument("smart_id") params = self..get_next_argument("transfer parameters") return {:type=>:object_list,:data=>api_console.create('smart_transfers/'+smart_id,params)[:data]} end when :current command=self..get_next_command([ :list ]) case command when :list return {:type=>:object_list, :data=>api_console.read('transfers',{ 'from'=>self..get_option(:filter_from,:mandatory), 'to'=>self..get_option(:filter_to,:mandatory) })[:data], :fields=>['id','contact','name','status']} end end end end |