aspera-cli 4.21.1 → 4.22.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/BUGS.md +1 -1
- data/CHANGELOG.md +52 -22
- data/CONTRIBUTING.md +69 -148
- data/README.md +929 -668
- data/bin/ascli +5 -14
- data/bin/asession +1 -3
- data/examples/get_proto_file.rb +4 -3
- data/examples/proxy.pac +20 -20
- data/lib/aspera/agent/base.rb +11 -5
- data/lib/aspera/agent/connect.rb +30 -28
- data/lib/aspera/agent/{alpha.rb → desktop.rb} +35 -31
- data/lib/aspera/agent/direct.rb +141 -121
- data/lib/aspera/agent/httpgw.rb +22 -26
- data/lib/aspera/agent/node.rb +14 -11
- data/lib/aspera/agent/transferd.rb +30 -19
- data/lib/aspera/api/alee.rb +1 -1
- data/lib/aspera/api/aoc.rb +6 -6
- data/lib/aspera/api/cos_node.rb +2 -2
- data/lib/aspera/api/httpgw.rb +7 -3
- data/lib/aspera/api/node.rb +10 -8
- data/lib/aspera/ascmd.rb +3 -3
- data/lib/aspera/ascp/installation.rb +53 -72
- data/lib/aspera/ascp/management.rb +1 -1
- data/lib/aspera/assert.rb +11 -2
- data/lib/aspera/cli/error.rb +2 -2
- data/lib/aspera/cli/extended_value.rb +46 -21
- data/lib/aspera/cli/formatter.rb +55 -48
- data/lib/aspera/cli/hints.rb +1 -1
- data/lib/aspera/cli/info.rb +1 -0
- data/lib/aspera/cli/main.rb +192 -170
- data/lib/aspera/cli/manager.rb +18 -18
- data/lib/aspera/cli/plugin.rb +23 -20
- data/lib/aspera/cli/plugin_factory.rb +1 -1
- data/lib/aspera/cli/plugins/alee.rb +1 -1
- data/lib/aspera/cli/plugins/aoc.rb +247 -159
- data/lib/aspera/cli/plugins/ats.rb +19 -17
- data/lib/aspera/cli/plugins/config.rb +76 -113
- data/lib/aspera/cli/plugins/console.rb +5 -3
- data/lib/aspera/cli/plugins/faspex.rb +39 -35
- data/lib/aspera/cli/plugins/faspex5.rb +111 -84
- data/lib/aspera/cli/plugins/faspio.rb +13 -1
- data/lib/aspera/cli/plugins/httpgw.rb +13 -1
- data/lib/aspera/cli/plugins/node.rb +312 -182
- data/lib/aspera/cli/plugins/orchestrator.rb +34 -40
- data/lib/aspera/cli/plugins/preview.rb +3 -3
- data/lib/aspera/cli/plugins/server.rb +6 -6
- data/lib/aspera/cli/plugins/shares.rb +5 -5
- data/lib/aspera/cli/sync_actions.rb +19 -18
- data/lib/aspera/cli/transfer_agent.rb +5 -5
- data/lib/aspera/cli/transfer_progress.rb +2 -2
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/command_line_builder.rb +116 -95
- data/lib/aspera/coverage.rb +8 -5
- data/lib/aspera/environment.rb +26 -17
- data/lib/aspera/faspex_gw.rb +14 -14
- data/lib/aspera/faspex_postproc.rb +10 -11
- data/lib/aspera/hash_ext.rb +4 -14
- data/lib/aspera/json_rpc.rb +1 -1
- data/lib/aspera/keychain/encrypted_hash.rb +47 -34
- data/lib/aspera/keychain/factory.rb +41 -0
- data/lib/aspera/keychain/hashicorp_vault.rb +71 -0
- data/lib/aspera/keychain/macos_security.rb +19 -11
- data/lib/aspera/log.rb +28 -34
- data/lib/aspera/nagios.rb +6 -6
- data/lib/aspera/node_simulator.rb +8 -8
- data/lib/aspera/oauth/base.rb +14 -7
- data/lib/aspera/oauth/factory.rb +5 -6
- data/lib/aspera/oauth/url_json.rb +6 -6
- data/lib/aspera/persistency_action_once.rb +6 -4
- data/lib/aspera/persistency_folder.rb +2 -2
- data/lib/aspera/preview/generator.rb +13 -10
- data/lib/aspera/preview/options.rb +16 -16
- data/lib/aspera/preview/terminal.rb +4 -4
- data/lib/aspera/preview/utils.rb +15 -17
- data/lib/aspera/products/connect.rb +35 -1
- data/lib/aspera/products/{alpha.rb → desktop.rb} +3 -3
- data/lib/aspera/products/transferd.rb +9 -2
- data/lib/aspera/proxy_auto_config.rb +2 -2
- data/lib/aspera/rest.rb +56 -47
- data/lib/aspera/rest_errors_aspera.rb +1 -1
- data/lib/aspera/secret_hider.rb +12 -5
- data/lib/aspera/ssh.rb +4 -4
- data/lib/aspera/temp_file_manager.rb +5 -4
- data/lib/aspera/transfer/convert.rb +29 -0
- data/lib/aspera/transfer/error_info.rb +66 -66
- data/lib/aspera/transfer/parameters.rb +13 -68
- data/lib/aspera/transfer/spec.rb +5 -6
- data/lib/aspera/transfer/spec.schema.yaml +753 -0
- data/lib/aspera/transfer/spec_doc.rb +62 -0
- data/lib/aspera/transfer/sync.rb +23 -72
- data/lib/aspera/transfer/sync_instance.schema.yaml +13 -0
- data/lib/aspera/transfer/sync_session.schema.yaml +79 -0
- data/lib/aspera/transfer/uri.rb +6 -6
- data/lib/aspera/uri_reader.rb +18 -1
- data/lib/aspera/web_auth.rb +1 -1
- data/lib/aspera/web_server_simple.rb +53 -44
- data.tar.gz.sig +0 -0
- metadata +28 -165
- metadata.gz.sig +0 -0
- data/examples/build_exec +0 -74
- data/examples/build_exec_rubyc +0 -40
- data/examples/build_package.sh +0 -28
- data/lib/aspera/transfer/spec.yaml +0 -718
data/bin/ascli
CHANGED
@@ -9,17 +9,8 @@ Encoding.default_internal = Encoding::UTF_8
|
|
9
9
|
Encoding.default_external = Encoding::UTF_8
|
10
10
|
$VERBOSE = old_verbose
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rescue LoadError
|
18
|
-
# if in development, add path toward gem
|
19
|
-
$LOAD_PATH.unshift(gem_lib_folder)
|
20
|
-
require 'aspera/cli/main'
|
21
|
-
end
|
22
|
-
require 'aspera/environment'
|
23
|
-
Aspera::Environment.fix_home
|
24
|
-
Aspera::Cli::Main.new(ARGV).process_command_line
|
25
|
-
end
|
12
|
+
require 'aspera/coverage'
|
13
|
+
require 'aspera/environment'
|
14
|
+
require 'aspera/cli/main'
|
15
|
+
Aspera::Environment.fix_home
|
16
|
+
Aspera::Cli::Main.new(ARGV).process_command_line
|
data/bin/asession
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
Kernel.load(File.join(gem_lib_folder, 'aspera/coverage.rb'))
|
6
|
-
$LOAD_PATH.unshift(gem_lib_folder)
|
4
|
+
require 'aspera/coverage'
|
7
5
|
require 'aspera/agent/direct'
|
8
6
|
require 'aspera/cli/extended_value'
|
9
7
|
require 'aspera/products/transferd'
|
data/examples/get_proto_file.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Retrieve `transfer.proto` from the web
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(File.dirname(File.realpath(__FILE__))), 'lib'))
|
6
4
|
require 'aspera/ascp/installation'
|
7
|
-
|
5
|
+
require 'aspera/cli/transfer_progress'
|
6
|
+
Aspera::RestParameters.instance.progress_bar = Aspera::Cli::TransferProgress.new
|
7
|
+
# Retrieve `transfer.proto` from the web
|
8
|
+
Aspera::Ascp::Installation.instance.install_sdk(folder: ARGV.first, backup: false, with_exe: false){ |name| name.end_with?('.proto') ? '/' : nil}
|
data/examples/proxy.pac
CHANGED
@@ -11,20 +11,20 @@ function FindProxyForURL(url, host) {
|
|
11
11
|
|
12
12
|
/* Don't proxy local domains */
|
13
13
|
if (dnsDomainIs(host, ".example1.com") || (host == "example1.com")
|
14
|
-
|
15
|
-
|
14
|
+
|| dnsDomainIs(host, ".example2.com") || (host == "example2.com")
|
15
|
+
|| dnsDomainIs(host, ".example3.com") || (host == "example3.com")) {
|
16
16
|
return 'DIRECT';
|
17
17
|
}
|
18
18
|
|
19
19
|
/* Don't proxy Windows Update */
|
20
20
|
if ((host == "download.microsoft.com")
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
|| (host == "ntservicepack.microsoft.com")
|
22
|
+
|| (host == "cdm.microsoft.com") || (host == "wustat.windows.com")
|
23
|
+
|| (host == "windowsupdate.microsoft.com")
|
24
|
+
|| (dnsDomainIs(host, ".windowsupdate.microsoft.com"))
|
25
|
+
|| (host == "update.microsoft.com")
|
26
|
+
|| (dnsDomainIs(host, ".update.microsoft.com"))
|
27
|
+
|| (dnsDomainIs(host, ".windowsupdate.com"))) {
|
28
28
|
return 'DIRECT';
|
29
29
|
}
|
30
30
|
|
@@ -33,22 +33,22 @@ function FindProxyForURL(url, host) {
|
|
33
33
|
|
34
34
|
/* Don't proxy private addresses (RFC 3330) */
|
35
35
|
if (isInNet(hostIP, '0.0.0.0', '255.0.0.0')
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
|| isInNet(hostIP, '10.0.0.0', '255.0.0.0')
|
37
|
+
|| isInNet(hostIP, '127.0.0.0', '255.0.0.0')
|
38
|
+
|| isInNet(hostIP, '169.254.0.0', '255.255.0.0')
|
39
|
+
|| isInNet(hostIP, '172.16.0.0', '255.240.0.0')
|
40
|
+
|| isInNet(hostIP, '192.0.2.0', '255.255.255.0')
|
41
|
+
|| isInNet(hostIP, '192.88.99.0', '255.255.255.0')
|
42
|
+
|| isInNet(hostIP, '192.168.0.0', '255.255.0.0')
|
43
|
+
|| isInNet(hostIP, '198.18.0.0', '255.254.0.0')
|
44
|
+
|| isInNet(hostIP, '224.0.0.0', '240.0.0.0')
|
45
|
+
|| isInNet(hostIP, '240.0.0.0', '240.0.0.0')) {
|
46
46
|
return 'DIRECT';
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
50
50
|
if (url.substring(0, 5) == 'http:' || url.substring(0, 6) == 'https:'
|
51
|
-
|
51
|
+
|| url.substring(0, 4) == 'ftp:') {
|
52
52
|
return 'PROXY proxy.example.com:8080';
|
53
53
|
}
|
54
54
|
|
data/lib/aspera/agent/base.rb
CHANGED
@@ -7,6 +7,7 @@ module Aspera
|
|
7
7
|
# Base class for transfer agents
|
8
8
|
class Base
|
9
9
|
RUBY_EXT = '.rb'
|
10
|
+
private_constant :RUBY_EXT
|
10
11
|
class << self
|
11
12
|
def factory_create(agent, options)
|
12
13
|
# Aspera.assert_values(agent, agent_list)
|
@@ -15,11 +16,12 @@ module Aspera
|
|
15
16
|
end
|
16
17
|
|
17
18
|
# discover available agents
|
19
|
+
# @return [Array] list of symbols of agents
|
18
20
|
def agent_list
|
19
21
|
base_class = File.basename(__FILE__)
|
20
22
|
Dir.entries(File.dirname(File.expand_path(__FILE__))).select do |file|
|
21
23
|
file.end_with?(RUBY_EXT) && !file.eql?(base_class)
|
22
|
-
end.map{|file|file[0..(-1 - RUBY_EXT.length)].to_sym}
|
24
|
+
end.map{ |file| file[0..(-1 - RUBY_EXT.length)].to_sym}
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -29,16 +31,20 @@ module Aspera
|
|
29
31
|
statuses = wait_for_transfers_completion
|
30
32
|
@progress&.reset
|
31
33
|
Aspera.assert_type(statuses, Array)
|
32
|
-
Aspera.assert(statuses.none?{|i
|
34
|
+
Aspera.assert(statuses.none?{ |i| !i.eql?(:success) && !i.is_a?(StandardError)}){"bad statuses content: #{statuses}"}
|
33
35
|
return statuses
|
34
36
|
end
|
35
37
|
|
36
38
|
private
|
37
39
|
|
40
|
+
Aspera.require_method!(:start_transfer)
|
41
|
+
Aspera.require_method!(:wait_for_transfers_completion)
|
42
|
+
# method `shutdown` is optional
|
43
|
+
def shutdown
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
38
47
|
def initialize(progress: nil)
|
39
|
-
# method `shutdown` is optional
|
40
|
-
Aspera.assert(respond_to?(:start_transfer))
|
41
|
-
Aspera.assert(respond_to?(:wait_for_transfers_completion))
|
42
48
|
@progress = progress
|
43
49
|
end
|
44
50
|
|
data/lib/aspera/agent/connect.rb
CHANGED
@@ -17,6 +17,7 @@ module Aspera
|
|
17
17
|
private_constant :CONNECT_START_URIS, :SLEEP_SEC_BETWEEN_RETRY
|
18
18
|
def initialize(**base_options)
|
19
19
|
super
|
20
|
+
@transfer_id = nil
|
20
21
|
@connect_settings = {
|
21
22
|
'app_id' => SecureRandom.uuid
|
22
23
|
}
|
@@ -46,21 +47,7 @@ module Aspera
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
#
|
50
|
-
def connect_api_url
|
51
|
-
connect_locations = Products::Other.find(Products::Connect.locations).first
|
52
|
-
raise "Product: #{name} not found, please install." if connect_locations.nil?
|
53
|
-
folder = File.join(connect_locations[:run_root], 'var', 'run')
|
54
|
-
['', 's'].each do |ext|
|
55
|
-
uri_file = File.join(folder, "http#{ext}.uri")
|
56
|
-
Log.log.debug{"checking connect port file: #{uri_file}"}
|
57
|
-
if File.exist?(uri_file)
|
58
|
-
return File.open(uri_file, &:gets).strip
|
59
|
-
end
|
60
|
-
end
|
61
|
-
raise "no connect uri file found in #{folder}"
|
62
|
-
end
|
63
|
-
|
50
|
+
# :reek:UnusedParameters token_regenerator
|
64
51
|
def start_transfer(transfer_spec, token_regenerator: nil)
|
65
52
|
if transfer_spec['direction'] == 'send'
|
66
53
|
Log.log.warn{"Connect requires upload selection using GUI, ignoring #{transfer_spec['paths']}".red}
|
@@ -71,15 +58,14 @@ module Aspera
|
|
71
58
|
'suggestedName' => '',
|
72
59
|
'allowMultipleSelection' => true,
|
73
60
|
'allowedFileTypes' => ''})
|
74
|
-
transfer_spec['paths'] = selection['dataTransfer']['files'].map
|
61
|
+
transfer_spec['paths'] = selection['dataTransfer']['files'].map{ |i| {'source' => i['name']}}
|
75
62
|
end
|
76
|
-
@request_id = SecureRandom.uuid
|
77
63
|
# if there is a token, we ask connect client to use well known ssh private keys
|
78
64
|
# instead of asking password
|
79
65
|
transfer_spec['authentication'] = 'token' if transfer_spec.key?('token')
|
80
66
|
connect_transfer_args = {
|
81
67
|
'aspera_connect_settings' => @connect_settings.merge({
|
82
|
-
'request_id' =>
|
68
|
+
'request_id' => SecureRandom.uuid,
|
83
69
|
'allow_dialogs' => true
|
84
70
|
}),
|
85
71
|
'transfer_specs' => [{
|
@@ -87,17 +73,16 @@ module Aspera
|
|
87
73
|
}]}
|
88
74
|
# asynchronous anyway
|
89
75
|
res = @connect_api.create('transfers/start', connect_transfer_args)
|
90
|
-
@
|
76
|
+
@transfer_id = res['transfer_specs'].first['transfer_spec']['tags'][Transfer::Spec::TAG_RESERVED]['xfer_id']
|
91
77
|
end
|
92
78
|
|
93
79
|
def wait_for_transfers_completion
|
94
80
|
connect_activity_args = {'aspera_connect_settings' => @connect_settings}
|
95
81
|
started = false
|
96
82
|
pre_calc = false
|
97
|
-
session_id = @xfer_id
|
98
83
|
begin
|
99
84
|
loop do
|
100
|
-
tr_info = @connect_api.create("transfers/info/#{@
|
85
|
+
tr_info = @connect_api.create("transfers/info/#{@transfer_id}", connect_activity_args)
|
101
86
|
Log.log.trace1{Log.dump(:tr_info, tr_info)}
|
102
87
|
if tr_info['transfer_info'].is_a?(Hash)
|
103
88
|
transfer = tr_info['transfer_info']
|
@@ -111,26 +96,26 @@ module Aspera
|
|
111
96
|
notify_progress(:pre_start, session_id: nil, info: transfer['status'])
|
112
97
|
when 'running'
|
113
98
|
if !started
|
114
|
-
notify_progress(:session_start, session_id:
|
99
|
+
notify_progress(:session_start, session_id: @transfer_id)
|
115
100
|
started = true
|
116
101
|
end
|
117
102
|
if !pre_calc && (transfer['bytes_expected'] != 0)
|
118
|
-
notify_progress(:session_size, session_id:
|
103
|
+
notify_progress(:session_size, session_id: @transfer_id, info: transfer['bytes_expected'])
|
119
104
|
pre_calc = true
|
120
105
|
else
|
121
|
-
notify_progress(:transfer, session_id:
|
106
|
+
notify_progress(:transfer, session_id: @transfer_id, info: transfer['bytes_written'])
|
122
107
|
end
|
123
108
|
when 'completed'
|
124
|
-
notify_progress(:end, session_id:
|
109
|
+
notify_progress(:end, session_id: @transfer_id)
|
125
110
|
break
|
126
111
|
when 'failed'
|
127
|
-
notify_progress(:end, session_id:
|
112
|
+
notify_progress(:end, session_id: @transfer_id)
|
128
113
|
raise Transfer::Error, transfer['error_desc']
|
129
114
|
when 'cancelled'
|
130
|
-
notify_progress(:end, session_id:
|
115
|
+
notify_progress(:end, session_id: @transfer_id)
|
131
116
|
raise Transfer::Error, 'Transfer cancelled by user'
|
132
117
|
else
|
133
|
-
notify_progress(:end, session_id:
|
118
|
+
notify_progress(:end, session_id: @transfer_id)
|
134
119
|
raise Transfer::Error, "unknown status: #{transfer['status']}: #{transfer['error_desc']}"
|
135
120
|
end
|
136
121
|
end
|
@@ -141,6 +126,23 @@ module Aspera
|
|
141
126
|
end
|
142
127
|
return [:success]
|
143
128
|
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
# @return the file path of local connect where API's URI can be read
|
133
|
+
def connect_api_url
|
134
|
+
connect_locations = Products::Other.find(Products::Connect.locations).first
|
135
|
+
raise "Product: #{name} not found, please install." if connect_locations.nil?
|
136
|
+
folder = File.join(connect_locations[:run_root], 'var', 'run')
|
137
|
+
['', 's'].each do |ext|
|
138
|
+
uri_file = File.join(folder, "http#{ext}.uri")
|
139
|
+
Log.log.debug{"checking connect port file: #{uri_file}"}
|
140
|
+
if File.exist?(uri_file)
|
141
|
+
return File.open(uri_file, &:gets).strip
|
142
|
+
end
|
143
|
+
end
|
144
|
+
raise "no connect uri file found in #{folder}"
|
145
|
+
end
|
144
146
|
end
|
145
147
|
end
|
146
148
|
end
|
@@ -4,13 +4,13 @@ require 'aspera/agent/base'
|
|
4
4
|
require 'aspera/rest'
|
5
5
|
require 'aspera/environment'
|
6
6
|
require 'aspera/json_rpc'
|
7
|
-
require 'aspera/products/
|
7
|
+
require 'aspera/products/desktop'
|
8
8
|
require 'securerandom'
|
9
9
|
|
10
10
|
module Aspera
|
11
11
|
module Agent
|
12
|
-
# Aspera Desktop
|
13
|
-
class
|
12
|
+
# Client: Aspera for Desktop
|
13
|
+
class Desktop < Base
|
14
14
|
# try twice the main init url in sequence
|
15
15
|
START_URIS = ['aspera://', 'aspera://', 'aspera://']
|
16
16
|
# delay between each try to start the app
|
@@ -19,7 +19,7 @@ module Aspera
|
|
19
19
|
|
20
20
|
def initialize(**base_options)
|
21
21
|
@application_id = SecureRandom.uuid
|
22
|
-
@
|
22
|
+
@transfer_id = nil
|
23
23
|
super
|
24
24
|
raise 'Using client requires a graphical environment' if !Environment.default_gui_mode.eql?(:graphical)
|
25
25
|
method_index = 0
|
@@ -33,39 +33,25 @@ module Aspera
|
|
33
33
|
rescue Errno::ECONNREFUSED => e
|
34
34
|
start_url = START_URIS[method_index]
|
35
35
|
method_index += 1
|
36
|
-
raise StandardError, "Unable to start #{Products::
|
37
|
-
Log.log.warn{"#{Products::
|
36
|
+
raise StandardError, "Unable to start #{Products::Desktop::APP_NAME} #{method_index} times" if start_url.nil?
|
37
|
+
Log.log.warn{"#{Products::Desktop::APP_NAME} is not started (#{e}). Trying to start it ##{method_index}..."}
|
38
38
|
if !Environment.open_uri_graphical(start_url)
|
39
39
|
Environment.open_uri_graphical('https://www.ibm.com/aspera/connect/')
|
40
|
-
raise StandardError, "#{Products::
|
40
|
+
raise StandardError, "#{Products::Desktop::APP_NAME} is not installed"
|
41
41
|
end
|
42
42
|
sleep(SLEEP_SEC_BETWEEN_RETRY)
|
43
43
|
retry
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
log_file = Products::Alpha.log_file
|
49
|
-
url = 'http://127.0.0.1:33024'
|
50
|
-
File.open(log_file, 'r') do |file|
|
51
|
-
file.each_line do |line|
|
52
|
-
line = line.chomp
|
53
|
-
if (m = line.match(/JSON-RPC server listening on (.*)/))
|
54
|
-
url = "http://#{m[1]}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
# raise StandardError, "Unable to find the JSON-RPC server URL in #{log_file}" if url.nil?
|
59
|
-
return url
|
60
|
-
end
|
61
|
-
|
47
|
+
# :reek:UnusedParameters token_regenerator
|
62
48
|
def start_transfer(transfer_spec, token_regenerator: nil)
|
63
49
|
@request_id = SecureRandom.uuid
|
64
50
|
# if there is a token, we ask the client app to use well known ssh private keys
|
65
51
|
# instead of asking password
|
66
52
|
transfer_spec['authentication'] = 'token' if transfer_spec.key?('token')
|
67
53
|
result = @client_app_api.start_transfer(app_id: @application_id, desktop_spec: {}, transfer_spec: transfer_spec)
|
68
|
-
@
|
54
|
+
@transfer_id = result['uuid']
|
69
55
|
end
|
70
56
|
|
71
57
|
def wait_for_transfers_completion
|
@@ -73,32 +59,32 @@ module Aspera
|
|
73
59
|
pre_calc = false
|
74
60
|
begin
|
75
61
|
loop do
|
76
|
-
transfer = @client_app_api.get_transfer(app_id: @application_id, transfer_id: @
|
62
|
+
transfer = @client_app_api.get_transfer(app_id: @application_id, transfer_id: @transfer_id)
|
77
63
|
case transfer['status']
|
78
64
|
when 'initiating', 'queued'
|
79
65
|
notify_progress(:pre_start, session_id: nil, info: transfer['status'])
|
80
66
|
when 'running'
|
81
67
|
if !started
|
82
|
-
notify_progress(:session_start, session_id: @
|
68
|
+
notify_progress(:session_start, session_id: @transfer_id)
|
83
69
|
started = true
|
84
70
|
end
|
85
71
|
if !pre_calc && (transfer['bytes_expected'] != 0)
|
86
|
-
notify_progress(:session_size, session_id: @
|
72
|
+
notify_progress(:session_size, session_id: @transfer_id, info: transfer['bytes_expected'])
|
87
73
|
pre_calc = true
|
88
74
|
else
|
89
|
-
notify_progress(:transfer, session_id: @
|
75
|
+
notify_progress(:transfer, session_id: @transfer_id, info: transfer['bytes_written'])
|
90
76
|
end
|
91
77
|
when 'completed'
|
92
|
-
notify_progress(:end, session_id: @
|
78
|
+
notify_progress(:end, session_id: @transfer_id)
|
93
79
|
break
|
94
80
|
when 'failed'
|
95
|
-
notify_progress(:end, session_id: @
|
81
|
+
notify_progress(:end, session_id: @transfer_id)
|
96
82
|
raise Transfer::Error, transfer['error_desc']
|
97
83
|
when 'cancelled'
|
98
|
-
notify_progress(:end, session_id: @
|
84
|
+
notify_progress(:end, session_id: @transfer_id)
|
99
85
|
raise Transfer::Error, 'Transfer cancelled by user'
|
100
86
|
else
|
101
|
-
notify_progress(:end, session_id: @
|
87
|
+
notify_progress(:end, session_id: @transfer_id)
|
102
88
|
raise Transfer::Error, "unknown status: #{transfer['status']}: #{transfer['error_desc']}"
|
103
89
|
end
|
104
90
|
sleep(1)
|
@@ -108,6 +94,24 @@ module Aspera
|
|
108
94
|
end
|
109
95
|
return [:success]
|
110
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# @return [String] the url where transferd is listening
|
101
|
+
def aspera_client_api_url
|
102
|
+
log_file = Products::Desktop.log_file
|
103
|
+
url = 'http://127.0.0.1:33024'
|
104
|
+
File.open(log_file, 'r') do |file|
|
105
|
+
file.each_line do |line|
|
106
|
+
line = line.chomp
|
107
|
+
if (m = line.match(/JSON-RPC server listening on (.*)/))
|
108
|
+
url = "http://#{m[1]}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
# raise StandardError, "Unable to find the JSON-RPC server URL in #{log_file}" if url.nil?
|
113
|
+
return url
|
114
|
+
end
|
111
115
|
end
|
112
116
|
end
|
113
117
|
end
|