aspera-cli 4.0.0 → 4.2.2
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 +843 -304
- data/bin/dascli +13 -0
- data/docs/Makefile +4 -4
- data/docs/README.erb.md +805 -172
- data/docs/test_env.conf +22 -3
- data/examples/aoc.rb +14 -3
- data/examples/faspex4.rb +89 -0
- data/lib/aspera/aoc.rb +87 -108
- data/lib/aspera/cli/formater.rb +2 -0
- data/lib/aspera/cli/main.rb +89 -49
- data/lib/aspera/cli/plugin.rb +9 -4
- data/lib/aspera/cli/plugins/alee.rb +1 -1
- data/lib/aspera/cli/plugins/aoc.rb +188 -173
- data/lib/aspera/cli/plugins/ats.rb +2 -2
- data/lib/aspera/cli/plugins/config.rb +218 -145
- data/lib/aspera/cli/plugins/console.rb +2 -2
- data/lib/aspera/cli/plugins/faspex.rb +114 -61
- data/lib/aspera/cli/plugins/faspex5.rb +85 -43
- data/lib/aspera/cli/plugins/node.rb +3 -3
- data/lib/aspera/cli/plugins/preview.rb +59 -45
- data/lib/aspera/cli/plugins/server.rb +23 -8
- data/lib/aspera/cli/transfer_agent.rb +77 -49
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/command_line_builder.rb +49 -31
- data/lib/aspera/cos_node.rb +33 -28
- data/lib/aspera/environment.rb +2 -2
- data/lib/aspera/fasp/connect.rb +28 -21
- data/lib/aspera/fasp/http_gw.rb +140 -28
- data/lib/aspera/fasp/installation.rb +93 -46
- data/lib/aspera/fasp/local.rb +88 -45
- data/lib/aspera/fasp/manager.rb +15 -0
- data/lib/aspera/fasp/node.rb +4 -4
- data/lib/aspera/fasp/parameters.rb +59 -101
- data/lib/aspera/fasp/parameters.yaml +531 -0
- data/lib/aspera/fasp/resume_policy.rb +13 -12
- data/lib/aspera/fasp/uri.rb +1 -1
- data/lib/aspera/log.rb +1 -1
- data/lib/aspera/node.rb +61 -1
- data/lib/aspera/oauth.rb +49 -46
- data/lib/aspera/persistency_folder.rb +9 -4
- data/lib/aspera/preview/file_types.rb +53 -21
- data/lib/aspera/preview/generator.rb +3 -3
- data/lib/aspera/rest.rb +29 -18
- data/lib/aspera/secrets.rb +20 -0
- data/lib/aspera/sync.rb +40 -35
- data/lib/aspera/temp_file_manager.rb +19 -0
- data/lib/aspera/web_auth.rb +105 -0
- metadata +54 -20
- data/docs/transfer_spec.html +0 -99
@@ -4,6 +4,7 @@ require 'aspera/temp_file_manager'
|
|
4
4
|
require 'securerandom'
|
5
5
|
require 'base64'
|
6
6
|
require 'json'
|
7
|
+
require 'yaml'
|
7
8
|
require 'securerandom'
|
8
9
|
require 'fileutils'
|
9
10
|
|
@@ -12,100 +13,67 @@ module Aspera
|
|
12
13
|
# translate transfer specification to ascp parameter list
|
13
14
|
class Parameters
|
14
15
|
private
|
15
|
-
#
|
16
|
+
# Temp folder for file lists, must contain only file lists
|
16
17
|
# because of garbage collection takes any file there
|
17
18
|
# this could be refined, as , for instance, on macos, temp folder is already user specific
|
18
19
|
@@file_list_folder=TempFileManager.instance.new_file_path_global('asession_filelists')
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
'
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
'EX_http_transfer_jpeg' => { :type => :opt_with_arg, :option_switch=>'-j',:accepted_types=>Integer},
|
72
|
-
'EX_multi_session_part' => { :type => :opt_with_arg, :option_switch=>'-C',:accepted_types=>String},
|
73
|
-
'EX_no_read' => { :type => :opt_without_arg, :option_switch=>'--no-read'},
|
74
|
-
'EX_no_write' => { :type => :opt_without_arg, :option_switch=>'--no-write'},
|
75
|
-
'EX_apply_local_docroot' => { :type => :opt_without_arg, :option_switch=>'--apply-local-docroot'},
|
76
|
-
# TODO: manage those parameters, some are for connect only ? node api ?
|
77
|
-
'target_rate_cap_kbps' => { :type => :ignore, :accepted_types=>Integer},
|
78
|
-
'target_rate_percentage' => { :type => :ignore, :accepted_types=>String}, # -wf -l<rate>p
|
79
|
-
'min_rate_cap_kbps' => { :type => :ignore, :accepted_types=>Integer},
|
80
|
-
'rate_policy_allowed' => { :type => :ignore, :accepted_types=>String},
|
81
|
-
'fasp_url' => { :type => :ignore, :accepted_types=>String},
|
82
|
-
'lock_rate_policy' => { :type => :ignore, :accepted_types=>Aspera::CommandLineBuilder::BOOLEAN_CLASSES},
|
83
|
-
'lock_min_rate' => { :type => :ignore, :accepted_types=>Aspera::CommandLineBuilder::BOOLEAN_CLASSES},
|
84
|
-
'lock_target_rate' => { :type => :ignore, :accepted_types=>Aspera::CommandLineBuilder::BOOLEAN_CLASSES},
|
85
|
-
#'authentication' => { :type => :ignore, :accepted_types=>String}, # = token
|
86
|
-
'https_fallback_port' => { :type => :ignore, :accepted_types=>Integer}, # same as http fallback, option -t ?
|
87
|
-
'content_protection' => { :type => :ignore, :accepted_types=>String},
|
88
|
-
'cipher_allowed' => { :type => :ignore, :accepted_types=>String},
|
89
|
-
'multi_session' => { :type => :ignore, :accepted_types=>Integer}, # managed
|
90
|
-
# optional tags ( additional option to generate: {:space=>' ',:object_nl=>' ',:space_before=>'+',:array_nl=>'1'} )
|
91
|
-
'tags' => { :type => :opt_with_arg, :option_switch=>'--tags64',:accepted_types=>Hash,:encode=>lambda{|tags|Base64.strict_encode64(JSON.generate(tags))}},
|
92
|
-
# special processing @builder.process_param( called individually
|
93
|
-
'use_ascp4' => { :type => :defer, :accepted_types=>Aspera::CommandLineBuilder::BOOLEAN_CLASSES},
|
94
|
-
'paths' => { :type => :defer, :accepted_types=>Array},
|
95
|
-
'EX_file_list' => { :type => :defer, :option_switch=>'--file-list', :accepted_types=>String},
|
96
|
-
'EX_file_pair_list' => { :type => :defer, :option_switch=>'--file-pair-list', :accepted_types=>String},
|
97
|
-
'EX_ascp_args' => { :type => :defer, :accepted_types=>Array},
|
98
|
-
'destination_root' => { :type => :defer, :accepted_types=>String},
|
99
|
-
'wss_enabled' => { :type => :defer, :accepted_types=>Aspera::CommandLineBuilder::BOOLEAN_CLASSES},
|
100
|
-
'wss_port' => { :type => :defer, :accepted_types=>Integer},
|
101
|
-
}
|
102
|
-
|
103
|
-
private_constant :SEC_IN_DAY,:FILE_LIST_AGE_MAX_SEC,:PARAM_DEFINITION
|
20
|
+
@@param_description_cache=nil
|
21
|
+
# @return normaiwed description of transfer spec parameters
|
22
|
+
def self.description
|
23
|
+
return @@param_description_cache unless @@param_description_cache.nil?
|
24
|
+
# config file in same folder with same name as this source
|
25
|
+
@@param_description_cache=YAML.load_file("#{__FILE__[0..-3]}yaml")
|
26
|
+
Aspera::CommandLineBuilder.normalize_description(@@param_description_cache)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Agents shown in manual
|
30
|
+
SUPPORTED_AGENTS=[:direct,:node,:connect]
|
31
|
+
# Short names of columns in manual
|
32
|
+
SUPPORTED_AGENTS_SHORT=SUPPORTED_AGENTS.map{|a|a.to_s[0].to_sym}
|
33
|
+
|
34
|
+
# @return a table suitable to display a manual
|
35
|
+
def self.man_table
|
36
|
+
result=[]
|
37
|
+
description.keys.map do |k|
|
38
|
+
i=description[k]
|
39
|
+
param={name: k, type: [i[:accepted_types]].flatten.join(','),description: i[:desc]}
|
40
|
+
SUPPORTED_AGENTS.each do |a|
|
41
|
+
param[a.to_s[0].to_sym]=i[:context].nil? || i[:context].include?(a) ? 'Y' : ''
|
42
|
+
end
|
43
|
+
# only keep lines that are usable in supported agents
|
44
|
+
next if SUPPORTED_AGENTS_SHORT.inject(true){|m,i|m and param[i].empty?}
|
45
|
+
param[:cli]=case i[:cltype]
|
46
|
+
when :envvar; 'env:'+i[:clvarname]
|
47
|
+
when :opt_without_arg,:opt_with_arg; i[:option_switch]
|
48
|
+
else ''
|
49
|
+
end
|
50
|
+
if i.has_key?(:enum)
|
51
|
+
param[:description] << "\nAllowed values: #{i[:enum].join(', ')}"
|
52
|
+
end
|
53
|
+
result.push(param)
|
54
|
+
end
|
55
|
+
return result
|
56
|
+
end
|
57
|
+
|
58
|
+
# special encoding methods used in YAML (key: :encode)
|
59
|
+
def self.encode_cipher(v)
|
60
|
+
v.tr('-','')
|
61
|
+
end
|
62
|
+
|
63
|
+
# special encoding methods used in YAML (key: :encode)
|
64
|
+
def self.encode_source_root(v)
|
65
|
+
Base64.strict_encode64(v)
|
66
|
+
end
|
67
|
+
|
68
|
+
# special encoding methods used in YAML (key: :encode)
|
69
|
+
def self.encode_tags(v)
|
70
|
+
Base64.strict_encode64(JSON.generate(v))
|
71
|
+
end
|
104
72
|
|
105
73
|
def initialize(job_spec,options)
|
106
74
|
@job_spec=job_spec
|
107
|
-
@builder=Aspera::CommandLineBuilder.new(@job_spec,PARAM_DEFINITION)
|
108
75
|
@options=options
|
76
|
+
@builder=Aspera::CommandLineBuilder.new(@job_spec,self.class.description)
|
109
77
|
end
|
110
78
|
|
111
79
|
public
|
@@ -128,7 +96,7 @@ module Aspera
|
|
128
96
|
# special cases
|
129
97
|
@job_spec.delete('source_root') if @job_spec.has_key?('source_root') and @job_spec['source_root'].empty?
|
130
98
|
|
131
|
-
# use web socket initiation ?
|
99
|
+
# use web socket session initiation ?
|
132
100
|
if @builder.process_param('wss_enabled',:get_value) and @options[:wss]
|
133
101
|
# by default use web socket session if available, unless removed by user
|
134
102
|
@builder.add_command_line_options(['--ws-connect'])
|
@@ -154,8 +122,7 @@ module Aspera
|
|
154
122
|
# destination will be base64 encoded, put before path arguments
|
155
123
|
@builder.add_command_line_options(['--dest64'])
|
156
124
|
end
|
157
|
-
|
158
|
-
PARAM_DEFINITION['paths'][:mandatory]=!@job_spec.has_key?('keepalive')
|
125
|
+
@builder.params_definition['paths'][:mandatory]=!@job_spec.has_key?('keepalive')
|
159
126
|
paths_array=@builder.process_param('paths',:get_value)
|
160
127
|
unless paths_array.nil?
|
161
128
|
# use file list if there is storage defined for it.
|
@@ -207,18 +174,9 @@ module Aspera
|
|
207
174
|
# temp file list files are created here
|
208
175
|
def self.file_list_folder=(v)
|
209
176
|
@@file_list_folder=v
|
210
|
-
|
177
|
+
if !@@file_list_folder.nil?
|
211
178
|
FileUtils.mkdir_p(@@file_list_folder)
|
212
|
-
|
213
|
-
Dir.entries(@@file_list_folder).each do |name|
|
214
|
-
file_path=File.join(@@file_list_folder,name)
|
215
|
-
age_sec=(Time.now - File.stat(file_path).mtime).to_i
|
216
|
-
# check age of file, delete too old
|
217
|
-
if File.file?(file_path) and age_sec > FILE_LIST_AGE_MAX_SEC
|
218
|
-
Log.log.debug("garbage collecting #{name}")
|
219
|
-
File.delete(file_path)
|
220
|
-
end
|
221
|
-
end
|
179
|
+
TempFileManager.instance.cleanup_expired(@@file_list_folder)
|
222
180
|
end
|
223
181
|
end
|
224
182
|
|