Class: Aspera::Cli::Plugins::Sync
- Inherits:
-
Aspera::Cli::Plugin
- Object
- Aspera::Cli::Plugin
- Aspera::Cli::Plugins::Sync
- Defined in:
- lib/aspera/cli/plugins/sync.rb
Overview
list and download connect client versions, select FASP implementation
Constant Summary collapse
- ACTIONS =
[ :start, :admin ]
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) ⇒ Sync
constructor
A new instance of Sync.
Methods inherited from Aspera::Cli::Plugin
#config, #entity_action, #entity_command, #format, #options, #transfer
Constructor Details
#initialize(env) ⇒ Sync
11 12 13 14 15 16 |
# File 'lib/aspera/cli/plugins/sync.rb', line 11 def initialize(env) super(env) self..add_opt_simple(:parameters,"extended value for session set definition") self..add_opt_simple(:session_name,"name of session to use for admin commands, by default first one") self.. end |
Instance Method Details
#execute_action ⇒ Object
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 59 60 61 |
# File 'lib/aspera/cli/plugins/sync.rb', line 20 def execute_action command=self..get_next_command(ACTIONS) case command when :start env_args=Aspera::Sync.new(self..get_option(:parameters,:mandatory)).compute_args async_bin='async' Log.log.debug("execute: #{env_args[:env].map{|k,v| "#{k}=\"#{v}\""}.join(' ')} \"#{async_bin}\" \"#{env_args[:args].join('" "')}\"") res=system(env_args[:env],[async_bin,async_bin],*env_args[:args]) Log.log.debug("result=#{res}") case res when true; return Main.result_success when false; raise "failed: #{$?}" when nil; return Main.result_status("not started: #{$?}") else raise "internal error: unspecified case" end when :admin p=self..get_option(:parameters,:mandatory) n=self..get_option(:session_name,:optional) cmdline=['asyncadmin','--quiet'] if n.nil? session=p['sessions'].first else session=p['sessions'].select{|s|s['name'].eql?(n)}.first end cmdline.push('--name='+session['name']) if session.has_key?('local_db_dir') cmdline.push('--local-db-dir='+session['local_db_dir']) else cmdline.push('--local-dir='+session['local_dir']) end command2=self..get_next_command([:status]) case command2 when :status stdout, stderr, status = Open3.capture3(*cmdline) Log.log.debug("status=#{status}, stderr=#{stderr}") items=stdout.split("\n").inject({}){|m,l|i=l.split(/: */);m[i.first.lstrip]=i.last.lstrip;m} return {:type=>:single_object,:data=>items} else raise "error" end # command else raise "error" end # command end |