asperalm 0.10.11 → 0.10.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,6 @@ module Asperalm
10
10
  class Ats < Plugin
11
11
  def initialize(env)
12
12
  super(env)
13
- self.options.add_opt_simple(:secret,"Access key secret") unless env[:skip_secret]
14
13
  self.options.add_opt_simple(:ibm_api_key,"IBM API key, see https://cloud.ibm.com/iam/apikeys")
15
14
  self.options.add_opt_simple(:instance,"ATS instance in ibm cloud")
16
15
  self.options.add_opt_simple(:ats_key,"ATS key identifier (ats_xxx)")
@@ -42,7 +41,7 @@ module Asperalm
42
41
  end
43
42
 
44
43
  def execute_action_access_key
45
- commands=[:create,:list,:show,:delete,:node,:cluster,:entitlement]
44
+ commands=[:create,:list,:show,:modify,:delete,:node,:cluster,:entitlement]
46
45
  command=self.options.get_next_command(commands)
47
46
  # those dont require access key id
48
47
  unless [:create,:list].include?(command)
@@ -62,9 +61,18 @@ module Asperalm
62
61
  case params['storage']['type']
63
62
  # here we need somehow to map storage type to field to get for auth end point
64
63
  when 'ibm-s3'
64
+ server_data2=nil
65
+ if server_data.nil?
66
+ server_data2=@ats_api_pub.all_servers.select{|s|s['id'].eql?(params['transfer_server_id'])}.first
67
+ raise "no such transfer server id: #{params['transfer_server_id']}" if server_data2.nil?
68
+ else
69
+ server_data2=@ats_api_pub.all_servers.select{|s|s['cloud'].eql?(server_data['cloud']) and s['region'].eql?(server_data['region']) and s.has_key?('s3_authentication_endpoint')}.first
70
+ raise "no such transfer server id: #{params['transfer_server_id']}" if server_data2.nil?
71
+ # specific one do not have s3 end point in id
72
+ params['transfer_server_id']=server_data2['id']
73
+ end
65
74
  if !params['storage'].has_key?('authentication_endpoint')
66
- server_data||=@ats_api_pub.all_servers.select{|i|i['id'].eql?(params['transfer_server_id'])}.first
67
- params['storage']['endpoint'] = server_data['s3_authentication_endpoint']
75
+ params['storage']['endpoint'] = server_data2['s3_authentication_endpoint']
68
76
  end
69
77
  end
70
78
  end
@@ -74,10 +82,15 @@ module Asperalm
74
82
  when :list
75
83
  params=self.options.get_option(:params,:optional) || {'offset'=>0,'max_results'=>1000}
76
84
  res=ats_api_pub_v1.read("access_keys",params)
77
- return {:type=>:object_list, :data=>res[:data]['data'], :fields => ['name','id','secret','created','modified']}
85
+ return {:type=>:object_list, :data=>res[:data]['data'], :fields => ['name','id','created.at','modified.at']}
78
86
  when :show
79
87
  res=ats_api_pub_v1.read("access_keys/#{access_key_id}")
80
88
  return {:type=>:single_object, :data=>res[:data]}
89
+ when :modify
90
+ params=self.options.get_option(:value,:mandatory)
91
+ params["id"]=access_key_id
92
+ res=ats_api_pub_v1.update("access_keys/#{access_key_id}",params)
93
+ return Main.result_status('modified')
81
94
  when :entitlement
82
95
  ak=ats_api_pub_v1.read("access_keys/#{access_key_id}")[:data]
83
96
  api_bss=OnCloud.metering_api(ak['license']['entitlement_id'],ak['license']['customer_id'])
@@ -93,8 +106,8 @@ module Asperalm
93
106
  :base_url => server_data['transfer_setup_url'],
94
107
  :auth => {
95
108
  :type => :basic,
96
- :username => ak_data['id'],
97
- :password => ak_data['secret']}})
109
+ :username => access_key_id,
110
+ :password => self.config.get_secret(access_key_id)}})
98
111
  command=self.options.get_next_command(Node::COMMON_ACTIONS)
99
112
  return Node.new(@agents.merge(skip_basic_auth_options: true, node_api: api_node)).execute_action(command)
100
113
  when :cluster
@@ -103,14 +116,8 @@ module Asperalm
103
116
  :auth => {
104
117
  :type => :basic,
105
118
  :username => access_key_id,
106
- :password => self.options.get_option(:secret,:optional)
119
+ :password => self.config.get_secret(access_key_id)
107
120
  }}
108
- # if no access key id provided, then we get from ATS API
109
- if rest_params[:auth][:password].nil?
110
- ak_data=ats_api_pub_v1.read("access_keys/#{access_key_id}")[:data]
111
- #rest_params[:username]=ak_data['id']
112
- rest_params[:auth][:password]=ak_data['secret']
113
- end
114
121
  api_ak_auth=Rest.new(rest_params)
115
122
  return {:type=>:single_object, :data=>api_ak_auth.read("servers")[:data]}
116
123
  else raise "INTERNAL ERROR"
@@ -45,9 +45,12 @@ module Asperalm
45
45
  end
46
46
 
47
47
  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
48
+ attr_accessor :option_ak_secret,:option_secrets
48
49
 
49
50
  def initialize(env,tool_name,help_url,version)
50
51
  super(env)
52
+ @option_ak_secret=nil
53
+ @option_secrets={}
51
54
  @plugins={}
52
55
  @plugin_lookup_folders=[]
53
56
  @use_plugin_defaults=true
@@ -74,11 +77,14 @@ module Asperalm
74
77
  # read correct file
75
78
  read_config_file
76
79
  # add preset handler (needed for smtp)
77
- ExtendedValue.instance.set_handler('preset',:reader,lambda{|v|preset_by_name(v)})
80
+ ExtendedValue.instance.set_handler(EXTV_PRESET,:reader,lambda{|v|preset_by_name(v)})
81
+ ExtendedValue.instance.set_handler(EXTV_INCLUDE_PRESETS,:decoder,lambda{|v|expanded_with_preset_includes(v)})
78
82
  self.options.set_obj_attr(:override,self,:option_override,:no)
79
83
  self.options.set_obj_attr(:ascp_path,self,:option_ascp_path)
80
84
  self.options.set_obj_attr(:use_product,self,:option_use_product)
81
85
  self.options.set_obj_attr(:preset,self,:option_preset)
86
+ self.options.set_obj_attr(:secret,self,:option_ak_secret)
87
+ self.options.set_obj_attr(:secrets,self,:option_secrets)
82
88
  self.options.add_opt_boolean(:override,"override existing value")
83
89
  self.options.add_opt_switch(:no_default,"-N","do not load default configuration for plugin") { @use_plugin_defaults=false }
84
90
  self.options.add_opt_boolean(:use_generic_client,'wizard: AoC: use global or org specific jwt client id')
@@ -89,10 +95,23 @@ module Asperalm
89
95
  self.options.add_opt_simple(:fpac,"proxy auto configuration URL")
90
96
  self.options.add_opt_simple(:preset,"-PVALUE","load the named option preset from current config file")
91
97
  self.options.add_opt_simple(:default,"set as default configuration for specified plugin")
98
+ self.options.add_opt_simple(:secret,"access key secret for node")
99
+ self.options.add_opt_simple(:secrets,"access key secret for node")
92
100
  self.options.add_opt_boolean(:test_mode,"skip user validation in wizard mode")
93
101
  self.options.set_option(:use_generic_client,true)
94
102
  self.options.set_option(:test_mode,false)
95
103
  self.options.parse_options!
104
+ raise CliBadArgument,"secrets shall be Hash" unless @option_secrets.is_a?(Hash)
105
+ end
106
+
107
+ def get_secret(id=nil,mandatory=true)
108
+ secret=self.options.get_option(:secret,:optional) || @option_secrets[id]
109
+ raise "please provide secret for #{id}" if secret.nil? and mandatory
110
+ return secret
111
+ end
112
+
113
+ def get_secrets
114
+ return @option_secrets
96
115
  end
97
116
 
98
117
  # retrieve structure from cloud (CDN) with all versions available
@@ -142,13 +161,17 @@ module Asperalm
142
161
  return r
143
162
  end
144
163
 
145
- def set_config_default(key,value)
146
- global_default_preset=get_plugin_default_config_name(CONF_GLOBAL_SYM)
147
- if global_default_preset.nil?
148
- global_default_preset='global_common_defaults'
149
- @config_presets[global_default_preset]={}
164
+ # set parameter and value in global config
165
+ # creates one if none already created
166
+ # @return preset that contains global default
167
+ def set_global_default(key,value)
168
+ global_default_preset_name=get_plugin_default_config_name(CONF_GLOBAL_SYM)
169
+ if global_default_preset_name.nil?
170
+ global_default_preset_name='global_common_defaults'
171
+ @config_presets[global_default_preset_name]={}
150
172
  end
151
- @config_presets[global_default_preset][key.to_s]=value
173
+ @config_presets[global_default_preset_name][key.to_s]=value
174
+ return global_default_preset_name
152
175
  end
153
176
 
154
177
  public
@@ -160,9 +183,32 @@ module Asperalm
160
183
  attr_accessor :option_override
161
184
  attr_accessor :option_config_file
162
185
 
163
- def preset_by_name(config_name)
186
+ EXTV_INCLUDE_PRESETS='incps'
187
+ EXTV_PRESET='preset'
188
+
189
+ # @return the hash from name (also expands possible includes)
190
+ def preset_by_name(config_name, include_path=[])
164
191
  raise CliError,"no such config preset: #{config_name}" unless @config_presets.has_key?(config_name)
165
- return @config_presets[config_name]
192
+ raise CliError,"loop in include" if include_path.include?(config_name)
193
+ return expanded_with_preset_includes(@config_presets[config_name],include_path.clone.push(config_name))
194
+ end
195
+
196
+ # @param hash_val
197
+ def expanded_with_preset_includes(hash_val, include_path=[])
198
+ raise CliError,"#{EXTV_INCLUDE_PRESETS} requires a Hash" unless hash_val.is_a?(Hash)
199
+ if hash_val.has_key?(EXTV_INCLUDE_PRESETS)
200
+ memory=hash_val.clone
201
+ includes=memory[EXTV_INCLUDE_PRESETS]
202
+ memory.delete(EXTV_INCLUDE_PRESETS)
203
+ hash_val={}
204
+ raise "#{EXTV_INCLUDE_PRESETS} must be an Array" unless includes.is_a?(Array)
205
+ raise "#{EXTV_INCLUDE_PRESETS} must contain names" unless includes.map{|i|i.class}.uniq.eql?([String])
206
+ includes.each do |preset_name|
207
+ hash_val.merge!(preset_by_name(preset_name,include_path))
208
+ end
209
+ hash_val.merge!(memory)
210
+ end
211
+ return hash_val
166
212
  end
167
213
 
168
214
  def option_ascp_path=(new_value)
@@ -330,7 +376,7 @@ module Asperalm
330
376
  raise "file name must be ascp" unless File.basename(default_ascp).eql?('ascp')
331
377
  raise "no such file: #{default_ascp}" unless File.exist?(default_ascp)
332
378
  raise "not executable: #{default_ascp}" unless File.executable?(default_ascp)
333
- preset_name=set_config_default(:ascp_path,default_ascp)
379
+ preset_name=set_global_default(:ascp_path,default_ascp)
334
380
  save_presets_to_config_file
335
381
  return {:type=>:status, :data=>"saved to default global preset #{preset_name}"}
336
382
  when :show # shows files used
@@ -360,7 +406,7 @@ module Asperalm
360
406
  when :use
361
407
  default_product=self.options.get_next_argument('product name')
362
408
  Fasp::Installation.instance.use_ascp_from_product(default_product)
363
- preset_name=set_config_default(:ascp_path,Fasp::Installation.instance.ascp_path)
409
+ preset_name=set_global_default(:ascp_path,Fasp::Installation.instance.ascp_path)
364
410
  save_presets_to_config_file
365
411
  return {:type=>:status, :data=>"saved to default global preset #{preset_name}"}
366
412
  end
@@ -505,6 +551,8 @@ module Asperalm
505
551
  pub_key_pem=OpenSSL::PKey::RSA.new(File.read(private_key_path)).public_key.to_s
506
552
  # define options
507
553
  require 'asperalm/cli/plugins/aspera'
554
+ # make username mandatory for jwt, this triggers interactive input
555
+ self.options.get_option(:username,:mandatory)
508
556
  files_plugin=Plugins::Aspera.new(@agents.merge({skip_basic_auth_options: true, private_key_path: private_key_path}))
509
557
  auto_set_pub_key=false
510
558
  auto_set_jwt=false
@@ -523,11 +571,6 @@ module Asperalm
523
571
  end
524
572
  else
525
573
  self.format.display_status("Using organization specific client_id.")
526
- # clear only if user did not specify it already
527
- if OnCloud.is_global_client_id?(self.options.get_option(:client_id,:optional))
528
- self.options.set_option(:client_id,nil)
529
- self.options.set_option(:client_secret,nil)
530
- end
531
574
  if self.options.get_option(:client_id,:optional).nil? or self.options.get_option(:client_secret,:optional).nil?
532
575
  self.format.display_status("Please login to your Aspera on Cloud instance.".red)
533
576
  self.format.display_status("Go to: Apps->Admin->Organization->Integrations")
@@ -565,13 +608,15 @@ module Asperalm
565
608
  self.format.display_status("creating new config preset: #{aspera_preset_name}")
566
609
  @config_presets[aspera_preset_name]={
567
610
  :url.to_s =>self.options.get_option(:url),
568
- :redirect_uri.to_s =>self.options.get_option(:redirect_uri),
569
- :client_id.to_s =>self.options.get_option(:client_id),
570
- :client_secret.to_s =>self.options.get_option(:client_secret),
611
+ :username.to_s =>myself['email'],
571
612
  :auth.to_s =>:jwt.to_s,
572
613
  :private_key.to_s =>'@file:'+private_key_path,
573
- :username.to_s =>myself['email'],
574
614
  }
615
+ # set only if non nil
616
+ [:client_id,:client_secret].each do |s|
617
+ o=self.options.get_option(s)
618
+ @config_presets[s.to_s] = o unless o.nil?
619
+ end
575
620
  self.format.display_status("Setting config preset as default for #{NEW_AOC_COMMAND}")
576
621
  @config_presets[CONF_PRESET_DEFAULT][NEW_AOC_COMMAND]=aspera_preset_name
577
622
  self.format.display_status("saving config file")
@@ -596,11 +641,10 @@ module Asperalm
596
641
  new_conf={
597
642
  'organization' => organization,
598
643
  'hostname' => [organization,instance_domain].join('.'),
599
- 'clientId' => self.options.get_option(:client_id,:mandatory),
600
- 'clientSecret' => self.options.get_option(:client_secret,:mandatory),
601
644
  'privateKeyFilename' => key_basename,
602
645
  'username' => self.options.get_option(:username,:mandatory)
603
646
  }
647
+ new_conf['clientId'],new_conf['clientSecret']=OnCloud.get_client_ids(self.options.get_option(:client_id,:optional),self.options.get_option(:client_secret,:optional))
604
648
  entry=data['AoCAccounts'].select{|i|i['organization'].eql?(organization)}.first
605
649
  if entry.nil?
606
650
  data['AoCAccounts'].push(new_conf)
@@ -78,9 +78,9 @@ module Asperalm
78
78
  :type => :basic,
79
79
  :username => ats_info['AccessKey']['Id'],
80
80
  :password => ats_info['AccessKey']['Secret']}})
81
- command=self.options.get_next_command([:upload,:download,:info,:access_key])
82
81
  #command=self.options.get_next_command(Node::ACTIONS)
83
82
  #command=self.options.get_next_command(Node::COMMON_ACTIONS)
83
+ command=self.options.get_next_command([:upload,:download,:info,:access_key,:api_details])
84
84
  node_plugin=Node.new(@agents.merge(skip_basic_auth_options: true, node_api: api_node, add_request_param: add_ts))
85
85
  return node_plugin.execute_action(command)
86
86
  end
@@ -293,7 +293,7 @@ module Asperalm
293
293
  when :info
294
294
  return {:data=>source_info,:type=>:single_object}
295
295
  when :node
296
- node_config=ExtendedValue.instance.parse(:node,source_info[KEY_NODE])
296
+ node_config=ExtendedValue.instance.evaluate(source_info[KEY_NODE])
297
297
  raise CliError,"bad type for: \"#{source_info[KEY_NODE]}\"" unless node_config.is_a?(Hash)
298
298
  Log.log.debug("node=#{node_config}")
299
299
  api_node=Rest.new({
@@ -82,7 +82,7 @@ module Asperalm
82
82
 
83
83
  SIMPLE_ACTIONS=[:nagios_check,:events, :space, :info, :license, :mkdir, :mklink, :mkfile, :rename, :delete, :search ]
84
84
 
85
- COMMON_ACTIONS=[:browse, :upload, :download ].concat(SIMPLE_ACTIONS)
85
+ COMMON_ACTIONS=[:browse, :upload, :download, :api_details ].concat(SIMPLE_ACTIONS)
86
86
 
87
87
  # common API to node and Shares
88
88
  # prefix_path is used to list remote sources in Faspex
@@ -192,6 +192,8 @@ module Asperalm
192
192
  # only one request, so only one answer
193
193
  transfer_spec=send_result['transfer_specs'].first['transfer_spec']
194
194
  return Main.result_transfer(self.transfer.start(transfer_spec,{:src=>:node_gen3}))
195
+ when :api_details
196
+ return { :type=>:single_object, :data => @api_node.params }
195
197
  end
196
198
  end
197
199
 
@@ -28,7 +28,6 @@ module Asperalm
28
28
  # source/destination pair, like "paths" of transfer spec
29
29
  @transfer_paths=nil
30
30
  @opt_mgr.set_obj_attr(:ts,self,:option_transfer_spec)
31
- @opt_mgr.set_obj_attr(:local_resume,Fasp::Local.instance,:resume_policy_parameters)
32
31
  @opt_mgr.add_opt_simple(:ts,"override transfer spec values (Hash, use @json: prefix), current=#{@opt_mgr.get_option(:ts,:optional)}")
33
32
  @opt_mgr.add_opt_simple(:local_resume,"set resume policy (Hash, use @json: prefix), current=#{@opt_mgr.get_option(:local_resume,:optional)}")
34
33
  @opt_mgr.add_opt_simple(:to_folder,"destination folder for downloaded files")
@@ -47,55 +46,57 @@ module Asperalm
47
46
 
48
47
  def option_transfer_spec_deep_merge(ts); @transfer_spec_cmdline.deep_merge!(ts); end
49
48
 
50
- # @return one of the Fasp:: agents based on parameters
49
+ def set_agent_instance(instance)
50
+ @agent=instance
51
+ @agent.add_listener(Listener::Logger.new)
52
+ @agent.add_listener(Listener::ProgressMulti.new)
53
+ end
54
+
55
+ # analyze options and create new agent if not already created or set
51
56
  def set_agent_by_options
52
57
  if @agent.nil?
53
58
  agent_type=@opt_mgr.get_option(:transfer,:mandatory)
54
59
  case agent_type
55
60
  when :direct
56
- @agent=Fasp::Local.instance
61
+ resume_policy=@opt_mgr.get_option(:transfer_info,:optional)
62
+ resume_policy=resume_policy.symbolize_keys if resume_policy.is_a?(Hash)
63
+ new_agent=Fasp::Local.new(resume_policy)
57
64
  # TODO: option to choose progress format
58
- # a- @agent.quiet=false
65
+ # a- new_agent.quiet=false
59
66
  # b- disable custom progress
60
67
  when :httpgw
61
68
  httpgw_config=@opt_mgr.get_option(:transfer_info,:mandatory)
62
- raise CliBadArgument,"transfer_info must have url" unless httpgw_config.has_key?('url')
63
- @agent=Fasp::HttpGW.instance
64
- @agent.url=httpgw_config['url']
69
+ new_agent=Fasp::HttpGW.new(httpgw_config)
65
70
  when :connect
66
- @agent=Fasp::Connect.instance
71
+ new_agent=Fasp::Connect.new
67
72
  when :node
68
- @agent=Fasp::Node.instance
69
- # get not api only if it is not already set
70
- if @agent.node_api.nil?
71
- # way for code to setup alternate node api in avance
72
- # support: @param:<name>
73
- # support extended values
74
- node_config=@opt_mgr.get_option(:transfer_info,:optional)
75
- # if not specified: use default node
76
- if node_config.nil?
77
- param_set_name=@config.get_plugin_default_config_name(:node)
78
- raise CliBadArgument,"No default node configured, Please specify --#{:transfer_info.to_s.gsub('_','-')}" if param_set_name.nil?
79
- node_config=@config.preset_by_name(param_set_name)
80
- end
81
- Log.log.debug("node=#{node_config}")
82
- raise CliBadArgument,"the node configuration shall be Hash, not #{node_config.class} (#{node_config}), use either @json:<json> or @preset:<parameter set name>" if !node_config.is_a?(Hash)
83
- # now check there are required parameters
84
- sym_config=[:url,:username,:password].inject({}) do |h,param|
85
- raise CliBadArgument,"missing parameter [#{param}] in node specification: #{node_config}" if !node_config.has_key?(param.to_s)
86
- h[param]=node_config[param.to_s]
87
- h
88
- end
89
- @agent.node_api=Rest.new({
90
- :base_url => sym_config[:url],
91
- :auth => {
92
- :type =>:basic,
93
- :username => sym_config[:username],
94
- :password => sym_config[:password]
95
- }})
73
+ # way for code to setup alternate node api in avance
74
+ # support: @preset:<name>
75
+ # support extended values
76
+ node_config=@opt_mgr.get_option(:transfer_info,:optional)
77
+ # if not specified: use default node
78
+ if node_config.nil?
79
+ param_set_name=@config.get_plugin_default_config_name(:node)
80
+ raise CliBadArgument,"No default node configured, Please specify --#{:transfer_info.to_s.gsub('_','-')}" if param_set_name.nil?
81
+ node_config=@config.preset_by_name(param_set_name)
82
+ end
83
+ Log.log.debug("node=#{node_config}")
84
+ raise CliBadArgument,"the node configuration shall be Hash, not #{node_config.class} (#{node_config}), use either @json:<json> or @preset:<parameter set name>" if !node_config.is_a?(Hash)
85
+ # now check there are required parameters
86
+ sym_config=[:url,:username,:password].inject({}) do |h,param|
87
+ raise CliBadArgument,"missing parameter [#{param}] in node specification: #{node_config}" if !node_config.has_key?(param.to_s)
88
+ h[param]=node_config[param.to_s]
89
+ h
96
90
  end
91
+ node_api=Rest.new({
92
+ :base_url => sym_config[:url],
93
+ :auth => {
94
+ :type =>:basic,
95
+ :username => sym_config[:username],
96
+ :password => sym_config[:password]
97
+ }})
98
+ new_agent=Fasp::Node.new(node_api)
97
99
  when :aoc
98
- @agent=Fasp::Aoc.instance
99
100
  aoc_config=@opt_mgr.get_option(:transfer_info,:optional)
100
101
  if aoc_config.nil?
101
102
  param_set_name=@config.get_plugin_default_config_name(:aspera)
@@ -103,19 +104,17 @@ module Asperalm
103
104
  aoc_config=@config.preset_by_name(param_set_name)
104
105
  end
105
106
  Log.log.debug("aoc=#{aoc_config}")
106
- 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)
107
- # now check there are required parameters
108
- sym_config=[:url,:subject].inject({}) do |h,param|
109
- raise CliBadArgument,"missing parameter [#{param}] in node specification: #{aoc_config}" if !aoc_config.has_key?(param.to_s)
110
- h[param]=aoc_config[param.to_s]
111
- h
112
- end
113
- #@agent.node_api=OnCloud.new(aoc_rest_params)
114
- raise "UNDER WORK"
107
+ raise CliBadArgument,"the aoc configuration shall be Hash, not #{aoc_config.class} (#{aoc_config}), refer to manual" if !aoc_config.is_a?(Hash)
108
+ # convert keys from string (config) to symbol (agent)
109
+ aoc_config=aoc_config.symbolize_keys
110
+ # convert auth value from string (config) to symbol (agent)
111
+ aoc_config[:auth]=aoc_config[:auth].to_sym if aoc_config[:auth].is_a?(String)
112
+ # private key could be @file:... in config
113
+ aoc_config[:private_key]=ExtendedValue.instance.evaluate(aoc_config[:private_key])
114
+ new_agent=Fasp::Aoc.new(aoc_config)
115
115
  else raise "INTERNAL ERROR"
116
116
  end
117
- @agent.add_listener(Listener::Logger.new)
118
- @agent.add_listener(Listener::ProgressMulti.new)
117
+ set_agent_instance(new_agent)
119
118
  end
120
119
  return nil
121
120
  end
@@ -203,7 +202,7 @@ module Asperalm
203
202
  @transfer_spec_cmdline['destination_root']=destination_folder(transfer_spec['direction'])
204
203
  when :node_gen3
205
204
  # in that case, destination is set in return by application (API/upload_setup)
206
- # but to_folder was used in intial api call
205
+ # but to_folder was used in initial API call
207
206
  @transfer_spec_cmdline.delete('destination_root')
208
207
  when :node_gen4
209
208
  @transfer_spec_cmdline['destination_root']='/'
@@ -1,14 +1,23 @@
1
- require 'asperalm/fasp/manager'
1
+ require 'asperalm/fasp/node'
2
2
  require 'asperalm/log'
3
- require 'singleton'
3
+ require 'asperalm/on_cloud.rb'
4
4
 
5
5
  module Asperalm
6
6
  module Fasp
7
- class Aoc < Manager
8
- include Singleton
9
- private
10
- def initialize
11
- super
7
+ class Aoc < Node
8
+ def initialize(on_cloud_options)
9
+ @app=on_cloud_options[:app] || OnCloud::FILES_APP
10
+ @api_oncloud=OnCloud.new(on_cloud_options)
11
+ Log.log.warn("Under Development")
12
+ server_node_file = @api_oncloud.resolve_node_file(server_home_node_file,server_folder)
13
+ # force node as transfer agent
14
+ node_api=Fasp::Node.new(@api_oncloud.get_node_api(client_node_file[:node_info],OnCloud::SCOPE_NODE_USER))
15
+ super(node_api)
16
+ # additional node to node TS info
17
+ @add_ts={
18
+ 'remote_access_key' => server_node_file[:node_info]['access_key'],
19
+ 'destination_root_id' => server_node_file[:file_id]
20
+ }
12
21
  end
13
22
  end
14
23
  end