dtk-client 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2NjNGJhMTdjNzA2ZTI2ZGIzNGU5NGQwOTE2NzY4YTgzNmJlY2Y3MA==
4
+ NjVkYjRmNjg4ZWIwNGZkNWQ1YzM1MjU0MTRmMmFjMDdiMjczNTQ4Ng==
5
5
  data.tar.gz: !binary |-
6
- Y2JiNzVhYWE5YzFlY2RjNzVkOWE3ZmI0MjM3YWFhZGU3OTgxOGY1OQ==
6
+ ZWE0NjRlNmNlZDNlMjMyZTU3YjUxMzkzNTM4NTVhYjUzYWNhMTQwNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmQxMGI5OWEzNDAyY2U3ZGY2MDBkODFmODZiZTAzNDljZmIwN2VjMGQ5MWMw
10
- OTBjZGJmZThhMWMxZjI5MzNlZWM1MDMwNjQzNzNmMzI2YjY3NWZjNzNjMmEx
11
- OGI1MWY0NDI5NWNhZjY4MTZjMWQzODY0NmVkNDE5ZjQ2NDM3ZWQ=
9
+ YjBmOGZiNzVhZGVhM2I2YTVhMjcxNGRjNmI0ZGJkNWU2ZDNlMGRmOTljZTBi
10
+ NmUyMDM0OTVlMzc3NTJjYzQ2ODI0YmI0ZWVjNzg0ZGRjN2Y0OGY4YmRlNDIw
11
+ MTFlZDVmODk4YTk1YWUwNWZmMmQzNDNlMmJkYjQ3MDVmNWIwYjM=
12
12
  data.tar.gz: !binary |-
13
- MGIxMTA5YWRmZGY2YjVmNmVmOTRmNWNjODc0NjAzZmNlMGQwOTQ2ZDZiMDQ1
14
- ZjRmZjY2NWMwOWYyODZlYWZlZmFlZTBhNzFmMGEwNWEzZmJkNWFjY2NlZTRl
15
- MDlkYzk1ZjhjMDg5NThlOWIyNDhiMDVlMDZhZGJmODVkMDE1YTI=
13
+ NGI3Yzk1OTQwOTBhYzc1ZDU4NTQ2NzIzNDRiOTlmNzY2NzkxOTFmMzY4Y2Q3
14
+ NWRhNDM2NDA4ZjViYzVkMzhmZTAwZjg0ODJkNjAyMzY2NzNlN2NiMDgzY2Nj
15
+ NzQzNmEzODUwMDJhOTk1NDA4NGNmNjAwNmEzNTc2ZDM2NmVhMjY=
@@ -38,7 +38,7 @@ module DTK::Client
38
38
  end
39
39
 
40
40
  if opts[:force] || Console.confirmation_prompt("Do you want to update in addition to this module its dependent modules from the catalog?")
41
- required_modules.each do |r_module|
41
+ required_modules.uniq.each do |r_module|
42
42
  module_name = full_module_name(r_module)
43
43
  module_type = r_module['type']
44
44
  version = r_module['version']
@@ -86,7 +86,7 @@ module DTK::Client
86
86
  update_none = RemoteDependencyUtil.check_for_frozen_modules(required_modules)
87
87
 
88
88
  # Print out or update installed modules from catalog
89
- required_modules.each do |r_module|
89
+ required_modules.uniq.each do |r_module|
90
90
  module_name = full_module_name(r_module)
91
91
  module_type = r_module['type']
92
92
  version = r_module['version']
@@ -128,6 +128,16 @@ module DTK::Client
128
128
  response.render_table()
129
129
  end
130
130
 
131
+ def list_actions_aux(context_params)
132
+ assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
133
+
134
+ post_body = { :assembly_id => assembly_or_workspace_id }
135
+ post_body.merge!(:type => options.type) if options.type?
136
+
137
+ response = post rest_url("assembly/list_actions"), post_body
138
+ response.render_table('service_actions')
139
+ end
140
+
131
141
  # desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]"
132
142
  def execute_ad_hoc_action_aux(context_params)
133
143
  assembly_or_workspace_id,component_id,method_name,action_params_string = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:option_1!,:option_2,:option_3],method_argument_names)
@@ -148,6 +158,68 @@ module DTK::Client
148
158
  nil
149
159
  end
150
160
 
161
+ def exec_aux(context_params, opts = {})
162
+ assembly_or_workspace_id, task_action, task_params_string = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID, :option_1!, :option_2], method_argument_names)
163
+
164
+ # support 'converge' task action as synonym for 'create'
165
+ task_action = 'create' if task_action && task_action.eql?('converge')
166
+
167
+ # parse params and return format { 'p_name1' => 'p_value1' , 'p_name2' => 'p_value2' }
168
+ task_params = parse_params?(task_params_string)||{}
169
+
170
+ # match if sent node/component
171
+ if task_action_match = task_action.match(/(^[\w\-\:]*)\/(.*)/)
172
+ node, task_action = $1, $2
173
+ task_params.merge!("node" => node)
174
+ end
175
+
176
+ post_body = PostBody.new(
177
+ :assembly_id => assembly_or_workspace_id,
178
+ :commit_msg? => options.commit_msg,
179
+ :task_action? => task_action,
180
+ :task_params? => task_params
181
+ )
182
+ response = post rest_url("assembly/exec"), post_body
183
+ return response unless response.ok?
184
+
185
+ response_data = response.data
186
+
187
+ if violations = response_data['violations']
188
+ OsUtil.print("The following violations were found; they must be corrected before workspace can be converged", :red)
189
+ resp = DTK::Client::Response.new(:assembly, { "status" => 'ok', "data" => violations })
190
+ return opts[:internal_trigger] ? { :violations => resp } : resp.render_table(:violation)
191
+ end
192
+
193
+ if confirmation_message = response_data["confirmation_message"]
194
+ return unless Console.confirmation_prompt("Workspace service is stopped, do you want to start it"+'?')
195
+
196
+ response = post rest_url("assembly/exec"), post_body.merge!(:start_assembly => true, :skip_violations => true)
197
+ return response unless response.ok?
198
+
199
+ response_data = response.data
200
+ end
201
+
202
+ if message = response_data["message"]
203
+ OsUtil.print(message, :yellow)
204
+ return
205
+ end
206
+
207
+ return Response::Ok.new()
208
+ end
209
+
210
+ def exec_sync_aux(context_params)
211
+ assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID], method_argument_names)
212
+
213
+ response = exec_aux(context_params, {:internal_trigger => true})
214
+ return response if (response.is_a?(Response) && !response.ok?) || response.nil?
215
+
216
+ if violations_response = response[:violations]
217
+ return violations_response.render_table(:violation)
218
+ end
219
+
220
+ task_status_stream(assembly_or_workspace_id)
221
+ end
222
+
151
223
  def converge_aux(context_params,opts={})
152
224
  assembly_or_workspace_id,task_action,task_params_string = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:option_1,:option_2],method_argument_names)
153
225
 
@@ -399,7 +471,7 @@ module DTK::Client
399
471
  Response::Ok.new()
400
472
  end
401
473
 
402
- def workflow_info_aux(context_params)
474
+ def action_info_aux(context_params)
403
475
  assembly_or_workspace_id,workflow_name = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:option_1],method_argument_names)
404
476
  post_body = {
405
477
  :assembly_id => assembly_or_workspace_id,
@@ -900,7 +972,8 @@ module DTK::Client
900
972
 
901
973
  if node_id.nil? && !(component_id.to_s =~ /^[0-9]+$/)
902
974
  if component_id.to_s.include?('/')
903
- node_id, component_id = component_id.split('/')
975
+ cmp_match = component_id.match(/([\w-]*)\/(.*)/)
976
+ node_id, component_id = cmp_match[1], cmp_match[2]
904
977
  node_name = node_id
905
978
  else
906
979
  # TODO: update server so dont have to pass in 'assembly_wide'
@@ -1346,6 +1419,10 @@ module DTK::Client
1346
1419
  detail_to_include = [:component_dependencies]
1347
1420
  end
1348
1421
  when "attributes"
1422
+ node_id = options.node unless node_id
1423
+ component_id = options.component unless component_id
1424
+ attribute_id = options.attribute unless attribute_id
1425
+
1349
1426
  data_type = (options.links? ? :workspace_attribute_w_link : :workspace_attribute)
1350
1427
  edit_attr_format = context_params.get_forwarded_options()[:format] if context_params.get_forwarded_options()
1351
1428
  if tags = options.tags
@@ -1371,10 +1448,11 @@ module DTK::Client
1371
1448
  end
1372
1449
 
1373
1450
  post_body = {
1374
- :assembly_id => assembly_or_workspace_id,
1375
- :node_id => node_id,
1451
+ :assembly_id => assembly_or_workspace_id,
1452
+ :node_id => node_id,
1376
1453
  :component_id => component_id,
1377
- :subtype => 'instance',
1454
+ :attribute_id => attribute_id,
1455
+ :subtype => 'instance',
1378
1456
  }.merge(post_options)
1379
1457
 
1380
1458
  post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
@@ -1441,5 +1519,38 @@ module DTK::Client
1441
1519
  raise DtkError, 'Please use -c option only with service instance component attributes (cmp_name/attribute_name)'
1442
1520
  end
1443
1521
  end
1522
+
1523
+ def stage_aux(context_params)
1524
+ assembly_template_name, instance_name = context_params.retrieve_arguments([:option_1!, :option_2], method_argument_names)
1525
+
1526
+ service_module_name, assembly, assembly_name = assembly_template_name.split('/')
1527
+ raise DtkValidationError, "Service module name is ill-formed! Should contain <namespace>:<name>" unless service_module_name =~ /(^[^:]+):([^:]+$)/
1528
+
1529
+ unless assembly_name
1530
+ assembly_name = assembly
1531
+ assembly = nil
1532
+ end
1533
+ raise DtkValidationError, "ASSEMBLY-NAME parameter is ill-formed! Should contain <namespace>:<service_name>/assembly/<assembly_name> or <namespace>:<service_name>/<assembly_name>" if assembly && !assembly.eql?('assembly')
1534
+
1535
+ new_context_params = DTK::Shell::ContextParams.new
1536
+ new_context_params.add_context_to_params(:service_module, :service_module)
1537
+ new_context_params.add_context_name_to_params(:service_module, :service_module, service_module_name)
1538
+ new_context_params.method_arguments = [assembly_name]
1539
+ new_context_params.method_arguments << instance_name if instance_name
1540
+
1541
+ fwd_opts = {}
1542
+ in_target = options["in-target"]
1543
+ node_size = options.node_size
1544
+ os_type = options.os_type
1545
+ version = options.version
1546
+
1547
+ fwd_opts.merge!(:in_target => in_target) if in_target
1548
+ fwd_opts.merge!(:node_size => node_size) if node_size
1549
+ fwd_opts.merge!(:os_type => os_type) if os_type
1550
+ fwd_opts.merge!(:version => version) if version
1551
+ new_context_params.forward_options(fwd_opts)
1552
+
1553
+ response = ContextRouter.routeTask(:service_module, "stage", new_context_params, @conn)
1554
+ end
1444
1555
  end
1445
1556
  end
@@ -22,8 +22,9 @@ module DTK::Client
22
22
  # clone base version first if not cloned already
23
23
  clone_base_aux(module_type, module_id, "#{module_namespace}:#{module_name}") if opts[:use_latest] && version
24
24
 
25
- module_location = OsUtil.module_location(module_type, "#{module_namespace}:#{module_name}", version)
26
- raise DTK::Client::DtkValidationError, "#{module_type.to_s.gsub('_',' ').capitalize} '#{module_name}#{version && "-#{version}"}' already cloned!" if File.directory?(module_location) && !opts[:skip_if_exist_check]
25
+ # TODO: DTK-2358: comenyed out because causing error in this jira; see if need to put in in revisedform to avoid this error; below is checking wromg thing ( module_location is set to wromg thing to check)
26
+ # module_location = OsUtil.module_location(module_type, "#{module_namespace}:#{module_name}", version)
27
+ # raise DTK::Client::DtkValidationError, "#{module_type.to_s.gsub('_',' ').capitalize} '#{module_name}#{version && "-#{version}"}' already cloned!" if File.directory?(module_location) && !opts[:skip_if_exist_check]
27
28
 
28
29
  full_module_name = ModuleUtil.resolve_name(module_name, module_namespace)
29
30
 
@@ -87,19 +87,21 @@ module DTK::Client
87
87
  end
88
88
  end
89
89
 
90
- def delete_module_aux(context_params, method_opts={})
90
+ def delete_module_aux(context_params, method_opts = {})
91
91
  module_location, modules_path = nil, nil
92
92
  module_id = context_params.retrieve_arguments([:option_1!], method_argument_names)
93
93
 
94
94
  delete_module_sub_aux(context_params, module_id, method_opts)
95
95
  end
96
96
 
97
- def delete_module_sub_aux(context_params, module_id, method_opts={})
98
- # ModuleUtil.check_format!(module_id)
99
- version = options.version
97
+ def delete_module_sub_aux(context_params, module_id, method_opts = {})
98
+ version = options.version
100
99
  module_name = get_name_from_id_helper(module_id)
101
100
  module_type = get_module_type(context_params)
102
101
 
102
+ # delete all versions
103
+ version = 'delete_all' if method_opts[:delete_all]
104
+
103
105
  unless (options.force? || method_opts[:force_delete])
104
106
  msg = "Are you sure you want to delete module '#{module_name}'"
105
107
  msg += " version '#{version}'" if version
@@ -111,26 +113,34 @@ module DTK::Client
111
113
  opts = { :module_name => module_name }
112
114
 
113
115
  unless version
114
- post_body.merge!(:include_base => true)
116
+ # post_body.merge!(:include_base => true)
115
117
 
116
118
  versions_response = post rest_url("#{module_type}/list_versions"), post_body
117
119
  return versions_response unless versions_response.ok?
118
120
 
119
121
  versions = versions_response.data.first['versions']
120
- if versions.size > 2
121
- versions << "all"
122
+ if versions.size > 0
123
+ versions << "all" unless versions.size == 1
122
124
  ret_version = Console.confirmation_prompt_multiple_choice("\nSelect version to delete:", versions)
123
125
  return unless ret_version
124
126
  raise DtkError, "You are not allowed to delete 'base' version while other versions exist!" if ret_version.eql?('base')
125
127
  version = ret_version
128
+ else
129
+ raise DtkError, "There are no versions created for #{module_type} '#{module_name}'!"
126
130
  end
127
131
  end
128
132
 
129
133
  if version
130
134
  if version.eql?('all')
135
+ # delete only versions (not base)
136
+ post_body.merge!(:all_except_base => true)
137
+ opts.merge!(:all_except_base => true)
138
+ elsif version.eql?('delete_all')
139
+ # this means delete entire module (including all versions + base)
131
140
  post_body.merge!(:delete_all_versions => true)
132
141
  opts.merge!(:delete_all_versions => true)
133
142
  else
143
+ # delete specific version only
134
144
  post_body.merge!(:version => version)
135
145
  opts.merge!(:version => version)
136
146
  end
@@ -156,6 +166,8 @@ module DTK::Client
156
166
 
157
167
  unless method_opts[:no_error_msg]
158
168
  if version && version.eql?('all')
169
+ OsUtil.print("All versions (except base) of '#{module_name}' module have been deleted.", :yellow)
170
+ elsif version && version.eql?('delete_all')
159
171
  OsUtil.print("All versions of '#{module_name}' module have been deleted.", :yellow)
160
172
  else
161
173
  msg = "Module '#{module_name}' "
@@ -242,6 +254,7 @@ module DTK::Client
242
254
  remote_module_name, version = context_params.retrieve_arguments([:option_1!, :option_2], method_argument_names)
243
255
  forwarded_version = context_params.get_forwarded_options()['version']
244
256
  add_version = false
257
+ master_only = (options.version? && options.version.eql?('master'))
245
258
 
246
259
  version ||= forwarded_version || options.version
247
260
  version = nil if version.eql?('master')
@@ -276,7 +289,8 @@ module DTK::Client
276
289
  # we need to install base module version if not installed
277
290
  unless skip_base
278
291
  master_response = install_base_version_aux?(context_params, post_body, module_type, version)
279
- return master_response unless master_response.ok?
292
+ # return master_response unless master_response.ok?
293
+ return master_response if !master_response.ok? || master_only
280
294
 
281
295
  latest_version = master_response.data(:latest_version)
282
296
 
@@ -317,7 +331,7 @@ module DTK::Client
317
331
  opts = { :do_not_raise => true }
318
332
  module_opts = ignore_component_error ? opts.merge(:ignore_component_error => true) : opts.merge(:additional_message => true)
319
333
  module_opts.merge!(:update_none => true) if options.update_none?
320
- module_opts.merge!(:hide_output => true) if skip_base
334
+ module_opts.merge!(:hide_output => true) if skip_base && !master_only
321
335
 
322
336
  continue = trigger_module_auto_import(missing_components, required_components, module_opts)
323
337
  return unless continue
@@ -362,14 +376,16 @@ module DTK::Client
362
376
  raise DtkError, "Module '#{remote_module_name}' version '#{version}' does not exist on repo manager!" unless versions.include?(version)
363
377
  end
364
378
 
379
+ base_response = nil
365
380
  if !head_installed && !latest_version.eql?('master')
366
381
  new_context_params = DTK::Shell::ContextParams.new
367
382
  new_context_params.add_context_to_params(module_type, module_type)
368
383
  new_context_params.method_arguments = [remote_module_name]
369
384
  new_context_params.forward_options('skip_base' => true, 'version' => 'master')
370
- install_module_aux(new_context_params)
385
+ base_response = install_module_aux(new_context_params)
371
386
  end
372
387
 
388
+ return base_response if base_response && (options.version? && options.version.eql?('master'))
373
389
  master_response
374
390
  end
375
391
 
@@ -436,10 +452,15 @@ module DTK::Client
436
452
 
437
453
  def publish_module_aux(context_params)
438
454
  module_type = get_module_type(context_params)
439
- module_id, module_name, input_remote_name = context_params.retrieve_arguments([REQ_MODULE_ID, REQ_MODULE_NAME, :option_1!], method_argument_names)
455
+ module_id, module_name, input_remote_name = context_params.retrieve_arguments([REQ_MODULE_ID, REQ_MODULE_NAME, :option_1], method_argument_names)
440
456
 
441
457
  raise DtkValidationError, "You have to provide version you want to publish!" unless options.version
442
458
 
459
+ unless input_remote_name
460
+ input_remote_name = module_name.gsub(":","/")
461
+ context_params.method_arguments << input_remote_name
462
+ end
463
+
443
464
  skip_base = context_params.get_forwarded_options()['skip_base']
444
465
  forwarded_version = context_params.get_forwarded_options()['version']
445
466
 
@@ -37,9 +37,9 @@ module DTK::Client
37
37
  raise DtkError,"No File found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run ssh-keygen -t rsa)"
38
38
  end
39
39
  opts_perform_locally = remote_params.merge(
40
- :full_module_name => full_module_name,
41
- :force => opts[:force],
42
- :do_not_raise => opts[:do_not_raise],
40
+ :full_module_name => full_module_name,
41
+ :force => opts[:force],
42
+ :do_not_raise => opts[:do_not_raise],
43
43
  :ignore_dependency_merge_conflict => opts[:ignore_dependency_merge_conflict]
44
44
  )
45
45
  PullFromRemote.perform_locally(self,module_type,module_id,module_name,opts_perform_locally)
@@ -102,9 +102,9 @@ module DTK::Client
102
102
  if custom_message = response.data[:custom_message]
103
103
  puts custom_message
104
104
  elsif (response.data[:diffs].nil? || response.data[:diffs].empty?)
105
- puts "No changes to pull from remote." unless response['errors']
105
+ puts "No changes to pull from remote.".colorize(:yellow) unless response['errors']
106
106
  else
107
- puts "Changes pulled from remote"
107
+ puts "Changes pulled from remote".colorize(:green)
108
108
  end
109
109
 
110
110
  response
@@ -4,10 +4,12 @@ module DTK::Client
4
4
  module_name = opts[:module_name]
5
5
  version = opts[:version]
6
6
  opts_module_loc = (opts[:assembly_module] ? {:assembly_module => opts[:assembly_module]} : Hash.new)
7
- module_location = OsUtil.module_location(module_type,module_name,version,opts_module_loc)
7
+ module_location = OsUtil.module_location(module_type, module_name, version, opts_module_loc)
8
8
  dirs_to_delete = [module_location]
9
9
  if opts[:delete_all_versions]
10
- dirs_to_delete += OsUtil.module_version_locations(module_type,module_name,version,opts)
10
+ dirs_to_delete += OsUtil.module_version_locations(module_type, module_name, version, opts)
11
+ elsif opts[:all_except_base]
12
+ dirs_to_delete = OsUtil.module_version_locations(module_type, module_name, version, opts)
11
13
  end
12
14
  response = Response::Ok.new()
13
15
  pwd = Dir.getwd()
@@ -5,14 +5,16 @@ dtk_require("../../../domain/git_adapter")
5
5
  module DTK::Client
6
6
  module PushToRemoteMixin
7
7
 
8
+ NO_PUSH_CHANGES_MSG = "There are no changes to push"
9
+
8
10
  def push_to_git_remote_aux(full_module_name, module_type, version, opts, force = false)
9
11
  opts.merge!(:force => force)
10
12
 
11
13
  response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
12
14
 
13
15
  return response unless response.ok?
14
- if response.data(:diffs).empty?
15
- raise DtkError, "No changes to push"
16
+ if response.data(:diffs) && !response.data(:diffs)[:are_there_changes]
17
+ raise DtkError, NO_PUSH_CHANGES_MSG
16
18
  end
17
19
 
18
20
  Response::Ok.new()
@@ -40,8 +42,8 @@ module DTK::Client
40
42
  response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
41
43
  return response unless response.ok?
42
44
 
43
- if response.data(:diffs).empty?
44
- raise DtkError, "No changes to push"
45
+ if response.data(:diffs) && !response.data(:diffs)[:are_there_changes]
46
+ raise DtkError, NO_PUSH_CHANGES_MSG
45
47
  end
46
48
 
47
49
  Response::Ok.new()
@@ -64,8 +66,8 @@ module DTK::Client
64
66
  }
65
67
  response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
66
68
  return response unless response.ok?
67
- if response.data(:diffs).empty?
68
- raise DtkError, "No changes to push"
69
+ if response.data(:diffs) && !response.data(:diffs)[:are_there_changes]
70
+ raise DtkError, NO_PUSH_CHANGES_MSG
69
71
  end
70
72
 
71
73
  Response::Ok.new()
@@ -26,6 +26,20 @@ module DTK::Client
26
26
  end
27
27
  end
28
28
 
29
+ def self.extended_context()
30
+ {
31
+ :context => {
32
+ :delete_ssh_key => {
33
+ :field => "username",
34
+ :url => "account/list_ssh_keys",
35
+ :opts => { :username => "#{::DTK::Client::Configurator.client_username}" }
36
+ }
37
+ },
38
+ :command => {
39
+ }
40
+ }
41
+ end
42
+
29
43
  def self.internal_add_user_access(url, post_body, component_name)
30
44
  response = post(rest_url(url),post_body)
31
45
  key_exists_already = (response.error_message||'').include?(KEY_EXISTS_ALREADY_CONTENT)
@@ -107,9 +121,7 @@ module DTK::Client
107
121
 
108
122
  desc "list-ssh-keys", "Show list of key pairs that your account profile has saved"
109
123
  def list_ssh_keys(context_params)
110
- username = parse_key_value_file(::DTK::Client::Configurator::CRED_FILE)[:username]
111
- post_body = {:username => username}
112
-
124
+ post_body = {:username => ::DTK::Client::Configurator.client_username }
113
125
  response = post rest_url("account/list_ssh_keys"), post_body
114
126
  response.render_table(:account_ssh_keys)
115
127
  end
@@ -51,7 +51,7 @@ module DTK::Client
51
51
  end
52
52
  end
53
53
 
54
- raise DTK::Client::DtkError, "Illegal name (#{assembly_template_name}) for assembly." if assembly_template_name.nil?
54
+ raise DTK::Client::DtkError, "Illegal name or id (#{assembly_template_id}) for assembly." if assembly_template_name.nil?
55
55
  return assembly_template_name
56
56
  end
57
57
 
@@ -60,17 +60,28 @@ module DTK::Client
60
60
  return :component_module, "component_module/list", nil
61
61
  end
62
62
 
63
- desc "delete COMPONENT-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
63
+ desc "delete-version COMPONENT-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete component module version and all items contained in it. Optional parameter [-p] is to delete local directory."
64
64
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
65
65
  method_option :purge, :aliases => '-p', :type => :boolean, :default => false
66
66
  version_method_option
67
- def delete(context_params,method_opts={})
67
+ def delete_version(context_params, method_opts = {})
68
68
  response = delete_module_aux(context_params, method_opts)
69
69
  @@invalidate_map << :component_module if response && response.ok?
70
70
 
71
71
  response
72
72
  end
73
73
 
74
+ desc "delete COMPONENT-MODULE-NAME [-y] [-p]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
75
+ method_option :force, :aliases => '-y', :type => :boolean, :default => false
76
+ method_option :purge, :aliases => '-p', :type => :boolean, :default => false
77
+ # version_method_option
78
+ def delete(context_params, method_opts = {})
79
+ response = delete_module_aux(context_params, method_opts.merge!(:delete_all => true))
80
+ @@invalidate_map << :component_module if response && response.ok?
81
+
82
+ response
83
+ end
84
+
74
85
  desc "COMPONENT-MODULE-NAME/ID set-attribute ATTRIBUTE-ID VALUE", "Set value of component module attributes"
75
86
  def set_attribute(context_params)
76
87
  set_attribute_module_aux(context_params)
@@ -289,7 +300,7 @@ module DTK::Client
289
300
  # return response
290
301
  # end
291
302
 
292
- desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME] [-v VERSION] [--force]", "Publish component module to remote repository."
303
+ desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME] -v VERSION [--force]", "Publish component module to remote repository."
293
304
  version_method_option
294
305
  method_option :force, :type => :boolean, :default => false, :aliases => '-f'
295
306
  def publish(context_params)
@@ -38,9 +38,13 @@ module DTK::Client
38
38
  def self.extended_context()
39
39
  {
40
40
  :context => {
41
- :add_component => "component_template"
42
41
  },
43
42
  :command => {
43
+ :add_component => {
44
+ :endpoint => "component_template",
45
+ :url => "component/list",
46
+ :opts => {:subtype=>"template", :ignore => "test_module", :hide_assembly_cmps => "true"}
47
+ },
44
48
  :delete_component => {
45
49
  :endpoint => "assembly",
46
50
  :url => "assembly/info_about",
@@ -101,19 +101,23 @@ module DTK::Client
101
101
  :url => "assembly/info_about",
102
102
  :opts => {:subtype=>"instance", :about=>"modules"}
103
103
  },
104
- :workflow_info => {
104
+ :action_info => {
105
105
  :endpoint => "assembly",
106
106
  :url => "assembly/task_action_list"
107
107
  },
108
108
  :exec => {
109
109
  :endpoint => "assembly",
110
- :url => "assembly/task_action_list"
110
+ :url => "assembly/list_actions"
111
111
  },
112
- # TODO: DEPRECATE execute_workflow
113
- :execute_workflow => {
112
+ :exec_sync => {
114
113
  :endpoint => "assembly",
115
- :url => "assembly/task_action_list"
114
+ :url => "assembly/list_actions"
116
115
  }
116
+ # TODO: DEPRECATE execute_workflow
117
+ # :execute_workflow => {
118
+ # :endpoint => "assembly",
119
+ # :url => "assembly/task_action_list"
120
+ # }
117
121
  }
118
122
  }
119
123
  end
@@ -264,24 +268,35 @@ module DTK::Client
264
268
  Response::Ok.new()
265
269
  end
266
270
 
267
- desc "SERVICE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action"
268
- method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
271
+ desc "SERVICE-NAME/ID exec [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action asynchronously"
269
272
  def exec(context_params)
270
- opts = {}
271
- opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
272
- converge_aux(context_params, opts)
273
+ exec_aux(context_params)
273
274
  end
274
- # TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
275
- desc "SERVICE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
276
- method_option "commit_msg",:aliases => "-m" ,
277
- :type => :string,
278
- :banner => "COMMIT-MSG",
279
- :desc => "Commit message"
280
- def execute_workflow(context_params)
281
- OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
282
- converge(context_params)
275
+
276
+ desc "SERVICE-NAME/ID exec-sync [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action synchronously"
277
+ def exec_sync(context_params)
278
+ exec_sync_aux(context_params)
283
279
  end
284
280
 
281
+ # desc "SERVICE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action", :hide => true
282
+ # method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
283
+ # def exec(context_params)
284
+ # opts = {}
285
+ # opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
286
+ # converge_aux(context_params, opts)
287
+ # end
288
+
289
+ # TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
290
+ # desc "SERVICE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
291
+ # method_option "commit_msg",:aliases => "-m" ,
292
+ # :type => :string,
293
+ # :banner => "COMMIT-MSG",
294
+ # :desc => "Commit message"
295
+ # def execute_workflow(context_params)
296
+ # OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
297
+ # converge(context_params)
298
+ # end
299
+
285
300
  desc "SERVICE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge service instance."
286
301
  method_option "commit_msg",:aliases => "-m" ,
287
302
  :type => :string,
@@ -294,15 +309,15 @@ module DTK::Client
294
309
  converge_aux(context_params, opts)
295
310
  end
296
311
 
297
- desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]", "Converge the component or execute tha action on the component."
298
- def execute_action(context_params)
299
- execute_ad_hoc_action_aux(context_params)
300
- end
312
+ # desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]", "Converge the component or execute tha action on the component.", :hide => true
313
+ # def execute_action(context_params)
314
+ # execute_ad_hoc_action_aux(context_params)
315
+ # end
301
316
 
302
- desc "SERVICE-NAME/ID list-actions [--summary]", "List the actions defined on components in the service instance."
303
- method_option :summary, :aliases => '-s', :type => :boolean, :default => false
317
+ desc "SERVICE-NAME/ID list-actions [--type TYPE]", "List the actions defined on components in the service instance."
318
+ method_option :type, :aliases => '-t'
304
319
  def list_actions(context_params)
305
- list_ad_hoc_actions_aux(context_params)
320
+ list_actions_aux(context_params)
306
321
  end
307
322
 
308
323
  desc "SERVICE-NAME/ID push-assembly-updates [NAMESPACE:SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
@@ -343,18 +358,21 @@ module DTK::Client
343
358
  edit_module_aux(context_params)
344
359
  end
345
360
 
346
- desc "SERVICE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the service instance."
347
- method_option :from, :type => :string
348
- def create_workflow(context_params)
349
- edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
350
- end
361
+ # desc "SERVICE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the service instance."
362
+ # method_option :from, :type => :string
363
+ # def create_workflow(context_params)
364
+ # edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
365
+ # end
351
366
 
352
- desc "SERVICE-NAME/ID edit-workflow [WORKFLOW-NAME]", "Edit a workflow in the service instance."
353
- def edit_workflow(context_params)
367
+ desc "SERVICE-NAME/ID edit-action [SERVICE-LEVEL-ACTION]", "Edit action in the service instance."
368
+ def edit_action(context_params)
354
369
  edit_or_create_workflow_aux(context_params)
355
370
  end
356
371
 
357
- desc "SERVICE-NAME/ID edit-attributes", "Edit service's attributes."
372
+ desc "SERVICE-NAME/ID edit-attributes [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]", "Edit service's attributes."
373
+ method_option :node, :aliases => '-n'
374
+ method_option :component, :aliases => '-c'
375
+ method_option :attribute, :aliases => '-a'
358
376
  def edit_attributes(context_params)
359
377
  edit_attributes_aux(context_params)
360
378
  end
@@ -421,10 +439,13 @@ TODO: will put in dot release and will rename to 'extend'
421
439
  list_components_aux(context_params)
422
440
  end
423
441
 
424
- desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links]","List attributes associated with service."
442
+ desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links] [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]","List attributes associated with service."
425
443
  method_option :format, :aliases => '-f'
426
444
  method_option :tags, :aliases => '-t'
427
445
  method_option :links, :type => :boolean, :default => false, :aliases => '-l'
446
+ method_option :node, :aliases => '-n'
447
+ method_option :component, :aliases => '-c'
448
+ method_option :attribute, :aliases => '-a'
428
449
  def list_attributes(context_params)
429
450
  list_attributes_aux(context_params)
430
451
  end
@@ -449,15 +470,15 @@ TODO: will put in dot release and will rename to 'extend'
449
470
  print_includes_aux(context_params)
450
471
  end
451
472
 
452
- desc "SERVICE-NAME/ID workflow-info [WORKFLOW-NAME]", "Get the contents of a workflow associated with the service."
453
- def workflow_info(context_params)
454
- workflow_info_aux(context_params)
473
+ desc "SERVICE-NAME/ID action-info [SERVICE-LEVEL-ACTION]", "Get the contents of action associated with the service."
474
+ def action_info(context_params)
475
+ action_info_aux(context_params)
455
476
  end
456
477
 
457
- desc "SERVICE-NAME/ID list-workflows", "List the workflows associated with the service."
458
- def list_workflows(context_params)
459
- workflow_list_aux(context_params)
460
- end
478
+ # desc "SERVICE-NAME/ID list-workflows", "List the workflows associated with the service.", :hide => true
479
+ # def list_workflows(context_params)
480
+ # workflow_list_aux(context_params)
481
+ # end
461
482
 
462
483
  desc "list","List services."
463
484
  def list(context_params)
@@ -777,6 +798,17 @@ TODO: will put in dot release and will rename to 'extend'
777
798
  grep_aux(context_params)
778
799
  end
779
800
 
801
+ desc "stage ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE] [-v VERSION]", "Stage assembly in target."
802
+ method_option "in-target", :aliases => "-t", :type => :string, :banner => "TARGET-NAME/ID", :desc => "Target (id) to create assembly in"
803
+ method_option :node_size, :type => :string, :aliases => "--node-size"
804
+ method_option :os_type, :type => :string, :aliases => "--os-type"
805
+ version_method_option
806
+ #hidden options
807
+ method_option "instance-bindings", :type => :string
808
+ method_option :settings, :type => :string, :aliases => '-s'
809
+ def stage(context_params)
810
+ stage_aux(context_params)
811
+ end
780
812
 
781
813
  end
782
814
  end
@@ -25,6 +25,35 @@ module DTK::Client
25
25
  def get_service_module_name(service_module_id)
26
26
  get_name_from_id_helper(service_module_id)
27
27
  end
28
+
29
+ def get_name_and_version_from_assembly_template(assembly_template_name)
30
+ name = assembly_template_name
31
+ version = nil
32
+
33
+ if assembly_template_name.match(/(.*)(\-v\d{1,2}\.\d{1,2}\.\d{1,2}\Z)/)
34
+ name, version = [$1,$2]
35
+ end
36
+
37
+ if version
38
+ version.gsub!('-v','')
39
+ else
40
+ version = 'base'
41
+ end
42
+
43
+ return name, version
44
+ end
45
+ end
46
+
47
+ def self.extended_context()
48
+ {
49
+ :command => {
50
+ :stage => {
51
+ :endpoint => "service_module",
52
+ :url => "service_module/list_assemblies",
53
+ :opts => {}
54
+ }
55
+ }
56
+ }
28
57
  end
29
58
 
30
59
  def self.valid_children()
@@ -269,7 +298,7 @@ module DTK::Client
269
298
  # post rest_url("service_module/export"), post_body
270
299
  # end
271
300
 
272
- desc "SERVICE-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-SERVICE-MODULE-NAME] [-v VERSION] [--force]","Publish service module to remote repository"
301
+ desc "SERVICE-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-SERVICE-MODULE-NAME] -v VERSION [--force]","Publish service module to remote repository"
273
302
  version_method_option
274
303
  method_option :force, :type => :boolean, :default => false, :aliases => '-f'
275
304
  def publish(context_params)
@@ -464,22 +493,24 @@ module DTK::Client
464
493
  # 'assembly-create', 'install' etc.
465
494
  @@invalidate_map << :assembly
466
495
 
496
+ fwd_options = context_params.get_forwarded_options()
497
+ in_target = fwd_options[:in_target]||options["in-target"]
498
+ instance_bindings = options["instance-bindings"]
499
+ settings = parse_service_settings(options["settings"])
500
+ node_size = fwd_options[:node_size]||options.node_size
501
+ os_type = fwd_options[:os_type]||options.os_type
502
+ version = fwd_options[:version]||options.version
503
+ assembly_list = Assembly.assembly_list()
504
+
467
505
  if assembly_template_name.to_s =~ /^[0-9]+$/
468
- assembly_template_name = get_assembly_name(assembly_template_id)
506
+ assembly_template_name = DTK::Client::Assembly.get_assembly_template_name_for_service(assembly_template_name, service_module_name)
507
+ assembly_template_name, version = get_name_and_version_from_assembly_template(assembly_template_name)
469
508
  else
470
509
  namespace, module_name = get_namespace_and_name(service_module_name, ':')
471
510
  assembly_template_name = "#{module_name}/#{assembly_template_name}"
472
511
  end
473
512
  assembly_template_name.gsub!(/(::)|(\/)/,'-') if assembly_template_name
474
513
 
475
- in_target = options["in-target"]
476
- instance_bindings = options["instance-bindings"]
477
- settings = parse_service_settings(options["settings"])
478
- node_size = options.node_size
479
- os_type = options.os_type
480
- version = options.version
481
- assembly_list = Assembly.assembly_list()
482
-
483
514
  if name
484
515
  raise DTK::Client::DtkValidationError, "Unable to stage service with name '#{name}'. Service with specified name exists already!" if assembly_list.include?(name)
485
516
  else
@@ -595,14 +626,22 @@ module DTK::Client
595
626
  # list_diffs_module_aux(context_params)
596
627
  end
597
628
 
598
- # desc "delete SERVICE-MODULE-NAME [-v VERSION] [-y] [-p]", "Delete service module or service module version and all items contained in it. Optional parameter [-p] is to delete local directory."
599
- # version_method_option
600
- desc "delete SERVICE-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete service module and all items contained in it. Optional parameter [-p] is to delete local directory."
629
+ desc "delete-version SERVICE-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete service module version and all items contained in it. Optional parameter [-p] is to delete local directory."
601
630
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
602
631
  method_option :purge, :aliases => '-p', :type => :boolean, :default => false
603
632
  version_method_option
633
+ def delete_version(context_params, method_opts = {})
634
+ response = delete_module_aux(context_params, method_opts)
635
+ @@invalidate_map << :service_module if response && response.ok?
636
+
637
+ response
638
+ end
639
+
640
+ desc "delete SERVICE-MODULE-NAME [-y] [-p]", "Delete service module and all items contained in it. Optional parameter [-p] is to delete local directory."
641
+ method_option :force, :aliases => '-y', :type => :boolean, :default => false
642
+ method_option :purge, :aliases => '-p', :type => :boolean, :default => false
604
643
  def delete(context_params)
605
- response = delete_module_aux(context_params)
644
+ response = delete_module_aux(context_params, :delete_all => true)
606
645
  @@invalidate_map << :service_module if response && response.ok?
607
646
 
608
647
  response
@@ -78,19 +78,23 @@ module DTK::Client
78
78
  :url => "assembly/info_about",
79
79
  :opts => {:subtype=>"instance", :about=>"modules"}
80
80
  },
81
- :workflow_info => {
81
+ :action_info => {
82
82
  :endpoint => "assembly",
83
83
  :url => "assembly/task_action_list"
84
84
  },
85
85
  :exec => {
86
86
  :endpoint => "assembly",
87
- :url => "assembly/task_action_list"
87
+ :url => "assembly/list_actions"
88
88
  },
89
- # TODO: DEPRECATE execute_workflow
90
- :execute_workflow => {
89
+ :exec_sync => {
91
90
  :endpoint => "assembly",
92
- :url => "assembly/task_action_list"
91
+ :url => "assembly/list_actions"
93
92
  }
93
+ # TODO: DEPRECATE execute_workflow
94
+ # :execute_workflow => {
95
+ # :endpoint => "assembly",
96
+ # :url => "assembly/task_action_list"
97
+ # }
94
98
  }
95
99
  }
96
100
  end
@@ -194,25 +198,35 @@ module DTK::Client
194
198
  # clear_tasks_aux(context_params)
195
199
  #end
196
200
 
197
- desc "WORKSPACE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action"
198
- method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
201
+ desc "WORKSPACE-NAME/ID exec [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action asynchronously"
199
202
  def exec(context_params)
200
- opts = {}
201
- opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
202
- converge_aux(context_params, opts)
203
+ exec_aux(context_params)
203
204
  end
204
205
 
205
- # TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
206
- desc "WORKSPACE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
207
- method_option "commit_msg",:aliases => "-m",
208
- :type => :string,
209
- :banner => "COMMIT-MSG",
210
- :desc => "Commit message"
211
- def execute_workflow(context_params)
212
- OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
213
- converge_aux(context_params)
206
+ desc "WORKSPACE-NAME/ID exec-sync [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action synchronously"
207
+ def exec_sync(context_params)
208
+ exec_sync_aux(context_params)
214
209
  end
215
210
 
211
+ # desc "WORKSPACE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action"
212
+ # method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
213
+ # def exec(context_params)
214
+ # opts = {}
215
+ # opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
216
+ # converge_aux(context_params, opts)
217
+ # end
218
+
219
+ # TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
220
+ # desc "WORKSPACE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
221
+ # method_option "commit_msg",:aliases => "-m",
222
+ # :type => :string,
223
+ # :banner => "COMMIT-MSG",
224
+ # :desc => "Commit message"
225
+ # def execute_workflow(context_params)
226
+ # OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
227
+ # converge_aux(context_params)
228
+ # end
229
+
216
230
 
217
231
  desc "WORKSPACE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge workspace instance."
218
232
  method_option "commit_msg",:aliases => "-m" ,
@@ -415,18 +429,21 @@ module DTK::Client
415
429
  edit_module_aux(context_params)
416
430
  end
417
431
 
418
- desc "WORKSPACE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the workspace."
419
- method_option :from, :type => :string
420
- def create_workflow(context_params)
421
- edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
422
- end
432
+ # desc "WORKSPACE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the workspace."
433
+ # method_option :from, :type => :string
434
+ # def create_workflow(context_params)
435
+ # edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
436
+ # end
423
437
 
424
- desc "WORKSPACE-NAME/ID edit-workflow [WORKFLOW-NAME]", "Edit a workflow in the workspace."
425
- def edit_workflow(context_params)
438
+ desc "WORKSPACE-NAME/ID edit-action [WORKSPACE-LEVEL-ACTION]", "Edit a workflow in the workspace."
439
+ def edit_action(context_params)
426
440
  edit_or_create_workflow_aux(context_params)
427
441
  end
428
442
 
429
- desc "WORKSPACE-NAME/ID edit-attributes", "Edit workspace's attributes."
443
+ desc "WORKSPACE-NAME/ID edit-attributes [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]", "Edit workspace's attributes."
444
+ method_option :node, :aliases => '-n'
445
+ method_option :component, :aliases => '-c'
446
+ method_option :attribute, :aliases => '-a'
430
447
  def edit_attributes(context_params)
431
448
  edit_attributes_aux(context_params)
432
449
  end
@@ -496,10 +513,13 @@ module DTK::Client
496
513
  end
497
514
  end
498
515
 
499
- desc "WORKSPACE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links]","List attributes associated with workspace."
516
+ desc "WORKSPACE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links] [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]","List attributes associated with workspace."
500
517
  method_option :format, :aliases => '-f'
501
518
  method_option :tags, :aliases => '-t'
502
519
  method_option :links, :type => :boolean, :default => false, :aliases => '-l'
520
+ method_option :node, :aliases => '-n'
521
+ method_option :component, :aliases => '-c'
522
+ method_option :attribute, :aliases => '-a'
503
523
  def list_attributes(context_params)
504
524
  list_attributes_aux(context_params)
505
525
  end
@@ -530,16 +550,22 @@ module DTK::Client
530
550
  list_tasks_aux(context_params)
531
551
  end
532
552
 
533
- desc "WORKSPACE-NAME/ID workflow-info [WORKFLOW-NAME]", "Get the contents of a workflow associated with the workspace."
534
- def workflow_info(context_params)
535
- workflow_info_aux(context_params)
553
+ desc "WORKSPACE-NAME/ID action-info [WORKSPACE-LEVEL-ACTION]", "Get the contents of action associated with the workspace."
554
+ def action_info(context_params)
555
+ action_info_aux(context_params)
536
556
  end
537
557
 
538
- desc "WORKSPACE-NAME/ID list-workflows", "List the workflows associated with the workspace."
539
- def list_workflows(context_params)
540
- workflow_list_aux(context_params)
558
+ desc "WORKSPACE-NAME/ID list-actions [--type TYPE]", "List the actions defined on components in the workspace."
559
+ method_option :type, :aliases => '-t'
560
+ def list_actions(context_params)
561
+ list_actions_aux(context_params)
541
562
  end
542
563
 
564
+ # desc "WORKSPACE-NAME/ID list-workflows", "List the workflows associated with the workspace.", :hide => true
565
+ # def list_workflows(context_params)
566
+ # workflow_list_aux(context_params)
567
+ # end
568
+
543
569
  desc "WORKSPACE-NAME/ID list-violations", "Finds violations in the workspace that will prevent a converge operation."
544
570
  def list_violations(context_params)
545
571
  list_violations_aux(context_params)
@@ -614,13 +640,23 @@ module DTK::Client
614
640
  task_status_aw_aux(context_params)
615
641
  end
616
642
 
617
-
618
-
619
-
620
643
  desc "WORKSPACE-NAME/ID task-action-detail", "Get the task info of the running or last running workspace task."
621
644
  def task_action_detail(context_params)
622
645
  task_action_detail_aw_aux(context_params)
623
646
  end
647
+
648
+ desc "stage INSTANCE-NAME ASSEMBLY-TEMPLATE [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE] [-v VERSION]", "Stage assembly in target."
649
+ method_option "in-target", :aliases => "-t", :type => :string, :banner => "TARGET-NAME/ID", :desc => "Target (id) to create assembly in"
650
+ method_option :node_size, :type => :string, :aliases => "--node-size"
651
+ method_option :os_type, :type => :string, :aliases => "--os-type"
652
+ version_method_option
653
+ #hidden options
654
+ method_option "instance-bindings", :type => :string
655
+ method_option :settings, :type => :string, :aliases => '-s'
656
+ def stage(context_params)
657
+ stage_aux(context_params)
658
+ end
659
+
624
660
  end
625
661
  end
626
662
 
@@ -69,7 +69,8 @@ module DTK
69
69
 
70
70
  files_modified = difference.stats[:files] ? difference.stats[:files].keys.collect { |file| { :path => file }} : []
71
71
  {
72
- :files_modified => files_modified
72
+ :files_modified => files_modified,
73
+ :are_there_changes => !files_modified.empty?
73
74
  }
74
75
  else
75
76
  raise Error.new("Error finding branches: local branch '#{local_branch}' (found: #{!branch_local_obj.nil?}), remote branch '#{remote_reference}' (found: #{!branch_remote_obj.nil?})")
@@ -92,10 +93,12 @@ module DTK
92
93
  end
93
94
 
94
95
  def local_summary()
96
+
95
97
  {
96
98
  :files_added => (untracked() + added()).collect { |file| { :path => file }},
97
99
  :files_modified => changed().collect { |file| { :path => file }},
98
- :files_deleted => deleted().collect { |file| { :path => file }}
100
+ :files_deleted => deleted().collect { |file| { :path => file }},
101
+ :are_there_changes => something_changed?
99
102
  }
100
103
  end
101
104
 
@@ -355,6 +358,10 @@ module DTK
355
358
  status.is_a?(Hash) ? status.added().keys : status.added().collect { |file| file.first }
356
359
  end
357
360
 
361
+ def something_changed?
362
+ ![changed, untracked, deleted, added].flatten.empty?
363
+ end
364
+
358
365
  def status
359
366
  @git_repo.status
360
367
  end
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.7.8"
2
+ VERSION="0.7.9"
3
3
  end
data/lib/shell/context.rb CHANGED
@@ -184,9 +184,7 @@ module DTK
184
184
  extended_context = command_clazz.respond_to?(:extended_context) ? command_clazz.extended_context() : {}
185
185
 
186
186
  unless extended_context.empty?
187
- extended_context = extended_context[:context]
188
- # extended_context.reject!{|k,v| k.to_s!=line_buffer}
189
- # extended_context.select!{|k,v| k.to_s.eql?(line_buffer_first) || k.to_s.eql?(line_buffer_last)}
187
+ extended_context = extended_context[:context] || {}
190
188
  extended_context.select!{|k,v| line_buffer.include?(k.to_s)} if extended_context.respond_to?(:select!)
191
189
 
192
190
  if (extended_context[line_buffer_last] && !line_buffer_first.eql?(line_buffer_last))
@@ -196,7 +194,18 @@ module DTK
196
194
  else
197
195
  new_context = extended_context[line_buffer_first.to_sym] unless line_buffer_first.nil? || line_buffer_first.empty?
198
196
  end
199
- active_context_copy.push_new_context(new_context, new_context) unless new_context.nil?
197
+
198
+ unless new_context.nil?
199
+ if new_context.is_a?(String)
200
+ active_context_copy.push_new_context(new_context, new_context)
201
+ elsif new_context.is_a?(Hash)
202
+ context_candidates = load_extended_context_commands(new_context, active_context_copy)
203
+ results_filter = (readline_input.match(/\/$/) && invalid_context.empty?) ? "" : readline_input.split("/").last
204
+ results_filter ||= ""
205
+ context_candidates = context_candidates.grep( /^#{Regexp.escape(results_filter)}/ )
206
+ return context_candidates
207
+ end
208
+ end
200
209
  end
201
210
  end
202
211
 
@@ -673,7 +682,7 @@ module DTK
673
682
  end
674
683
 
675
684
  if extended_context_commands
676
- context_candidates = load_extended_context_commands(extended_context_commands, active_context_copy)
685
+ context_candidates = load_extended_context_commands(extended_context_commands, active_context_copy)
677
686
  else
678
687
  # If command does not end with '/' check if there are more than one result candidate for current context
679
688
  if !readline_input.empty? && !readline_input.match(/\/$/) && invalid_context.empty? && !active_context_copy.empty?
@@ -794,15 +803,17 @@ module DTK
794
803
  end
795
804
 
796
805
  def load_extended_context_commands(extended_context_commands, active_context_copy)
797
- candidates = []
798
- entity_name = active_context_copy.last_context
799
- parent_entity = active_context_copy.context_list[1]
806
+ candidates = []
807
+ entity_name = active_context_copy.last_context
808
+ parent_entity = active_context_copy.context_list[1]
809
+ response_ruby_obj = nil
800
810
 
801
- if entity_name.is_identifier?
802
- endpoint = extended_context_commands[:endpoint]
803
- url = extended_context_commands[:url]
804
- opts = extended_context_commands[:opts]||{}
811
+ field = extended_context_commands[:field]||'display_name'
812
+ endpoint = extended_context_commands[:endpoint]
813
+ url = extended_context_commands[:url]
814
+ opts = extended_context_commands[:opts]||{}
805
815
 
816
+ if entity_name.is_identifier?
806
817
  if (parent_entity && parent_entity.is_identifier? && (parent_entity != entity_name))
807
818
  parent_id_label = "#{endpoint}_id".to_sym
808
819
  parent_id = parent_entity.identifier
@@ -814,13 +825,16 @@ module DTK
814
825
  id = entity_name.identifier
815
826
  opts[id_label] = id
816
827
 
817
- # response_ruby_obj = DTK::Client::CommandBaseThor.get_cached_response(endpoint.to_sym, url, opts)
818
- # when extended context autocomplete always send new request
819
- response_ruby_obj = post rest_url(url), opts
820
- return [] if(response_ruby_obj.nil? || !response_ruby_obj.ok?)
828
+ response_ruby_obj = DTK::Client::CommandBaseThor.get_cached_response(endpoint, url, opts)
829
+ # response_ruby_obj = post rest_url(url), opts
830
+ else
831
+ response_ruby_obj = DTK::Client::CommandBaseThor.get_cached_response(endpoint, url, opts)
832
+ # response_ruby_obj = post rest_url(url), opts
833
+ end
821
834
 
835
+ if response_ruby_obj && response_ruby_obj.ok?
822
836
  response_ruby_obj.data.each do |d|
823
- candidates << d["display_name"]
837
+ candidates << d[field]
824
838
  end
825
839
  end
826
840
 
data/lib/util/console.rb CHANGED
@@ -39,13 +39,13 @@ module DTK::Client
39
39
  def confirmation_prompt_simple(message, add_options=true)
40
40
  # used to disable skip with ctrl+c
41
41
  trap("INT", "SIG_IGN")
42
- message += " (y/n)" if add_options
42
+ message += " (Y/n)" if add_options
43
43
 
44
44
  while line = Readline.readline("#{message}: ", true)
45
- if (line.eql?("yes") || line.eql?("y") || line.empty?)
45
+ if (line.downcase.eql?("yes") || line.downcase.eql?("y") || line.empty?)
46
46
  trap("INT",false)
47
47
  return true
48
- elsif (line.eql?("no") || line.eql?("n"))
48
+ elsif (line.downcase.eql?("no") || line.downcase.eql?("n"))
49
49
  trap("INT",false)
50
50
  return false
51
51
  end
data/lib/util/os_util.rb CHANGED
@@ -126,11 +126,11 @@ module DTK
126
126
  end
127
127
  end
128
128
 
129
- def module_version_locations(module_type,module_name,version=nil,opts={})
130
- base_path, namespace, name = module_location_parts(module_type,module_name,version,opts) #.first
129
+ def module_version_locations(module_type, module_name, version = nil, opts={})
130
+ base_path, namespace, name = module_location_parts(module_type, module_name, version, opts) #.first
131
131
  namespace_path = "#{base_path}/#{namespace}"
132
132
  module_versions = Dir.entries(namespace_path).select{|a| a.match(/^#{name}-\d{1,2}.\d{1,2}.\d{1,2}$/)}
133
- module_versions.map{ |version|"#{namespace_path}/#{version}" }
133
+ module_versions.map{ |version| "#{namespace_path}/#{version}" }
134
134
  end
135
135
 
136
136
  def module_clone_location(module_type)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types