aspera-cli 4.5.0 → 4.8.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 +1 -0
- data/README.md +1894 -1574
- data/bin/ascli +21 -1
- data/bin/asession +38 -34
- data/docs/test_env.conf +14 -3
- data/examples/aoc.rb +17 -15
- data/examples/dascli +26 -0
- data/examples/faspex4.rb +42 -35
- data/examples/proxy.pac +1 -1
- data/examples/transfer.rb +38 -37
- data/lib/aspera/aoc.rb +245 -205
- data/lib/aspera/ascmd.rb +111 -90
- data/lib/aspera/ats_api.rb +16 -14
- data/lib/aspera/cli/basic_auth_plugin.rb +19 -18
- data/lib/aspera/cli/extended_value.rb +50 -39
- data/lib/aspera/cli/formater.rb +161 -135
- data/lib/aspera/cli/info.rb +18 -0
- data/lib/aspera/cli/listener/line_dump.rb +4 -2
- data/lib/aspera/cli/listener/logger.rb +3 -1
- data/lib/aspera/cli/listener/progress.rb +20 -21
- data/lib/aspera/cli/listener/progress_multi.rb +29 -31
- data/lib/aspera/cli/main.rb +194 -183
- data/lib/aspera/cli/manager.rb +213 -206
- data/lib/aspera/cli/plugin.rb +71 -49
- data/lib/aspera/cli/plugins/alee.rb +8 -7
- data/lib/aspera/cli/plugins/aoc.rb +675 -558
- data/lib/aspera/cli/plugins/ats.rb +116 -109
- data/lib/aspera/cli/plugins/bss.rb +35 -34
- data/lib/aspera/cli/plugins/config.rb +722 -542
- data/lib/aspera/cli/plugins/console.rb +28 -22
- data/lib/aspera/cli/plugins/cos.rb +28 -37
- data/lib/aspera/cli/plugins/faspex.rb +281 -227
- data/lib/aspera/cli/plugins/faspex5.rb +129 -84
- data/lib/aspera/cli/plugins/node.rb +426 -232
- data/lib/aspera/cli/plugins/orchestrator.rb +106 -98
- data/lib/aspera/cli/plugins/preview.rb +196 -191
- data/lib/aspera/cli/plugins/server.rb +131 -126
- data/lib/aspera/cli/plugins/shares.rb +49 -36
- data/lib/aspera/cli/plugins/sync.rb +27 -28
- data/lib/aspera/cli/transfer_agent.rb +84 -79
- data/lib/aspera/cli/version.rb +3 -1
- data/lib/aspera/colors.rb +37 -28
- data/lib/aspera/command_line_builder.rb +84 -63
- data/lib/aspera/cos_node.rb +68 -34
- data/lib/aspera/data_repository.rb +4 -2
- data/lib/aspera/environment.rb +61 -46
- data/lib/aspera/fasp/agent_base.rb +36 -31
- data/lib/aspera/fasp/agent_connect.rb +44 -37
- data/lib/aspera/fasp/agent_direct.rb +101 -104
- data/lib/aspera/fasp/agent_httpgw.rb +91 -90
- data/lib/aspera/fasp/agent_node.rb +36 -33
- data/lib/aspera/fasp/agent_trsdk.rb +28 -31
- data/lib/aspera/fasp/error.rb +3 -1
- data/lib/aspera/fasp/error_info.rb +81 -54
- data/lib/aspera/fasp/installation.rb +171 -151
- data/lib/aspera/fasp/listener.rb +2 -0
- data/lib/aspera/fasp/parameters.rb +105 -111
- data/lib/aspera/fasp/parameters.yaml +305 -249
- data/lib/aspera/fasp/resume_policy.rb +20 -20
- data/lib/aspera/fasp/transfer_spec.rb +27 -0
- data/lib/aspera/fasp/uri.rb +31 -29
- data/lib/aspera/faspex_gw.rb +95 -118
- data/lib/aspera/hash_ext.rb +12 -13
- data/lib/aspera/id_generator.rb +11 -9
- data/lib/aspera/keychain/encrypted_hash.rb +73 -57
- data/lib/aspera/keychain/macos_security.rb +27 -29
- data/lib/aspera/log.rb +40 -39
- data/lib/aspera/nagios.rb +24 -22
- data/lib/aspera/node.rb +38 -30
- data/lib/aspera/oauth.rb +217 -248
- data/lib/aspera/open_application.rb +9 -7
- data/lib/aspera/persistency_action_once.rb +15 -14
- data/lib/aspera/persistency_folder.rb +15 -18
- data/lib/aspera/preview/file_types.rb +266 -270
- data/lib/aspera/preview/generator.rb +94 -92
- data/lib/aspera/preview/image_error.png +0 -0
- data/lib/aspera/preview/options.rb +20 -17
- data/lib/aspera/preview/utils.rb +99 -102
- data/lib/aspera/preview/video_error.png +0 -0
- data/lib/aspera/{proxy_auto_config.erb.js → proxy_auto_config.js} +23 -31
- data/lib/aspera/proxy_auto_config.rb +114 -21
- data/lib/aspera/rest.rb +144 -142
- data/lib/aspera/rest_call_error.rb +3 -2
- data/lib/aspera/rest_error_analyzer.rb +31 -31
- data/lib/aspera/rest_errors_aspera.rb +18 -16
- data/lib/aspera/secret_hider.rb +68 -0
- data/lib/aspera/ssh.rb +20 -16
- data/lib/aspera/sync.rb +57 -54
- data/lib/aspera/temp_file_manager.rb +20 -14
- data/lib/aspera/timer_limiter.rb +10 -8
- data/lib/aspera/uri_reader.rb +14 -15
- data/lib/aspera/web_auth.rb +85 -80
- data.tar.gz.sig +0 -0
- metadata +169 -40
- metadata.gz.sig +2 -0
- data/bin/dascli +0 -13
- data/docs/Makefile +0 -63
- data/docs/README.erb.md +0 -4221
- data/docs/README.md +0 -13
- data/docs/diagrams.txt +0 -49
- data/docs/doc_tools.rb +0 -58
- data/lib/aspera/cli/plugins/shares2.rb +0 -114
- data/lib/aspera/fasp/default.rb +0 -17
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'aspera/log'
|
2
4
|
require 'aspera/command_line_builder'
|
3
5
|
require 'aspera/temp_file_manager'
|
@@ -5,7 +7,6 @@ require 'securerandom'
|
|
5
7
|
require 'base64'
|
6
8
|
require 'json'
|
7
9
|
require 'yaml'
|
8
|
-
require 'securerandom'
|
9
10
|
require 'fileutils'
|
10
11
|
require 'openssl'
|
11
12
|
|
@@ -13,108 +14,119 @@ module Aspera
|
|
13
14
|
module Fasp
|
14
15
|
# translate transfer specification to ascp parameter list
|
15
16
|
class Parameters
|
16
|
-
private
|
17
|
-
# Temp folder for file lists, must contain only file lists
|
18
|
-
# because of garbage collection takes any file there
|
19
|
-
# this could be refined, as , for instance, on macos, temp folder is already user specific
|
20
|
-
@@file_list_folder=TempFileManager.instance.new_file_path_global('asession_filelists')
|
21
|
-
@@param_description_cache=nil
|
22
|
-
# @return normaiwed description of transfer spec parameters
|
23
|
-
def self.description
|
24
|
-
return @@param_description_cache unless @@param_description_cache.nil?
|
25
|
-
# config file in same folder with same name as this source
|
26
|
-
@@param_description_cache=YAML.load_file("#{__FILE__[0..-3]}yaml")
|
27
|
-
Aspera::CommandLineBuilder.normalize_description(@@param_description_cache)
|
28
|
-
end
|
29
|
-
|
30
17
|
# Agents shown in manual for parameters (sub list)
|
31
|
-
SUPPORTED_AGENTS=[
|
18
|
+
SUPPORTED_AGENTS = %i[direct node connect].freeze
|
32
19
|
# Short names of columns in manual
|
33
|
-
SUPPORTED_AGENTS_SHORT=SUPPORTED_AGENTS.map{|a|a.to_s[0].to_sym}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
when :envvar; 'env:'+i[:clvarname]
|
48
|
-
when :opt_without_arg,:opt_with_arg; i[:option_switch]
|
49
|
-
else ''
|
20
|
+
SUPPORTED_AGENTS_SHORT = SUPPORTED_AGENTS.map{|a|a.to_s[0].to_sym}
|
21
|
+
|
22
|
+
class << self
|
23
|
+
# Temp folder for file lists, must contain only file lists
|
24
|
+
# because of garbage collection takes any file there
|
25
|
+
# this could be refined, as , for instance, on macos, temp folder is already user specific
|
26
|
+
@file_list_folder = TempFileManager.instance.new_file_path_global('asession_filelists')
|
27
|
+
@param_description_cache = nil
|
28
|
+
# @return normalized description of transfer spec parameters, direct from yaml
|
29
|
+
def description
|
30
|
+
if @param_description_cache.nil?
|
31
|
+
# config file in same folder with same name as this source
|
32
|
+
description_from_yaml=YAML.load_file("#{__FILE__[0..-3]}yaml")
|
33
|
+
@param_description_cache = Aspera::CommandLineBuilder.normalize_description(description_from_yaml)
|
50
34
|
end
|
51
|
-
|
52
|
-
|
35
|
+
return @param_description_cache
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return a table suitable to display in manual
|
39
|
+
def man_table
|
40
|
+
result = []
|
41
|
+
description.each do |k,i|
|
42
|
+
param = {name: k, type: [i[:accepted_types]].flatten.join(','),description: i[:desc]}
|
43
|
+
SUPPORTED_AGENTS.each do |a|
|
44
|
+
param[a.to_s[0].to_sym] = i[:tragents].nil? || i[:tragents].include?(a) ? 'Y' : ''
|
45
|
+
end
|
46
|
+
# only keep lines that are usable in supported agents
|
47
|
+
next if SUPPORTED_AGENTS_SHORT.inject(true){|m,j|m && param[j].empty?}
|
48
|
+
param[:cli] =
|
49
|
+
case i[:cltype]
|
50
|
+
when :envvar then 'env:' + i[:clvarname]
|
51
|
+
when :opt_without_arg,:opt_with_arg then i[:clswitch]
|
52
|
+
else ''
|
53
|
+
end
|
54
|
+
if i.has_key?(:enum)
|
55
|
+
param[:description] += "\nAllowed values: #{i[:enum].join(', ')}"
|
56
|
+
end
|
57
|
+
result.push(param)
|
53
58
|
end
|
54
|
-
result
|
59
|
+
return result
|
55
60
|
end
|
56
|
-
return result
|
57
|
-
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
v.tr('-','')
|
62
|
-
end
|
62
|
+
# special encoding methods used in YAML (key: :clconvert)
|
63
|
+
def clconv_remove_hyphen(v); v.tr('-',''); end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
Base64.strict_encode64(v)
|
67
|
-
end
|
65
|
+
# special encoding methods used in YAML (key: :clconvert)
|
66
|
+
def clconv_json64(v); Base64.strict_encode64(JSON.generate(v)); end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
Base64.strict_encode64(JSON.generate(v))
|
72
|
-
end
|
68
|
+
# special encoding methods used in YAML (key: :clconvert)
|
69
|
+
def clconv_base64(v); Base64.strict_encode64(v); end
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
def ts_has_file_list(ts)
|
72
|
+
ts.has_key?('EX_ascp_args') && ts['EX_ascp_args'].is_a?(Array) && ['--file-list','--file-pair-list'].any?{|i|ts['EX_ascp_args'].include?(i)}
|
73
|
+
end
|
77
74
|
|
75
|
+
def ts_to_env_args(transfer_spec,options)
|
76
|
+
return Parameters.new(transfer_spec,options).ascp_args
|
77
|
+
end
|
78
|
+
|
79
|
+
# temp file list files are created here
|
80
|
+
def file_list_folder=(v)
|
81
|
+
@file_list_folder = v
|
82
|
+
return if @file_list_folder.nil?
|
83
|
+
FileUtils.mkdir_p(@file_list_folder)
|
84
|
+
TempFileManager.instance.cleanup_expired(@file_list_folder)
|
85
|
+
end
|
86
|
+
|
87
|
+
# static methods
|
88
|
+
attr_reader :file_list_folder
|
89
|
+
end # self
|
90
|
+
|
91
|
+
# @param options [Hash] key: :wss: bool
|
78
92
|
def initialize(job_spec,options)
|
79
|
-
@job_spec=job_spec
|
80
|
-
@options=options
|
81
|
-
@builder=Aspera::CommandLineBuilder.new(@job_spec,self.class.description)
|
93
|
+
@job_spec = job_spec
|
94
|
+
@options = options
|
95
|
+
@builder = Aspera::CommandLineBuilder.new(@job_spec,self.class.description)
|
82
96
|
Log.log.debug("agent options: #{@options}")
|
83
97
|
end
|
84
98
|
|
85
|
-
public
|
86
|
-
|
87
99
|
# translate transfer spec to env vars and command line arguments for ascp
|
88
100
|
# NOTE: parameters starting with "EX_" (extended) are not standard
|
89
|
-
def ascp_args
|
90
|
-
env_args={
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
101
|
+
def ascp_args
|
102
|
+
env_args = {
|
103
|
+
args: [],
|
104
|
+
env: {},
|
105
|
+
ascp_version: :ascp
|
94
106
|
}
|
95
107
|
# some ssh credentials are required to avoid interactive password input
|
96
|
-
if !@job_spec.has_key?('remote_password')
|
97
|
-
!@job_spec.has_key?('ssh_private_key')
|
98
|
-
!@job_spec.has_key?('EX_ssh_key_paths')
|
99
|
-
raise Fasp::Error
|
108
|
+
if !@job_spec.has_key?('remote_password') &&
|
109
|
+
!@job_spec.has_key?('ssh_private_key') &&
|
110
|
+
!@job_spec.has_key?('EX_ssh_key_paths')
|
111
|
+
raise Fasp::Error, 'required: password or ssh key (value or path)'
|
100
112
|
end
|
101
113
|
|
102
114
|
# special cases
|
103
|
-
@job_spec.delete('source_root') if @job_spec.has_key?('source_root')
|
115
|
+
@job_spec.delete('source_root') if @job_spec.has_key?('source_root') && @job_spec['source_root'].empty?
|
104
116
|
|
105
117
|
# use web socket session initiation ?
|
106
|
-
if @builder.process_param('wss_enabled',:get_value)
|
118
|
+
if @builder.process_param('wss_enabled',:get_value) && (@options[:wss] || !@job_spec.has_key?('fasp_port'))
|
107
119
|
# by default use web socket session if available, unless removed by user
|
108
120
|
@builder.add_command_line_options(['--ws-connect'])
|
109
121
|
# TODO: option to give order ssh,ws (legacy http is implied bu ssh)
|
110
122
|
# quel bordel:
|
111
|
-
@job_spec['ssh_port']
|
123
|
+
@job_spec['ssh_port'] = @builder.process_param('wss_port',:get_value)
|
112
124
|
@job_spec.delete('fasp_port')
|
113
125
|
@job_spec.delete('EX_ssh_key_paths')
|
114
126
|
@job_spec.delete('sshfp')
|
115
|
-
# set
|
116
|
-
@job_spec['EX_ssh_key_paths']=[OpenSSL::X509::DEFAULT_CERT_FILE]
|
117
|
-
Log.log.debug(
|
127
|
+
# set location for CA bundle to be the one of Ruby, see env var SSL_CERT_FILE / SSL_CERT_DIR
|
128
|
+
@job_spec['EX_ssh_key_paths'] = [OpenSSL::X509::DEFAULT_CERT_FILE]
|
129
|
+
Log.log.debug('CA certs: EX_ssh_key_paths <- DEFAULT_CERT_FILE from openssl')
|
118
130
|
else
|
119
131
|
# remove unused parameter (avoid warning)
|
120
132
|
@job_spec.delete('wss_port')
|
@@ -132,42 +144,42 @@ module Aspera
|
|
132
144
|
@builder.add_command_line_options(['--dest64'])
|
133
145
|
end
|
134
146
|
# paths is mandatory, unless ...
|
135
|
-
file_list_provided=self.class.ts_has_file_list(@job_spec)
|
136
|
-
@builder.params_definition['paths'][:mandatory]
|
137
|
-
paths_array
|
138
|
-
if file_list_provided
|
139
|
-
Log.log.warn(
|
140
|
-
paths_array=nil
|
147
|
+
file_list_provided = self.class.ts_has_file_list(@job_spec)
|
148
|
+
(@builder.params_definition['paths'][:mandatory] = !@job_spec.has_key?('keepalive')) && !file_list_provided
|
149
|
+
paths_array = @builder.process_param('paths',:get_value)
|
150
|
+
if file_list_provided && !paths_array.nil?
|
151
|
+
Log.log.warn('file list provided both in transfer spec and ascp file list. Keeping file list only.')
|
152
|
+
paths_array = nil
|
141
153
|
end
|
142
|
-
if !
|
154
|
+
if !paths_array.nil?
|
143
155
|
# it's an array
|
144
|
-
raise
|
156
|
+
raise 'paths is empty in transfer spec' if paths_array.empty?
|
145
157
|
# use file list if there is storage defined for it.
|
146
|
-
if
|
158
|
+
if self.class.file_list_folder.nil?
|
147
159
|
# not safe for special characters ? (maybe not, depends on OS)
|
148
|
-
Log.log.debug(
|
160
|
+
Log.log.debug('placing source file list on command line (no file list file)')
|
149
161
|
@builder.add_command_line_options(paths_array.map{|i|i['source']})
|
150
162
|
else
|
151
|
-
file_list_file
|
163
|
+
file_list_file = @builder.process_param('EX_file_list',:get_value)
|
152
164
|
if !file_list_file.nil?
|
153
|
-
option='--file-list'
|
165
|
+
option = '--file-list'
|
154
166
|
else
|
155
|
-
file_list_file
|
167
|
+
file_list_file = @builder.process_param('EX_file_pair_list',:get_value)
|
156
168
|
if !file_list_file.nil?
|
157
|
-
option='--file-pair-list'
|
169
|
+
option = '--file-pair-list'
|
158
170
|
else
|
159
171
|
# safer option: file list
|
160
172
|
# if there is destination in paths, then use filepairlist
|
161
173
|
# TODO: well, we test only the first one, but anyway it shall be consistent
|
162
174
|
if paths_array.first.has_key?('destination')
|
163
|
-
option='--file-pair-list'
|
164
|
-
lines=paths_array.
|
175
|
+
option = '--file-pair-list'
|
176
|
+
lines = paths_array.each_with_object([]){|e,m|m.push(e['source'],e['destination']);}
|
165
177
|
else
|
166
|
-
option='--file-list'
|
167
|
-
lines=paths_array.map{|i|i['source']}
|
178
|
+
option = '--file-list'
|
179
|
+
lines = paths_array.map{|i|i['source']}
|
168
180
|
end
|
169
|
-
file_list_file=Aspera::TempFileManager.instance.new_file_path_in_folder(
|
170
|
-
File.
|
181
|
+
file_list_file = Aspera::TempFileManager.instance.new_file_path_in_folder(self.class.file_list_folder)
|
182
|
+
File.write(file_list_file, lines.join("\n"))
|
171
183
|
Log.log.debug{"#{option}=\n#{File.read(file_list_file)}".red}
|
172
184
|
end
|
173
185
|
end
|
@@ -187,24 +199,6 @@ module Aspera
|
|
187
199
|
|
188
200
|
return env_args
|
189
201
|
end
|
190
|
-
|
191
|
-
# temp file list files are created here
|
192
|
-
def self.file_list_folder=(v)
|
193
|
-
@@file_list_folder=v
|
194
|
-
if !@@file_list_folder.nil?
|
195
|
-
FileUtils.mkdir_p(@@file_list_folder)
|
196
|
-
TempFileManager.instance.cleanup_expired(@@file_list_folder)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# static methods
|
201
|
-
class << self
|
202
|
-
def file_list_folder; @@file_list_folder;end
|
203
|
-
|
204
|
-
def ts_to_env_args(transfer_spec,options)
|
205
|
-
return Parameters.new(transfer_spec,options).ascp_args()
|
206
|
-
end
|
207
|
-
end
|
208
202
|
end # Parameters
|
209
203
|
end
|
210
204
|
end
|