aspera-cli 4.6.0 → 4.7.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
- data/README.md +427 -300
- data/bin/ascli +2 -1
- data/bin/asession +1 -0
- data/docs/test_env.conf +2 -0
- data/examples/aoc.rb +4 -3
- data/examples/faspex4.rb +21 -19
- data/examples/proxy.pac +1 -1
- data/examples/transfer.rb +15 -15
- data/lib/aspera/aoc.rb +135 -124
- data/lib/aspera/ascmd.rb +85 -75
- data/lib/aspera/ats_api.rb +11 -10
- data/lib/aspera/cli/basic_auth_plugin.rb +13 -14
- data/lib/aspera/cli/extended_value.rb +42 -33
- data/lib/aspera/cli/formater.rb +138 -111
- data/lib/aspera/cli/info.rb +17 -0
- data/lib/aspera/cli/listener/line_dump.rb +3 -2
- data/lib/aspera/cli/listener/logger.rb +2 -1
- data/lib/aspera/cli/listener/progress.rb +16 -18
- data/lib/aspera/cli/listener/progress_multi.rb +13 -16
- data/lib/aspera/cli/main.rb +122 -130
- data/lib/aspera/cli/manager.rb +146 -154
- data/lib/aspera/cli/plugin.rb +38 -34
- data/lib/aspera/cli/plugins/alee.rb +6 -6
- data/lib/aspera/cli/plugins/aoc.rb +273 -276
- data/lib/aspera/cli/plugins/ats.rb +82 -76
- data/lib/aspera/cli/plugins/bss.rb +14 -16
- data/lib/aspera/cli/plugins/config.rb +350 -306
- data/lib/aspera/cli/plugins/console.rb +23 -19
- data/lib/aspera/cli/plugins/cos.rb +18 -18
- data/lib/aspera/cli/plugins/faspex.rb +180 -159
- data/lib/aspera/cli/plugins/faspex5.rb +64 -54
- data/lib/aspera/cli/plugins/node.rb +147 -140
- data/lib/aspera/cli/plugins/orchestrator.rb +68 -66
- data/lib/aspera/cli/plugins/preview.rb +92 -96
- data/lib/aspera/cli/plugins/server.rb +79 -75
- data/lib/aspera/cli/plugins/shares.rb +23 -24
- data/lib/aspera/cli/plugins/sync.rb +20 -22
- data/lib/aspera/cli/transfer_agent.rb +40 -39
- data/lib/aspera/cli/version.rb +2 -1
- data/lib/aspera/colors.rb +35 -27
- data/lib/aspera/command_line_builder.rb +48 -34
- data/lib/aspera/cos_node.rb +29 -21
- data/lib/aspera/data_repository.rb +3 -2
- data/lib/aspera/environment.rb +50 -45
- data/lib/aspera/fasp/agent_base.rb +22 -20
- data/lib/aspera/fasp/agent_connect.rb +13 -11
- data/lib/aspera/fasp/agent_direct.rb +48 -59
- data/lib/aspera/fasp/agent_httpgw.rb +33 -39
- data/lib/aspera/fasp/agent_node.rb +15 -13
- data/lib/aspera/fasp/agent_trsdk.rb +12 -14
- data/lib/aspera/fasp/error.rb +2 -1
- data/lib/aspera/fasp/error_info.rb +68 -52
- data/lib/aspera/fasp/installation.rb +106 -94
- data/lib/aspera/fasp/listener.rb +1 -0
- data/lib/aspera/fasp/parameters.rb +83 -92
- data/lib/aspera/fasp/parameters.yaml +305 -249
- data/lib/aspera/fasp/resume_policy.rb +11 -14
- data/lib/aspera/fasp/transfer_spec.rb +26 -0
- data/lib/aspera/fasp/uri.rb +22 -21
- data/lib/aspera/faspex_gw.rb +55 -90
- data/lib/aspera/hash_ext.rb +4 -3
- data/lib/aspera/id_generator.rb +8 -7
- data/lib/aspera/keychain/encrypted_hash.rb +17 -16
- data/lib/aspera/keychain/macos_security.rb +6 -10
- data/lib/aspera/log.rb +25 -20
- data/lib/aspera/nagios.rb +13 -12
- data/lib/aspera/node.rb +30 -22
- data/lib/aspera/oauth.rb +175 -226
- data/lib/aspera/open_application.rb +4 -3
- data/lib/aspera/persistency_action_once.rb +6 -6
- data/lib/aspera/persistency_folder.rb +5 -9
- data/lib/aspera/preview/file_types.rb +6 -5
- data/lib/aspera/preview/generator.rb +25 -24
- data/lib/aspera/preview/options.rb +16 -14
- data/lib/aspera/preview/utils.rb +98 -98
- data/lib/aspera/{proxy_auto_config.erb.js → proxy_auto_config.js} +23 -31
- data/lib/aspera/proxy_auto_config.rb +111 -20
- data/lib/aspera/rest.rb +115 -113
- data/lib/aspera/rest_call_error.rb +2 -2
- data/lib/aspera/rest_error_analyzer.rb +23 -25
- data/lib/aspera/rest_errors_aspera.rb +15 -14
- data/lib/aspera/ssh.rb +12 -10
- data/lib/aspera/sync.rb +42 -41
- data/lib/aspera/temp_file_manager.rb +18 -14
- data/lib/aspera/timer_limiter.rb +2 -1
- data/lib/aspera/uri_reader.rb +7 -5
- data/lib/aspera/web_auth.rb +79 -76
- metadata +64 -21
- data/docs/Makefile +0 -65
- data/docs/README.erb.md +0 -4424
- 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,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'aspera/cli/basic_auth_plugin'
|
|
2
3
|
require 'aspera/nagios'
|
|
3
4
|
require 'aspera/hash_ext'
|
|
4
5
|
require 'aspera/id_generator'
|
|
5
6
|
require 'aspera/node'
|
|
7
|
+
require 'aspera/fasp/transfer_spec'
|
|
6
8
|
require 'base64'
|
|
7
9
|
require 'zlib'
|
|
8
10
|
|
|
@@ -27,30 +29,29 @@ module Aspera
|
|
|
27
29
|
super(env)
|
|
28
30
|
# this is added to some requests , for instance to add tags (COS)
|
|
29
31
|
@add_request_param = env[:add_request_param] || {}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
options.add_opt_simple(:validator,'identifier of validator (optional for central)')
|
|
33
|
+
options.add_opt_simple(:asperabrowserurl,'URL for simple aspera web ui')
|
|
34
|
+
options.add_opt_simple(:sync_name,'sync name')
|
|
35
|
+
options.add_opt_list(:token_type,[:aspera,:basic,:hybrid],'Type of token used for transfers')
|
|
36
|
+
options.set_option(:asperabrowserurl,'https://asperabrowser.mybluemix.net')
|
|
37
|
+
options.set_option(:token_type,:aspera)
|
|
38
|
+
options.parse_options!
|
|
37
39
|
return if env[:man_only]
|
|
40
|
+
@api_node=
|
|
38
41
|
if env.has_key?(:node_api)
|
|
39
|
-
|
|
42
|
+
env[:node_api]
|
|
43
|
+
elsif options.get_option(:password,:mandatory).start_with?('Bearer ')
|
|
44
|
+
# info is provided like node_info of aoc
|
|
45
|
+
Rest.new({
|
|
46
|
+
base_url: options.get_option(:url,:mandatory),
|
|
47
|
+
headers: {
|
|
48
|
+
'Authorization' => options.get_option(:password,:mandatory),
|
|
49
|
+
'X-Aspera-AccessKey' => options.get_option(:username,:mandatory)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
40
52
|
else
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@api_node=Rest.new({
|
|
44
|
-
base_url: self.options.get_option(:url,:mandatory),
|
|
45
|
-
headers: {
|
|
46
|
-
'Authorization' => self.options.get_option(:password,:mandatory),
|
|
47
|
-
'X-Aspera-AccessKey' => self.options.get_option(:username,:mandatory),
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
else
|
|
51
|
-
# this is normal case
|
|
52
|
-
@api_node=basic_auth_api
|
|
53
|
-
end
|
|
53
|
+
# this is normal case
|
|
54
|
+
basic_auth_api
|
|
54
55
|
end
|
|
55
56
|
end
|
|
56
57
|
|
|
@@ -61,14 +62,13 @@ module Aspera
|
|
|
61
62
|
# key/value is defined in main in hash_table
|
|
62
63
|
def c_textify_bool_list_result(list,name_list)
|
|
63
64
|
list.each_index do |i|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
list.delete_at(i)
|
|
69
|
-
# continue at same index because we delete current one
|
|
70
|
-
redo
|
|
65
|
+
next unless name_list.include?(list[i]['key'])
|
|
66
|
+
list[i]['value'].each do |item|
|
|
67
|
+
list.push({'key'=>item['name'],'value'=>item['value']})
|
|
71
68
|
end
|
|
69
|
+
list.delete_at(i)
|
|
70
|
+
# continue at same index because we delete current one
|
|
71
|
+
redo
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
@@ -78,11 +78,11 @@ module Aspera
|
|
|
78
78
|
case result[:type]
|
|
79
79
|
when :object_list
|
|
80
80
|
result[:data].each do |item|
|
|
81
|
-
item[column]
|
|
81
|
+
item[column]=item[column][path_prefix.length..-1] if item[column].start_with?(path_prefix)
|
|
82
82
|
end
|
|
83
83
|
when :single_object
|
|
84
84
|
item=result[:data]
|
|
85
|
-
item[column]
|
|
85
|
+
item[column]=item[column][path_prefix.length..-1] if item[column].start_with?(path_prefix)
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
return result
|
|
@@ -95,7 +95,7 @@ module Aspera
|
|
|
95
95
|
result=success_msg
|
|
96
96
|
if p.has_key?('error')
|
|
97
97
|
Log.log.error("#{p['error']['user_message']} : #{p['path']}")
|
|
98
|
-
result=
|
|
98
|
+
result='ERROR: '+p['error']['user_message']
|
|
99
99
|
end
|
|
100
100
|
resres[:data].push({type=>p['path'],'result'=>result})
|
|
101
101
|
end
|
|
@@ -104,16 +104,16 @@ module Aspera
|
|
|
104
104
|
|
|
105
105
|
# get path arguments from command line, and add prefix
|
|
106
106
|
def get_next_arg_add_prefix(path_prefix,name,number=:single)
|
|
107
|
-
thepath=
|
|
107
|
+
thepath=options.get_next_argument(name,number)
|
|
108
108
|
return thepath if path_prefix.nil?
|
|
109
109
|
return File.join(path_prefix,thepath) if thepath.is_a?(String)
|
|
110
110
|
return thepath.map {|p| File.join(path_prefix,p)} if thepath.is_a?(Array)
|
|
111
|
-
raise StandardError,
|
|
111
|
+
raise StandardError,'expect: nil, String or Array'
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
SIMPLE_ACTIONS=[:health,:events, :space, :info, :license, :mkdir, :mklink, :mkfile, :rename, :delete, :search
|
|
114
|
+
SIMPLE_ACTIONS=[:health,:events, :space, :info, :license, :mkdir, :mklink, :mkfile, :rename, :delete, :search]
|
|
115
115
|
|
|
116
|
-
COMMON_ACTIONS=[:browse, :upload, :download, :api_details
|
|
116
|
+
COMMON_ACTIONS=[:browse, :upload, :download, :api_details].concat(SIMPLE_ACTIONS)
|
|
117
117
|
|
|
118
118
|
# common API to node and Shares
|
|
119
119
|
# prefix_path is used to list remote sources in Faspex
|
|
@@ -125,137 +125,146 @@ module Aspera
|
|
|
125
125
|
info=@api_node.read('info')[:data]
|
|
126
126
|
nagios.add_ok('node api','accessible')
|
|
127
127
|
nagios.check_time_offset(info['current_time'],'node api')
|
|
128
|
-
nagios.check_product_version(
|
|
129
|
-
rescue => e
|
|
128
|
+
nagios.check_product_version('node api','entsrv', info['version'])
|
|
129
|
+
rescue StandardError => e
|
|
130
130
|
nagios.add_critical('node api',e.to_s)
|
|
131
131
|
end
|
|
132
132
|
begin
|
|
133
|
-
@api_node.call({ operation: 'POST', subpath: 'services/soap/Transfer-201210',
|
|
133
|
+
@api_node.call({ operation: 'POST', subpath: 'services/soap/Transfer-201210',
|
|
134
|
+
headers: {'Content-Type'=>'text/xml;charset=UTF-8','SOAPAction'=>'FASPSessionNET-200911#GetSessionInfo'}, text_body_params: SAMPLE_SOAP_CALL})[:http].body
|
|
134
135
|
nagios.add_ok('central','accessible by node')
|
|
135
|
-
rescue => e
|
|
136
|
+
rescue StandardError => e
|
|
136
137
|
nagios.add_critical('central',e.to_s)
|
|
137
138
|
end
|
|
138
139
|
return nagios.result
|
|
139
140
|
when :events
|
|
140
|
-
events=@api_node.read('events',
|
|
141
|
+
events=@api_node.read('events',options.get_option(:value,:optional))[:data]
|
|
141
142
|
return { type: :object_list, data: events}
|
|
142
143
|
when :info
|
|
143
144
|
node_info=@api_node.read('info')[:data]
|
|
144
145
|
return { type: :single_object, data: node_info, textify: lambda { |table_data| c_textify_bool_list_result(table_data,['capabilities','settings'])}}
|
|
145
146
|
when :license # requires: asnodeadmin -mu <node user> --acl-add=internal --internal
|
|
146
147
|
node_license=@api_node.read('license')[:data]
|
|
147
|
-
if node_license['failure'].is_a?(String)
|
|
148
|
-
Log.log.error(
|
|
148
|
+
if node_license['failure'].is_a?(String) && node_license['failure'].include?('ACL')
|
|
149
|
+
Log.log.error('server must have: asnodeadmin -mu <node user> --acl-add=internal --internal')
|
|
149
150
|
end
|
|
150
151
|
return { type: :single_object, data: node_license}
|
|
151
152
|
when :delete
|
|
152
|
-
paths_to_delete = get_next_arg_add_prefix(prefix_path,
|
|
153
|
+
paths_to_delete = get_next_arg_add_prefix(prefix_path,'file list',:multiple)
|
|
153
154
|
resp=@api_node.create('files/delete',{ paths: paths_to_delete.map{|i| {'path'=>i.start_with?('/') ? i : '/'+i} }})
|
|
154
155
|
return c_result_translate_rem_prefix(resp,'file','deleted',prefix_path)
|
|
155
156
|
when :search
|
|
156
|
-
search_root = get_next_arg_add_prefix(prefix_path,
|
|
157
|
+
search_root = get_next_arg_add_prefix(prefix_path,'search root')
|
|
157
158
|
parameters={'path'=>search_root}
|
|
158
|
-
other_options=
|
|
159
|
+
other_options=options.get_option(:value,:optional)
|
|
159
160
|
parameters.merge!(other_options) unless other_options.nil?
|
|
160
161
|
resp=@api_node.create('files/search',parameters)
|
|
161
162
|
result={ type: :object_list, data: resp[:data]['items']}
|
|
162
163
|
return Main.result_empty if result[:data].empty?
|
|
163
|
-
result[:fields]=result[:data].first.keys.
|
|
164
|
+
result[:fields]=result[:data].first.keys.reject{|i|['basename','permissions'].include?(i)}
|
|
164
165
|
self.format.display_status("Items: #{resp[:data]['item_count']}/#{resp[:data]['total_count']}")
|
|
165
166
|
self.format.display_status("params: #{resp[:data]['parameters'].keys.map{|k|"#{k}:#{resp[:data]['parameters'][k]}"}.join(',')}")
|
|
166
167
|
return c_result_remove_prefix_path(result,'path',prefix_path)
|
|
167
168
|
when :space
|
|
168
169
|
# TODO: could be a list of path
|
|
169
|
-
path_list=get_next_arg_add_prefix(prefix_path,
|
|
170
|
+
path_list=get_next_arg_add_prefix(prefix_path,'folder path or ext.val. list')
|
|
170
171
|
path_list=[path_list] unless path_list.is_a?(Array)
|
|
171
|
-
resp=@api_node.create('space',{
|
|
172
|
+
resp=@api_node.create('space',{ 'paths' => path_list.map {|i| { path: i} } })
|
|
172
173
|
result={ data: resp[:data]['paths'], type: :object_list}
|
|
173
174
|
#return c_result_translate_rem_prefix(resp,'folder','created',prefix_path)
|
|
174
175
|
return c_result_remove_prefix_path(result,'path',prefix_path)
|
|
175
176
|
when :mkdir
|
|
176
|
-
path_list=get_next_arg_add_prefix(prefix_path,
|
|
177
|
+
path_list=get_next_arg_add_prefix(prefix_path,'folder path or ext.val. list')
|
|
177
178
|
path_list=[path_list] unless path_list.is_a?(Array)
|
|
178
179
|
#TODO: a command for that ?
|
|
179
180
|
#resp=@api_node.create('space',{ "paths" => path_list.map {|i| { type: :directory, path: i} } } )
|
|
180
|
-
resp=@api_node.create('files/create',{
|
|
181
|
+
resp=@api_node.create('files/create',{ 'paths' => [{ type: :directory, path: path_list }] })
|
|
181
182
|
return c_result_translate_rem_prefix(resp,'folder','created',prefix_path)
|
|
182
183
|
when :mklink
|
|
183
|
-
target=get_next_arg_add_prefix(prefix_path,
|
|
184
|
-
path_list=get_next_arg_add_prefix(prefix_path,
|
|
185
|
-
resp=@api_node.create('files/create',{
|
|
184
|
+
target=get_next_arg_add_prefix(prefix_path,'target')
|
|
185
|
+
path_list=get_next_arg_add_prefix(prefix_path,'link path')
|
|
186
|
+
resp=@api_node.create('files/create',{ 'paths' => [{ type: :symbolic_link, path: path_list, target: { path: target} }] })
|
|
186
187
|
return c_result_translate_rem_prefix(resp,'folder','created',prefix_path)
|
|
187
188
|
when :mkfile
|
|
188
|
-
path_list=get_next_arg_add_prefix(prefix_path,
|
|
189
|
-
contents64=Base64.strict_encode64(
|
|
190
|
-
resp=@api_node.create('files/create',{
|
|
189
|
+
path_list=get_next_arg_add_prefix(prefix_path,'file path')
|
|
190
|
+
contents64=Base64.strict_encode64(options.get_next_argument('contents'))
|
|
191
|
+
resp=@api_node.create('files/create',{ 'paths' => [{ type: :file, path: path_list, contents: contents64 }] })
|
|
191
192
|
return c_result_translate_rem_prefix(resp,'folder','created',prefix_path)
|
|
192
193
|
when :rename
|
|
193
|
-
path_base=get_next_arg_add_prefix(prefix_path,
|
|
194
|
-
path_src=get_next_arg_add_prefix(prefix_path,
|
|
195
|
-
path_dst=get_next_arg_add_prefix(prefix_path,
|
|
196
|
-
resp=@api_node.create('files/rename',{
|
|
194
|
+
path_base=get_next_arg_add_prefix(prefix_path,'path_base')
|
|
195
|
+
path_src=get_next_arg_add_prefix(prefix_path,'path_src')
|
|
196
|
+
path_dst=get_next_arg_add_prefix(prefix_path,'path_dst')
|
|
197
|
+
resp=@api_node.create('files/rename',{ 'paths' => [{ 'path' => path_base, 'source' => path_src, 'destination' => path_dst }] })
|
|
197
198
|
return c_result_translate_rem_prefix(resp,'entry','moved',prefix_path)
|
|
198
199
|
when :browse
|
|
199
|
-
thepath=get_next_arg_add_prefix(prefix_path,
|
|
200
|
+
thepath=get_next_arg_add_prefix(prefix_path,'path')
|
|
200
201
|
query={ path: thepath}
|
|
201
|
-
additional_query=
|
|
202
|
+
additional_query=options.get_option(:query,:optional)
|
|
202
203
|
query.merge!(additional_query) unless additional_query.nil?
|
|
203
204
|
send_result=@api_node.create('files/browse', query)[:data]
|
|
204
205
|
#example: send_result={'items'=>[{'file'=>"filename1","permissions"=>[{'name'=>'read'},{'name'=>'write'}]}]}
|
|
205
206
|
# if there is no items
|
|
206
207
|
case send_result['self']['type']
|
|
207
208
|
when 'directory','container' # directory: node, container: shares
|
|
208
|
-
result={ data: send_result['items']
|
|
209
|
+
result={ data: send_result['items'], type: :object_list, textify: lambda { |table_data| c_textify_browse(table_data) } }
|
|
209
210
|
self.format.display_status("Items: #{send_result['item_count']}/#{send_result['total_count']}")
|
|
210
211
|
else # 'file','symbolic_link'
|
|
211
|
-
result={ data: send_result['self']
|
|
212
|
+
result={ data: send_result['self'], type: :single_object}
|
|
212
213
|
#result={ data: [send_result['self']] , type: :object_list, textify: lambda { |table_data| c_textify_browse(table_data) } }
|
|
213
214
|
#raise "unknown type: #{send_result['self']['type']}"
|
|
214
215
|
end
|
|
215
216
|
return c_result_remove_prefix_path(result,'path',prefix_path)
|
|
216
217
|
when :upload,:download
|
|
217
|
-
token_type=
|
|
218
|
+
token_type=options.get_option(:token_type,:optional)
|
|
218
219
|
# nil if Shares 1.x
|
|
219
220
|
token_type=:aspera if token_type.nil?
|
|
220
221
|
case token_type
|
|
221
222
|
when :aspera,:hybrid
|
|
222
|
-
transfer_paths=
|
|
223
|
-
|
|
224
|
-
when :
|
|
223
|
+
transfer_paths=
|
|
224
|
+
case command
|
|
225
|
+
when :upload then[{ destination: transfer.destination_folder('send') }]
|
|
226
|
+
when :download then transfer.ts_source_paths
|
|
225
227
|
end
|
|
226
228
|
# only one request, so only one answer
|
|
227
|
-
transfer_spec=@api_node.create("files/#{command}_setup",{ transfer_requests: [
|
|
229
|
+
transfer_spec=@api_node.create("files/#{command}_setup",{ transfer_requests: [{ transfer_request: {
|
|
228
230
|
paths: transfer_paths
|
|
229
|
-
}.deep_merge(@add_request_param) }
|
|
231
|
+
}.deep_merge(@add_request_param) }] })[:data]['transfer_specs'].first['transfer_spec']
|
|
230
232
|
# delete this part, as the returned value contains only destination, and not sources
|
|
231
233
|
transfer_spec.delete('paths') if command.eql?(:upload)
|
|
232
234
|
when :basic
|
|
233
|
-
raise
|
|
234
|
-
raise
|
|
235
|
+
raise 'shall have auth' unless @api_node.params[:auth].is_a?(Hash)
|
|
236
|
+
raise 'shall be basic auth' unless @api_node.params[:auth][:type].eql?(:basic)
|
|
237
|
+
ts_direction=
|
|
238
|
+
case command
|
|
239
|
+
when :upload then Fasp::TransferSpec::DIRECTION_SEND
|
|
240
|
+
when :download then Fasp::TransferSpec::DIRECTION_RECEIVE
|
|
241
|
+
else raise 'Error: need upload or download'
|
|
242
|
+
end
|
|
235
243
|
transfer_spec={
|
|
236
|
-
'remote_host'=>URI.parse(@api_node.params[:base_url]).host,
|
|
237
|
-
'remote_user'=>Aspera::Fasp::
|
|
238
|
-
'ssh_port'
|
|
239
|
-
'direction'
|
|
244
|
+
'remote_host' =>URI.parse(@api_node.params[:base_url]).host,
|
|
245
|
+
'remote_user' =>Aspera::Fasp::TransferSpec::ACCESS_KEY_TRANSFER_USER,
|
|
246
|
+
'ssh_port' =>Aspera::Fasp::TransferSpec::SSH_PORT,
|
|
247
|
+
'direction' =>ts_direction,
|
|
248
|
+
'destination_root'=>transfer.destination_folder(ts_direction)
|
|
240
249
|
}.deep_merge(@add_request_param)
|
|
241
250
|
else raise "ERROR: token_type #{tt}"
|
|
242
251
|
end
|
|
243
252
|
if [:basic,:hybrid].include?(token_type)
|
|
244
253
|
Aspera::Node.set_ak_basic_token(transfer_spec,@api_node.params[:auth][:username],@api_node.params[:auth][:password])
|
|
245
254
|
end
|
|
246
|
-
return Main.result_transfer(
|
|
255
|
+
return Main.result_transfer(transfer.start(transfer_spec,{ src: :node_gen3}))
|
|
247
256
|
when :api_details
|
|
248
257
|
return { type: :single_object, data: @api_node.params }
|
|
249
258
|
end
|
|
250
259
|
end
|
|
251
260
|
|
|
252
261
|
def execute_async
|
|
253
|
-
command=
|
|
262
|
+
command=options.get_next_command([:list,:delete,:files,:show,:counters,:bandwidth])
|
|
254
263
|
unless command.eql?(:list)
|
|
255
|
-
asyncname=
|
|
264
|
+
asyncname=options.get_option(:sync_name,:optional)
|
|
256
265
|
if asyncname.nil?
|
|
257
|
-
asyncid=
|
|
258
|
-
if asyncid.eql?('ALL')
|
|
266
|
+
asyncid=instance_identifier()
|
|
267
|
+
if asyncid.eql?('ALL') && [:show,:delete].include?(command)
|
|
259
268
|
asyncids=@api_node.read('async/list')[:data]['sync_ids']
|
|
260
269
|
else
|
|
261
270
|
Integer(asyncid) # must be integer
|
|
@@ -274,42 +283,39 @@ module Aspera
|
|
|
274
283
|
case command
|
|
275
284
|
when :list
|
|
276
285
|
resp=@api_node.read('async/list')[:data]['sync_ids']
|
|
277
|
-
return { type: :value_list, data: resp, name: 'id'
|
|
286
|
+
return { type: :value_list, data: resp, name: 'id' }
|
|
278
287
|
when :show
|
|
279
288
|
resp=@api_node.create('async/summary',pdata)[:data]['sync_summaries']
|
|
280
289
|
return Main.result_empty if resp.empty?
|
|
281
|
-
if asyncid.eql?('ALL')
|
|
282
|
-
|
|
283
|
-
else
|
|
284
|
-
return { type: :single_object, data: resp.first }
|
|
285
|
-
end
|
|
290
|
+
return { type: :object_list, data: resp, fields: ['snid','name','local_dir','remote_dir'] } if asyncid.eql?('ALL')
|
|
291
|
+
return { type: :single_object, data: resp.first }
|
|
286
292
|
when :delete
|
|
287
293
|
resp=@api_node.create('async/delete',pdata)[:data]
|
|
288
|
-
return { type: :single_object, data: resp, name: 'id'
|
|
294
|
+
return { type: :single_object, data: resp, name: 'id' }
|
|
289
295
|
when :bandwidth
|
|
290
|
-
pdata['seconds']=100
|
|
296
|
+
pdata['seconds']=100 # TODO: as parameter with --value
|
|
291
297
|
resp=@api_node.create('async/bandwidth',pdata)[:data]
|
|
292
298
|
data=resp['bandwidth_data']
|
|
293
299
|
return Main.result_empty if data.empty?
|
|
294
300
|
data=data.first[asyncid]['data']
|
|
295
|
-
return { type: :object_list, data: data, name: 'id'
|
|
301
|
+
return { type: :object_list, data: data, name: 'id' }
|
|
296
302
|
when :files
|
|
297
303
|
# count int
|
|
298
304
|
# filename str
|
|
299
305
|
# skip int
|
|
300
306
|
# status int
|
|
301
|
-
filter=
|
|
307
|
+
filter=options.get_option(:value,:optional)
|
|
302
308
|
pdata.merge!(filter) unless filter.nil?
|
|
303
309
|
resp=@api_node.create('async/files',pdata)[:data]
|
|
304
310
|
data=resp['sync_files']
|
|
305
311
|
data=data.first[asyncid] unless data.empty?
|
|
306
312
|
iteration_data=[]
|
|
307
313
|
skip_ids_persistency=nil
|
|
308
|
-
if
|
|
314
|
+
if options.get_option(:once_only,:mandatory)
|
|
309
315
|
skip_ids_persistency=PersistencyActionOnce.new(
|
|
310
316
|
manager: @agents[:persistency],
|
|
311
317
|
data: iteration_data,
|
|
312
|
-
id: IdGenerator.from_list(['sync_files',
|
|
318
|
+
id: IdGenerator.from_list(['sync_files',options.get_option(:url,:mandatory),options.get_option(:username,:mandatory),asyncid]))
|
|
313
319
|
unless iteration_data.first.nil?
|
|
314
320
|
data.select!{|l| l['fnid'].to_i>iteration_data.first}
|
|
315
321
|
end
|
|
@@ -317,57 +323,58 @@ module Aspera
|
|
|
317
323
|
end
|
|
318
324
|
return Main.result_empty if data.empty?
|
|
319
325
|
skip_ids_persistency.save unless skip_ids_persistency.nil?
|
|
320
|
-
return { type: :object_list, data: data, name: 'id'
|
|
326
|
+
return { type: :object_list, data: data, name: 'id' }
|
|
321
327
|
when :counters
|
|
322
|
-
resp=@api_node.create('async/counters',pdata)[:data][
|
|
328
|
+
resp=@api_node.create('async/counters',pdata)[:data]['sync_counters'].first[asyncid].last
|
|
323
329
|
return Main.result_empty if resp.nil?
|
|
324
330
|
return { type: :single_object, data: resp }
|
|
325
331
|
end
|
|
326
332
|
end
|
|
327
333
|
|
|
328
|
-
ACTIONS=[
|
|
334
|
+
ACTIONS=[:postprocess,:stream, :transfer, :cleanup, :forward, :access_key, :watch_folder, :service, :async, :central, :asperabrowser, :basic_token].concat(COMMON_ACTIONS)
|
|
329
335
|
|
|
330
336
|
def execute_action(command=nil,prefix_path=nil)
|
|
331
|
-
command||=
|
|
337
|
+
command||=options.get_next_command(ACTIONS)
|
|
332
338
|
case command
|
|
333
|
-
when *COMMON_ACTIONS
|
|
334
|
-
when :async
|
|
339
|
+
when *COMMON_ACTIONS then return execute_simple_common(command,prefix_path)
|
|
340
|
+
when :async then return execute_async()
|
|
335
341
|
when :stream
|
|
336
|
-
command=
|
|
342
|
+
command=options.get_next_command([:list, :create, :show, :modify, :cancel])
|
|
337
343
|
case command
|
|
338
344
|
when :list
|
|
339
|
-
resp=@api_node.read('ops/transfers',
|
|
340
|
-
return { type: :object_list, data: resp[:data], fields: ['id','status']
|
|
345
|
+
resp=@api_node.read('ops/transfers',options.get_option(:value,:optional))
|
|
346
|
+
return { type: :object_list, data: resp[:data], fields: ['id','status'] } # TODO: useful?
|
|
341
347
|
when :create
|
|
342
|
-
resp=@api_node.create('streams',
|
|
348
|
+
resp=@api_node.create('streams',options.get_option(:value,:mandatory))
|
|
343
349
|
return { type: :single_object, data: resp[:data] }
|
|
344
350
|
when :show
|
|
345
|
-
trid=
|
|
351
|
+
trid=options.get_next_argument('transfer id')
|
|
346
352
|
resp=@api_node.read('ops/transfers/'+trid)
|
|
347
353
|
return { type: :other_struct, data: resp[:data] }
|
|
348
354
|
when :modify
|
|
349
|
-
trid=
|
|
350
|
-
resp=@api_node.update('streams/'+trid,
|
|
355
|
+
trid=options.get_next_argument('transfer id')
|
|
356
|
+
resp=@api_node.update('streams/'+trid,options.get_option(:value,:mandatory))
|
|
351
357
|
return { type: :other_struct, data: resp[:data] }
|
|
352
358
|
when :cancel
|
|
353
|
-
trid=
|
|
359
|
+
trid=options.get_next_argument('transfer id')
|
|
354
360
|
resp=@api_node.cancel('streams/'+trid)
|
|
355
361
|
return { type: :other_struct, data: resp[:data] }
|
|
356
362
|
else
|
|
357
|
-
raise
|
|
363
|
+
raise 'error'
|
|
358
364
|
end
|
|
359
365
|
when :transfer
|
|
360
|
-
command=
|
|
366
|
+
command=options.get_next_command([:list, :cancel, :show])
|
|
361
367
|
res_class_path='ops/transfers'
|
|
362
368
|
if [:cancel, :show].include?(command)
|
|
363
|
-
one_res_id=
|
|
369
|
+
one_res_id=instance_identifier()
|
|
364
370
|
one_res_path="#{res_class_path}/#{one_res_id}"
|
|
365
371
|
end
|
|
366
372
|
case command
|
|
367
373
|
when :list
|
|
368
374
|
# could use ? subpath: 'transfers'
|
|
369
|
-
resp=@api_node.read(res_class_path,
|
|
370
|
-
return { type: :object_list, data: resp[:data],
|
|
375
|
+
resp=@api_node.read(res_class_path,options.get_option(:value,:optional))
|
|
376
|
+
return { type: :object_list, data: resp[:data],
|
|
377
|
+
fields: ['id','status','start_spec.direction','start_spec.remote_user','start_spec.remote_host','start_spec.destination_path']}
|
|
371
378
|
when :cancel
|
|
372
379
|
resp=@api_node.cancel(one_res_path)
|
|
373
380
|
return { type: :other_struct, data: resp[:data] }
|
|
@@ -375,34 +382,33 @@ module Aspera
|
|
|
375
382
|
resp=@api_node.read(one_res_path)
|
|
376
383
|
return { type: :other_struct, data: resp[:data] }
|
|
377
384
|
else
|
|
378
|
-
raise
|
|
385
|
+
raise 'error'
|
|
379
386
|
end
|
|
380
387
|
when :access_key
|
|
381
|
-
return
|
|
388
|
+
return entity_action(@api_node,'access_keys',id_default: 'self')
|
|
382
389
|
when :service
|
|
383
|
-
command=
|
|
390
|
+
command=options.get_next_command([:list, :create, :delete])
|
|
384
391
|
if [:delete].include?(command)
|
|
385
|
-
svcid=
|
|
392
|
+
svcid=instance_identifier()
|
|
386
393
|
end
|
|
387
394
|
case command
|
|
388
395
|
when :list
|
|
389
396
|
resp=@api_node.read('rund/services')
|
|
390
|
-
return { type: :object_list, data: resp[:data][
|
|
397
|
+
return { type: :object_list, data: resp[:data]['services'] }
|
|
391
398
|
when :create
|
|
392
399
|
# @json:'{"type":"WATCHFOLDERD","run_as":{"user":"user1"}}'
|
|
393
|
-
params=
|
|
400
|
+
params=options.get_next_argument('Run creation data (structure)')
|
|
394
401
|
resp=@api_node.create('rund/services',params)
|
|
395
402
|
return Main.result_status("#{resp[:data]['id']} created")
|
|
396
403
|
when :delete
|
|
397
|
-
|
|
404
|
+
@api_node.delete("rund/services/#{svcid}")
|
|
398
405
|
return Main.result_status("#{svcid} deleted")
|
|
399
406
|
end
|
|
400
407
|
when :watch_folder
|
|
401
408
|
res_class_path='v3/watchfolders'
|
|
402
|
-
|
|
403
|
-
command=self.options.get_next_command([ :create, :list, :show, :modify, :delete, :state])
|
|
409
|
+
command=options.get_next_command([:create, :list, :show, :modify, :delete, :state])
|
|
404
410
|
if [:show,:modify,:delete,:state].include?(command)
|
|
405
|
-
one_res_id=
|
|
411
|
+
one_res_id=instance_identifier()
|
|
406
412
|
one_res_path="#{res_class_path}/#{one_res_id}"
|
|
407
413
|
end
|
|
408
414
|
# hum, to avoid: Unable to convert 2016_09_14 configuration
|
|
@@ -410,15 +416,15 @@ module Aspera
|
|
|
410
416
|
@api_node.params[:headers]['X-aspera-WF-version']='2017_10_23'
|
|
411
417
|
case command
|
|
412
418
|
when :create
|
|
413
|
-
resp=@api_node.create(res_class_path,
|
|
419
|
+
resp=@api_node.create(res_class_path,options.get_option(:value,:mandatory))
|
|
414
420
|
return Main.result_status("#{resp[:data]['id']} created")
|
|
415
421
|
when :list
|
|
416
|
-
resp=@api_node.read(res_class_path,
|
|
422
|
+
resp=@api_node.read(res_class_path,options.get_option(:value,:optional))
|
|
417
423
|
return { type: :value_list, data: resp[:data]['ids'], name: 'id' }
|
|
418
424
|
when :show
|
|
419
425
|
return { type: :single_object, data: @api_node.read(one_res_path)[:data]}
|
|
420
426
|
when :modify
|
|
421
|
-
@api_node.update(one_res_path,
|
|
427
|
+
@api_node.update(one_res_path,options.get_option(:value,:mandatory))
|
|
422
428
|
return Main.result_status("#{one_res_id} updated")
|
|
423
429
|
when :delete
|
|
424
430
|
@api_node.delete(one_res_path)
|
|
@@ -427,29 +433,30 @@ module Aspera
|
|
|
427
433
|
return { type: :single_object, data: @api_node.read("#{one_res_path}/state")[:data] }
|
|
428
434
|
end
|
|
429
435
|
when :central
|
|
430
|
-
command=
|
|
431
|
-
validator_id=
|
|
432
|
-
validation={
|
|
433
|
-
request_data=
|
|
436
|
+
command=options.get_next_command([:session,:file])
|
|
437
|
+
validator_id=options.get_option(:validator)
|
|
438
|
+
validation={'validator_id'=>validator_id} unless validator_id.nil?
|
|
439
|
+
request_data=options.get_option(:value,:optional)
|
|
434
440
|
request_data||={}
|
|
435
441
|
case command
|
|
436
442
|
when :session
|
|
437
|
-
command=
|
|
443
|
+
command=options.get_next_command([:list])
|
|
438
444
|
case command
|
|
439
445
|
when :list
|
|
440
|
-
request_data.deep_merge!({
|
|
446
|
+
request_data.deep_merge!({'validation'=>validation}) unless validation.nil?
|
|
441
447
|
resp=@api_node.create('services/rest/transfers/v1/sessions',request_data)
|
|
442
|
-
return { type: :object_list, data: resp[:data][
|
|
448
|
+
return { type: :object_list, data: resp[:data]['session_info_result']['session_info'],
|
|
449
|
+
fields: ['session_uuid','status','transport','direction','bytes_transferred']}
|
|
443
450
|
end
|
|
444
451
|
when :file
|
|
445
|
-
command=
|
|
452
|
+
command=options.get_next_command([:list, :modify])
|
|
446
453
|
case command
|
|
447
454
|
when :list
|
|
448
455
|
request_data.deep_merge!({'validation'=>validation}) unless validation.nil?
|
|
449
456
|
resp=@api_node.create('services/rest/transfers/v1/files',request_data)[:data]
|
|
450
457
|
resp=JSON.parse(resp) if resp.is_a?(String)
|
|
451
458
|
Log.dump(:resp,resp)
|
|
452
|
-
return { type: :object_list, data: resp['file_transfer_info_result']['file_transfer_info'], fields: [
|
|
459
|
+
return { type: :object_list, data: resp['file_transfer_info_result']['file_transfer_info'], fields: ['session_uuid','file_id','status','path']}
|
|
453
460
|
when :modify
|
|
454
461
|
request_data.deep_merge!(validation) unless validation.nil?
|
|
455
462
|
@api_node.update('services/rest/transfers/v1/files',request_data)
|
|
@@ -458,18 +465,18 @@ module Aspera
|
|
|
458
465
|
end
|
|
459
466
|
when :asperabrowser
|
|
460
467
|
browse_params={
|
|
461
|
-
'nodeUser' =>
|
|
462
|
-
'nodePW' =>
|
|
463
|
-
'nodeURL' =>
|
|
468
|
+
'nodeUser' => options.get_option(:username,:mandatory),
|
|
469
|
+
'nodePW' => options.get_option(:password,:mandatory),
|
|
470
|
+
'nodeURL' => options.get_option(:url,:mandatory)
|
|
464
471
|
}
|
|
465
472
|
# encode parameters so that it looks good in url
|
|
466
473
|
encoded_params=Base64.strict_encode64(Zlib::Deflate.deflate(JSON.generate(browse_params))).gsub(/=+$/, '').tr('+/', '-_').reverse
|
|
467
|
-
OpenApplication.instance.uri(
|
|
474
|
+
OpenApplication.instance.uri(options.get_option(:asperabrowserurl)+'?goto='+encoded_params)
|
|
468
475
|
return Main.result_status('done')
|
|
469
476
|
when :basic_token
|
|
470
|
-
return Main.result_status(
|
|
477
|
+
return Main.result_status('Basic '+Base64.strict_encode64("#{options.get_option(:username,:mandatory)}:#{options.get_option(:password,:mandatory)}"))
|
|
471
478
|
end # case command
|
|
472
|
-
raise
|
|
479
|
+
raise 'ERROR: shall not reach this line'
|
|
473
480
|
end # execute_action
|
|
474
481
|
end # Main
|
|
475
482
|
end # Plugin
|