asperalm 0.10.6 → 0.10.7

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
2
  SHA256:
3
- metadata.gz: 751f34427a8052336c92efce4ba309f56eeef82cc175ad50ce10bc95864f4912
4
- data.tar.gz: eb4246a5e02303ef96b1d2f6e4e509224bea91cdd85a69dad2e5dbcb9a493a90
3
+ metadata.gz: 587ccc4506626802e9f576923507dd3029c08844f0b6d8a9bd9e60f82d773eaa
4
+ data.tar.gz: 0a8b098bb8905f07bd3fc7e85811ac9a986eaec25097d7f7e30a9cd23fd7c5c3
5
5
  SHA512:
6
- metadata.gz: 5ebfaca63443ddc3095af08c4b1e0bd0a6eb23ffd4a00123df9b90b60001ed7e576247f0fceca706029b9f4ca4de43214dc1b8a1a1f77a5f82a46a480c1978eb
7
- data.tar.gz: c1578064c66d25d57e3f2cf3e7799e123f597edddada534eeb68255556991f274a37d5b9636559f992bd846efbe149d44f62db9a09a0fa4fb50e833516f07152
6
+ metadata.gz: cfc250e4bf18d6b1de3230bf20ada521958670724685eb4d9b75991455477cac4b482e0b1d919aa822d5941c6d35f4b4ac91fe4c28483dd74c6b2b331818414e
7
+ data.tar.gz: 332030a5a3fa1fbd6390d12419ebd0cda8861fdca5c0dc1574d67cc3c70524c1967e6793523fb1639f71c0daca98c3e6156d3ee7c02ad7f74e17ec7c1cd731fb
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.10.6
3
+ Version : 0.10.7
4
4
 
5
5
 
6
6
  _Laurent/2016-2018_
@@ -39,7 +39,7 @@ Once the gem is installed, `mlia` shall be accessible:
39
39
 
40
40
  ```bash
41
41
  $ mlia --version
42
- 0.10.6
42
+ 0.10.7
43
43
  ```
44
44
 
45
45
  ## First use
@@ -1260,7 +1260,7 @@ mlia sync start --parameters=@json:'{"sessions":[{"name":"test","reset":true,"re
1260
1260
  ```bash
1261
1261
  $ mlia -h
1262
1262
  NAME
1263
- mlia -- a command line tool for Aspera Applications (v0.10.6)
1263
+ mlia -- a command line tool for Aspera Applications (v0.10.7)
1264
1264
 
1265
1265
  SYNOPSIS
1266
1266
  mlia COMMANDS [OPTIONS] [ARGS]
@@ -1324,6 +1324,7 @@ OPTIONS:
1324
1324
  --smtp=VALUE smtp configuration (extended value: hash)
1325
1325
  --fpac=VALUE proxy auto configuration URL
1326
1326
  -P, --presetVALUE load the named option preset from current config file
1327
+ --default=VALUE set as default configuration for specified plugin
1327
1328
  --test-mode=ENUM skip user validation in wizard mode: yes, no
1328
1329
  --ts=VALUE override transfer spec values (Hash, use @json: prefix), current={}
1329
1330
  --local-resume=VALUE set resume policy (Hash, use @json: prefix), current={:iter_max=>7, :sleep_initial=>2, :sleep_factor=>2, :sleep_max=>60}
@@ -2833,6 +2834,10 @@ So, it evolved into `mlia`:
2833
2834
 
2834
2835
  # Release Notes
2835
2836
 
2837
+ * version 0.10.7
2838
+
2839
+ * fix: mlia fails when username cannot be computed on Linux.
2840
+
2836
2841
  * version 0.10.6
2837
2842
 
2838
2843
  * FaspManager: transfer spec `authentication` no more needed for local tranfer to use aspera public keys. public keys will be used if there is a token and no key or password is provided.
@@ -1 +1 @@
1
- 0.10.6
1
+ 0.10.7
@@ -143,6 +143,8 @@ module Asperalm
143
143
  result=node_api.delete("files/#{node_file[:file_id]}")[:data]
144
144
  return Main.result_status("deleted: #{thepath}")
145
145
  when :transfer
146
+ # client side is agent
147
+ # server side is protocol server
146
148
  # in same workspace
147
149
  server_home_node_file=client_home_node_file=top_node_file
148
150
  case self.options.get_option(:operation,:mandatory)
@@ -155,20 +157,19 @@ module Asperalm
155
157
  client_folder=self.transfer.destination_folder(client_tr_oper)
156
158
  server_folder=self.options.get_option(:from_folder,:mandatory)
157
159
  end
158
- node_file_client = @api_aoc.resolve_node_file(client_home_node_file,client_folder)
159
- node_file_server = @api_aoc.resolve_node_file(server_home_node_file,server_folder)
160
+ client_node_file = @api_aoc.resolve_node_file(client_home_node_file,client_folder)
161
+ server_node_file = @api_aoc.resolve_node_file(server_home_node_file,server_folder)
160
162
  # force node as agent
161
163
  self.options.set_option(:transfer,:node)
162
164
  # force node api in node agent
163
- Fasp::Node.instance.node_api=@api_aoc.get_node_api(node_file_client[:node_info],OnCloud::SCOPE_NODE_USER)
165
+ Fasp::Node.instance.node_api=@api_aoc.get_node_api(client_node_file[:node_info],OnCloud::SCOPE_NODE_USER)
164
166
  # additional node to node TS info
165
167
  add_ts={
166
- 'remote_access_key' => node_file_server[:node_info]['access_key'],
167
- 'destination_root_id' => node_file_server[:file_id],
168
- 'source_root_id' => node_file_client[:file_id]
168
+ 'remote_access_key' => server_node_file[:node_info]['access_key'],
169
+ 'destination_root_id' => server_node_file[:file_id],
170
+ 'source_root_id' => client_node_file[:file_id]
169
171
  }
170
- return Main.result_transfer(transfer_start(OnCloud::FILES,client_tr_oper,node_file_server,add_ts))
171
- #bad: return Main.result_transfer(transfer_start(OnCloud::FILES,client_tr_oper,node_file_client,add_ts))
172
+ return Main.result_transfer(transfer_start(OnCloud::FILES,client_tr_oper,server_node_file,add_ts))
172
173
  when :upload
173
174
  node_file = @api_aoc.resolve_node_file(top_node_file,self.transfer.destination_folder('send'))
174
175
  add_ts={'tags'=>{'aspera'=>{'files'=>{'parentCwd'=>"#{node_file[:node_info]['id']}:#{node_file[:file_id]}"}}}}
@@ -256,10 +257,7 @@ module Asperalm
256
257
  raise CliBadArgument,'too many redirections'
257
258
  end
258
259
 
259
- # Create a new AoC API REST object and set @api_aoc.
260
- # Parameters based on command line options
261
- # @return nil
262
- def update_aoc_api
260
+ def aoc_rest_params
263
261
 
264
262
  # if auth is a public link
265
263
  # option "link" is a shortcut for options: url, auth, public_token
@@ -267,8 +265,8 @@ module Asperalm
267
265
 
268
266
  # Connection paramaters (url and auth) to Aspera on Cloud
269
267
  # pre populate rest parameters based on URL
270
- aoc_rest_params=OnCloud.base_rest_params(self.options.get_option(:url,:mandatory))
271
- aoc_rest_auth=aoc_rest_params[:auth]
268
+ res_rest_params=OnCloud.base_rest_params(self.options.get_option(:url,:mandatory))
269
+ aoc_rest_auth=res_rest_params[:auth]
272
270
  aoc_rest_auth.merge!({
273
271
  :grant => self.options.get_option(:auth,:mandatory),
274
272
  :client_id => self.options.get_option(:client_id,:mandatory),
@@ -300,6 +298,13 @@ module Asperalm
300
298
  })
301
299
  else raise "ERROR: unsupported auth method"
302
300
  end
301
+ return res_rest_params
302
+ end
303
+
304
+ # Create a new AoC API REST object and set @api_aoc.
305
+ # Parameters based on command line options
306
+ # @return nil
307
+ def update_aoc_api
303
308
  @api_aoc=OnCloud.new(aoc_rest_params)
304
309
  # add access key secrets
305
310
  @api_aoc.add_secrets(@option_secrets)
@@ -611,8 +616,63 @@ module Asperalm
611
616
  when :admin
612
617
  self.options.set_option(:scope,OnCloud::SCOPE_FILES_ADMIN)
613
618
  update_aoc_api
614
- command_admin=self.options.get_next_command([ :ats, :resource, :usage_reports, :search_nodes, :events ])
619
+ command_admin=self.options.get_next_command([ :ats, :resource, :usage_reports, :search_nodes, :events, :subscription ])
615
620
  case command_admin
621
+ when :subscription
622
+ org=@api_aoc.read('organization')[:data]
623
+ bss_rest_param=aoc_rest_params
624
+ bss_rest_param[:base_url].gsub!('api/v1','bss/platform')
625
+ bss_api=Rest.new(bss_rest_param)
626
+ graphql_query="
627
+ query ($organization_id: ID!) {
628
+ aoc (organization_id: $organization_id) {
629
+ bssSubscription {
630
+ endDate
631
+ startDate
632
+ termMonths
633
+ plan
634
+ trial
635
+ termType
636
+ instances {
637
+ id
638
+ entitlements {
639
+ maxUsageMb
640
+ }
641
+ }
642
+ additionalStorageVolumeGb
643
+ additionalEgressVolumeGb
644
+ additionalUsers
645
+ term {
646
+ startDate
647
+ endDate
648
+ transferVolumeGb
649
+ egressVolumeGb
650
+ storageVolumeGb
651
+ }
652
+ paygoRate {
653
+ rate
654
+ currency
655
+ }
656
+ aocPlanData {
657
+ tier
658
+ trial
659
+ workspaces { max }
660
+ users {
661
+ planAmount
662
+ max
663
+ }
664
+ samlIntegration
665
+ activity
666
+ sharedInboxes
667
+ uniqueUrls
668
+ support
669
+ }
670
+ }
671
+ }
672
+ }
673
+ "
674
+ result=bss_api.create('graphql',{'variables'=>{'organization_id'=>org['id']},'query'=>graphql_query})[:data]['data']
675
+ return {:type=>:single_object,:data=>result['aoc']['bssSubscription']}
616
676
  when :ats
617
677
  ats_api = Rest.new(@api_aoc.params.deep_merge({
618
678
  :base_url => @api_aoc.params[:base_url]+'/admin/ats/pub/v1',
@@ -88,6 +88,7 @@ module Asperalm
88
88
  self.options.add_opt_simple(:smtp,"smtp configuration (extended value: hash)")
89
89
  self.options.add_opt_simple(:fpac,"proxy auto configuration URL")
90
90
  self.options.add_opt_simple(:preset,"-PVALUE","load the named option preset from current config file")
91
+ self.options.add_opt_simple(:default,"set as default configuration for specified plugin")
91
92
  self.options.add_opt_boolean(:test_mode,"skip user validation in wizard mode")
92
93
  self.options.set_option(:use_generic_client,true)
93
94
  self.options.set_option(:test_mode,false)
@@ -414,11 +415,16 @@ module Asperalm
414
415
  save_presets_to_config_file
415
416
  return Main.result_status("modified: #{@option_config_file}")
416
417
  when :update
417
- # TODO: when arguments are provided: --option=value, this creates an entry in the named configuration
418
+ default_for_plugin=self.options.get_option(:default,:optional)
419
+ # get unprocessed options
418
420
  theopts=self.options.get_options_table
419
421
  Log.log.debug("opts=#{theopts}")
420
- @config_presets[config_name]={} if !@config_presets.has_key?(config_name)
422
+ @config_presets[config_name]||={}
421
423
  @config_presets[config_name].merge!(theopts)
424
+ if ! default_for_plugin.nil?
425
+ @config_presets[CONF_PRESET_DEFAULT]||=Hash.new
426
+ @config_presets[CONF_PRESET_DEFAULT][default_for_plugin]=config_name
427
+ end
422
428
  save_presets_to_config_file
423
429
  return Main.result_status("updated: #{config_name}")
424
430
  when :ask
@@ -162,7 +162,6 @@ module Asperalm
162
162
  @default_transfer_spec=['ssh_port','fasp_port'].inject({}){|h,e|h[e]=sample_transfer_spec[e];h}
163
163
  @default_transfer_spec.merge!({
164
164
  'token' => "Basic #{Base64.strict_encode64("#{@access_key_self['id']}:#{self.options.get_option(:password,:mandatory)}")}",
165
- 'authentication' => 'token', # connect client: do not ask password
166
165
  'remote_host' => @transfer_server_address,
167
166
  'remote_user' => Fasp::ACCESS_KEY_TRANSFER_USER
168
167
  })
@@ -97,7 +97,22 @@ module Asperalm
97
97
  end
98
98
  when :aoc
99
99
  @agent=Fasp::Aoc.instance
100
- node_config=@opt_mgr.get_option(:transfer_info,:optional)
100
+ aoc_config=@opt_mgr.get_option(:transfer_info,:optional)
101
+ if aoc_config.nil?
102
+ param_set_name=@env[:config].get_plugin_default_config_name(:aspera)
103
+ raise CliBadArgument,"No default AoC configured, Please specify --#{:transfer_info.to_s.gsub('_','-')}" if param_set_name.nil?
104
+ aoc_config=@env[:config].preset_by_name(param_set_name)
105
+ end
106
+ Log.log.debug("aoc=#{aoc_config}")
107
+ raise CliBadArgument,"the node configuration shall be Hash, not #{aoc_config.class} (#{aoc_config}), use either @json:<json> or @preset:<parameter set name>" if !aoc_config.is_a?(Hash)
108
+ # now check there are required parameters
109
+ sym_config=[:url,:subject].inject({}) do |h,param|
110
+ raise CliBadArgument,"missing parameter [#{param}] in node specification: #{aoc_config}" if !aoc_config.has_key?(param.to_s)
111
+ h[param]=aoc_config[param.to_s]
112
+ h
113
+ end
114
+ #@agent.node_api=OnCloud.new(aoc_rest_params)
115
+ raise "UNDER WORK"
101
116
  else raise "INTERNAL ERROR"
102
117
  end
103
118
  @agent.add_listener(Listener::Logger.new)
@@ -162,7 +177,7 @@ module Asperalm
162
177
  when :pair
163
178
  raise CliBadArgument,"whe using pair, provide even number of paths: #{file_list.length}" unless file_list.length.even?
164
179
  @transfer_paths=file_list.each_slice(2).to_a.map{|s,d|{'source'=>s,'destination'=>d}}
165
- else raise "ERROR"
180
+ else raise "ERROR"
166
181
  end
167
182
  Log.log.debug("paths=#{@transfer_paths}")
168
183
  return @transfer_paths
@@ -202,8 +217,6 @@ module Asperalm
202
217
  @transfer_spec_cmdline['paths']=transfer_spec['paths'] || ts_source_paths
203
218
 
204
219
  transfer_spec.merge!(@transfer_spec_cmdline)
205
- # add bypass keys if there is a token, also prevents connect plugin to ask password
206
- transfer_spec['authentication']='token' if transfer_spec.has_key?('token')
207
220
  # create transfer agent
208
221
  self.set_agent_by_options
209
222
  Log.log.debug("mgr is a #{@agent.class}")
@@ -5,7 +5,6 @@ require 'securerandom'
5
5
  require 'base64'
6
6
  require 'json'
7
7
  require 'securerandom'
8
- require 'etc'
9
8
  require 'fileutils'
10
9
 
11
10
  module Asperalm
@@ -16,7 +15,7 @@ module Asperalm
16
15
  # temp folder for file lists, must contain only file lists
17
16
  # because of garbage collection takes any file there
18
17
  # this could be refined, as , for instance, on macos, temp folder is already user specific
19
- @@file_list_folder=File.join(Etc.systmpdir,Etc.getlogin)+'_asession_filelists'
18
+ @@file_list_folder=TempFileManager.instance.global_tmpfile_path('asession_filelists')
20
19
  SEC_IN_DAY=86400
21
20
  # assume no transfer last longer than this
22
21
  # (garbage collect file list which were not deleted after transfer)
@@ -69,7 +68,7 @@ module Asperalm
69
68
  'lock_rate_policy' => { :type => :ignore, :accepted_types=>Asperalm::CommandLineBuilder::BOOLEAN_CLASSES},
70
69
  'lock_min_rate' => { :type => :ignore, :accepted_types=>Asperalm::CommandLineBuilder::BOOLEAN_CLASSES},
71
70
  'lock_target_rate' => { :type => :ignore, :accepted_types=>Asperalm::CommandLineBuilder::BOOLEAN_CLASSES},
72
- 'authentication' => { :type => :ignore, :accepted_types=>String}, # = token
71
+ #'authentication' => { :type => :ignore, :accepted_types=>String}, # = token
73
72
  'https_fallback_port' => { :type => :ignore, :accepted_types=>Integer}, # same as http fallback, option -t ?
74
73
  'content_protection' => { :type => :ignore, :accepted_types=>String},
75
74
  'cipher_allowed' => { :type => :ignore, :accepted_types=>String},
@@ -21,6 +21,8 @@ end
21
21
 
22
22
  module Asperalm
23
23
  # a simple class to make HTTP calls, equivalent to rest-client
24
+ # rest call errors are raised as exception RestCallError
25
+ # and error are analyzed in RestErrorAnalyzer
24
26
  class Rest
25
27
 
26
28
  private
@@ -5,6 +5,7 @@ require 'json'
5
5
 
6
6
  module Asperalm
7
7
  # builds a meaningful error message from known formats in Aspera products
8
+ # TODO: probably too monolithic..
8
9
  class RestErrorAnalyzer
9
10
  attr_reader :messages
10
11
  attr_reader :request
@@ -1,5 +1,6 @@
1
1
  require 'singleton'
2
2
  require 'fileutils'
3
+ require 'etc'
3
4
 
4
5
  module Asperalm
5
6
  # create a temp file name for a given folder
@@ -23,5 +24,10 @@ module Asperalm
23
24
  end
24
25
  @created_files=[]
25
26
  end
27
+
28
+ def global_tmpfile_path(some_name)
29
+ username = Etc.getlogin || Etc.getpwuid(Process.uid).name || 'unknown' rescue 'unknown'
30
+ return File.join(Etc.systmpdir,username)+'_'+some_name
31
+ end
26
32
  end
27
33
  end
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.10.6
4
+ version: 0.10.7
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-12-11 00:00:00.000000000 Z
11
+ date: 2020-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-simple