aspera-cli 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1267 -999
- data/bin/ascli +20 -1
- data/bin/asession +37 -34
- data/docs/test_env.conf +7 -3
- data/examples/aoc.rb +13 -12
- data/examples/dascli +23 -0
- data/examples/faspex4.rb +34 -29
- data/examples/{transfer.rb → node.rb} +31 -59
- data/examples/server.rb +93 -0
- data/lib/aspera/aoc.rb +153 -143
- data/lib/aspera/ascmd.rb +56 -45
- data/lib/aspera/ats_api.rb +9 -6
- data/lib/aspera/cli/basic_auth_plugin.rb +18 -16
- data/lib/aspera/cli/extended_value.rb +33 -30
- data/lib/aspera/cli/formater.rb +105 -111
- data/lib/aspera/cli/info.rb +3 -2
- data/lib/aspera/cli/listener/line_dump.rb +1 -0
- data/lib/aspera/cli/listener/logger.rb +1 -0
- data/lib/aspera/cli/listener/progress.rb +13 -12
- data/lib/aspera/cli/listener/progress_multi.rb +21 -20
- data/lib/aspera/cli/main.rb +110 -90
- data/lib/aspera/cli/manager.rb +99 -88
- data/lib/aspera/cli/plugin.rb +98 -39
- data/lib/aspera/cli/plugins/alee.rb +6 -5
- data/lib/aspera/cli/plugins/aoc.rb +581 -450
- data/lib/aspera/cli/plugins/ats.rb +84 -83
- data/lib/aspera/cli/plugins/bss.rb +30 -27
- data/lib/aspera/cli/plugins/config.rb +488 -397
- data/lib/aspera/cli/plugins/console.rb +17 -15
- data/lib/aspera/cli/plugins/cos.rb +26 -35
- data/lib/aspera/cli/plugins/faspex.rb +206 -172
- data/lib/aspera/cli/plugins/faspex5.rb +109 -74
- data/lib/aspera/cli/plugins/node.rb +379 -189
- data/lib/aspera/cli/plugins/orchestrator.rb +71 -65
- data/lib/aspera/cli/plugins/preview.rb +131 -122
- data/lib/aspera/cli/plugins/server.rb +50 -150
- data/lib/aspera/cli/plugins/shares.rb +61 -27
- data/lib/aspera/cli/plugins/sync.rb +15 -14
- data/lib/aspera/cli/transfer_agent.rb +75 -64
- data/lib/aspera/cli/version.rb +2 -1
- data/lib/aspera/colors.rb +29 -28
- data/lib/aspera/command_line_builder.rb +50 -43
- data/lib/aspera/cos_node.rb +64 -38
- data/lib/aspera/data_repository.rb +1 -0
- data/lib/aspera/environment.rb +33 -10
- data/lib/aspera/fasp/agent_base.rb +35 -30
- data/lib/aspera/fasp/agent_connect.rb +35 -30
- data/lib/aspera/fasp/agent_direct.rb +68 -60
- data/lib/aspera/fasp/agent_httpgw.rb +71 -64
- data/lib/aspera/fasp/agent_node.rb +24 -23
- data/lib/aspera/fasp/agent_trsdk.rb +19 -20
- data/lib/aspera/fasp/error.rb +2 -1
- data/lib/aspera/fasp/error_info.rb +79 -68
- data/lib/aspera/fasp/installation.rb +130 -126
- data/lib/aspera/fasp/listener.rb +1 -0
- data/lib/aspera/fasp/parameters.rb +71 -60
- data/lib/aspera/fasp/parameters.yaml +69 -17
- data/lib/aspera/fasp/resume_policy.rb +14 -11
- data/lib/aspera/fasp/transfer_spec.rb +6 -5
- data/lib/aspera/fasp/uri.rb +25 -24
- data/lib/aspera/faspex_gw.rb +83 -72
- data/lib/aspera/hash_ext.rb +23 -13
- data/lib/aspera/id_generator.rb +16 -13
- data/lib/aspera/keychain/encrypted_hash.rb +61 -46
- data/lib/aspera/keychain/macos_security.rb +26 -24
- data/lib/aspera/log.rb +35 -39
- data/lib/aspera/nagios.rb +36 -28
- data/lib/aspera/node.rb +19 -19
- data/lib/aspera/oauth.rb +120 -100
- data/lib/aspera/open_application.rb +25 -22
- data/lib/aspera/persistency_action_once.rb +9 -8
- data/lib/aspera/persistency_folder.rb +13 -9
- data/lib/aspera/preview/file_types.rb +261 -266
- data/lib/aspera/preview/generator.rb +74 -73
- data/lib/aspera/preview/image_error.png +0 -0
- data/lib/aspera/preview/options.rb +7 -6
- data/lib/aspera/preview/utils.rb +30 -33
- data/lib/aspera/preview/video_error.png +0 -0
- data/lib/aspera/proxy_auto_config.rb +27 -23
- data/lib/aspera/rest.rb +73 -74
- data/lib/aspera/rest_call_error.rb +1 -0
- data/lib/aspera/rest_error_analyzer.rb +23 -19
- data/lib/aspera/rest_errors_aspera.rb +43 -40
- data/lib/aspera/secret_hider.rb +74 -0
- data/lib/aspera/ssh.rb +13 -10
- data/lib/aspera/sync.rb +49 -47
- data/lib/aspera/temp_file_manager.rb +7 -5
- data/lib/aspera/timer_limiter.rb +9 -8
- data/lib/aspera/uri_reader.rb +17 -18
- data/lib/aspera/web_auth.rb +17 -15
- data.tar.gz.sig +5 -0
- metadata +119 -35
- metadata.gz.sig +0 -0
- data/bin/dascli +0 -13
data/lib/aspera/cli/main.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'aspera/cli/manager'
|
3
4
|
require 'aspera/cli/formater'
|
4
5
|
require 'aspera/cli/plugins/config'
|
@@ -14,18 +15,24 @@ require 'aspera/log'
|
|
14
15
|
require 'aspera/rest'
|
15
16
|
require 'aspera/nagios'
|
16
17
|
require 'aspera/colors'
|
18
|
+
require 'aspera/secret_hider'
|
19
|
+
require 'net/ssh'
|
17
20
|
|
18
21
|
module Aspera
|
19
22
|
module Cli
|
20
23
|
# The main CLI class
|
21
24
|
class Main
|
22
|
-
# prefix to display error messages
|
23
|
-
ERROR_FLASH='ERROR:'.bg_red.gray.blink.freeze
|
24
|
-
|
25
|
+
# prefix to display error messages in user messages (terminal)
|
26
|
+
ERROR_FLASH = 'ERROR:'.bg_red.gray.blink.freeze
|
27
|
+
WARNING_FLASH = 'WARNING:'.bg_red.gray.blink.freeze
|
28
|
+
private_constant :ERROR_FLASH,:WARNING_FLASH
|
25
29
|
|
26
30
|
# store transfer result using this key and use result_transfer_multiple
|
27
31
|
STATUS_FIELD = 'status'
|
28
32
|
|
33
|
+
# for testing only
|
34
|
+
SELF_SIGNED_CERT = OpenSSL::SSL.const_get(:enon_yfirev.to_s.upcase.reverse)
|
35
|
+
|
29
36
|
class << self
|
30
37
|
# expect some list, but nothing to display
|
31
38
|
def result_empty; return {type: :empty, data: :nil}; end
|
@@ -41,7 +48,7 @@ module Aspera
|
|
41
48
|
# raise exception if there is one error
|
42
49
|
# else returns an empty status
|
43
50
|
def result_transfer(statuses)
|
44
|
-
worst=TransferAgent.session_status(statuses)
|
51
|
+
worst = TransferAgent.session_status(statuses)
|
45
52
|
raise worst unless worst.eql?(:success)
|
46
53
|
return Main.result_nothing
|
47
54
|
end
|
@@ -51,12 +58,12 @@ module Aspera
|
|
51
58
|
# @return a status object suitable as command result
|
52
59
|
# each element has a key STATUS_FIELD which contains the result of possibly multiple sessions
|
53
60
|
def result_transfer_multiple(status_table)
|
54
|
-
global_status
|
61
|
+
global_status = :success
|
55
62
|
# transform status array into string and find if there was problem
|
56
63
|
status_table.each do |item|
|
57
|
-
worst=TransferAgent.session_status(item[STATUS_FIELD])
|
58
|
-
global_status=worst unless worst.eql?(:success)
|
59
|
-
item[STATUS_FIELD]=item[STATUS_FIELD].map(&:to_s).join(',')
|
64
|
+
worst = TransferAgent.session_status(item[STATUS_FIELD])
|
65
|
+
global_status = worst unless worst.eql?(:success)
|
66
|
+
item[STATUS_FIELD] = item[STATUS_FIELD].map(&:to_s).join(',')
|
60
67
|
end
|
61
68
|
raise global_status unless global_status.eql?(:success)
|
62
69
|
return {type: :object_list,data: status_table}
|
@@ -72,17 +79,24 @@ module Aspera
|
|
72
79
|
|
73
80
|
def option_ui; OpenApplication.instance.url_method; end
|
74
81
|
|
75
|
-
def option_ui=(value); OpenApplication.instance.url_method=value; end
|
82
|
+
def option_ui=(value); OpenApplication.instance.url_method = value; end
|
76
83
|
|
77
84
|
# called everytime a new REST HTTP session is opened
|
78
85
|
# @param http [Net::HTTP] the newly created http session object
|
79
86
|
def http_parameters=(http)
|
80
|
-
|
87
|
+
if @option_insecure
|
88
|
+
url=http.inspect.gsub(/^[^ ]* /,'https://').gsub(/ [^ ]*$/,'')
|
89
|
+
if !@ssl_warned_urls.include?(url)
|
90
|
+
@plugin_env[:formater].display_message(:error,"#{WARNING_FLASH} ignoring certificate for: #{url}. Only for tests, do not use in production.")
|
91
|
+
@ssl_warned_urls.push(url)
|
92
|
+
end
|
93
|
+
http.verify_mode = SELF_SIGNED_CERT
|
94
|
+
end
|
81
95
|
http.set_debug_output($stdout) if @option_rest_debug
|
82
96
|
raise 'http_options expects Hash' unless @option_http_options.is_a?(Hash)
|
83
97
|
|
84
98
|
@option_http_options.each do |k,v|
|
85
|
-
method="#{k}=".to_sym
|
99
|
+
method = "#{k}=".to_sym
|
86
100
|
# check if accessor is a method of Net::HTTP
|
87
101
|
# continue_timeout= read_timeout= write_timeout=
|
88
102
|
if http.respond_to?(method)
|
@@ -98,91 +112,94 @@ module Aspera
|
|
98
112
|
# first thing : manage debug level (allows debugging of option parser)
|
99
113
|
early_debug_setup(argv)
|
100
114
|
# compare $0 with expected name
|
101
|
-
current_prog_name=File.basename($PROGRAM_NAME)
|
102
|
-
@plugin_env[:formater].display_message(:error,"#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'")
|
103
|
-
|
104
|
-
@
|
105
|
-
@
|
106
|
-
@
|
107
|
-
@
|
108
|
-
@
|
109
|
-
@
|
115
|
+
current_prog_name = File.basename($PROGRAM_NAME)
|
116
|
+
@plugin_env[:formater].display_message(:error,"#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'") \
|
117
|
+
unless current_prog_name.eql?(PROGRAM_NAME)
|
118
|
+
@option_help = false
|
119
|
+
@bash_completion = false
|
120
|
+
@option_show_config = false
|
121
|
+
@option_insecure = false
|
122
|
+
@option_rest_debug = false
|
123
|
+
@option_cache_tokens = true
|
124
|
+
@option_http_options = {}
|
125
|
+
@ssl_warned_urls=[]
|
110
126
|
# environment provided to plugin for various capabilities
|
111
|
-
@plugin_env={}
|
127
|
+
@plugin_env = {}
|
112
128
|
# give command line arguments to option manager
|
113
|
-
@plugin_env[:options]
|
129
|
+
@plugin_env[:options] = @opt_mgr = Manager.new(PROGRAM_NAME,argv: argv)
|
114
130
|
# formatter adds options
|
115
|
-
@plugin_env[:formater]=Formater.new(@plugin_env[:options])
|
116
|
-
Rest.user_agent=PROGRAM_NAME
|
117
|
-
Rest.session_cb=lambda{|http|self.http_parameters=http}
|
131
|
+
@plugin_env[:formater] = Formater.new(@plugin_env[:options])
|
132
|
+
Rest.user_agent = PROGRAM_NAME
|
133
|
+
Rest.session_cb = lambda{|http|self.http_parameters = http}
|
118
134
|
# declare and parse global options
|
119
|
-
init_global_options
|
135
|
+
init_global_options
|
120
136
|
# the Config plugin adds the @preset parser, so declare before TransferAgent which may use it
|
121
|
-
@plugin_env[:config]=Plugins::Config.new(@plugin_env, gem: GEM_NAME, name: PROGRAM_NAME, help: DOC_URL, version: Aspera::Cli::VERSION)
|
137
|
+
@plugin_env[:config] = Plugins::Config.new(@plugin_env, gem: GEM_NAME, name: PROGRAM_NAME, help: DOC_URL, version: Aspera::Cli::VERSION)
|
122
138
|
# the TransferAgent plugin may use the @preset parser
|
123
|
-
@plugin_env[:transfer]=TransferAgent.new(@plugin_env[:options],@plugin_env[:config])
|
139
|
+
@plugin_env[:transfer] = TransferAgent.new(@plugin_env[:options],@plugin_env[:config])
|
124
140
|
# data persistency
|
125
|
-
@plugin_env[:persistency]=PersistencyFolder.new(File.join(@plugin_env[:config].main_folder,'persist_store'))
|
141
|
+
@plugin_env[:persistency] = PersistencyFolder.new(File.join(@plugin_env[:config].main_folder,'persist_store'))
|
126
142
|
Log.log.debug('plugin env created'.red)
|
127
|
-
Oauth.persist_mgr
|
128
|
-
Fasp::Parameters.file_list_folder=File.join(@plugin_env[:config].main_folder,'filelists')
|
129
|
-
Aspera::RestErrorAnalyzer.instance.log_file=File.join(@plugin_env[:config].main_folder,'rest_exceptions.log')
|
143
|
+
Oauth.persist_mgr = @plugin_env[:persistency] if @option_cache_tokens
|
144
|
+
Fasp::Parameters.file_list_folder = File.join(@plugin_env[:config].main_folder,'filelists')
|
145
|
+
Aspera::RestErrorAnalyzer.instance.log_file = File.join(@plugin_env[:config].main_folder,'rest_exceptions.log')
|
130
146
|
# register aspera REST call error handlers
|
131
147
|
Aspera::RestErrorsAspera.register_handlers
|
132
148
|
# set banner when all environment is created so that additional extended value modifiers are known, e.g. @preset
|
133
|
-
@opt_mgr.parser.banner=app_banner
|
149
|
+
@opt_mgr.parser.banner = app_banner
|
134
150
|
end
|
135
151
|
|
136
152
|
def app_banner
|
153
|
+
t=' '*8
|
137
154
|
return <<~END_OF_BANNER
|
138
155
|
NAME
|
139
|
-
|
156
|
+
#{t}#{PROGRAM_NAME} -- a command line tool for Aspera Applications (v#{Aspera::Cli::VERSION})
|
140
157
|
|
141
158
|
SYNOPSIS
|
142
|
-
|
159
|
+
#{t}#{PROGRAM_NAME} COMMANDS [OPTIONS] [ARGS]
|
143
160
|
|
144
161
|
DESCRIPTION
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
162
|
+
#{t}Use Aspera application to perform operations on command line.
|
163
|
+
#{t}Documentation and examples: #{GEM_URL}
|
164
|
+
#{t}execute: #{PROGRAM_NAME} conf doc
|
165
|
+
#{t}or visit: #{DOC_URL}
|
166
|
+
#{t}source repo: #{SRC_URL}
|
150
167
|
|
151
168
|
ENVIRONMENT VARIABLES
|
152
|
-
|
153
|
-
|
169
|
+
#{t}#{@plugin_env[:config].conf_dir_env_var} config folder, default: $HOME/#{Plugins::Config::ASPERA_HOME_FOLDER_NAME}/#{PROGRAM_NAME}
|
170
|
+
#{t}Any option can be set as an environment variable, refer to the manual
|
154
171
|
|
155
172
|
COMMANDS
|
156
|
-
|
157
|
-
|
173
|
+
#{t}To list first level commands, execute: #{PROGRAM_NAME}
|
174
|
+
#{t}Note that commands can be written shortened (provided it is unique).
|
158
175
|
|
159
176
|
OPTIONS
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
177
|
+
#{t}Options begin with a '-' (minus), and value is provided on command line.
|
178
|
+
#{t}Special values are supported beginning with special prefix @pfx:, where pfx is one of:
|
179
|
+
#{t}#{ExtendedValue.instance.modifiers.map(&:to_s).join(', ')}
|
180
|
+
#{t}Dates format is 'DD-MM-YY HH:MM:SS', or 'now' or '-<num>h'
|
164
181
|
|
165
182
|
ARGS
|
166
|
-
|
183
|
+
#{t}Some commands require mandatory arguments, e.g. a path.
|
167
184
|
END_OF_BANNER
|
168
185
|
end
|
169
186
|
|
170
187
|
# define header for manual
|
171
188
|
def init_global_options
|
172
189
|
Log.log.debug('init_global_options')
|
173
|
-
@opt_mgr.add_opt_switch(:help,'-h','Show this message.') { @option_help=true }
|
174
|
-
@opt_mgr.add_opt_switch(:bash_comp,'generate bash completion for command') { @bash_completion=true }
|
175
|
-
@opt_mgr.add_opt_switch(:show_config, 'Display parameters used for the provided action.') { @option_show_config=true }
|
176
|
-
@opt_mgr.add_opt_switch(:rest_debug,'-r','more debug for HTTP calls') { @option_rest_debug=true }
|
190
|
+
@opt_mgr.add_opt_switch(:help,'-h','Show this message.') { @option_help = true }
|
191
|
+
@opt_mgr.add_opt_switch(:bash_comp,'generate bash completion for command') { @bash_completion = true }
|
192
|
+
@opt_mgr.add_opt_switch(:show_config, 'Display parameters used for the provided action.') { @option_show_config = true }
|
193
|
+
@opt_mgr.add_opt_switch(:rest_debug,'-r','more debug for HTTP calls') { @option_rest_debug = true }
|
177
194
|
@opt_mgr.add_opt_switch(:version,'-v','display version') { @plugin_env[:formater].display_message(:data,Aspera::Cli::VERSION);Process.exit(0) }
|
178
|
-
@opt_mgr.add_opt_switch(:warnings,'-w','check for language warnings') { $VERBOSE=true }
|
195
|
+
@opt_mgr.add_opt_switch(:warnings,'-w','check for language warnings') { $VERBOSE = true }
|
179
196
|
# handler must be set before declaration
|
180
197
|
@opt_mgr.set_obj_attr(:log_level,Log.instance,:level)
|
181
198
|
@opt_mgr.set_obj_attr(:logger,Log.instance,:logger_type)
|
182
199
|
@opt_mgr.set_obj_attr(:insecure,self,:option_insecure,:no)
|
183
200
|
@opt_mgr.set_obj_attr(:ui,self,:option_ui)
|
184
201
|
@opt_mgr.set_obj_attr(:http_options,self,:option_http_options)
|
185
|
-
@opt_mgr.set_obj_attr(:log_secrets,
|
202
|
+
@opt_mgr.set_obj_attr(:log_secrets,SecretHider,:log_secrets)
|
186
203
|
@opt_mgr.set_obj_attr(:cache_tokens,self,:option_cache_tokens)
|
187
204
|
@opt_mgr.add_opt_list(:ui,OpenApplication.user_interfaces,'method to start browser')
|
188
205
|
@opt_mgr.add_opt_list(:log_level,Log.levels,'Log level')
|
@@ -204,19 +221,19 @@ module Aspera
|
|
204
221
|
# also loads the plugin options, and default values from conf file
|
205
222
|
# @param plugin_name_sym : symbol for plugin name
|
206
223
|
def get_plugin_instance_with_options(plugin_name_sym,env=nil)
|
207
|
-
env
|
224
|
+
env ||= @plugin_env
|
208
225
|
Log.log.debug("get_plugin_instance_with_options(#{plugin_name_sym})")
|
209
226
|
require @plugin_env[:config].plugins[plugin_name_sym][:require_stanza]
|
210
227
|
# load default params only if no param already loaded before plugin instanciation
|
211
228
|
env[:config].add_plugin_default_preset(plugin_name_sym)
|
212
|
-
command_plugin=Plugins::Config.plugin_class(plugin_name_sym).new(env)
|
229
|
+
command_plugin = Plugins::Config.plugin_class(plugin_name_sym).new(env)
|
213
230
|
Log.log.debug("got #{command_plugin.class}")
|
214
231
|
# TODO: check that ancestor is Plugin?
|
215
232
|
return command_plugin
|
216
233
|
end
|
217
234
|
|
218
235
|
def generate_bash_completion
|
219
|
-
if @opt_mgr.get_next_argument(''
|
236
|
+
if @opt_mgr.get_next_argument('',expected: :multiple,mandatory: false).nil?
|
220
237
|
@plugin_env[:config].plugins.keys.each{|p|puts p.to_s}
|
221
238
|
else
|
222
239
|
Log.log.warn('only first level completion so far')
|
@@ -233,10 +250,10 @@ module Aspera
|
|
233
250
|
@plugin_env[:config].plugins.keys.each do |plugin_name_sym|
|
234
251
|
next if plugin_name_sym.eql?(Plugins::Config::CONF_PLUGIN_SYM)
|
235
252
|
# override main option parser with a brand new, to avoid having global options
|
236
|
-
plugin_env
|
237
|
-
plugin_env[:man_only]=true
|
238
|
-
plugin_env[:options]=Manager.new(PROGRAM_NAME)
|
239
|
-
plugin_env[:options].parser.banner='' # remove default banner
|
253
|
+
plugin_env = @plugin_env.clone
|
254
|
+
plugin_env[:man_only] = true
|
255
|
+
plugin_env[:options] = Manager.new(PROGRAM_NAME)
|
256
|
+
plugin_env[:options].parser.banner = '' # remove default banner
|
240
257
|
get_plugin_instance_with_options(plugin_name_sym,plugin_env)
|
241
258
|
# display generated help for plugin options
|
242
259
|
@plugin_env[:formater].display_message(:error,plugin_env[:options].parser.help)
|
@@ -250,12 +267,12 @@ module Aspera
|
|
250
267
|
# early debug for parser
|
251
268
|
# Note: does not accept shortcuts
|
252
269
|
def early_debug_setup(argv)
|
253
|
-
Log.instance.program_name=PROGRAM_NAME
|
270
|
+
Aspera::Log.instance.program_name = PROGRAM_NAME
|
254
271
|
argv.each do |arg|
|
255
272
|
case arg
|
256
273
|
when '--' then break
|
257
|
-
when /^--log-level=(.*)/ then Log.instance.level = Regexp.last_match(1).to_sym
|
258
|
-
when /^--logger=(.*)/ then Log.instance.logger_type=Regexp.last_match(1).to_sym
|
274
|
+
when /^--log-level=(.*)/ then Aspera::Log.instance.level = Regexp.last_match(1).to_sym
|
275
|
+
when /^--logger=(.*)/ then Aspera::Log.instance.logger_type = Regexp.last_match(1).to_sym
|
259
276
|
end
|
260
277
|
end
|
261
278
|
end
|
@@ -266,9 +283,9 @@ module Aspera
|
|
266
283
|
def process_command_line
|
267
284
|
Log.log.debug('process_command_line')
|
268
285
|
# catch exception information , if any
|
269
|
-
exception_info=nil
|
286
|
+
exception_info = nil
|
270
287
|
# false if command shall not be executed ("once_only")
|
271
|
-
execute_command=true
|
288
|
+
execute_command = true
|
272
289
|
begin
|
273
290
|
# find plugins, shall be after parse! ?
|
274
291
|
@plugin_env[:config].add_plugins_from_lookup_folders
|
@@ -276,23 +293,23 @@ module Aspera
|
|
276
293
|
exit_with_usage(true) if @option_help && @opt_mgr.command_or_arg_empty?
|
277
294
|
generate_bash_completion if @bash_completion
|
278
295
|
@plugin_env[:config].periodic_check_newer_gem_version
|
279
|
-
command_sym=
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
296
|
+
command_sym =
|
297
|
+
if @option_show_config && @opt_mgr.command_or_arg_empty?
|
298
|
+
Plugins::Config::CONF_PLUGIN_SYM
|
299
|
+
else
|
300
|
+
@opt_mgr.get_next_command(@plugin_env[:config].plugins.keys.dup.unshift(:help))
|
301
|
+
end
|
285
302
|
# command will not be executed, but we need manual
|
286
|
-
@opt_mgr.fail_on_missing_mandatory=false if @option_help || @option_show_config
|
303
|
+
@opt_mgr.fail_on_missing_mandatory = false if @option_help || @option_show_config
|
287
304
|
# main plugin is not dynamically instanciated
|
288
305
|
case command_sym
|
289
306
|
when :help
|
290
307
|
exit_with_usage(true)
|
291
308
|
when Plugins::Config::CONF_PLUGIN_SYM
|
292
|
-
command_plugin
|
309
|
+
command_plugin = @plugin_env[:config]
|
293
310
|
else
|
294
311
|
# get plugin, set options, etc
|
295
|
-
command_plugin=get_plugin_instance_with_options(command_sym)
|
312
|
+
command_plugin = get_plugin_instance_with_options(command_sym)
|
296
313
|
# parse plugin specific options
|
297
314
|
@opt_mgr.parse_options!
|
298
315
|
end
|
@@ -300,17 +317,17 @@ module Aspera
|
|
300
317
|
exit_with_usage(false) if @option_help
|
301
318
|
if @option_show_config
|
302
319
|
@plugin_env[:formater].display_results({type: :single_object,data: @opt_mgr.declared_options(only_defined: true)})
|
303
|
-
execute_command=false
|
320
|
+
execute_command = false
|
304
321
|
end
|
305
322
|
# locking for single execution (only after "per plugin" option, in case lock port is there)
|
306
|
-
lock_port
|
323
|
+
lock_port = @opt_mgr.get_option(:lock_port)
|
307
324
|
if !lock_port.nil?
|
308
325
|
begin
|
309
326
|
# no need to close later, will be freed on process exit. must save in member else it is garbage collected
|
310
327
|
Log.log.debug("Opening lock port #{lock_port.to_i}")
|
311
|
-
@tcp_server=TCPServer.new('127.0.0.1',lock_port.to_i)
|
328
|
+
@tcp_server = TCPServer.new('127.0.0.1',lock_port.to_i)
|
312
329
|
rescue StandardError => e
|
313
|
-
execute_command=false
|
330
|
+
execute_command = false
|
314
331
|
Log.log.warn("Another instance is already running (#{e.message}).")
|
315
332
|
end
|
316
333
|
end
|
@@ -318,23 +335,26 @@ module Aspera
|
|
318
335
|
@plugin_env[:formater].display_results(command_plugin.execute_action) if execute_command
|
319
336
|
# finish
|
320
337
|
@plugin_env[:transfer].shutdown
|
321
|
-
rescue
|
322
|
-
rescue
|
323
|
-
rescue
|
324
|
-
rescue
|
325
|
-
rescue
|
326
|
-
rescue
|
327
|
-
rescue
|
328
|
-
rescue
|
338
|
+
rescue Net::SSH::AuthenticationFailed => e; exception_info = {e: e,t: 'SSH',security: true}
|
339
|
+
rescue CliBadArgument => e; exception_info = {e: e,t: 'Argument',usage: true}
|
340
|
+
rescue CliNoSuchId => e; exception_info = {e: e,t: 'Identifier'}
|
341
|
+
rescue CliError => e; exception_info = {e: e,t: 'Tool',usage: true}
|
342
|
+
rescue Fasp::Error => e; exception_info = {e: e,t: 'FASP(ascp)'}
|
343
|
+
rescue Aspera::RestCallError => e; exception_info = {e: e,t: 'Rest'}
|
344
|
+
rescue SocketError => e; exception_info = {e: e,t: 'Network'}
|
345
|
+
rescue StandardError => e; exception_info = {e: e,t: 'Other',debug: true}
|
346
|
+
rescue Interrupt => e; exception_info = {e: e,t: 'Interruption',debug: true}
|
329
347
|
end
|
330
348
|
# cleanup file list files
|
331
349
|
TempFileManager.instance.cleanup
|
332
350
|
# 1- processing of error condition
|
333
351
|
unless exception_info.nil?
|
352
|
+
Log.log.warn(exception_info[:e].message) if Aspera::Log.instance.logger_type.eql?(:syslog) && exception_info[:security]
|
334
353
|
@plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} #{exception_info[:t]}: #{exception_info[:e].message}")
|
335
354
|
@plugin_env[:formater].display_message(:error,'Use option -h to get help.') if exception_info[:usage]
|
336
355
|
if exception_info[:e].is_a?(Fasp::Error) && exception_info[:e].message.eql?('Remote host is not who we expected')
|
337
|
-
@plugin_env[:formater].display_message(:error,"For this specific error, refer to:\n
|
356
|
+
@plugin_env[:formater].display_message(:error,"For this specific error, refer to:\n"\
|
357
|
+
"#{SRC_URL}#error-remote-host-is-not-who-we-expected\nAdd this to arguments:\n--ts=@json:'{\"sshfp\":null}'")
|
338
358
|
end
|
339
359
|
end
|
340
360
|
# 2- processing of command not processed (due to exception or bad command line)
|
@@ -342,7 +362,7 @@ module Aspera
|
|
342
362
|
@opt_mgr.final_errors.each do |msg|
|
343
363
|
@plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} Argument: #{msg}")
|
344
364
|
# add code as exception if there is not already an error
|
345
|
-
exception_info={e: Exception.new(msg),t: 'UnusedArg'} if exception_info.nil?
|
365
|
+
exception_info = {e: Exception.new(msg),t: 'UnusedArg'} if exception_info.nil?
|
346
366
|
end
|
347
367
|
end
|
348
368
|
# 3- in case of error, fail the process status
|