aspera-cli 4.7.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 +844 -861
- data/bin/ascli +20 -1
- data/bin/asession +37 -34
- data/docs/test_env.conf +11 -3
- data/examples/aoc.rb +13 -12
- data/examples/dascli +26 -0
- data/examples/faspex4.rb +34 -29
- data/examples/transfer.rb +30 -29
- data/lib/aspera/aoc.rb +151 -143
- data/lib/aspera/ascmd.rb +56 -45
- data/lib/aspera/ats_api.rb +6 -5
- data/lib/aspera/cli/basic_auth_plugin.rb +18 -16
- data/lib/aspera/cli/extended_value.rb +32 -30
- data/lib/aspera/cli/formater.rb +103 -111
- data/lib/aspera/cli/info.rb +2 -1
- 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 +106 -89
- data/lib/aspera/cli/manager.rb +96 -85
- data/lib/aspera/cli/plugin.rb +50 -32
- data/lib/aspera/cli/plugins/alee.rb +6 -5
- data/lib/aspera/cli/plugins/aoc.rb +521 -426
- 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 +483 -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 +201 -168
- data/lib/aspera/cli/plugins/faspex5.rb +109 -74
- data/lib/aspera/cli/plugins/node.rb +378 -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 +94 -93
- data/lib/aspera/cli/plugins/shares.rb +42 -28
- data/lib/aspera/cli/plugins/sync.rb +15 -14
- data/lib/aspera/cli/transfer_agent.rb +56 -52
- 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 +18 -8
- data/lib/aspera/fasp/agent_base.rb +26 -23
- 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 +122 -114
- data/lib/aspera/fasp/listener.rb +1 -0
- data/lib/aspera/fasp/parameters.rb +44 -41
- 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 +10 -12
- data/lib/aspera/id_generator.rb +8 -7
- data/lib/aspera/keychain/encrypted_hash.rb +60 -45
- data/lib/aspera/keychain/macos_security.rb +26 -24
- data/lib/aspera/log.rb +34 -38
- data/lib/aspera/nagios.rb +14 -13
- data/lib/aspera/node.rb +19 -19
- data/lib/aspera/oauth.rb +121 -101
- data/lib/aspera/open_application.rb +6 -5
- data/lib/aspera/persistency_action_once.rb +9 -8
- data/lib/aspera/persistency_folder.rb +10 -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 +25 -23
- data/lib/aspera/rest.rb +73 -74
- data/lib/aspera/rest_call_error.rb +1 -0
- data/lib/aspera/rest_error_analyzer.rb +11 -9
- data/lib/aspera/rest_errors_aspera.rb +5 -4
- data/lib/aspera/secret_hider.rb +68 -0
- data/lib/aspera/ssh.rb +12 -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 +11 -14
- data/lib/aspera/web_auth.rb +17 -15
- data.tar.gz.sig +0 -0
- metadata +117 -34
- metadata.gz.sig +2 -0
- data/bin/dascli +0 -13
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'English'
|
3
4
|
require 'singleton'
|
4
5
|
require 'aspera/log'
|
@@ -22,15 +23,15 @@ module Aspera
|
|
22
23
|
class Installation
|
23
24
|
include Singleton
|
24
25
|
# known product names
|
25
|
-
PRODUCT_CONNECT='Aspera Connect'
|
26
|
-
PRODUCT_CLI_V1='Aspera CLI'
|
27
|
-
PRODUCT_DRIVE='Aspera Drive'
|
28
|
-
PRODUCT_ENTSRV='Enterprise Server'
|
26
|
+
PRODUCT_CONNECT = 'Aspera Connect'
|
27
|
+
PRODUCT_CLI_V1 = 'Aspera CLI'
|
28
|
+
PRODUCT_DRIVE = 'Aspera Drive'
|
29
|
+
PRODUCT_ENTSRV = 'Enterprise Server'
|
29
30
|
# protobuf generated files from sdk
|
30
|
-
EXT_RUBY_PROTOBUF='_pb.rb'
|
31
|
-
RB_SDK_FOLDER='lib'
|
32
|
-
ONE_YEAR_SECONDS=365 * 24 * 60 * 60
|
33
|
-
DEFAULT_ASPERA_CONF
|
31
|
+
EXT_RUBY_PROTOBUF = '_pb.rb'
|
32
|
+
RB_SDK_FOLDER = 'lib'
|
33
|
+
ONE_YEAR_SECONDS = 365 * 24 * 60 * 60
|
34
|
+
DEFAULT_ASPERA_CONF = <<~END_OF_CONFIG_FILE
|
34
35
|
<?xml version='1.0' encoding='UTF-8'?>
|
35
36
|
<CONF version="2">
|
36
37
|
<default>
|
@@ -41,10 +42,12 @@ module Aspera
|
|
41
42
|
</default>
|
42
43
|
</CONF>
|
43
44
|
END_OF_CONFIG_FILE
|
44
|
-
|
45
|
+
DUMMY_CERT_INFO='/C=US/ST=California/L=Emeryville/O=Aspera Inc./OU=Corporate/CN=Aspera Inc./emailAddress=info@asperasoft.com'
|
46
|
+
private_constant :PRODUCT_CONNECT,:PRODUCT_CLI_V1,:PRODUCT_DRIVE,:PRODUCT_ENTSRV,:EXT_RUBY_PROTOBUF,:RB_SDK_FOLDER,
|
47
|
+
:ONE_YEAR_SECONDS,:DEFAULT_ASPERA_CONF,:DUMMY_CERT_INFO
|
45
48
|
# set ascp executable path
|
46
49
|
def ascp_path=(v)
|
47
|
-
@path_to_ascp=v
|
50
|
+
@path_to_ascp = v
|
48
51
|
end
|
49
52
|
|
50
53
|
def ascp_path
|
@@ -52,19 +55,19 @@ module Aspera
|
|
52
55
|
end
|
53
56
|
|
54
57
|
def sdk_ruby_folder
|
55
|
-
ruby_pb_folder=File.join(sdk_folder,RB_SDK_FOLDER)
|
58
|
+
ruby_pb_folder = File.join(sdk_folder,RB_SDK_FOLDER)
|
56
59
|
FileUtils.mkdir_p(ruby_pb_folder) unless Dir.exist?(ruby_pb_folder)
|
57
60
|
return ruby_pb_folder
|
58
61
|
end
|
59
62
|
|
60
63
|
# location of SDK files
|
61
64
|
def sdk_folder=(v)
|
62
|
-
@sdk_dir=v
|
65
|
+
@sdk_dir = v
|
63
66
|
sdk_folder
|
64
67
|
end
|
65
68
|
|
66
69
|
# backward compatibility in sample program
|
67
|
-
|
70
|
+
alias_method :folder=, :sdk_folder=
|
68
71
|
|
69
72
|
# @return the path to folder where SDK is installed
|
70
73
|
def sdk_folder
|
@@ -77,43 +80,43 @@ module Aspera
|
|
77
80
|
# or select one from installed_products()
|
78
81
|
def use_ascp_from_product(product_name)
|
79
82
|
if product_name.eql?(FIRST_FOUND)
|
80
|
-
pl=installed_products.first
|
83
|
+
pl = installed_products.first
|
81
84
|
raise "no FASP installation found\nPlease check manual on how to install FASP." if pl.nil?
|
82
85
|
else
|
83
|
-
pl=installed_products.
|
86
|
+
pl = installed_products.find{|i|i[:name].eql?(product_name)}
|
84
87
|
raise "no such product installed: #{product_name}" if pl.nil?
|
85
88
|
end
|
86
|
-
self.ascp_path=pl[:ascp_path]
|
89
|
+
self.ascp_path = pl[:ascp_path]
|
87
90
|
Log.log.debug("ascp_path=#{@path_to_ascp}")
|
88
91
|
end
|
89
92
|
|
90
93
|
# @return the list of installed products in format of product_locations
|
91
94
|
def installed_products
|
92
95
|
if @found_products.nil?
|
93
|
-
scan_locations=product_locations.clone
|
96
|
+
scan_locations = product_locations.clone
|
94
97
|
# add SDK as first search path
|
95
98
|
scan_locations.unshift({
|
96
99
|
expected: 'SDK',
|
97
100
|
app_root: sdk_folder,
|
98
|
-
sub_bin:
|
101
|
+
sub_bin: ''
|
99
102
|
})
|
100
103
|
# search installed products: with ascp
|
101
|
-
@found_products=scan_locations.select! do |item|
|
104
|
+
@found_products = scan_locations.select! do |item|
|
102
105
|
# skip if not main folder
|
103
106
|
next false unless Dir.exist?(item[:app_root])
|
104
107
|
Log.log.debug("Found #{item[:app_root]}")
|
105
108
|
sub_bin = item[:sub_bin] || BIN_SUBFOLDER
|
106
|
-
item[:ascp_path]=File.join(item[:app_root],sub_bin,ascp_filename)
|
109
|
+
item[:ascp_path] = File.join(item[:app_root],sub_bin,ascp_filename)
|
107
110
|
# skip if no ascp
|
108
111
|
next false unless File.exist?(item[:ascp_path])
|
109
112
|
# read info from product info file if present
|
110
|
-
product_info_file="#{item[:app_root]}/#{PRODUCT_INFO}"
|
113
|
+
product_info_file = "#{item[:app_root]}/#{PRODUCT_INFO}"
|
111
114
|
if File.exist?(product_info_file)
|
112
|
-
res_s=XmlSimple.xml_in(File.read(product_info_file),{'ForceArray'=>false})
|
113
|
-
item[:name]=res_s['name']
|
114
|
-
item[:version]=res_s['version']
|
115
|
+
res_s = XmlSimple.xml_in(File.read(product_info_file),{'ForceArray' => false})
|
116
|
+
item[:name] = res_s['name']
|
117
|
+
item[:version] = res_s['version']
|
115
118
|
else
|
116
|
-
item[:name]=item[:expected]
|
119
|
+
item[:name] = item[:expected]
|
117
120
|
end
|
118
121
|
true # select this version
|
119
122
|
end
|
@@ -122,7 +125,7 @@ module Aspera
|
|
122
125
|
end
|
123
126
|
|
124
127
|
# all ascp files (in SDK)
|
125
|
-
FILES=[
|
128
|
+
FILES = %i[ascp ascp4 ssh_bypass_key_dsa ssh_bypass_key_rsa aspera_license aspera_conf fallback_cert fallback_key].freeze
|
126
129
|
|
127
130
|
# get path of one resource file of currently activated product
|
128
131
|
# keys and certs are generated locally... (they are well known values, arch. independant)
|
@@ -130,36 +133,43 @@ module Aspera
|
|
130
133
|
case k
|
131
134
|
when :ascp,:ascp4
|
132
135
|
use_ascp_from_product(FIRST_FOUND) if @path_to_ascp.nil?
|
133
|
-
file
|
136
|
+
file = @path_to_ascp
|
134
137
|
# note that there might be a .exe at the end
|
135
|
-
file=file.gsub('ascp','ascp4') if k.eql?(:ascp4)
|
138
|
+
file = file.gsub('ascp','ascp4') if k.eql?(:ascp4)
|
136
139
|
when :transferd
|
137
|
-
file=transferd_filepath
|
140
|
+
file = transferd_filepath
|
138
141
|
when :ssh_bypass_key_dsa
|
139
|
-
file=File.join(sdk_folder,'aspera_bypass_dsa.pem')
|
142
|
+
file = File.join(sdk_folder,'aspera_bypass_dsa.pem')
|
140
143
|
File.write(file,get_key('dsa',1)) unless File.exist?(file)
|
141
144
|
File.chmod(0400,file)
|
142
145
|
when :ssh_bypass_key_rsa
|
143
|
-
file=File.join(sdk_folder,'aspera_bypass_rsa.pem')
|
146
|
+
file = File.join(sdk_folder,'aspera_bypass_rsa.pem')
|
144
147
|
File.write(file,get_key('rsa',2)) unless File.exist?(file)
|
145
148
|
File.chmod(0400,file)
|
146
149
|
when :aspera_license
|
147
|
-
file=File.join(sdk_folder,'aspera-license')
|
148
|
-
|
150
|
+
file = File.join(sdk_folder,'aspera-license')
|
151
|
+
unless File.exist?(file)
|
152
|
+
clear=[
|
153
|
+
Zlib::Inflate.inflate(DataRepository.instance.data(6)),
|
154
|
+
"==SIGNATURE==\n",
|
155
|
+
Base64.strict_encode64(DataRepository.instance.data(7))
|
156
|
+
]
|
157
|
+
File.write(file,Base64.strict_encode64(clear.join))
|
158
|
+
end
|
149
159
|
File.chmod(0400,file)
|
150
160
|
when :aspera_conf
|
151
|
-
file=File.join(sdk_folder,'aspera.conf')
|
161
|
+
file = File.join(sdk_folder,'aspera.conf')
|
152
162
|
File.write(file,DEFAULT_ASPERA_CONF) unless File.exist?(file)
|
153
163
|
File.chmod(0400,file)
|
154
164
|
when :fallback_cert,:fallback_key
|
155
|
-
file_key=File.join(sdk_folder,'aspera_fallback_key.pem')
|
156
|
-
file_cert=File.join(sdk_folder,'aspera_fallback_cert.pem')
|
165
|
+
file_key = File.join(sdk_folder,'aspera_fallback_key.pem')
|
166
|
+
file_cert = File.join(sdk_folder,'aspera_fallback_cert.pem')
|
157
167
|
if !File.exist?(file_key) || !File.exist?(file_cert)
|
158
168
|
require 'openssl'
|
159
169
|
# create new self signed certificate for http fallback
|
160
170
|
private_key = OpenSSL::PKey::RSA.new(1024)
|
161
171
|
cert = OpenSSL::X509::Certificate.new
|
162
|
-
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(
|
172
|
+
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(DUMMY_CERT_INFO)
|
163
173
|
cert.not_before = Time.now
|
164
174
|
cert.not_after = Time.now + ONE_YEAR_SECONDS
|
165
175
|
cert.public_key = private_key.public_key
|
@@ -181,10 +191,10 @@ module Aspera
|
|
181
191
|
|
182
192
|
# @return the file path of local connect where API's URI can be read
|
183
193
|
def connect_uri
|
184
|
-
connect=get_product_folders(PRODUCT_CONNECT)
|
185
|
-
folder=File.join(connect[:run_root],VARRUN_SUBFOLDER)
|
194
|
+
connect = get_product_folders(PRODUCT_CONNECT)
|
195
|
+
folder = File.join(connect[:run_root],VARRUN_SUBFOLDER)
|
186
196
|
['','s'].each do |ext|
|
187
|
-
uri_file=File.join(folder,"http#{ext}.uri")
|
197
|
+
uri_file = File.join(folder,"http#{ext}.uri")
|
188
198
|
Log.log.debug("checking connect port file: #{uri_file}")
|
189
199
|
if File.exist?(uri_file)
|
190
200
|
return File.open(uri_file, &:gets).strip
|
@@ -195,7 +205,7 @@ module Aspera
|
|
195
205
|
|
196
206
|
# @ return path to configuration file of aspera CLI
|
197
207
|
def cli_conf_file
|
198
|
-
connect=get_product_folders(PRODUCT_CLI_V1)
|
208
|
+
connect = get_product_folders(PRODUCT_CLI_V1)
|
199
209
|
return File.join(connect[:app_root],BIN_SUBFOLDER,'.aspera_cli_conf')
|
200
210
|
end
|
201
211
|
|
@@ -205,7 +215,7 @@ module Aspera
|
|
205
215
|
end
|
206
216
|
|
207
217
|
def bypass_keys
|
208
|
-
return [
|
218
|
+
return %i[ssh_bypass_key_dsa ssh_bypass_key_rsa].map{|i|Installation.instance.path(i)}
|
209
219
|
end
|
210
220
|
|
211
221
|
# use in plugin `config`
|
@@ -217,12 +227,12 @@ module Aspera
|
|
217
227
|
def get_exe_version(exe_path,vers_arg)
|
218
228
|
raise 'ERROR: nil arg' if exe_path.nil?
|
219
229
|
return nil unless File.exist?(exe_path)
|
220
|
-
exe_version=nil
|
221
|
-
cmd_out
|
230
|
+
exe_version = nil
|
231
|
+
cmd_out = %x("#{exe_path}" #{vers_arg})
|
222
232
|
raise "An error occured when testing #{ascp_filename}: #{cmd_out}" unless $CHILD_STATUS == 0
|
223
233
|
# get version from ascp, only after full extract, as windows requires DLLs (SSL/TLS/etc...)
|
224
|
-
m=cmd_out.match(/ version ([0-9.]+)/)
|
225
|
-
exe_version=m[1] unless m.nil?
|
234
|
+
m = cmd_out.match(/ version ([0-9.]+)/)
|
235
|
+
exe_version = m[1] unless m.nil?
|
226
236
|
return exe_version
|
227
237
|
end
|
228
238
|
|
@@ -231,11 +241,11 @@ module Aspera
|
|
231
241
|
# @return ascp version (from execution)
|
232
242
|
def install_sdk(sdk_url)
|
233
243
|
require 'zip'
|
234
|
-
sdk_zip_path=File.join(Dir.tmpdir,'sdk.zip')
|
244
|
+
sdk_zip_path = File.join(Dir.tmpdir,'sdk.zip')
|
235
245
|
if sdk_url.start_with?('file:')
|
236
246
|
# require specific file scheme: the path part is "relative", or absolute if there are 4 slash
|
237
247
|
raise 'use format: file:///<path>' unless sdk_url.start_with?('file:///')
|
238
|
-
sdk_zip_path=sdk_url.gsub(%r{^file:///},'')
|
248
|
+
sdk_zip_path = sdk_url.gsub(%r{^file:///},'')
|
239
249
|
else
|
240
250
|
Aspera::Rest.new(base_url: sdk_url, redirect_max: 3).call(operation: 'GET',save_to_file: sdk_zip_path)
|
241
251
|
end
|
@@ -246,17 +256,17 @@ module Aspera
|
|
246
256
|
# TODO: delete old archives ?
|
247
257
|
end
|
248
258
|
# SDK is organized by architecture
|
249
|
-
arch_filter="#{Environment.architecture}/"
|
259
|
+
arch_filter = "#{Environment.architecture}/"
|
250
260
|
# extract files from archive
|
251
261
|
Zip::File.open(sdk_zip_path) do |zip_file|
|
252
262
|
zip_file.each do |entry|
|
253
263
|
# skip folder entries
|
254
264
|
next if entry.name.end_with?('/')
|
255
|
-
dest_folder=nil
|
265
|
+
dest_folder = nil
|
256
266
|
# binaries
|
257
|
-
dest_folder=sdk_folder if entry.name.include?(arch_filter)
|
267
|
+
dest_folder = sdk_folder if entry.name.include?(arch_filter)
|
258
268
|
# ruby adapters
|
259
|
-
dest_folder=sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
|
269
|
+
dest_folder = sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
|
260
270
|
next if dest_folder.nil?
|
261
271
|
File.open(File.join(dest_folder,File.basename(entry.name)), 'wb') do |output_stream|
|
262
272
|
IO.copy_stream(entry.get_input_stream, output_stream)
|
@@ -267,53 +277,53 @@ module Aspera
|
|
267
277
|
# ensure license file are generated so that ascp invokation for version works
|
268
278
|
path(:aspera_license)
|
269
279
|
path(:aspera_conf)
|
270
|
-
ascp_path=File.join(sdk_folder,ascp_filename)
|
280
|
+
ascp_path = File.join(sdk_folder,ascp_filename)
|
271
281
|
raise "No #{ascp_filename} found in SDK archive" unless File.exist?(ascp_path)
|
272
282
|
FileUtils.chmod(0755,ascp_path)
|
273
283
|
FileUtils.chmod(0755,ascp_path.gsub('ascp','ascp4'))
|
274
|
-
ascp_version=get_ascp_version(File.join(sdk_folder,ascp_filename))
|
275
|
-
trd_path=transferd_filepath
|
284
|
+
ascp_version = get_ascp_version(File.join(sdk_folder,ascp_filename))
|
285
|
+
trd_path = transferd_filepath
|
276
286
|
Log.log.warn("No #{trd_path} in SDK archive") unless File.exist?(trd_path)
|
277
287
|
FileUtils.chmod(0755,trd_path) if File.exist?(trd_path)
|
278
|
-
transferd_version=get_exe_version(trd_path,'version')
|
279
|
-
sdk_version = transferd_version||ascp_version
|
288
|
+
transferd_version = get_exe_version(trd_path,'version')
|
289
|
+
sdk_version = transferd_version || ascp_version
|
280
290
|
File.write(File.join(sdk_folder,PRODUCT_INFO),"<product><name>IBM Aspera SDK</name><version>#{sdk_version}</version></product>")
|
281
291
|
return sdk_version
|
282
292
|
end
|
283
293
|
|
284
294
|
private
|
285
295
|
|
286
|
-
BIN_SUBFOLDER='bin'
|
287
|
-
ETC_SUBFOLDER='etc'
|
288
|
-
VARRUN_SUBFOLDER=File.join('var','run')
|
296
|
+
BIN_SUBFOLDER = 'bin'
|
297
|
+
ETC_SUBFOLDER = 'etc'
|
298
|
+
VARRUN_SUBFOLDER = File.join('var','run')
|
289
299
|
# product information manifest: XML (part of aspera product)
|
290
|
-
PRODUCT_INFO='product-info.mf'
|
300
|
+
PRODUCT_INFO = 'product-info.mf'
|
291
301
|
# policy for product selection
|
292
|
-
FIRST_FOUND='FIRST'
|
302
|
+
FIRST_FOUND = 'FIRST'
|
293
303
|
|
294
304
|
private_constant :BIN_SUBFOLDER,:ETC_SUBFOLDER,:VARRUN_SUBFOLDER,:PRODUCT_INFO
|
295
305
|
|
296
306
|
def initialize
|
297
|
-
@path_to_ascp=nil
|
298
|
-
@sdk_dir=nil
|
299
|
-
@found_products=nil
|
307
|
+
@path_to_ascp = nil
|
308
|
+
@sdk_dir = nil
|
309
|
+
@found_products = nil
|
300
310
|
end
|
301
311
|
|
302
312
|
# @return folder paths for specified applications
|
303
313
|
# @param name Connect or CLI
|
304
314
|
def get_product_folders(name)
|
305
|
-
found=installed_products.select{|i|i[:expected].eql?(name)
|
315
|
+
found = installed_products.select{|i|i[:expected].eql?(name) || i[:name].eql?(name)}
|
306
316
|
raise "Product: #{name} not found, please install." if found.empty?
|
307
317
|
return found.first
|
308
318
|
end
|
309
319
|
|
310
320
|
# filename for ascp with optional extension (Windows)
|
311
321
|
def ascp_filename
|
312
|
-
return 'ascp'+Environment.exe_extension
|
322
|
+
return 'ascp' + Environment.exe_extension
|
313
323
|
end
|
314
324
|
|
315
325
|
def transferd_filepath
|
316
|
-
return File.join(sdk_folder,'asperatransferd'+Environment.exe_extension)
|
326
|
+
return File.join(sdk_folder,'asperatransferd' + Environment.exe_extension)
|
317
327
|
end
|
318
328
|
|
319
329
|
# @return product folders depending on OS fields
|
@@ -325,50 +335,50 @@ module Aspera
|
|
325
335
|
def product_locations
|
326
336
|
case Aspera::Environment.os
|
327
337
|
when Aspera::Environment::OS_WINDOWS; return [{
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
338
|
+
expected: PRODUCT_CONNECT,
|
339
|
+
app_root: File.join(ENV['LOCALAPPDATA'],'Programs','Aspera','Aspera Connect'),
|
340
|
+
log_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect','var','log'),
|
341
|
+
run_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect')
|
342
|
+
},{
|
343
|
+
expected: PRODUCT_CLI_V1,
|
344
|
+
app_root: File.join('C:','Program Files','Aspera','cli'),
|
345
|
+
log_root: File.join('C:','Program Files','Aspera','cli','var','log')
|
346
|
+
},{
|
347
|
+
expected: PRODUCT_ENTSRV,
|
348
|
+
app_root: File.join('C:','Program Files','Aspera','Enterprise Server'),
|
349
|
+
log_root: File.join('C:','Program Files','Aspera','Enterprise Server','var','log')
|
350
|
+
}]
|
341
351
|
when Aspera::Environment::OS_X; return [{
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
352
|
+
expected: PRODUCT_CONNECT,
|
353
|
+
app_root: File.join(Dir.home,'Applications','Aspera Connect.app'),
|
354
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera_Connect'),
|
355
|
+
run_root: File.join(Dir.home,'Library','Application Support','Aspera','Aspera Connect'),
|
356
|
+
sub_bin: File.join('Contents','Resources')
|
357
|
+
},{
|
358
|
+
expected: PRODUCT_CLI_V1,
|
359
|
+
app_root: File.join(Dir.home,'Applications','Aspera CLI'),
|
360
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera')
|
361
|
+
},{
|
362
|
+
expected: PRODUCT_ENTSRV,
|
363
|
+
app_root: File.join('','Library','Aspera'),
|
364
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera')
|
365
|
+
},{
|
366
|
+
expected: PRODUCT_DRIVE,
|
367
|
+
app_root: File.join('','Applications','Aspera Drive.app'),
|
368
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera_Drive'),
|
369
|
+
sub_bin: File.join('Contents','Resources')
|
370
|
+
}]
|
361
371
|
else; return [{ # other: Linux and Unix family
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
+
expected: PRODUCT_CONNECT,
|
373
|
+
app_root: File.join(Dir.home,'.aspera','connect'),
|
374
|
+
run_root: File.join(Dir.home,'.aspera','connect')
|
375
|
+
},{
|
376
|
+
expected: PRODUCT_CLI_V1,
|
377
|
+
app_root: File.join(Dir.home,'.aspera','cli')
|
378
|
+
},{
|
379
|
+
expected: PRODUCT_ENTSRV,
|
380
|
+
app_root: File.join('','opt','aspera')
|
381
|
+
}]
|
372
382
|
end
|
373
383
|
end
|
374
384
|
|
@@ -376,10 +386,8 @@ module Aspera
|
|
376
386
|
# @param type rsa or dsa
|
377
387
|
# @param id in repository 1 for dsa, 2 for rsa
|
378
388
|
def get_key(type,id)
|
379
|
-
|
380
|
-
|
381
|
-
# validate valie and generate key in connonical format
|
382
|
-
OpenSSL::PKey.const_get(type.upcase).send(:new,hf.insert(1,bin).join("\n")).to_pem
|
389
|
+
# generate PEM from DER
|
390
|
+
OpenSSL::PKey.const_get(type.upcase).new(DataRepository.instance.data(id)).to_pem
|
383
391
|
end
|
384
392
|
end # Installation
|
385
393
|
end
|
data/lib/aspera/fasp/listener.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'aspera/log'
|
3
4
|
require 'aspera/command_line_builder'
|
4
5
|
require 'aspera/temp_file_manager'
|
@@ -14,40 +15,42 @@ module Aspera
|
|
14
15
|
# translate transfer specification to ascp parameter list
|
15
16
|
class Parameters
|
16
17
|
# Agents shown in manual for parameters (sub list)
|
17
|
-
SUPPORTED_AGENTS=[
|
18
|
+
SUPPORTED_AGENTS = %i[direct node connect].freeze
|
18
19
|
# Short names of columns in manual
|
19
|
-
SUPPORTED_AGENTS_SHORT=SUPPORTED_AGENTS.map{|a|a.to_s[0].to_sym}
|
20
|
+
SUPPORTED_AGENTS_SHORT = SUPPORTED_AGENTS.map{|a|a.to_s[0].to_sym}
|
20
21
|
|
21
22
|
class << self
|
22
23
|
# Temp folder for file lists, must contain only file lists
|
23
24
|
# because of garbage collection takes any file there
|
24
25
|
# this could be refined, as , for instance, on macos, temp folder is already user specific
|
25
|
-
@file_list_folder=TempFileManager.instance.new_file_path_global('asession_filelists')
|
26
|
-
@param_description_cache=nil
|
26
|
+
@file_list_folder = TempFileManager.instance.new_file_path_global('asession_filelists')
|
27
|
+
@param_description_cache = nil
|
27
28
|
# @return normalized description of transfer spec parameters, direct from yaml
|
28
29
|
def description
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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)
|
34
|
+
end
|
35
|
+
return @param_description_cache
|
33
36
|
end
|
34
37
|
|
35
38
|
# @return a table suitable to display in manual
|
36
39
|
def man_table
|
37
|
-
result=[]
|
40
|
+
result = []
|
38
41
|
description.each do |k,i|
|
39
|
-
param={name: k, type: [i[:accepted_types]].flatten.join(','),description: i[:desc]}
|
42
|
+
param = {name: k, type: [i[:accepted_types]].flatten.join(','),description: i[:desc]}
|
40
43
|
SUPPORTED_AGENTS.each do |a|
|
41
|
-
param[a.to_s[0].to_sym]=i[:tragents].nil? || i[:tragents].include?(a) ? 'Y' : ''
|
44
|
+
param[a.to_s[0].to_sym] = i[:tragents].nil? || i[:tragents].include?(a) ? 'Y' : ''
|
42
45
|
end
|
43
46
|
# only keep lines that are usable in supported agents
|
44
47
|
next if SUPPORTED_AGENTS_SHORT.inject(true){|m,j|m && param[j].empty?}
|
45
|
-
param[:cli]=
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
51
54
|
if i.has_key?(:enum)
|
52
55
|
param[:description] += "\nAllowed values: #{i[:enum].join(', ')}"
|
53
56
|
end
|
@@ -66,16 +69,16 @@ module Aspera
|
|
66
69
|
def clconv_base64(v); Base64.strict_encode64(v); end
|
67
70
|
|
68
71
|
def ts_has_file_list(ts)
|
69
|
-
ts.has_key?('EX_ascp_args')
|
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)}
|
70
73
|
end
|
71
74
|
|
72
75
|
def ts_to_env_args(transfer_spec,options)
|
73
|
-
return Parameters.new(transfer_spec,options).ascp_args
|
76
|
+
return Parameters.new(transfer_spec,options).ascp_args
|
74
77
|
end
|
75
78
|
|
76
79
|
# temp file list files are created here
|
77
80
|
def file_list_folder=(v)
|
78
|
-
@file_list_folder=v
|
81
|
+
@file_list_folder = v
|
79
82
|
return if @file_list_folder.nil?
|
80
83
|
FileUtils.mkdir_p(@file_list_folder)
|
81
84
|
TempFileManager.instance.cleanup_expired(@file_list_folder)
|
@@ -87,18 +90,18 @@ module Aspera
|
|
87
90
|
|
88
91
|
# @param options [Hash] key: :wss: bool
|
89
92
|
def initialize(job_spec,options)
|
90
|
-
@job_spec=job_spec
|
91
|
-
@options=options
|
92
|
-
@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)
|
93
96
|
Log.log.debug("agent options: #{@options}")
|
94
97
|
end
|
95
98
|
|
96
99
|
# translate transfer spec to env vars and command line arguments for ascp
|
97
100
|
# NOTE: parameters starting with "EX_" (extended) are not standard
|
98
101
|
def ascp_args
|
99
|
-
env_args={
|
100
|
-
args:
|
101
|
-
env:
|
102
|
+
env_args = {
|
103
|
+
args: [],
|
104
|
+
env: {},
|
102
105
|
ascp_version: :ascp
|
103
106
|
}
|
104
107
|
# some ssh credentials are required to avoid interactive password input
|
@@ -117,12 +120,12 @@ module Aspera
|
|
117
120
|
@builder.add_command_line_options(['--ws-connect'])
|
118
121
|
# TODO: option to give order ssh,ws (legacy http is implied bu ssh)
|
119
122
|
# quel bordel:
|
120
|
-
@job_spec['ssh_port']
|
123
|
+
@job_spec['ssh_port'] = @builder.process_param('wss_port',:get_value)
|
121
124
|
@job_spec.delete('fasp_port')
|
122
125
|
@job_spec.delete('EX_ssh_key_paths')
|
123
126
|
@job_spec.delete('sshfp')
|
124
127
|
# set location for CA bundle to be the one of Ruby, see env var SSL_CERT_FILE / SSL_CERT_DIR
|
125
|
-
@job_spec['EX_ssh_key_paths']=[OpenSSL::X509::DEFAULT_CERT_FILE]
|
128
|
+
@job_spec['EX_ssh_key_paths'] = [OpenSSL::X509::DEFAULT_CERT_FILE]
|
126
129
|
Log.log.debug('CA certs: EX_ssh_key_paths <- DEFAULT_CERT_FILE from openssl')
|
127
130
|
else
|
128
131
|
# remove unused parameter (avoid warning)
|
@@ -141,12 +144,12 @@ module Aspera
|
|
141
144
|
@builder.add_command_line_options(['--dest64'])
|
142
145
|
end
|
143
146
|
# paths is mandatory, unless ...
|
144
|
-
file_list_provided=self.class.ts_has_file_list(@job_spec)
|
145
|
-
@builder.params_definition['paths'][:mandatory]
|
146
|
-
paths_array
|
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)
|
147
150
|
if file_list_provided && !paths_array.nil?
|
148
151
|
Log.log.warn('file list provided both in transfer spec and ascp file list. Keeping file list only.')
|
149
|
-
paths_array=nil
|
152
|
+
paths_array = nil
|
150
153
|
end
|
151
154
|
if !paths_array.nil?
|
152
155
|
# it's an array
|
@@ -157,25 +160,25 @@ module Aspera
|
|
157
160
|
Log.log.debug('placing source file list on command line (no file list file)')
|
158
161
|
@builder.add_command_line_options(paths_array.map{|i|i['source']})
|
159
162
|
else
|
160
|
-
file_list_file
|
163
|
+
file_list_file = @builder.process_param('EX_file_list',:get_value)
|
161
164
|
if !file_list_file.nil?
|
162
|
-
option='--file-list'
|
165
|
+
option = '--file-list'
|
163
166
|
else
|
164
|
-
file_list_file
|
167
|
+
file_list_file = @builder.process_param('EX_file_pair_list',:get_value)
|
165
168
|
if !file_list_file.nil?
|
166
|
-
option='--file-pair-list'
|
169
|
+
option = '--file-pair-list'
|
167
170
|
else
|
168
171
|
# safer option: file list
|
169
172
|
# if there is destination in paths, then use filepairlist
|
170
173
|
# TODO: well, we test only the first one, but anyway it shall be consistent
|
171
174
|
if paths_array.first.has_key?('destination')
|
172
|
-
option='--file-pair-list'
|
173
|
-
lines=paths_array.each_with_object([]){|e,m|m.push(e['source'],e['destination']);}
|
175
|
+
option = '--file-pair-list'
|
176
|
+
lines = paths_array.each_with_object([]){|e,m|m.push(e['source'],e['destination']);}
|
174
177
|
else
|
175
|
-
option='--file-list'
|
176
|
-
lines=paths_array.map{|i|i['source']}
|
178
|
+
option = '--file-list'
|
179
|
+
lines = paths_array.map{|i|i['source']}
|
177
180
|
end
|
178
|
-
file_list_file=Aspera::TempFileManager.instance.new_file_path_in_folder(self.class.file_list_folder)
|
181
|
+
file_list_file = Aspera::TempFileManager.instance.new_file_path_in_folder(self.class.file_list_folder)
|
179
182
|
File.write(file_list_file, lines.join("\n"))
|
180
183
|
Log.log.debug{"#{option}=\n#{File.read(file_list_file)}".red}
|
181
184
|
end
|