aspera-cli 4.9.0 → 4.11.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 +20 -0
- data/CHANGELOG.md +509 -0
- data/CONTRIBUTING.md +118 -0
- data/README.md +1241 -916
- data/bin/ascli +4 -4
- data/bin/asession +11 -11
- data/docs/test_env.conf +32 -21
- data/examples/aoc.rb +4 -4
- data/examples/dascli +16 -9
- data/examples/faspex4.rb +8 -8
- data/examples/node.rb +12 -12
- data/examples/server.rb +10 -10
- data/lib/aspera/aoc.rb +273 -266
- data/lib/aspera/ascmd.rb +56 -54
- data/lib/aspera/ats_api.rb +4 -4
- data/lib/aspera/cli/basic_auth_plugin.rb +15 -12
- data/lib/aspera/cli/extended_value.rb +5 -5
- data/lib/aspera/cli/formater.rb +64 -64
- data/lib/aspera/cli/info.rb +2 -2
- data/lib/aspera/cli/listener/line_dump.rb +1 -1
- data/lib/aspera/cli/listener/logger.rb +1 -1
- data/lib/aspera/cli/listener/progress.rb +5 -6
- data/lib/aspera/cli/listener/progress_multi.rb +14 -19
- data/lib/aspera/cli/main.rb +66 -67
- data/lib/aspera/cli/manager.rb +112 -110
- data/lib/aspera/cli/plugin.rb +57 -36
- data/lib/aspera/cli/plugins/alee.rb +4 -4
- data/lib/aspera/cli/plugins/aoc.rb +309 -670
- data/lib/aspera/cli/plugins/ats.rb +44 -46
- data/lib/aspera/cli/plugins/bss.rb +10 -10
- data/lib/aspera/cli/plugins/config.rb +497 -378
- data/lib/aspera/cli/plugins/console.rb +12 -12
- data/lib/aspera/cli/plugins/cos.rb +18 -20
- data/lib/aspera/cli/plugins/faspex.rb +112 -114
- data/lib/aspera/cli/plugins/faspex5.rb +71 -46
- data/lib/aspera/cli/plugins/node.rb +379 -283
- data/lib/aspera/cli/plugins/orchestrator.rb +46 -46
- data/lib/aspera/cli/plugins/preview.rb +122 -114
- data/lib/aspera/cli/plugins/server.rb +137 -83
- data/lib/aspera/cli/plugins/shares.rb +30 -29
- data/lib/aspera/cli/plugins/sync.rb +13 -33
- data/lib/aspera/cli/transfer_agent.rb +60 -59
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/colors.rb +3 -3
- data/lib/aspera/command_line_builder.rb +27 -27
- data/lib/aspera/cos_node.rb +22 -20
- data/lib/aspera/data_repository.rb +1 -1
- data/lib/aspera/environment.rb +35 -15
- data/lib/aspera/fasp/agent_base.rb +15 -15
- data/lib/aspera/fasp/agent_connect.rb +23 -21
- data/lib/aspera/fasp/agent_direct.rb +66 -64
- data/lib/aspera/fasp/agent_httpgw.rb +141 -78
- data/lib/aspera/fasp/agent_node.rb +23 -21
- data/lib/aspera/fasp/agent_trsdk.rb +20 -20
- data/lib/aspera/fasp/error.rb +3 -2
- data/lib/aspera/fasp/error_info.rb +11 -8
- data/lib/aspera/fasp/installation.rb +79 -79
- data/lib/aspera/fasp/listener.rb +1 -1
- data/lib/aspera/fasp/parameters.rb +86 -71
- data/lib/aspera/fasp/parameters.yaml +7 -4
- data/lib/aspera/fasp/resume_policy.rb +8 -8
- data/lib/aspera/fasp/transfer_spec.rb +35 -2
- data/lib/aspera/fasp/uri.rb +7 -7
- data/lib/aspera/faspex_gw.rb +7 -5
- data/lib/aspera/hash_ext.rb +3 -3
- data/lib/aspera/id_generator.rb +5 -5
- data/lib/aspera/keychain/encrypted_hash.rb +38 -105
- data/lib/aspera/keychain/macos_security.rb +128 -57
- data/lib/aspera/log.rb +7 -7
- data/lib/aspera/nagios.rb +19 -18
- data/lib/aspera/node.rb +209 -35
- data/lib/aspera/oauth.rb +37 -36
- data/lib/aspera/open_application.rb +19 -11
- data/lib/aspera/persistency_action_once.rb +4 -4
- data/lib/aspera/persistency_folder.rb +16 -15
- data/lib/aspera/preview/file_types.rb +8 -8
- data/lib/aspera/preview/generator.rb +67 -67
- data/lib/aspera/preview/utils.rb +27 -27
- data/lib/aspera/proxy_auto_config.js +41 -41
- data/lib/aspera/proxy_auto_config.rb +21 -14
- data/lib/aspera/rest.rb +72 -67
- data/lib/aspera/rest_call_error.rb +2 -1
- data/lib/aspera/rest_error_analyzer.rb +18 -17
- data/lib/aspera/rest_errors_aspera.rb +16 -16
- data/lib/aspera/secret_hider.rb +15 -13
- data/lib/aspera/ssh.rb +11 -10
- data/lib/aspera/sync.rb +158 -44
- data/lib/aspera/temp_file_manager.rb +2 -2
- data/lib/aspera/uri_reader.rb +4 -4
- data/lib/aspera/web_auth.rb +14 -13
- data.tar.gz.sig +0 -0
- metadata +11 -36
- metadata.gz.sig +0 -0
data/bin/ascli
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'securerandom'
|
6
|
-
GEM_ROOT=File.realpath(File.join(File.dirname(File.realpath(__FILE__)),'..'))
|
6
|
+
GEM_ROOT = File.realpath(File.join(File.dirname(File.realpath(__FILE__)), '..'))
|
7
7
|
# coverage for tests
|
8
|
-
if ENV.
|
8
|
+
if ENV.key?('ENABLE_COVERAGE')
|
9
9
|
require 'simplecov'
|
10
10
|
SimpleCov.root(GEM_ROOT)
|
11
11
|
SimpleCov.enable_for_subprocesses if SimpleCov.respond_to?(:enable_for_subprocesses)
|
@@ -14,13 +14,13 @@ if ENV.has_key?('ENABLE_COVERAGE')
|
|
14
14
|
SimpleCov.command_name(SecureRandom.uuid)
|
15
15
|
SimpleCov.at_exit do
|
16
16
|
original_file_descriptor = $stdout
|
17
|
-
$stdout.reopen(File.join(GEM_ROOT,'simplecov.log'))
|
17
|
+
$stdout.reopen(File.join(GEM_ROOT, 'simplecov.log'))
|
18
18
|
SimpleCov.result.format!
|
19
19
|
$stdout.reopen(original_file_descriptor)
|
20
20
|
end
|
21
21
|
SimpleCov.start
|
22
22
|
end
|
23
|
-
$LOAD_PATH.unshift(File.join(GEM_ROOT,'lib'))
|
23
|
+
$LOAD_PATH.unshift(File.join(GEM_ROOT, 'lib'))
|
24
24
|
require 'aspera/cli/main'
|
25
25
|
require 'aspera/environment'
|
26
26
|
Encoding.default_internal = Encoding::UTF_8
|
data/bin/asession
CHANGED
@@ -13,9 +13,9 @@ TS_LOGLEVEL = 'EX_loglevel'
|
|
13
13
|
# by default go to /tmp/username.filelist
|
14
14
|
TS_TMP_FILELIST_FOLDER = 'EX_file_list_folder'
|
15
15
|
|
16
|
-
SAMPLE_DEMO='"remote_host":"demo.asperasoft.com","remote_user":"asperaweb","ssh_port":33001,"remote_password":"demoaspera"'
|
17
|
-
SAMPLE_DEMO2='"direction":"receive","destination_root":"./test.dir"'
|
18
|
-
def assert_usage(assertion,errmsg)
|
16
|
+
SAMPLE_DEMO = '"remote_host":"demo.asperasoft.com","remote_user":"asperaweb","ssh_port":33001,"remote_password":"demoaspera"'
|
17
|
+
SAMPLE_DEMO2 = '"direction":"receive","destination_root":"./test.dir"'
|
18
|
+
def assert_usage(assertion, errmsg)
|
19
19
|
return if assertion
|
20
20
|
$stderr.puts('ERROR: '.red.blink + errmsg) if errmsg
|
21
21
|
$stderr.puts('USAGE')
|
@@ -48,24 +48,24 @@ if ARGV.empty?
|
|
48
48
|
parameter_source_err_msg = ' (JSON on stdin)'
|
49
49
|
end
|
50
50
|
# anyway expect only one argument: session information
|
51
|
-
assert_usage(ARGV.length.eql?(1),'exactly one argument is expected')
|
52
|
-
assert_usage(!['-h','--help'].include?(ARGV.first),nil)
|
51
|
+
assert_usage(ARGV.length.eql?(1), 'exactly one argument is expected')
|
52
|
+
assert_usage(!['-h', '--help'].include?(ARGV.first), nil)
|
53
53
|
# parse transfer spec
|
54
54
|
begin
|
55
55
|
transfer_spec_arg = ARGV.pop
|
56
56
|
transfer_spec = Aspera::Cli::ExtendedValue.instance.evaluate(transfer_spec_arg)
|
57
57
|
rescue
|
58
|
-
assert_usage(false,"Cannot extract transfer spec from: #{transfer_spec_arg}")
|
58
|
+
assert_usage(false, "Cannot extract transfer spec from: #{transfer_spec_arg}")
|
59
59
|
end
|
60
60
|
# ensure right type
|
61
|
-
assert_usage(transfer_spec.is_a?(Hash),"the value must be a hash table#{parameter_source_err_msg}")
|
61
|
+
assert_usage(transfer_spec.is_a?(Hash), "the value must be a hash table#{parameter_source_err_msg}")
|
62
62
|
# additional debug capability
|
63
|
-
if transfer_spec.
|
63
|
+
if transfer_spec.key?(TS_LOGLEVEL)
|
64
64
|
Aspera::Log.instance.level = transfer_spec[TS_LOGLEVEL]
|
65
65
|
transfer_spec.delete(TS_LOGLEVEL)
|
66
66
|
end
|
67
67
|
# possibly override temp folder
|
68
|
-
if transfer_spec.
|
68
|
+
if transfer_spec.key?(TS_TMP_FILELIST_FOLDER)
|
69
69
|
Aspera::Fasp::Parameters.file_list_folder = transfer_spec[TS_TMP_FILELIST_FOLDER]
|
70
70
|
transfer_spec.delete(TS_TMP_FILELIST_FOLDER)
|
71
71
|
end
|
@@ -77,10 +77,10 @@ client.add_listener(Aspera::Cli::Listener::LineDump.new)
|
|
77
77
|
job_id = client.start_transfer(transfer_spec)
|
78
78
|
# async commands
|
79
79
|
Thread.new do
|
80
|
-
begin
|
80
|
+
begin # rubocop:disable Style/RedundantBegin
|
81
81
|
loop do
|
82
82
|
data = JSON.parse($stdin.gets)
|
83
|
-
client.send_command(job_id,0,data)
|
83
|
+
client.send_command(job_id, 0, data)
|
84
84
|
end
|
85
85
|
rescue
|
86
86
|
Process.exit(1)
|
data/docs/test_env.conf
CHANGED
@@ -3,12 +3,11 @@ config:
|
|
3
3
|
version: 4.0.0
|
4
4
|
default:
|
5
5
|
config: cli_default
|
6
|
-
aoc:
|
6
|
+
aoc: tst_aoc_jwt
|
7
7
|
faspex: tst_faspex
|
8
|
-
faspex5:
|
9
|
-
shares:
|
10
|
-
|
11
|
-
node: tst_node
|
8
|
+
faspex5: tst_faspex5_jwt
|
9
|
+
shares: tst_shares
|
10
|
+
node: tst_node_simple
|
12
11
|
server: tst_server
|
13
12
|
orchestrator: tst_orch
|
14
13
|
console: tst_console
|
@@ -19,7 +18,6 @@ default:
|
|
19
18
|
cli_default:
|
20
19
|
interactive: your value here
|
21
20
|
smtp: your value here
|
22
|
-
secrets: your value here
|
23
21
|
local_user:
|
24
22
|
ssh_keys: your value here
|
25
23
|
smtp_config:
|
@@ -31,11 +29,17 @@ smtp_config:
|
|
31
29
|
from_name: your value here
|
32
30
|
username: your value here
|
33
31
|
password: your value here
|
34
|
-
|
32
|
+
tst_aoc_jwt:
|
35
33
|
url: your value here
|
36
34
|
username: your value here
|
37
35
|
auth: your value here
|
38
36
|
private_key: your value here
|
37
|
+
tst_aoc_web:
|
38
|
+
url: your value here
|
39
|
+
auth: your value here
|
40
|
+
redirect_uri: your value here
|
41
|
+
client_id: your value here
|
42
|
+
client_secret: your value here
|
39
43
|
tst_faspex:
|
40
44
|
url: your value here
|
41
45
|
username: your value here
|
@@ -44,10 +48,6 @@ tst_faspex:
|
|
44
48
|
tst_hstsfaspex_ssh:
|
45
49
|
url: your value here
|
46
50
|
username: your value here
|
47
|
-
tst_node_faspex:
|
48
|
-
url: your value here
|
49
|
-
username: your value here
|
50
|
-
password: your value here
|
51
51
|
tst_faspex5_boot:
|
52
52
|
url: your value here
|
53
53
|
auth: your value here
|
@@ -58,8 +58,7 @@ tst_faspex5_web:
|
|
58
58
|
auth: your value here
|
59
59
|
redirect_uri: your value here
|
60
60
|
client_id: your value here
|
61
|
-
|
62
|
-
tst_faspex5:
|
61
|
+
tst_faspex5_jwt:
|
63
62
|
url: your value here
|
64
63
|
auth: your value here
|
65
64
|
client_id: your value here
|
@@ -74,11 +73,23 @@ tst_shares_1:
|
|
74
73
|
url: your value here
|
75
74
|
username: your value here
|
76
75
|
password: your value here
|
77
|
-
|
76
|
+
tst_node_simple:
|
78
77
|
url: your value here
|
79
78
|
username: your value here
|
80
79
|
password: your value here
|
81
|
-
|
80
|
+
tst_node_ak:
|
81
|
+
url: your value here
|
82
|
+
username: your value here
|
83
|
+
password: your value here
|
84
|
+
tst_node_faspex:
|
85
|
+
url: your value here
|
86
|
+
username: your value here
|
87
|
+
password: your value here
|
88
|
+
tst_node_admak:
|
89
|
+
url: your value here
|
90
|
+
username: your value here
|
91
|
+
password: your value here
|
92
|
+
tst_node_preview:
|
82
93
|
url: your value here
|
83
94
|
username: your value here
|
84
95
|
password: your value here
|
@@ -109,15 +120,16 @@ tst_ak_preview:
|
|
109
120
|
username: your value here
|
110
121
|
password: your value here
|
111
122
|
mimemagic: your value here
|
112
|
-
tst_node_preview:
|
113
|
-
url: your value here
|
114
|
-
username: your value here
|
115
|
-
password: your value here
|
116
123
|
tst_cos:
|
117
124
|
apikey: your value here
|
118
125
|
crn: your value here
|
119
126
|
bucket: your value here
|
120
127
|
endpoint: your value here
|
128
|
+
sync:
|
129
|
+
local_path: your value here
|
130
|
+
remote_path: your value here
|
131
|
+
nowss:
|
132
|
+
ts: your value here
|
121
133
|
misc:
|
122
134
|
upload_folder: your value here
|
123
135
|
syncuser: your value here
|
@@ -150,6 +162,7 @@ misc:
|
|
150
162
|
aoc_shbx_meta: your value here
|
151
163
|
aoc_ak_name: your value here
|
152
164
|
aoc_ak_secret: your value here
|
165
|
+
aoc_test_folder: your value here
|
153
166
|
icos_bucket_key: your value here
|
154
167
|
icos_bucket_secret: your value here
|
155
168
|
icos_bucket_name: your value here
|
@@ -163,5 +176,3 @@ misc:
|
|
163
176
|
aoc_user_email: your value here
|
164
177
|
aoc_workspace2: your value here
|
165
178
|
http_gw_fqdn_port: your value here
|
166
|
-
tst_secrets:
|
167
|
-
eudemo-sedemo: your value here
|
data/examples/aoc.rb
CHANGED
@@ -7,9 +7,9 @@ require 'aspera/log'
|
|
7
7
|
Aspera::Log.instance.level = :debug
|
8
8
|
|
9
9
|
if !ARGV.length.eql?(3)
|
10
|
-
Aspera::Log.log.error
|
11
|
-
Aspera::Log.log.error
|
12
|
-
Aspera::Log.log.error
|
10
|
+
Aspera::Log.log.error{"wrong number of args: #{ARGV.length}"}
|
11
|
+
Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <aoc URL> <aoc username> <aoc private key content>"}
|
12
|
+
Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://myorg.ibmaspera.com john@example.com $(cat /home/john/my_key.pem)"}
|
13
13
|
Process.exit(1)
|
14
14
|
end
|
15
15
|
|
@@ -27,4 +27,4 @@ aocapi = Aspera::AoC.new(
|
|
27
27
|
|
28
28
|
self_user_data = aocapi.read('self')
|
29
29
|
|
30
|
-
Aspera::Log.dump('self',self_user_data)
|
30
|
+
Aspera::Log.dump('self', self_user_data)
|
data/examples/dascli
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
|
+
# set env var image to specify another docker image
|
2
3
|
: ${image:=martinlaurent/ascli}
|
3
|
-
#
|
4
|
+
# set env var version to specify another image version (default: latest version)
|
4
5
|
: ${version:=latest}
|
5
|
-
imgtag
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# set env var imgtag to specify a specific image/version
|
7
|
+
: ${imgtag=$image:$version}
|
8
|
+
# set env var `docker` to podman, to use podman
|
9
|
+
: ${docker:=docker}
|
10
|
+
# set env var docker_args to add options to docker run (transform var into array)
|
11
|
+
add_dock_args=( $docker_args )
|
12
|
+
# set env var ASCLI_HOME to set the config folder on host
|
11
13
|
: ${ASCLI_HOME:=$HOME/.aspera/ascli}
|
14
|
+
# main config folder for ascli in container (same value as in `Dockerfile`)
|
15
|
+
ascli_home_container=/home/cliuser/.aspera/ascli
|
12
16
|
if test ! -d $ASCLI_HOME;then
|
13
17
|
echo "creating foder: $ASCLI_HOME"
|
14
18
|
# create it if necessary to allow mounting the volume in container
|
15
19
|
mkdir -p "$ASCLI_HOME"
|
16
20
|
fi
|
17
|
-
exec docker run \
|
21
|
+
exec $docker run \
|
18
22
|
--rm \
|
19
23
|
--tty \
|
20
24
|
--interactive \
|
25
|
+
--user root \
|
26
|
+
--env ASCLI_HOME=$ascli_home_container \
|
21
27
|
--volume "$ASCLI_HOME:$ascli_home_container" \
|
28
|
+
"${add_dock_args[@]}" \
|
22
29
|
$imgtag \
|
23
|
-
|
30
|
+
"$@"
|
data/examples/faspex4.rb
CHANGED
@@ -20,9 +20,9 @@ Aspera::Log.instance.level = :debug
|
|
20
20
|
Aspera::Fasp::Installation.instance.folder = tmpdir
|
21
21
|
|
22
22
|
if !ARGV.length.eql?(3)
|
23
|
-
Aspera::Log.log.error
|
24
|
-
Aspera::Log.log.error
|
25
|
-
Aspera::Log.log.error
|
23
|
+
Aspera::Log.log.error{"Wrong number of args: #{ARGV.length}"}
|
24
|
+
Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <faspex URL> <faspex username> <faspex password>"}
|
25
|
+
Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://faspex.com/aspera/faspex john p@sSw0rd"}
|
26
26
|
Process.exit(1)
|
27
27
|
end
|
28
28
|
|
@@ -52,7 +52,7 @@ api_v3.read('me')
|
|
52
52
|
#---------------
|
53
53
|
|
54
54
|
# create a sample file to send
|
55
|
-
file_to_send = File.join(tmpdir,'myfile.bin')
|
55
|
+
file_to_send = File.join(tmpdir, 'myfile.bin')
|
56
56
|
File.write(file_to_send, 'sample data')
|
57
57
|
# package creation parameters
|
58
58
|
package_create_params = {'delivery' => {
|
@@ -60,7 +60,7 @@ package_create_params = {'delivery' => {
|
|
60
60
|
'recipients' => ['aspera.user1@gmail.com'],
|
61
61
|
'sources' => [{'paths' => [file_to_send]}]
|
62
62
|
}}
|
63
|
-
pkg_created = api_v3.create('send',package_create_params)[:data]
|
63
|
+
pkg_created = api_v3.create('send', package_create_params)[:data]
|
64
64
|
# get transfer specification (normally: only one)
|
65
65
|
transfer_spec = pkg_created['xfer_sessions'].first
|
66
66
|
# set paths of files to send
|
@@ -69,12 +69,12 @@ transfer_spec['paths'] = [{'source' => file_to_send}]
|
|
69
69
|
transfer_client = Aspera::Fasp::AgentDirect.new({quiet: true})
|
70
70
|
# start transfer (asynchronous)
|
71
71
|
job_id = transfer_client.start_transfer(transfer_spec)
|
72
|
-
Aspera::Log.dump('job_id',job_id)
|
72
|
+
Aspera::Log.dump('job_id', job_id)
|
73
73
|
# wait for all transfer completion (for the example)
|
74
74
|
result = transfer_client.wait_for_transfers_completion
|
75
75
|
# notify of any transfer error
|
76
76
|
result.reject{|i|i.eql?(:success)}.each do |e|
|
77
|
-
Aspera::Log.log.error
|
77
|
+
Aspera::Log.log.error{"A transfer error occurred: #{e.message}"}
|
78
78
|
end
|
79
79
|
|
80
80
|
# 3: Faspex 4 API v4
|
@@ -91,4 +91,4 @@ api_v4 = Aspera::Rest.new({
|
|
91
91
|
}})
|
92
92
|
|
93
93
|
# Use it. Note that Faspex 4 API v4 is totally different from Faspex 4 v3 APIs, see ref on line 2
|
94
|
-
Aspera::Log.dump('users',api_v4.read('users')[:data])
|
94
|
+
Aspera::Log.dump('users', api_v4.read('users')[:data])
|
data/examples/node.rb
CHANGED
@@ -15,7 +15,7 @@ require 'tmpdir'
|
|
15
15
|
|
16
16
|
tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
|
17
17
|
|
18
|
-
raise 'Usage: PASSWORD=<password> $0 https://<address>:<port> <node user>' unless ARGV.length.eql?(2) && ENV.
|
18
|
+
raise 'Usage: PASSWORD=<password> $0 https://<address>:<port> <node user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
|
19
19
|
|
20
20
|
# example : https://node_asperaweb@eudemo.asperademo.com:9092
|
21
21
|
node_uri = URI.parse(ARGV.shift)
|
@@ -34,10 +34,10 @@ Aspera::RestErrorsAspera.register_handlers
|
|
34
34
|
# some required files are generated here (keys, certs)
|
35
35
|
Aspera::Fasp::Installation.instance.folder = tmpdir
|
36
36
|
# set path to your copy of ascp binary (else, let the system find)
|
37
|
-
Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.
|
37
|
+
Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
|
38
38
|
# another way is to detect installed products and use one of them
|
39
|
-
#Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
|
40
|
-
#Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
|
39
|
+
# Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
|
40
|
+
# Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
|
41
41
|
# or install:
|
42
42
|
#
|
43
43
|
|
@@ -45,10 +45,10 @@ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('asc
|
|
45
45
|
transfer_agent = Aspera::Fasp::AgentDirect.new
|
46
46
|
|
47
47
|
# Note that it would also be possible to start transfers using other agents
|
48
|
-
#require 'aspera/fasp/connect'
|
49
|
-
#transfer_agent=Aspera::Fasp::Connect.new
|
50
|
-
#require 'aspera/fasp/node'
|
51
|
-
#transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
|
48
|
+
# require 'aspera/fasp/connect'
|
49
|
+
# transfer_agent=Aspera::Fasp::Connect.new
|
50
|
+
# require 'aspera/fasp/node'
|
51
|
+
# transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
|
52
52
|
|
53
53
|
##############################################################
|
54
54
|
# Optional : register an event listener
|
@@ -57,7 +57,7 @@ transfer_agent = Aspera::Fasp::AgentDirect.new
|
|
57
57
|
class MyListener < Aspera::Fasp::Listener
|
58
58
|
# this is the callback called during transfers, here we only display the received information
|
59
59
|
# but it could be used to get detailed error information, check "type" field is "ERROR"
|
60
|
-
def event_enhanced(data)
|
60
|
+
def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
|
61
61
|
end
|
62
62
|
|
63
63
|
# register the sample listener to display events
|
@@ -78,9 +78,9 @@ node_api = Aspera::Rest.new({
|
|
78
78
|
sources = ["#{tmpdir}/sample_file.txt"]
|
79
79
|
destination = '/Upload'
|
80
80
|
# create sample file(s)
|
81
|
-
sources.each{|p|File.write(p,'Hello World!')}
|
81
|
+
sources.each{|p|File.write(p, 'Hello World!')}
|
82
82
|
# request transfer authorization to node for a single transfer (This is a node api v3 call)
|
83
|
-
send_result = node_api.create('files/upload_setup',{ transfer_requests: [{ transfer_request: { paths: [{ destination: destination }] } }] })[:data]
|
83
|
+
send_result = node_api.create('files/upload_setup', { transfer_requests: [{ transfer_request: { paths: [{ destination: destination }] } }] })[:data]
|
84
84
|
# we normally have only one transfer spec in list, so just get the first transfer_spec
|
85
85
|
transfer_spec = send_result['transfer_specs'].first['transfer_spec']
|
86
86
|
# add list of files to upload
|
@@ -93,4 +93,4 @@ transfer_agent.start_transfer(transfer_spec)
|
|
93
93
|
transfer_result = transfer_agent.wait_for_transfers_completion
|
94
94
|
errors = transfer_result.reject{|i|i.eql?(:success)}
|
95
95
|
# the transfer was not success, as there is at least one error
|
96
|
-
raise "Error(s)
|
96
|
+
raise "Error(s) occurred: #{errors.join(',')}" if !errors.empty?
|
data/examples/server.rb
CHANGED
@@ -15,7 +15,7 @@ require 'tmpdir'
|
|
15
15
|
|
16
16
|
tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
|
17
17
|
|
18
|
-
raise 'Usage: PASSWORD=<password> $0 ssh://<address>:<port> <transfer user>' unless ARGV.length.eql?(2) && ENV.
|
18
|
+
raise 'Usage: PASSWORD=<password> $0 ssh://<address>:<port> <transfer user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
|
19
19
|
|
20
20
|
# example : ssh://asperaweb@eudemo.asperademo.com:33001
|
21
21
|
server_uri = URI.parse(ARGV.shift)
|
@@ -34,10 +34,10 @@ Aspera::RestErrorsAspera.register_handlers
|
|
34
34
|
# some required files are generated here (keys, certs)
|
35
35
|
Aspera::Fasp::Installation.instance.folder = tmpdir
|
36
36
|
# set path to your copy of ascp binary (else, let the system find)
|
37
|
-
Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.
|
37
|
+
Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
|
38
38
|
# another way is to detect installed products and use one of them
|
39
|
-
#Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
|
40
|
-
#Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
|
39
|
+
# Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
|
40
|
+
# Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
|
41
41
|
# or install:
|
42
42
|
#
|
43
43
|
|
@@ -45,10 +45,10 @@ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('asc
|
|
45
45
|
transfer_agent = Aspera::Fasp::AgentDirect.new
|
46
46
|
|
47
47
|
# Note that it would also be possible to start transfers using other agents
|
48
|
-
#require 'aspera/fasp/connect'
|
49
|
-
#transfer_agent=Aspera::Fasp::Connect.new
|
50
|
-
#require 'aspera/fasp/node'
|
51
|
-
#transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
|
48
|
+
# require 'aspera/fasp/connect'
|
49
|
+
# transfer_agent=Aspera::Fasp::Connect.new
|
50
|
+
# require 'aspera/fasp/node'
|
51
|
+
# transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
|
52
52
|
|
53
53
|
##############################################################
|
54
54
|
# Optional : register an event listener
|
@@ -57,7 +57,7 @@ transfer_agent = Aspera::Fasp::AgentDirect.new
|
|
57
57
|
class MyListener < Aspera::Fasp::Listener
|
58
58
|
# this is the callback called during transfers, here we only display the received information
|
59
59
|
# but it could be used to get detailed error information, check "type" field is "ERROR"
|
60
|
-
def event_enhanced(data)
|
60
|
+
def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
|
61
61
|
end
|
62
62
|
|
63
63
|
# register the sample listener to display events
|
@@ -90,4 +90,4 @@ $stdout.puts(JSON.generate(transfer_result))
|
|
90
90
|
# get list of errors only
|
91
91
|
errors = transfer_result.reject{|i|i.eql?(:success)}
|
92
92
|
# the transfer was not success, as there is at least one error
|
93
|
-
raise "Error(s)
|
93
|
+
raise "Error(s) occurred: #{errors.join(',')}" if !errors.empty?
|