asperalm 0.9.21 → 0.9.23

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
  SHA1:
3
- metadata.gz: e478093d2b8acde7c3ddc2f3bf946c7dc1820182
4
- data.tar.gz: 046301231db845bdd1224bd5e1dc43142fd4a13d
3
+ metadata.gz: 4c49454795d24583a8b1added44e594c4d0dea5d
4
+ data.tar.gz: 5284f4394fa5131f0d89e228876b8aa1f0ceda7e
5
5
  SHA512:
6
- metadata.gz: e5e85cba9ce0dff85a5dc4835656afd15d0456acf0353835c5223cfde4f96155acce3f8d089bc3cf3acc8909689b128d7cddcd0f1e46d436904c80a0de2c4069
7
- data.tar.gz: f296f52266041d52f5ad0bf341f72741896fba7c2b161f350bb469728e5f3dbe96c1afa3bd8458a465d1c2100fb57bc4fa4f9225e0ec200c7038d9a1c049fcd5
6
+ metadata.gz: bb78e193773c12e0f9c99b77409aba035871b03cfa9462698a4635fb397572eb32565f534c5268ebec445969c33d4fc5060fe2277eb6bbd158cb382b97a94e89
7
+ data.tar.gz: cd2865ac68d47dc970fe493440ac66422d93b2d91426d8aad53194576822540e50b630686e0c224d7ea3e4e087c0642ae556509f67ec79011d4e8cd38be92bcc
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.21
3
+ Version : 0.9.23
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.21
40
+ 0.9.23
41
41
  ```
42
42
 
43
43
  ## First use
@@ -159,7 +159,13 @@ $ gem update asperalm
159
159
 
160
160
  ## FASP Protocol
161
161
 
162
- Most file transfers will be done using the FASP protocol. This requires one of IBM Asprea transfer server or client with its license file (some are free):
162
+ Most file transfers will be done using the FASP protocol. Only two additional files are required to perform
163
+ an Aspera Transfer:
164
+
165
+ * ascp
166
+ * aspera-license (in same folder, or ../etc)
167
+
168
+ Those can be found in one of IBM Asprea transfer server or client with its license file (some are free):
163
169
 
164
170
  * IBM Aspera Connect Client (Free)
165
171
  * IBM Aspera Desktop Client (Free)
@@ -170,9 +176,11 @@ Most file transfers will be done using the FASP protocol. This requires one of I
170
176
  For instance, Aspera Connect Client can be installed
171
177
  by visiting the page: [http://downloads.asperasoft.com/connect2/](http://downloads.asperasoft.com/connect2/).
172
178
 
173
- `mlia` will detect most of Aspera transfer products in standard locations and use the first one found. Refer to section [FASP](#client) for details.
179
+ `mlia` will detect most of Aspera transfer products in standard locations and use the first one found.
180
+ Refer to section [FASP](#client) for details on how to select a client or set path to the FASP protocol.
174
181
 
175
- Several methods are provided on how to effectively start a transfer, refer to section: [Transfer Agents](#agents)
182
+ Several methods are provided on how to start a transfer. Use of a local client is one of them, but
183
+ other methods are available. Refer to section: [Transfer Agents](#agents)
176
184
 
177
185
  # <a name="cli"></a>Command Line Interface: `mlia`
178
186
 
@@ -509,7 +517,7 @@ So, the key file will be read only at execution time, but not be embedded in the
509
517
  Options are loaded using this algorithm:
510
518
 
511
519
  * if option '--preset=xxxx' is specified (or -Pxxxx), this reads the [option preset](#lprt) specified from the configuration file.
512
- * else if option --no-default is specified, then dont load default
520
+ * else if option --no-default (or -N) is specified, then dont load default
513
521
  * else it looks for the name of the default [option preset](#lprt) in section "default" and loads it
514
522
  * environment variables are evaluated
515
523
  * command line options are evaluated
@@ -921,7 +929,7 @@ A non complete list of commands used in unit tests:
921
929
  ```bash
922
930
  $ mlia -h
923
931
  NAME
924
- mlia -- a command line tool for Aspera Applications (v0.9.21)
932
+ mlia -- a command line tool for Aspera Applications (v0.9.23)
925
933
 
926
934
  COMMAND: config
927
935
  SUBCOMMANDS: gem_path, genkey, plugins, flush_tokens, list, overview, open, echo, id, documentation, wizard, export_to_cli, detect, coffee, ascp
@@ -935,6 +943,7 @@ OPTIONS:
935
943
  --use-generic-client=ENUM wizard: AoC: use global or org specific jwt client id: yes, no
936
944
  --pkeypath=VALUE path to private key for JWT (wizard)
937
945
  --ascp-path=VALUE path to ascp
946
+ --use-product=VALUE use ascp from specified product
938
947
  SYNOPSIS
939
948
  mlia COMMANDS [OPTIONS] [ARGS]
940
949
 
@@ -976,7 +985,6 @@ OPTIONS: global
976
985
  --fasp-proxy=VALUE URL of FASP proxy (dnat / dnats)
977
986
  --http-proxy=VALUE URL of HTTP proxy (for http fallback)
978
987
  --lock-port=VALUE prevent dual execution of a command, e.g. in cron
979
- --use-product=VALUE DEPRECATED
980
988
  --query=VALUE additional filter for API calls (extended value) (some commands)
981
989
  --insecure=ENUM do not validate HTTPS certificate: yes, no
982
990
  --flat-hash=ENUM display hash values as additional keys: yes, no
@@ -1642,38 +1650,57 @@ $ mlia node access_key create --value=@json:'{"id":"eudemo-sedemo","secret":"mys
1642
1650
  The `config` plugin also allows specification for the use of a local FASP client. It provides the following commands for `ascp` subcommand:
1643
1651
 
1644
1652
  * `show` : shows the path of ascp used
1653
+ * `use` : list,download connect client versions available on internet
1645
1654
  * `products` : list Aspera transfer products available locally
1646
1655
  * `connect` : list,download connect client versions available on internet
1647
1656
 
1648
- ### List installed clients
1657
+ ### Show path of currently used `ascp`
1658
+
1659
+ ```
1660
+ $ mlia config ascp show
1661
+ /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/ascp
1662
+ ```
1663
+
1664
+ ### Selection of local `ascp`
1665
+
1666
+ To temporarily use an alternate ascp path use option `ascp_path` (`--ascp-path=`)
1667
+
1668
+ To permanently use another ascp:
1669
+
1670
+ ```
1671
+ $ mlia config ascp use '/Users/laurent/Applications/Aspera CLI/bin/ascp'
1672
+ saved to default global preset /Users/laurent/Applications/Aspera CLI/bin/ascp
1673
+ ```
1674
+
1675
+ This sets up a global default.
1676
+
1677
+ ### List locally installed Aspera Transfer products
1649
1678
 
1650
1679
  Locally installed Aspera products can be listed with:
1651
1680
 
1652
1681
  ```bash
1653
- $ mlia config products list
1654
- :..........................:................................................:
1655
- : name : app_root :
1656
- :..........................:................................................:
1657
- : Connect Client : /Users/laurent/Applications/Aspera Connect.app :
1658
- : Aspera Enterprise Server : /Library/Aspera :
1659
- :..........................:................................................:
1682
+ $ mlia config ascp products list
1683
+ :.........................................:................................................:
1684
+ : name : app_root :
1685
+ :.........................................:................................................:
1686
+ : Aspera Connect : /Users/laurent/Applications/Aspera Connect.app :
1687
+ : IBM Aspera CLI : /Users/laurent/Applications/Aspera CLI :
1688
+ : IBM Aspera High-Speed Transfer Endpoint : /Library/Aspera :
1689
+ : Aspera Drive : /Applications/Aspera Drive.app :
1690
+ :.........................................:................................................:
1660
1691
  ```
1661
1692
 
1662
1693
  ### Selection of local client
1663
1694
 
1664
- By default, the special value `FIRST` is used and will select the first product in list.
1665
- To select another product use option: `use_product`, either on command line:
1666
- `--use-product='Aspera Enterprise Server'`, or by setting as default:
1695
+ If no ascp is selected, this is equivalent to using option: `--use-product=FIRST`.
1667
1696
 
1668
- ```
1669
- $ mlia config ascp product use 'Aspera Enterprise Server'
1670
- ```
1697
+ Using the option use_product finds the ascp binary of the selected product.
1671
1698
 
1672
- ### List current resources used
1699
+ To permanently use the ascp of a product:
1673
1700
 
1674
- ```
1675
- $ mlia config ascp show
1676
- /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/ascp
1701
+ ```bash
1702
+ $ mlia config ascp products use 'Aspera Connect'
1703
+ saved to default global preset /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/ascp
1677
1704
  ```
1678
1705
 
1679
1706
  ### Installation of Connect Client on command line
@@ -2008,8 +2035,8 @@ yum install libreoffice
2008
2035
  Although libreoffice is run headless, older versions may require an X server. If you get error running libreoffice headless, then install Xvfb:
2009
2036
 
2010
2037
  ```
2011
- yum install libreoffice Xvfb
2012
- cat<<EOF>/etc/init.d/xvfb
2038
+ yum install -y Xvfb
2039
+ cat<<EOF>/etc/init.d/xvfb
2013
2040
  # !/bin/bash
2014
2041
  # chkconfig: 345 95 50
2015
2042
  # description: Starts xvfb on display 42 for headless Libreoffice
@@ -2022,6 +2049,7 @@ start) /usr/bin/Xvfb :42 -screen 0 1280x1024x8 -extension RANDR&;;
2022
2049
  stop) killall Xvfb;;
2023
2050
  esac
2024
2051
  EOF
2052
+ chmod a+x /etc/init.d/xvfb
2025
2053
  chkconfig xvfb on
2026
2054
  service xvfb start
2027
2055
  ```
@@ -2218,6 +2246,11 @@ Gems, or remove your ed25519 key from your `.ssh` folder to solve the issue.
2218
2246
 
2219
2247
  # Release Notes
2220
2248
 
2249
+ * version 0.9.23
2250
+
2251
+ * defined REST error handlers, more error conditions detected
2252
+ * commands to select specific ascp location
2253
+
2221
2254
  * version 0.9.21
2222
2255
 
2223
2256
  * supports simplified wizard using global client
data/bin/mlia CHANGED
@@ -2,4 +2,6 @@
2
2
  require 'rubygems'
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib")
4
4
  require 'asperalm/cli/main'
5
+ Encoding.default_internal = Encoding::UTF_8
6
+ Encoding.default_external = Encoding::UTF_8
5
7
  Asperalm::Cli::Main.new(ARGV).process_command_line
data/lib/asperalm/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.21
1
+ 0.9.23
@@ -35,7 +35,6 @@ module Asperalm
35
35
  FIELDS_ALL='ALL'
36
36
  FIELDS_DEFAULT='DEF'
37
37
  VERBOSE_LEVELS=[:normal,:minimal,:quiet]
38
- CONFIG_PLUGIN_SYM = Plugins::Config.name.split('::').last.downcase.to_sym
39
38
 
40
39
  private_constant :PROGRAM_NAME,:GEM_NAME,:CLI_MODULE,:PLUGINS_MODULE,:FIELDS_ALL,:FIELDS_DEFAULT,:VERBOSE_LEVELS
41
40
 
@@ -149,7 +148,6 @@ module Asperalm
149
148
  @opt_mgr.add_opt_simple(:fasp_proxy,"URL of FASP proxy (dnat / dnats)")
150
149
  @opt_mgr.add_opt_simple(:http_proxy,"URL of HTTP proxy (for http fallback)")
151
150
  @opt_mgr.add_opt_simple(:lock_port,"prevent dual execution of a command, e.g. in cron")
152
- @opt_mgr.add_opt_simple(:use_product,"DEPRECATED")
153
151
  @opt_mgr.add_opt_simple(:query,"additional filter for API calls (extended value) (some commands)")
154
152
  @opt_mgr.add_opt_boolean(:insecure,"do not validate HTTPS certificate")
155
153
  @opt_mgr.add_opt_boolean(:flat_hash,"display hash values as additional keys")
@@ -380,7 +378,7 @@ module Asperalm
380
378
  if all_plugins
381
379
  # list plugins that have a "require" field, i.e. all but main plugin
382
380
  @plugin_env[:config].plugins.keys.each do |plugin_name_sym|
383
- next if plugin_name_sym.eql?(CONFIG_PLUGIN_SYM)
381
+ next if plugin_name_sym.eql?(Plugins::Config::CONF_PLUGIN_SYM)
384
382
  # override main option parser with a brand new, to avoid having global options
385
383
  plugin_env=@plugin_env.clone
386
384
  plugin_env[:man_only]=true
@@ -451,7 +449,7 @@ module Asperalm
451
449
  exit_with_usage(true) if @option_help and @opt_mgr.command_or_arg_empty?
452
450
  generate_bash_completion if @bash_completion
453
451
  # load global default options and process
454
- @plugin_env[:config].add_plugin_default_preset(CONFIG_PLUGIN_SYM)
452
+ @plugin_env[:config].add_plugin_default_preset(Plugins::Config::CONF_GLOBAL_SYM)
455
453
  @opt_mgr.parse_options!
456
454
  # dual execution locking
457
455
  lock_port=@opt_mgr.get_option(:lock_port,:optional)
@@ -464,16 +462,16 @@ module Asperalm
464
462
  end
465
463
  end
466
464
  if @option_show_config and @opt_mgr.command_or_arg_empty?
467
- command_sym=CONFIG_PLUGIN_SYM
465
+ command_sym=Plugins::Config::CONF_PLUGIN_SYM
468
466
  else
469
467
  command_sym=@opt_mgr.get_next_command(@plugin_env[:config].plugins.keys.dup.unshift(:help))
470
468
  end
471
469
  # main plugin is not dynamically instanciated
472
- Log.log.debug(">>>#{CONFIG_PLUGIN_SYM.to_s}")
470
+ Log.log.debug(">>>#{Plugins::Config::CONF_PLUGIN_SYM.to_s}")
473
471
  case command_sym
474
472
  when :help
475
473
  exit_with_usage(true)
476
- when CONFIG_PLUGIN_SYM
474
+ when Plugins::Config::CONF_PLUGIN_SYM
477
475
  command_plugin=@plugin_env[:config]
478
476
  else
479
477
  # get plugin, set options, etc
@@ -14,9 +14,18 @@ module Asperalm
14
14
  VAL_ALL='ALL'
15
15
  private_constant :VAL_ALL
16
16
  attr_reader :api_aoc
17
+ attr_accessor :option_ak_secret
17
18
  def initialize(env)
18
19
  super(env)
20
+ @default_workspace_id=nil
21
+ @workspace_name=nil
22
+ @workspace_id=nil
23
+ @user_id=nil
24
+ @home_node_file=nil
25
+ @api_aoc=nil
26
+ @option_ak_secret=nil
19
27
  @ats=Ats.new(@agents.merge(skip_secret: true))
28
+ self.options.set_obj_attr(:secret,self,:option_ak_secret)
20
29
  self.options.add_opt_list(:auth,Oauth.auth_types,"type of Oauth authentication")
21
30
  self.options.add_opt_list(:operation,[:push,:pull],"client operation for transfers")
22
31
  self.options.add_opt_simple(:client_id,"API client identifier in application")
@@ -44,16 +53,10 @@ module Asperalm
44
53
  self.options.set_option(:private_key,'@file:'+env[:private_key_path]) if env[:private_key_path].is_a?(String)
45
54
  self.options.parse_options!
46
55
  return if env[:man_only]
47
- @default_workspace_id=nil
48
- @workspace_name=nil
49
- @workspace_id=nil
50
- @user_id=nil
51
- @home_node_file=nil
52
- @api_aoc=nil
53
- @ak_secret=self.options.get_option(:secret,:optional)
54
56
  update_aoc_api
55
57
  end
56
58
 
59
+ # add some tags and then starts transfer using agent
57
60
  def transfer_start(api_aoc,app,direction,node_file,ts_add)
58
61
  # activity tracking
59
62
  ts_add.deep_merge!({'tags'=>{'aspera'=>{'files'=>{'workspace_name'=>@workspace_name}}}})
@@ -98,6 +101,7 @@ module Asperalm
98
101
  result=node_api.delete("files/#{node_file[:file_id]}")[:data]
99
102
  return Main.result_status("deleted: #{thepath}")
100
103
  when :transfer
104
+ # in same workspace
101
105
  server_home_node_file=client_home_node_file=top_node_file
102
106
  case self.options.get_option(:operation,:mandatory)
103
107
  when :push
@@ -109,8 +113,8 @@ module Asperalm
109
113
  client_folder=self.transfer.destination_folder(client_tr_oper)
110
114
  server_folder=self.options.get_option(:from_folder,:mandatory)
111
115
  end
112
- node_file_server = @api_aoc.resolve_node_file(server_home_node_file,server_folder)
113
116
  node_file_client = @api_aoc.resolve_node_file(client_home_node_file,client_folder)
117
+ node_file_server = @api_aoc.resolve_node_file(server_home_node_file,server_folder)
114
118
  # force node as agent
115
119
  self.options.set_option(:transfer,:node)
116
120
  # force node api in node agent
@@ -170,7 +174,9 @@ module Asperalm
170
174
  end # command_repo
171
175
  end # execute_node_gen4_action
172
176
 
173
- # @return REST object. parameters based on command line options
177
+ # Create a new AoC API REST object and set @api_aoc.
178
+ # Parameters based on command line options
179
+ # @return nil
174
180
  def update_aoc_api
175
181
  public_link_url=self.options.get_option(:link,:optional)
176
182
 
@@ -188,9 +194,6 @@ module Asperalm
188
194
  self.options.set_option(:url,'https://'+uri.host)
189
195
  self.options.set_option(:public_token,url_token_value)
190
196
  self.options.set_option(:auth,:url_token)
191
- #client_data=FilesApi.random_drive
192
- #self.options.set_option(:client_id,client_data.first)
193
- #self.options.set_option(:client_secret,client_data.last)
194
197
  end
195
198
  # Connection paramaters (url and auth) to Aspera on Cloud
196
199
  # pre populate rest parameters based on URL
@@ -464,7 +467,7 @@ module Asperalm
464
467
  end
465
468
  when :files
466
469
  set_workspace_info
467
- @api_aoc.secrets[@home_node_file[:node_info]['id']]=@ak_secret
470
+ @api_aoc.secrets[@home_node_file[:node_info]['id']]=@option_ak_secret
468
471
  return execute_node_gen4_action(@home_node_file)
469
472
  when :faspexgw
470
473
  set_workspace_info
@@ -516,7 +519,7 @@ module Asperalm
516
519
  Log.log.warn("name overrides id") unless res_id.nil?
517
520
  matching=@api_aoc.read(resource_class_path,{:q=>res_name})[:data]
518
521
  raise CliError,"no resource match name" if matching.empty?
519
- raise CliError,"several resources match name" unless matching.length.eql?(1)
522
+ raise CliError,"several resources match name (#{matching.join(',')})" unless matching.length.eql?(1)
520
523
  res_id=matching.first['id']
521
524
  end
522
525
  raise CliBadArgument,"provide either id or name" if res_id.nil?
@@ -555,8 +558,8 @@ module Asperalm
555
558
  res_data=@api_aoc.read(resource_instance_path)[:data]
556
559
  # mandatory secret : we have only AK
557
560
  self.options.get_option(:secret,:mandatory)
558
- @api_aoc.secrets[res_data['id']]=@ak_secret unless @ak_secret.nil?
559
- api_node=@api_aoc.get_files_node_api(res_data,nil)
561
+ @api_aoc.secrets[res_data['id']]=@option_ak_secret unless @option_ak_secret.nil?
562
+ api_node=@api_aoc.get_files_node_api(res_data)
560
563
  return Node.new(@agents.merge(skip_basic_auth_options: true, node_api: api_node)).execute_action if command.eql?(:v3)
561
564
  ak_data=api_node.call({:operation=>'GET',:subpath=>"access_keys/#{res_data['access_key']}",:headers=>{'Accept'=>'application/json'}})[:data]
562
565
  return execute_node_gen4_action({node_info: res_data, file_id: ak_data['root_file_id']})
@@ -18,6 +18,8 @@ module Asperalm
18
18
  CONF_PRESET_CONFIG='config'
19
19
  CONF_PRESET_VERSION='version'
20
20
  CONF_PRESET_DEFAULT='default'
21
+ CONF_PLUGIN_SYM = :config # Plugins::Config.name.split('::').last.downcase.to_sym
22
+ CONF_GLOBAL_SYM = :config
21
23
  # old tool name
22
24
  OLD_PROGRAM_NAME = 'aslmcli'
23
25
  # default redirect for AoC web auth
@@ -29,7 +31,7 @@ module Asperalm
29
31
  RUBY_FILE_EXT='.rb'
30
32
  OLD_AOC_COMMAND='files'
31
33
  NEW_AOC_COMMAND='aspera'
32
- CONNECT_WEB_URL = 'http://d3gcli72yxqn2z.cloudfront.net/connect'
34
+ CONNECT_WEB_URL = 'https://d3gcli72yxqn2z.cloudfront.net/connect'
33
35
  CONNECT_VERSIONS = 'connectversions.js'
34
36
 
35
37
  private_constant :ASPERA_HOME_FOLDER_NAME,:DEFAULT_CONFIG_FILENAME,:CONF_PRESET_CONFIG,:CONF_PRESET_VERSION,:CONF_PRESET_DEFAULT,:OLD_PROGRAM_NAME,:DEFAULT_REDIRECT,:ASPERA_PLUGINS_FOLDERNAME,:GEM_PLUGINS_FOLDER,:RUBY_FILE_EXT,:OLD_AOC_COMMAND,:NEW_AOC_COMMAND
@@ -51,6 +53,7 @@ module Asperalm
51
53
  @option_config_file=File.join(@main_folder,DEFAULT_CONFIG_FILENAME)
52
54
  @help_url='http://www.rubydoc.info/gems/'+@gem_name
53
55
  @gem_url='https://rubygems.org/gems/'+@gem_name
56
+ @connect_versions=nil
54
57
  # set folder where generated FASP files are
55
58
  Fasp::Installation.instance.config_folder=@main_folder
56
59
  add_plugin_lookup_folder(File.join(@main_folder,ASPERA_PLUGINS_FOLDERNAME))
@@ -58,12 +61,14 @@ module Asperalm
58
61
  self.options.set_obj_attr(:override,self,:option_override,:no)
59
62
  self.options.set_obj_attr(:config_file,self,:option_config_file)
60
63
  self.options.set_obj_attr(:ascp_path,self,:option_ascp_path)
64
+ self.options.set_obj_attr(:use_product,self,:option_use_product)
61
65
  self.options.add_opt_boolean(:override,"override existing value")
62
66
  self.options.add_opt_simple(:config_file,"read parameters from file in YAML format, current=#{@option_config_file}")
63
67
  self.options.add_opt_switch(:no_default,"-N","do not load default configuration for plugin") { @use_plugin_defaults=false }
64
68
  self.options.add_opt_boolean(:use_generic_client,'wizard: AoC: use global or org specific jwt client id')
65
69
  self.options.add_opt_simple(:pkeypath,"path to private key for JWT (wizard)")
66
70
  self.options.add_opt_simple(:ascp_path,"path to ascp")
71
+ self.options.add_opt_simple(:use_product,"use ascp from specified product")
67
72
  self.options.set_option(:use_generic_client,true)
68
73
  self.options.parse_options!
69
74
  end
@@ -115,6 +120,15 @@ module Asperalm
115
120
  return r
116
121
  end
117
122
 
123
+ def set_config_default(key,value)
124
+ global_default_preset=get_plugin_default_config_name(CONF_GLOBAL_SYM)
125
+ if global_default_preset.nil?
126
+ global_default_preset='global_common_defaults'
127
+ @config_presets[global_default_preset]={}
128
+ end
129
+ @config_presets[global_default_preset][key.to_s]=value
130
+ end
131
+
118
132
  public
119
133
 
120
134
  # $HOME/.aspera/`program_name`
@@ -138,6 +152,14 @@ module Asperalm
138
152
  Fasp::Installation.instance.ascp_path
139
153
  end
140
154
 
155
+ def option_use_product=(value)
156
+ Fasp::Installation.instance.use_ascp_from_product(value)
157
+ end
158
+
159
+ def option_use_product
160
+ "write-only value"
161
+ end
162
+
141
163
  # read config file and validate format
142
164
  # tries to cnvert if possible and required
143
165
  def read_config_file
@@ -278,21 +300,33 @@ module Asperalm
278
300
  end
279
301
 
280
302
  def execute_action_ascp
281
- command=self.options.get_next_command([:connect,:use,:show,:products])
303
+ command=self.options.get_next_command([:connect,:use,:show,:products,:info])
282
304
  case command
283
305
  when :connect
284
306
  return execute_connect_action
285
307
  when :use
286
- raise "TODO: not implemented (set default ascp to use)"
308
+ default_ascp=self.options.get_next_argument('path to ascp')
309
+ raise "file name must be ascp" unless File.basename(default_ascp).eql?('ascp')
310
+ raise "no such file: #{default_ascp}" unless File.exist?(default_ascp)
311
+ raise "not executable: #{default_ascp}" unless File.executable?(default_ascp)
312
+ preset_name=set_config_default(:ascp_path,default_ascp)
313
+ save_presets_to_config_file
314
+ return {:type=>:status, :data=>"saved to default global preset #{preset_name}"}
287
315
  when :show # shows files used
288
316
  return {:type=>:status, :data=>Fasp::Installation.instance.path(:ascp)}
317
+ when :info # shows files used
318
+ return {:type=>:status, :data=>Fasp::Installation.instance.path(:ascp)}
289
319
  when :products
290
320
  command=self.options.get_next_command([:list,:use])
291
321
  case command
292
322
  when :list
293
323
  return {:type=>:object_list, :data=>Fasp::Installation.instance.installed_products, :fields=>['name','app_root']}
294
324
  when :use
295
- raise "TODO: not implemented (set default ascp to use from product)"
325
+ default_product=self.options.get_next_argument('product name')
326
+ Fasp::Installation.instance.use_ascp_from_product(default_product)
327
+ preset_name=set_config_default(:ascp_path,Fasp::Installation.instance.ascp_path)
328
+ save_presets_to_config_file
329
+ return {:type=>:status, :data=>"saved to default global preset #{preset_name}"}
296
330
  end
297
331
  end
298
332
  end
@@ -553,7 +587,7 @@ module Asperalm
553
587
  File.write(@option_config_file,@config_presets.to_yaml)
554
588
  end
555
589
 
556
- # returns name if config_presets has default
590
+ # returns [String] name if config_presets has default
557
591
  # returns nil if there is no config or bypass default params
558
592
  def get_plugin_default_config_name(plugin_sym)
559
593
  raise "internal error: config_presets shall be defined" if @config_presets.nil?
@@ -571,7 +605,7 @@ module Asperalm
571
605
  return default_config_name
572
606
  end
573
607
  return nil
574
- end
608
+ end # get_plugin_default_config_name
575
609
 
576
610
  end
577
611
  end