asperalm 0.9.24 → 0.9.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 68a05ce8269d75e633fdfbe49308e362f8cc850c
4
- data.tar.gz: 40b521e2c5aff40bb2340b9db2770cf798429caf
2
+ SHA256:
3
+ metadata.gz: 8afcea9cc622d5476770c52d004651d7a41f954ee15fe4887601dfa95cad1a71
4
+ data.tar.gz: ed2d08c76ed1cd4c7b256ec2d37fed12f8581e561fdd4a0e35998ed65aeff462
5
5
  SHA512:
6
- metadata.gz: 01d25beae1bae179283a327014a24517658170f3ef48305cc775eaf9c27c275d2da228844d1337030127d509276b80a38fb03b0beb5474d0337a30a7773d3708
7
- data.tar.gz: 67736d6590ccec042344991a0b538120f748a4850ab9e21040cdf68189aea65fd6f2a95a9f58aaeb6638b4f523487fc139c34ba3bce594488f24a28a03948fe5
6
+ metadata.gz: 6a610b087542245c167378c34571077d7624e4776922179b59a3b51e29a01eeddf97bea08d0f2880c65480f401f4c8ef13cc3f54d25c0223fde957fd9c3c06e7
7
+ data.tar.gz: 0ee1a55a78c071fa9e720f988afa8044cfec76a8445372673489499e36cd8f0972700fc4d4b0844d1b5dce87d94c25452ba18421e2d085d2e77da85a51949181
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Asperalm - A Ruby library for Aspera transfers and "Amelia", the _Multi Layer IBM Aspera_ Command Line Tool
2
2
 
3
- Version : 0.9.24
3
+ Version : 0.9.25
4
4
 
5
5
 
6
6
  _Laurent/2016-2018_
@@ -37,7 +37,7 @@ Once the gem is installed, `mlia` shall be accessible:
37
37
 
38
38
  ```bash
39
39
  $ mlia --version
40
- 0.9.24
40
+ 0.9.25
41
41
  ```
42
42
 
43
43
  ## First use
@@ -929,7 +929,7 @@ A non complete list of commands used in unit tests:
929
929
  ```bash
930
930
  $ mlia -h
931
931
  NAME
932
- mlia -- a command line tool for Aspera Applications (v0.9.24)
932
+ mlia -- a command line tool for Aspera Applications (v0.9.25)
933
933
 
934
934
  COMMAND: config
935
935
  SUBCOMMANDS: gem_path, genkey, plugins, flush_tokens, list, overview, open, echo, id, documentation, wizard, export_to_cli, detect, coffee, ascp
@@ -1552,6 +1552,8 @@ Notes:
1552
1552
 
1553
1553
  ### Receive only new packages
1554
1554
 
1555
+ TODO
1556
+
1555
1557
  ### Download Files
1556
1558
 
1557
1559
  Download of files is straightforward with a specific syntax for the `aspera files download` action: Like other commands the source file list is provided as a list with the `sources` option. Nevertheless, consider this:
@@ -1559,6 +1561,16 @@ Download of files is straightforward with a specific syntax for the `aspera file
1559
1561
  * if only one source is provided, it is downloaded
1560
1562
  * if multiple sources must be downloaded, then the first in list is the path of the source folder, and the remaining items are the file names in this folder (without path).
1561
1563
 
1564
+ ### Find Files
1565
+
1566
+ Use the command `aspera files find [--value=regex]`.
1567
+
1568
+ if no regex is provided, it will list all files recursively.
1569
+
1570
+ if a regex is provided (using ruby regex syntax, very similar to standard syntax), it find files recursively whose
1571
+ filename matches the regex.
1572
+
1573
+ For instance, to find files with a special extension, use `--value='\.myext$'`
1562
1574
 
1563
1575
  ## Aspera Node (Transfer Server)
1564
1576
 
@@ -2246,6 +2258,12 @@ Gems, or remove your ed25519 key from your `.ssh` folder to solve the issue. Not
2246
2258
 
2247
2259
  # Release Notes
2248
2260
 
2261
+ * version 0.9.25
2262
+
2263
+ * the option `value` of command `find`, to filter on name, is not optional
2264
+ * `find` now also reports all types (file, folder, link)
2265
+ * `find` now is able to report all fields (type, size, etc...)
2266
+
2249
2267
  * version 0.9.24
2250
2268
 
2251
2269
  * fix bug where AoC node to node transfer did not work
data/lib/asperalm/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.24
1
+ 0.9.25
@@ -8,7 +8,6 @@ require 'asperalm/temp_file_manager'
8
8
  require 'asperalm/persistency_file'
9
9
  require 'asperalm/log'
10
10
  require 'asperalm/rest'
11
- require 'asperalm/files_api'
12
11
  require 'asperalm/nagios'
13
12
  require 'text-table'
14
13
  require 'fileutils'
@@ -2,7 +2,7 @@ require 'asperalm/cli/plugins/node'
2
2
  require 'asperalm/cli/plugins/ats'
3
3
  require 'asperalm/cli/basic_auth_plugin'
4
4
  require 'asperalm/cli/transfer_agent'
5
- require 'asperalm/files_api'
5
+ require 'asperalm/on_cloud'
6
6
  require 'asperalm/persistency_file'
7
7
  require 'securerandom'
8
8
  require 'resolv'
@@ -45,11 +45,11 @@ module Asperalm
45
45
  self.options.set_option(:bulk,:no)
46
46
  self.options.set_option(:new_user_option,{'package_contact'=>true})
47
47
  self.options.set_option(:operation,:push)
48
- client_data=FilesApi.random_cli
48
+ client_data=OnCloud.random_cli
49
49
  self.options.set_option(:auth,:jwt)
50
50
  self.options.set_option(:client_id,client_data.first)
51
51
  self.options.set_option(:client_secret,client_data.last)
52
- self.options.set_option(:scope,FilesApi::SCOPE_FILES_USER)
52
+ self.options.set_option(:scope,OnCloud::SCOPE_FILES_USER)
53
53
  self.options.set_option(:private_key,'@file:'+env[:private_key_path]) if env[:private_key_path].is_a?(String)
54
54
  self.options.parse_options!
55
55
  return if env[:man_only]
@@ -69,35 +69,35 @@ module Asperalm
69
69
  when :browse
70
70
  thepath=self.options.get_next_argument('path')
71
71
  node_file = @api_aoc.resolve_node_file(top_node_file,thepath)
72
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
72
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
73
73
  result=node_api.read("files/#{node_file[:file_id]}/files",self.options.get_option(:value,:optional))
74
74
  items=result[:data]
75
75
  self.format.display_status("Items: #{result[:data].length}/#{result[:http]['X-Total-Count']}")
76
76
  return {:type=>:object_list,:data=>items,:fields=>['name','type','recursive_size','size','modified_time','access_level']}
77
77
  when :find
78
78
  thepath=self.options.get_next_argument('path')
79
- regex=self.options.get_option(:value,:mandatory)
79
+ regex=self.options.get_option(:value,:optional)||''
80
80
  node_file=@api_aoc.resolve_node_file(top_node_file,thepath)
81
- return {:type=>:value_list,:data=>@api_aoc.find_files(node_file,regex),:name=>'path'}
81
+ return {:type=>:object_list,:data=>@api_aoc.find_files(node_file,regex),:fields=>['path']}
82
82
  when :mkdir
83
83
  thepath=self.options.get_next_argument('path')
84
- containing_folder_path = thepath.split(FilesApi::PATH_SEPARATOR)
84
+ containing_folder_path = thepath.split(OnCloud::PATH_SEPARATOR)
85
85
  new_folder=containing_folder_path.pop
86
- node_file = @api_aoc.resolve_node_file(top_node_file,containing_folder_path.join(FilesApi::PATH_SEPARATOR))
87
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
86
+ node_file = @api_aoc.resolve_node_file(top_node_file,containing_folder_path.join(OnCloud::PATH_SEPARATOR))
87
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
88
88
  result=node_api.create("files/#{node_file[:file_id]}/files",{:name=>new_folder,:type=>:folder})[:data]
89
89
  return Main.result_status("created: #{result['name']} (id=#{result['id']})")
90
90
  when :rename
91
91
  thepath=self.options.get_next_argument('source path')
92
92
  newname=self.options.get_next_argument('new name')
93
93
  node_file = @api_aoc.resolve_node_file(top_node_file,thepath)
94
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
94
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
95
95
  result=node_api.update("files/#{node_file[:file_id]}",{:name=>newname})[:data]
96
96
  return Main.result_status("renamed #{thepath} to #{newname}")
97
97
  when :delete
98
98
  thepath=self.options.get_next_argument('path')
99
99
  node_file = @api_aoc.resolve_node_file(top_node_file,thepath)
100
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
100
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
101
101
  result=node_api.delete("files/#{node_file[:file_id]}")[:data]
102
102
  return Main.result_status("deleted: #{thepath}")
103
103
  when :transfer
@@ -118,7 +118,7 @@ module Asperalm
118
118
  # force node as agent
119
119
  self.options.set_option(:transfer,:node)
120
120
  # force node api in node agent
121
- Fasp::Node.instance.node_api=@api_aoc.get_files_node_api(node_file_client[:node_info],FilesApi::SCOPE_NODE_USER)
121
+ Fasp::Node.instance.node_api=@api_aoc.get_files_node_api(node_file_client[:node_info],OnCloud::SCOPE_NODE_USER)
122
122
  # additional node to node TS info
123
123
  add_ts={
124
124
  'remote_access_key' => node_file_server[:node_info]['access_key'],
@@ -136,9 +136,9 @@ module Asperalm
136
136
  source_folder=source_paths.shift['source']
137
137
  # if a single file: split into folder and path
138
138
  if source_paths.empty?
139
- source_folder=source_folder.split(FilesApi::PATH_SEPARATOR)
139
+ source_folder=source_folder.split(OnCloud::PATH_SEPARATOR)
140
140
  source_paths=[{'source'=>source_folder.pop}]
141
- source_folder=source_folder.join(FilesApi::PATH_SEPARATOR)
141
+ source_folder=source_folder.join(OnCloud::PATH_SEPARATOR)
142
142
  end
143
143
  node_file = @api_aoc.resolve_node_file(top_node_file,source_folder)
144
144
  # override paths with just filename
@@ -149,26 +149,26 @@ module Asperalm
149
149
  source_paths=self.transfer.ts_source_paths
150
150
  source_folder=source_paths.shift['source']
151
151
  if source_paths.empty?
152
- source_folder=source_folder.split(FilesApi::PATH_SEPARATOR)
152
+ source_folder=source_folder.split(OnCloud::PATH_SEPARATOR)
153
153
  source_paths=[{'source'=>source_folder.pop}]
154
- source_folder=source_folder.join(FilesApi::PATH_SEPARATOR)
154
+ source_folder=source_folder.join(OnCloud::PATH_SEPARATOR)
155
155
  end
156
156
  raise CliBadArgument,'one file at a time only in HTTP mode' if source_paths.length > 1
157
157
  file_name = source_paths.first['source']
158
158
  node_file = @api_aoc.resolve_node_file(top_node_file,File.join(source_folder,file_name))
159
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
159
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
160
160
  node_api.call({:operation=>'GET',:subpath=>"files/#{node_file[:file_id]}/content",:save_to_file=>File.join(self.transfer.destination_folder('receive'),file_name)})
161
161
  return Main.result_status("downloaded: #{file_name}")
162
162
  when :v3
163
163
  # Note: other "common" actions are unauthorized with user scope
164
164
  command_legacy=self.options.get_next_command(Node::SIMPLE_ACTIONS)
165
165
  # TODO: shall we support all methods here ? what if there is a link ?
166
- node_api=@api_aoc.get_files_node_api(top_node_file[:node_info],FilesApi::SCOPE_NODE_USER)
166
+ node_api=@api_aoc.get_files_node_api(top_node_file[:node_info],OnCloud::SCOPE_NODE_USER)
167
167
  return Node.new(@agents.merge(skip_basic_auth_options: true, node_api: node_api)).execute_action(command_legacy)
168
168
  when :file
169
169
  fileid=self.options.get_next_argument('file id')
170
170
  node_file = @api_aoc.resolve_node_file(top_node_file)
171
- node_api=@api_aoc.get_files_node_api(node_file[:node_info],FilesApi::SCOPE_NODE_USER)
171
+ node_api=@api_aoc.get_files_node_api(node_file[:node_info],OnCloud::SCOPE_NODE_USER)
172
172
  items=node_api.read("files/#{fileid}")[:data]
173
173
  return {:type=>:single_object,:data=>items}
174
174
  end # command_repo
@@ -184,8 +184,8 @@ module Asperalm
184
184
  unless public_link_url.nil?
185
185
  uri=URI.parse(public_link_url)
186
186
  public_link_url=nil #no more needed
187
- unless uri.path.eql?(FilesApi::PATH_PUBLIC_PACKAGE)
188
- raise CliArgument,"only public package link is supported: #{FilesApi::PATH_PUBLIC_PACKAGE}"
187
+ unless uri.path.eql?(OnCloud::PATH_PUBLIC_PACKAGE)
188
+ raise CliArgument,"only public package link is supported: #{OnCloud::PATH_PUBLIC_PACKAGE}"
189
189
  end
190
190
  url_token_value=URI::decode_www_form(uri.query).select{|e|e.first.eql?('token')}.first
191
191
  if url_token_value.nil?
@@ -197,7 +197,7 @@ module Asperalm
197
197
  end
198
198
  # Connection paramaters (url and auth) to Aspera on Cloud
199
199
  # pre populate rest parameters based on URL
200
- aoc_rest_params=FilesApi.base_rest_params(self.options.get_option(:url,:mandatory))
200
+ aoc_rest_params=OnCloud.base_rest_params(self.options.get_option(:url,:mandatory))
201
201
  aoc_rest_auth=aoc_rest_params[:auth]
202
202
  aoc_rest_auth.merge!({
203
203
  :grant => self.options.get_option(:auth,:mandatory),
@@ -207,7 +207,7 @@ module Asperalm
207
207
  })
208
208
 
209
209
  # add jwt payload for global ids
210
- if FilesApi.is_global_client_id?(aoc_rest_auth[:client_id])
210
+ if OnCloud.is_global_client_id?(aoc_rest_auth[:client_id])
211
211
  org=aoc_rest_auth[:base_url].gsub(/.*\//,'')
212
212
  aoc_rest_auth.merge!({:jwt_add=>{org: org}})
213
213
  end
@@ -230,7 +230,7 @@ module Asperalm
230
230
  })
231
231
  else raise "ERROR: unsupported auth method"
232
232
  end
233
- @api_aoc=FilesApi.new(aoc_rest_params)
233
+ @api_aoc=OnCloud.new(aoc_rest_params)
234
234
  nil
235
235
  end
236
236
 
@@ -474,14 +474,14 @@ module Asperalm
474
474
  require 'asperalm/faspex_gw'
475
475
  FaspexGW.instance.start_server(@api_aoc,@workspace_id)
476
476
  when :admin
477
- self.options.set_option(:scope,FilesApi::SCOPE_FILES_ADMIN)
477
+ self.options.set_option(:scope,OnCloud::SCOPE_FILES_ADMIN)
478
478
  update_aoc_api
479
479
  command_admin=self.options.get_next_command([ :ats, :resource, :set_client_key, :usage_reports, :search_nodes, :events ])
480
480
  case command_admin
481
481
  when :ats
482
482
  ats_api = Rest.new(@api_aoc.params.deep_merge({
483
483
  :base_url => @api_aoc.params[:base_url]+'/admin/ats/pub/v1',
484
- :auth => {:scope => FilesApi::SCOPE_FILES_ADMIN_USER}
484
+ :auth => {:scope => OnCloud::SCOPE_FILES_ADMIN_USER}
485
485
  }))
486
486
  return @ats.execute_action_gen(ats_api)
487
487
  when :search_nodes
@@ -2,6 +2,7 @@ require 'asperalm/cli/basic_auth_plugin'
2
2
  require 'asperalm/fasp/installation'
3
3
  require 'asperalm/api_detector'
4
4
  require 'asperalm/open_application'
5
+ require 'asperalm/on_cloud'
5
6
  require 'xmlsimple'
6
7
  require 'base64'
7
8
 
@@ -430,7 +431,7 @@ module Asperalm
430
431
  case appli[:product]
431
432
  when :aoc
432
433
  self.format.display_status("Detected: Aspera on Cloud")
433
- organization,instance_domain=FilesApi.parse_url(instance_url)
434
+ organization,instance_domain=OnCloud.parse_url(instance_url)
434
435
  aspera_preset_name='aoc_'+organization
435
436
  self.format.display_status("Preparing preset: #{aspera_preset_name}")
436
437
  # init defaults if necessary
@@ -478,7 +479,7 @@ module Asperalm
478
479
  else
479
480
  self.format.display_status("Using organization specific client_id.")
480
481
  # clear only if user did not specify it already
481
- if FilesApi.is_global_client_id?(self.options.get_option(:client_id,:optional))
482
+ if OnCloud.is_global_client_id?(self.options.get_option(:client_id,:optional))
482
483
  self.options.set_option(:client_id,nil)
483
484
  self.options.set_option(:client_secret,nil)
484
485
  end
@@ -503,7 +504,7 @@ module Asperalm
503
504
  self.options.set_option(:redirect_uri,DEFAULT_REDIRECT)
504
505
  auto_set_pub_key=true
505
506
  auto_set_jwt=true
506
- self.options.set_option(:scope,FilesApi::SCOPE_FILES_ADMIN)
507
+ self.options.set_option(:scope,OnCloud::SCOPE_FILES_ADMIN)
507
508
  end
508
509
  files_plugin.update_aoc_api
509
510
  myself=files_plugin.api_aoc.read('self')[:data]
@@ -543,7 +544,7 @@ module Asperalm
543
544
  url=self.options.get_option(:url,:mandatory)
544
545
  cli_conf_file=Fasp::Installation.instance.cli_conf_file
545
546
  data=JSON.parse(File.read(cli_conf_file))
546
- organization,instance_domain=FilesApi.parse_url(url)
547
+ organization,instance_domain=OnCloud.parse_url(url)
547
548
  key_basename='org_'+organization+'.pem'
548
549
  key_file=File.join(File.dirname(File.dirname(cli_conf_file)),'etc',key_basename)
549
550
  File.write(key_file,self.options.get_option(:private_key,:mandatory))
@@ -7,12 +7,12 @@ module Asperalm
7
7
 
8
8
  private
9
9
  # default value for command line based on option name
10
- def switch_name(ts_name,options)
10
+ def switch_name(param_name,options)
11
11
  return options[:option_switch] if options.has_key?(:option_switch)
12
- return '--'+ts_name.to_s.gsub('_','-')
12
+ return '--'+param_name.to_s.gsub('_','-')
13
13
  end
14
14
 
15
- def env_name(ts_name,options)
15
+ def env_name(param_name,options)
16
16
  return options[:variable]
17
17
  end
18
18
 
@@ -20,21 +20,27 @@ module Asperalm
20
20
 
21
21
  BOOLEAN_CLASSES=[TrueClass,FalseClass]
22
22
 
23
- # @param job_params
24
- def initialize(job_params,params_definition)
25
- @job_params=job_params.clone # shallow copy is sufficient
23
+ # @param param_hash
24
+ def initialize(param_hash,params_definition)
25
+ @param_hash=param_hash.clone # shallow copy is sufficient
26
+ @params_definition=params_definition
26
27
  @result_env={}
27
28
  @result_args=[]
28
- @used_ts_keys=[]
29
- @params_definition=params_definition
29
+ @used_param_names=[]
30
30
  end
31
-
32
- def add_env_args(env_args)
31
+
32
+ def warn_unrecognized_params
33
33
  # warn about non translated arguments
34
- @job_params.each_pair{|key,val|Log.log.error("unrecognized parameter: #{key} = \"#{val}\"") if !@used_ts_keys.include?(key)}
34
+ @param_hash.each_pair{|key,val|Log.log.error("unrecognized parameter: #{key} = \"#{val}\"") if !@used_param_names.include?(key)}
35
+ end
36
+
37
+ # adds keys :env :args with resulting values after processing
38
+ # warns if some parameters were not used
39
+ def add_env_args(env,args)
35
40
  Log.log.debug("ENV=#{@result_env}, ARGS=#{@result_args}")
36
- env_args[:env].merge!(@result_env)
37
- env_args[:args].push(*@result_args)
41
+ warn_unrecognized_params
42
+ env.merge!(@result_env)
43
+ args.push(*@result_args)
38
44
  return nil
39
45
  end
40
46
 
@@ -60,10 +66,10 @@ module Asperalm
60
66
  end
61
67
 
62
68
  # Process a parameter from transfer specification and generate command line param or env var
63
- # @param ts_name : key in transfer spec
69
+ # @param param_name : key in transfer spec
64
70
  # @param option_type : type of processing
65
71
  # @param options : options for type
66
- def process_param(ts_name,option_type,options={})
72
+ def process_param(param_name,option_type,options={})
67
73
  # by default : not mandatory
68
74
  options[:mandatory]||=false
69
75
  if options.has_key?(:accepted_types)
@@ -74,12 +80,12 @@ module Asperalm
74
80
  options[:accepted_types]=option_type.eql?(:opt_without_arg) ? BOOLEAN_CLASSES : [String]
75
81
  end
76
82
  # check mandatory parameter (nil is valid value)
77
- raise Fasp::Error.new("mandatory parameter: #{ts_name}") if options[:mandatory] and !@job_params.has_key?(ts_name)
78
- parameter_value=@job_params[ts_name]
83
+ raise Fasp::Error.new("mandatory parameter: #{param_name}") if options[:mandatory] and !@param_hash.has_key?(param_name)
84
+ parameter_value=@param_hash[param_name]
79
85
  parameter_value=options[:default] if parameter_value.nil? and options.has_key?(:default)
80
86
  # check provided type
81
- raise Fasp::Error.new("#{ts_name} is : #{parameter_value.class} (#{parameter_value}), shall be #{options[:accepted_types]}, ") unless parameter_value.nil? or options[:accepted_types].inject(false){|m,v|m or parameter_value.is_a?(v)}
82
- @used_ts_keys.push(ts_name)
87
+ raise Fasp::Error.new("#{param_name} is : #{parameter_value.class} (#{parameter_value}), shall be #{options[:accepted_types]}, ") unless parameter_value.nil? or options[:accepted_types].inject(false){|m,v|m or parameter_value.is_a?(v)}
88
+ @used_param_names.push(param_name)
83
89
 
84
90
  # process only non-nil values
85
91
  return nil if parameter_value.nil?
@@ -93,7 +99,7 @@ module Asperalm
93
99
  raise "unsupported value: #{parameter_value}" unless options[:accepted_values].nil? or options[:accepted_values].include?(parameter_value)
94
100
  if options[:encode]
95
101
  newvalue=options[:encode].call(parameter_value)
96
- raise Fasp::Error.new("unsupported #{ts_name}: #{parameter_value}") if newvalue.nil?
102
+ raise Fasp::Error.new("unsupported #{param_name}: #{parameter_value}") if newvalue.nil?
97
103
  parameter_value=newvalue
98
104
  end
99
105
 
@@ -104,21 +110,21 @@ module Asperalm
104
110
  return parameter_value
105
111
  when :envvar # set in env var
106
112
  # define ascp parameter in env var from transfer spec
107
- @result_env[env_name(ts_name,options)] = parameter_value
113
+ @result_env[env_name(param_name,options)] = parameter_value
108
114
  when :opt_without_arg # if present and true : just add option without value
109
115
  add_param=false
110
116
  case parameter_value
111
117
  when false# nothing to put on command line, no creation by default
112
118
  when true; add_param=true
113
- else raise Fasp::Error.new("unsupported #{ts_name}: #{parameter_value}")
119
+ else raise Fasp::Error.new("unsupported #{param_name}: #{parameter_value}")
114
120
  end
115
121
  add_param=!add_param if options[:add_on_false]
116
- add_command_line_options([switch_name(ts_name,options)]) if add_param
122
+ add_command_line_options([switch_name(param_name,options)]) if add_param
117
123
  when :opt_with_arg # transform into command line option with value
118
124
  #parameter_value=parameter_value.to_s if parameter_value.is_a?(Integer)
119
125
  parameter_value=[parameter_value] unless parameter_value.is_a?(Array)
120
126
  # if transfer_spec value is an array, applies option many times
121
- parameter_value.each{|v|add_command_line_options([switch_name(ts_name,options),v])}
127
+ parameter_value.each{|v|add_command_line_options([switch_name(param_name,options),v])}
122
128
  else
123
129
  raise "Error"
124
130
  end
@@ -131,7 +131,7 @@ module Asperalm
131
131
  # destination, use base64 encoding (as defined previously: --dest64)
132
132
  @builder.add_command_line_options([Base64.strict_encode64(@builder.process_param('destination_root',:get_value,:accepted_types=>String,:mandatory=>true))])
133
133
 
134
- @builder.add_env_args(env_args)
134
+ @builder.add_env_args(env_args[:env],env_args[:args])
135
135
 
136
136
  return env_args
137
137
  end
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'securerandom'
6
6
  require 'singleton'
7
7
  require 'asperalm/log'
8
+ require 'asperalm/on_cloud'
8
9
 
9
10
  module Asperalm
10
11
  # this class answers the Faspex /send API and creates a package on Files
@@ -51,7 +52,7 @@ module Asperalm
51
52
  node_info=FaspexGW.instance.aoc_api_user.read("nodes/#{the_package['node_id']}")[:data]
52
53
 
53
54
  # get transfer token (for node)
54
- node_auth_bearer_token=FaspexGW.instance.aoc_api_user.oauth_token(scope: FilesApi.node_scope(node_info['access_key'],FilesApi::SCOPE_NODE_USER))
55
+ node_auth_bearer_token=FaspexGW.instance.aoc_api_user.oauth_token(scope: OnCloud.node_scope(node_info['access_key'],OnCloud::SCOPE_NODE_USER))
55
56
 
56
57
  # tell Files what to expect in package: 1 transfer (can also be done after transfer)
57
58
  FaspexGW.instance.aoc_api_user.update("packages/#{the_package['id']}",{"sent"=>true,"transfers_expected"=>1})
@@ -4,7 +4,7 @@ require 'asperalm/hash_ext'
4
4
  require 'base64'
5
5
 
6
6
  module Asperalm
7
- class FilesApi < Rest
7
+ class OnCloud < Rest
8
8
 
9
9
  public
10
10
  # various API scopes supported
@@ -91,7 +91,7 @@ module Asperalm
91
91
  # - source and token regeneration method
92
92
  def tr_spec(app,direction,node_file,ws_id,ts_add)
93
93
  # the rest end point is used to generate the bearer token
94
- token_generation_method=lambda {|do_refresh|self.oauth_token(scope: FilesApi.node_scope(node_file[:node_info]['access_key'],FilesApi::SCOPE_NODE_USER), refresh: do_refresh)}
94
+ token_generation_method=lambda {|do_refresh|self.oauth_token(scope: self.class.node_scope(node_file[:node_info]['access_key'],SCOPE_NODE_USER), refresh: do_refresh)}
95
95
  # note xfer_id and xfer_retry are set by the transfer agent itself
96
96
  return {
97
97
  'direction' => direction,
@@ -140,7 +140,7 @@ module Asperalm
140
140
  }
141
141
  else
142
142
  node_rest_params[:auth]=self.params[:auth].clone
143
- node_rest_params[:auth][:scope]=FilesApi.node_scope(node_info['access_key'],node_scope)
143
+ node_rest_params[:auth][:scope]=self.class.node_scope(node_info['access_key'],node_scope)
144
144
  end
145
145
  return Rest.new(node_rest_params)
146
146
  end
@@ -162,7 +162,7 @@ module Asperalm
162
162
  top_node_info,top_file_id=check_get_node_file(top_node_file)
163
163
  Log.log.debug("find_files: node_info=#{top_node_info}, fileid=#{top_file_id}, regex=#{element_regex}")
164
164
  result=[]
165
- top_node_api=get_files_node_api(top_node_info,FilesApi::SCOPE_NODE_USER)
165
+ top_node_api=get_files_node_api(top_node_info,SCOPE_NODE_USER)
166
166
  # initialize loop elements : list of folders to scan
167
167
  items_to_explore=[{:node_api=>top_node_api,:folder_id=>top_file_id,:path=>''}]
168
168
  # Note: top file id is necessarily a folder
@@ -185,13 +185,13 @@ module Asperalm
185
185
  item_path=File.join(current_item[:path],current_file_info['name'])
186
186
  Log.log.debug("looking #{item_path}".bg_green)
187
187
  begin
188
+ result.push(current_file_info.merge({'path'=>item_path})) if test_block.call(current_file_info['name'])
188
189
  # process type of file
189
190
  case current_file_info['type']
190
191
  when 'file'
191
192
  Log.log.debug("testing : #{current_file_info['name']}")
192
- result.push(item_path) if test_block.call(current_file_info['name'])
193
193
  when 'link'
194
- new_node_api=get_files_node_api(self.read("nodes/#{current_file_info['target_node_id']}")[:data],FilesApi::SCOPE_NODE_USER)
194
+ new_node_api=get_files_node_api(self.read("nodes/#{current_file_info['target_node_id']}")[:data],SCOPE_NODE_USER)
195
195
  items_to_explore.push({:node_api=>new_node_api,:folder_id=>current_file_info["target_id"],:path=>item_path})
196
196
  when 'folder'
197
197
  items_to_explore.push({:node_api=>current_item[:node_api],:folder_id=>current_file_info["id"],:path=>item_path})
@@ -220,7 +220,7 @@ module Asperalm
220
220
  current_item = items_to_explore.shift
221
221
  Log.log.debug "searching #{current_item}".bg_green
222
222
  # get API if changed
223
- current_node_api=get_files_node_api(current_node_info,FilesApi::SCOPE_NODE_USER) if current_node_api.nil?
223
+ current_node_api=get_files_node_api(current_node_info,SCOPE_NODE_USER) if current_node_api.nil?
224
224
  # get folder content
225
225
  folder_contents = current_node_api.read("files/#{current_file_id}/files")
226
226
  Log.dump(:folder_contents,folder_contents)
@@ -251,5 +251,5 @@ module Asperalm
251
251
  return {node_info: current_node_info, file_id: current_file_id}
252
252
  end
253
253
 
254
- end # FilesApi
254
+ end # OnCloud
255
255
  end # Asperalm
data/lib/asperalm/sync.rb CHANGED
@@ -64,7 +64,7 @@ module Asperalm
64
64
  raise StandardError,"instance key must be hash" unless @sync_params['instance'].is_a?(Hash)
65
65
  instance_builder=CommandLineBuilder.new(@sync_params['instance'],INSTANCE_PARAMS)
66
66
  instance_builder.process_params
67
- instance_builder.add_env_args(env_args)
67
+ instance_builder.add_env_args(env_args[:env],env_args[:args])
68
68
  end
69
69
 
70
70
  @sync_params['sessions'].each do |session_params|
@@ -72,7 +72,7 @@ module Asperalm
72
72
  raise StandardError,"session must contain at leat name" unless session_params.has_key?('name')
73
73
  session_builder=CommandLineBuilder.new(session_params,SESSION_PARAMS)
74
74
  session_builder.process_params
75
- session_builder.add_env_args(env_args)
75
+ session_builder.add_env_args(env_args[:env],env_args[:args])
76
76
  end
77
77
 
78
78
  return env_args
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asperalm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.24
4
+ version: 0.9.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-simple
@@ -54,60 +54,60 @@ dependencies:
54
54
  name: ruby-progressbar
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '1.0'
60
57
  - - ">="
61
58
  - !ruby/object:Gem::Version
62
59
  version: 1.0.0
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.0'
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
69
  version: 1.0.0
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: net-ssh
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '4.0'
80
77
  - - ">="
81
78
  - !ruby/object:Gem::Version
82
79
  version: 4.0.0
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '4.0'
90
87
  - - ">="
91
88
  - !ruby/object:Gem::Version
92
89
  version: 4.0.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '4.0'
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: mimemagic
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0.3'
100
- - - ">="
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0.3'
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0.3'
110
- - - ">="
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0.3'
113
113
  - !ruby/object:Gem::Dependency
@@ -235,11 +235,11 @@ files:
235
235
  - lib/asperalm/fasp/resume_policy.rb
236
236
  - lib/asperalm/fasp/uri.rb
237
237
  - lib/asperalm/faspex_gw.rb
238
- - lib/asperalm/files_api.rb
239
238
  - lib/asperalm/hash_ext.rb
240
239
  - lib/asperalm/log.rb
241
240
  - lib/asperalm/nagios.rb
242
241
  - lib/asperalm/oauth.rb
242
+ - lib/asperalm/on_cloud.rb
243
243
  - lib/asperalm/open_application.rb
244
244
  - lib/asperalm/persistency_file.rb
245
245
  - lib/asperalm/preview/file_types.rb
@@ -272,8 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  version: '0'
273
273
  requirements:
274
274
  - Aspera connect client installed for the user
275
- rubyforge_project:
276
- rubygems_version: 2.5.2.3
275
+ rubygems_version: 3.0.2
277
276
  signing_key:
278
277
  specification_version: 4
279
278
  summary: 'gem and command line tool for Aspera Server products: Aspera Files, Faspex,