dtk-client 0.5.17 → 0.5.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +8 -8
  2. data/lib/command_helpers/git_repo.rb +82 -48
  3. data/lib/command_helpers/service_importer.rb +26 -17
  4. data/lib/command_helpers/test_module_creator.rb +6 -5
  5. data/lib/commands/common/thor/access_control.rb +5 -4
  6. data/lib/commands/common/thor/assembly_template.rb +75 -0
  7. data/lib/commands/common/thor/assembly_workspace.rb +86 -71
  8. data/lib/commands/common/thor/clone.rb +9 -7
  9. data/lib/commands/common/thor/common.rb +17 -10
  10. data/lib/commands/common/thor/edit.rb +65 -6
  11. data/lib/commands/common/thor/list_diffs.rb +4 -3
  12. data/lib/commands/common/thor/module.rb +86 -89
  13. data/lib/commands/common/thor/pull_clone_changes.rb +3 -2
  14. data/lib/commands/common/thor/pull_from_remote.rb +9 -5
  15. data/lib/commands/common/thor/purge_clone.rb +2 -2
  16. data/lib/commands/common/thor/push_clone_changes.rb +39 -16
  17. data/lib/commands/common/thor/push_to_remote.rb +3 -3
  18. data/lib/commands/thor/account.rb +16 -4
  19. data/lib/commands/thor/assembly.rb +66 -89
  20. data/lib/commands/thor/component_module.rb +40 -24
  21. data/lib/commands/thor/node.rb +7 -0
  22. data/lib/commands/thor/provider.rb +45 -23
  23. data/lib/commands/thor/service.rb +4 -7
  24. data/lib/commands/thor/service_module.rb +45 -20
  25. data/lib/commands/thor/test_module.rb +36 -22
  26. data/lib/commands/thor/workspace.rb +6 -6
  27. data/lib/core.rb +18 -17
  28. data/lib/domain/git_adapter.rb +30 -9
  29. data/lib/dtk-client/version.rb +1 -1
  30. data/lib/parser/adapters/thor.rb +47 -25
  31. data/lib/shell/context.rb +10 -2
  32. data/lib/shell.rb +18 -12
  33. data/lib/util/module_util.rb +41 -0
  34. data/lib/util/os_util.rb +25 -7
  35. metadata +4 -2
@@ -25,7 +25,7 @@ module DTK::Client
25
25
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:option_1]
26
26
  end
27
27
 
28
- assembly_or_workspace_id, node_pattern = context_params.retrieve_arguments(mapping,method_argument_names)
28
+ assembly_or_workspace_id, node_pattern = context_params.retrieve_arguments(mapping,method_argument_names)
29
29
  assembly_start(assembly_or_workspace_id, node_pattern)
30
30
  end
31
31
 
@@ -49,13 +49,24 @@ module DTK::Client
49
49
  post rest_url("assembly/cancel_task"), post_body
50
50
  end
51
51
 
52
- #mode will be :create or :update
53
- def promote_assembly_aux(mode,assembly_or_workspace_id,service_module_name=nil,assembly_template_name=nil)
52
+ # mode will be :create or :update
53
+ # service_module_name_x can be name or fullname (NS:MOduleName)
54
+ def promote_assembly_aux(mode,assembly_or_workspace_id,service_module_name_x=nil,assembly_template_name=nil)
54
55
  post_body = {
55
56
  :assembly_id => assembly_or_workspace_id,
56
57
  :mode => mode.to_s
57
58
  }
58
- post_body.merge!(:service_module_name => service_module_name) if service_module_name
59
+ if service_module_name_x
60
+ service_module_name = service_module_name_x
61
+ namespace = nil
62
+ if service_module_name_x =~ /(^[^:]+):([^:]+$)/
63
+ namespace,service_module_name = [$1,$2]
64
+ end
65
+ post_body.merge!(:service_module_name => service_module_name)
66
+ if namespace
67
+ post_body.merge!(:namespace => namespace)
68
+ end
69
+ end
59
70
  post_body.merge!(:assembly_template_name => assembly_template_name) if assembly_template_name
60
71
  response = post rest_url("assembly/promote_to_template"), post_body
61
72
  # when changing context send request for getting latest assembly_templates instead of getting from cache
@@ -63,9 +74,10 @@ module DTK::Client
63
74
 
64
75
  return response unless response.ok?()
65
76
  #synchronize_clone will load new assembly template into service clone on workspace (if it exists)
66
- commit_sha,workspace_branch = response.data(:commit_sha,:workspace_branch)
77
+ commit_sha,workspace_branch,namespace = response.data(:commit_sha,:workspace_branch,:module_namespace)
67
78
  service_module_name ||= response.data(:module_name)
68
- Helper(:git_repo).synchronize_clone(:service_module,service_module_name,commit_sha,:local_branch=>workspace_branch)
79
+ opts = {:local_branch=>workspace_branch, :namespace => namespace}
80
+ Helper(:git_repo).synchronize_clone(:service_module,service_module_name,commit_sha,opts)
69
81
  end
70
82
 
71
83
  def list_violations_aux(context_params)
@@ -73,7 +85,7 @@ module DTK::Client
73
85
  response = post rest_url("assembly/find_violations"),:assembly_id => assembly_or_workspace_id
74
86
  response.render_table(:violation)
75
87
  end
76
-
88
+
77
89
  def converge_aux(context_params)
78
90
  assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
79
91
 
@@ -97,7 +109,7 @@ module DTK::Client
97
109
 
98
110
  if response.data
99
111
  confirmation_message = response.data["confirmation_message"]
100
-
112
+
101
113
  if confirmation_message
102
114
  return unless Console.confirmation_prompt("Workspace service is stopped, do you want to start it"+'?')
103
115
  post_body.merge!(:start_assembly=>true)
@@ -122,7 +134,9 @@ module DTK::Client
122
134
  return response unless response.ok?
123
135
 
124
136
 
125
- assembly_name,component_module_id,version,repo_url,branch,commit_sha = response.data(:assembly_name,:module_id,:version,:repo_url,:workspace_branch,:branch_head_sha)
137
+ assembly_name,component_module_id,version,repo_url,branch,commit_sha,full_module_name = response.data(:assembly_name,:module_id,:version,:repo_url,:workspace_branch,:branch_head_sha,:full_module_name)
138
+ component_module_name = full_module_name if full_module_name
139
+
126
140
  edit_opts = {
127
141
  :automatically_clone => true,
128
142
  :pull_if_needed => true,
@@ -137,6 +151,7 @@ module DTK::Client
137
151
  :commit_sha => commit_sha
138
152
  }
139
153
  }
154
+
140
155
  version = nil #TODO: version associated with assembly is passed in edit_opts, which is a little confusing
141
156
  edit_aux(:component_module,component_module_id,component_module_name,version,edit_opts)
142
157
  end
@@ -150,7 +165,7 @@ module DTK::Client
150
165
  }
151
166
  response = post rest_url("assembly/prepare_for_edit_module"), post_body
152
167
  return response unless response.ok?
153
- assembly_name,service_module_id,service_module_name,version,repo_url,branch,branch_head_sha,edit_file = response.data(:assembly_name,:module_id,:module_name,:version,:repo_url,:workspace_branch,:branch_head_sha,:edit_file)
168
+ assembly_name,service_module_id,service_module_name,version,repo_url,branch,branch_head_sha,edit_file = response.data(:assembly_name,:module_id,:full_module_name,:version,:repo_url,:workspace_branch,:branch_head_sha,:edit_file)
154
169
  edit_opts = {
155
170
  :automatically_clone => true,
156
171
  :assembly_module => {
@@ -170,26 +185,23 @@ module DTK::Client
170
185
  version = nil #TODO: version associated with assembly is passed in edit_opts, which is a little confusing
171
186
  edit_aux(:service_module,service_module_id,service_module_name,version,edit_opts)
172
187
  end
173
-
188
+
174
189
  def edit_attributes_aux(context_params)
175
190
  assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
176
-
177
- # if no format is set then we use 'yaml'
178
- format = options.format || 'yaml'
179
- context_params.forward_options( { :format => format})
180
-
181
- response = list_attributes_aux(context_params)
191
+ context_params.forward_options(:format => 'yaml')
192
+
193
+ response = list_attributes_aux(context_params,:attribute_type=>:editable)
182
194
  return response unless response.ok?
183
195
 
184
- attributes_list = response.data
185
- attributes_hash = attributes_editor(attributes_list, format)
186
-
196
+ yaml_input = response.data
197
+ edited_yaml = attributes_editor(yaml_input)
198
+ # sending params in yaml format because marshalling fouls with some data types like nil and Booleans
187
199
  post_body = {
188
200
  :assembly_id => assembly_or_workspace_id,
189
- :av_pairs_hash => attributes_hash
201
+ :settings_yaml_content => edited_yaml
190
202
  }
191
-
192
- response = post rest_url("assembly/set_attributes"), post_body
203
+
204
+ post rest_url("assembly/apply_attribute_settings"), post_body
193
205
  end
194
206
 
195
207
  def push_module_updates_aux(context_params)
@@ -204,14 +216,13 @@ module DTK::Client
204
216
  return response unless response.ok?
205
217
  return Response::Ok.new() unless response.data(:any_updates)
206
218
  if dsl_parsing_errors = response.data(:dsl_parsing_errors)
207
- #TODO: not sure if this should be reached
208
219
  error_message = "Module '#{component_module_name}' parsing errors found:\n#{dsl_parsing_errors}\nYou can fix errors using 'edit' command from module context and invoke promote-module-updates again.\n"
209
- OsUtil.print(dsl_parsed_message, :red)
220
+ OsUtil.print(error_message, :red)
210
221
  return Response::Error.new()
211
222
  end
212
- module_name,branch,ff_change = response.data(:module_name,:workspace_branch,:fast_forward_change)
223
+ module_name,namespace,branch,ff_change = response.data(:module_name,:module_namespace,:workspace_branch,:fast_forward_change)
213
224
  ff_change ||= true
214
- opts = {:local_branch => branch}
225
+ opts = {:local_branch => branch,:namespace => namespace}
215
226
  opts.merge!(:hard_reset => true) if !ff_change
216
227
  response = Helper(:git_repo).pull_changes?(:component_module,module_name,opts)
217
228
  return response unless response.ok?()
@@ -240,7 +251,7 @@ module DTK::Client
240
251
  end
241
252
  end
242
253
  end
243
-
254
+
244
255
  response
245
256
  end
246
257
 
@@ -257,7 +268,6 @@ module DTK::Client
257
268
  def list_nodes_aux(context_params)
258
269
  context_params.method_arguments = ["nodes"]
259
270
  list_aux(context_params)
260
- # list_assemblies(context_params)
261
271
  end
262
272
 
263
273
  def list_components_aux(context_params)
@@ -272,9 +282,9 @@ module DTK::Client
272
282
  # list_assemblies(context_params)
273
283
  end
274
284
 
275
- def list_attributes_aux(context_params)
285
+ def list_attributes_aux(context_params,opts={})
276
286
  context_params.method_arguments = ["attributes"]
277
- list_aux(context_params)
287
+ list_aux(context_params,opts)
278
288
  end
279
289
 
280
290
  def list_tasks_aux(context_params)
@@ -323,7 +333,7 @@ module DTK::Client
323
333
  # data_type = :task
324
334
  # else
325
335
  # raise_validation_error_method_usage('list')
326
- # end
336
+ # end
327
337
  # end
328
338
 
329
339
  # post_body = {
@@ -335,7 +345,7 @@ module DTK::Client
335
345
  # post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
336
346
  # rest_endpoint = "assembly/info_about"
337
347
 
338
- # if context_params.is_last_command_eql_to?(:attribute)
348
+ # if context_params.is_last_command_eql_to?(:attribute)
339
349
  # raise DTK::Client::DtkError, "Not supported command for current context level." if attribute_id
340
350
  # about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
341
351
  # elsif context_params.is_last_command_eql_to?(:component)
@@ -358,7 +368,7 @@ module DTK::Client
358
368
  # data_type = :assembly
359
369
  # post_body = { :subtype => 'instance', :detail_level => 'nodes' }
360
370
  # rest_endpoint = "assembly/list"
361
- # end
371
+ # end
362
372
  # end
363
373
 
364
374
  # post_body[:about] = about
@@ -395,7 +405,7 @@ module DTK::Client
395
405
  end
396
406
 
397
407
  def create_component_aux(context_params)
398
- # If method is invoked from 'assembly/node' level retrieve node_id argument
408
+ # If method is invoked from 'assembly/node' level retrieve node_id argument
399
409
  # directly from active context
400
410
  if context_params.is_there_identifier?(:node)
401
411
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:node_id!,:option_1!]
@@ -405,6 +415,7 @@ module DTK::Client
405
415
  end
406
416
 
407
417
  assembly_id,node_id,component_template_id = context_params.retrieve_arguments(mapping,method_argument_names)
418
+ namespace, component_template_id = get_namespace_and_name_for_component(component_template_id)
408
419
 
409
420
  post_body = {
410
421
  :assembly_id => assembly_id,
@@ -412,6 +423,7 @@ module DTK::Client
412
423
  :component_template_id => component_template_id
413
424
  }
414
425
 
426
+ post_body.merge!(:namespace => namespace) if namespace
415
427
  post rest_url("assembly/add_component"), post_body
416
428
  end
417
429
 
@@ -433,7 +445,7 @@ module DTK::Client
433
445
  end
434
446
  post_body = {
435
447
  :assembly_id => assembly_or_workspace_id,
436
- :input_component_id => dep_cmp,
448
+ :input_component_id => dep_cmp,
437
449
  :output_component_id => antec_cmp
438
450
  }
439
451
  post_body.merge!(:dependency_name => dependency_name) if dependency_name
@@ -477,15 +489,15 @@ module DTK::Client
477
489
 
478
490
  def info_aux(context_params)
479
491
  assembly_or_workspace_id, node_id, component_id, attribute_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID, :node_id, :component_id, :attribute_id],method_argument_names)
480
- is_json_return = context_params.get_forwarded_option(:json_return) || false
481
-
492
+ is_json_return = context_params.get_forwarded_option(:json_return) || false
493
+
482
494
  post_body = {
483
495
  :assembly_id => assembly_or_workspace_id,
484
496
  :node_id => node_id,
485
497
  :component_id => component_id,
486
498
  :attribute_id => attribute_id,
487
499
  :subtype => :instance,
488
- :json_return => is_json_return
500
+ :json_return => is_json_return
489
501
  }
490
502
 
491
503
  resp = post rest_url("assembly/info"), post_body
@@ -496,7 +508,7 @@ module DTK::Client
496
508
  if (component_id.nil? && !node_id.nil?)
497
509
  resp.render_workspace_node_info("node")
498
510
  elsif (component_id && node_id)
499
- resp.render_workspace_node_info("component")
511
+ resp.render_workspace_node_info("component")
500
512
  else
501
513
  return resp
502
514
  end
@@ -523,7 +535,7 @@ module DTK::Client
523
535
  }
524
536
 
525
537
  response = post rest_url("assembly/delete"), post_body
526
-
538
+
527
539
  # when changing context send request for getting latest assemblies instead of getting from cache
528
540
  # @@invalidate_map << :assembly
529
541
  response
@@ -544,7 +556,7 @@ module DTK::Client
544
556
  else
545
557
  mapping = (options.unset? ? [REQ_ASSEMBLY_OR_WS_ID,:option_1!] : [REQ_ASSEMBLY_OR_WS_ID,:option_1!,:option_2!])
546
558
  end
547
-
559
+
548
560
  assembly_or_workspace_id, pattern, value = context_params.retrieve_arguments(mapping,method_argument_names)
549
561
  post_body = {
550
562
  :assembly_id => assembly_or_workspace_id,
@@ -583,7 +595,7 @@ module DTK::Client
583
595
  end
584
596
 
585
597
  assembly_or_workspace_id, pattern, value = context_params.retrieve_arguments(mapping,method_argument_names)
586
-
598
+
587
599
  post_body = {
588
600
  :assembly_id => assembly_or_workspace_id,
589
601
  :pattern => pattern,
@@ -639,7 +651,7 @@ module DTK::Client
639
651
 
640
652
  def delete_aux(context_params)
641
653
  if context_params.is_last_command_eql_to?(:node)
642
- delete_node_aux(context_params)
654
+ delete_node_aux(context_params)
643
655
  elsif context_params.is_last_command_eql_to?(:component)
644
656
  delete_component_aux(context_params)
645
657
  end
@@ -689,7 +701,7 @@ module DTK::Client
689
701
  post_body = {
690
702
  :assembly_id => assembly_or_workspace_id,
691
703
  :node_id => node_id
692
- }
704
+ }
693
705
 
694
706
  response = post(rest_url("assembly/initiate_get_netstats"),post_body)
695
707
  return response unless response.ok?
@@ -739,7 +751,7 @@ module DTK::Client
739
751
  post_body = {
740
752
  :assembly_id => assembly_or_workspace_id,
741
753
  :components => options["component"]
742
- }
754
+ }
743
755
  post_body[:node_id] = node_id unless node_id.nil?
744
756
 
745
757
  response = post(rest_url("assembly/initiate_execute_tests"),post_body)
@@ -764,7 +776,7 @@ module DTK::Client
764
776
  if count > execute_test_tries or response.data(:is_complete)
765
777
  response.data(:results).each do |res|
766
778
  if res.key?('test_error')
767
- test_error = res.delete('test_error')
779
+ test_error = res.delete('test_error')
768
780
  res['errors'] = { "message" => test_error, "type" => "test_error" }
769
781
  end
770
782
  end
@@ -779,7 +791,7 @@ module DTK::Client
779
791
  end
780
792
 
781
793
  if (response.data(:results).empty? && options['timeout'].nil?)
782
- raise DTK::Client::DtkValidationError, "Could not finish execution of tests in default timeframe (#{execute_test_tries} seconds). Try again with passing --timeout TIMEOUT parameter"
794
+ raise DTK::Client::DtkValidationError, "Could not finish execution of tests in default timeframe (#{execute_test_tries} seconds). Try again with passing --timeout TIMEOUT parameter"
783
795
  elsif (response.data(:results).empty? && !options['timeout'].nil?)
784
796
  raise DTK::Client::DtkValidationError, "Could not finish execution of tests in set timeframe (#{execute_test_tries} seconds). Try again with increasing --timeout TIMEOUT parameter"
785
797
  else
@@ -798,8 +810,8 @@ module DTK::Client
798
810
  post_body = {
799
811
  :assembly_id => assembly_or_workspace_id,
800
812
  :node_id => node_id
801
- }
802
-
813
+ }
814
+
803
815
  response = post(rest_url("assembly/initiate_get_ps"),post_body)
804
816
  return response unless response.ok?
805
817
 
@@ -828,18 +840,18 @@ module DTK::Client
828
840
  end
829
841
  filtered = response.data(:results).flatten
830
842
 
831
- # Amar: had to add more complex filtering in order to print node id and node name in output,
843
+ # Amar: had to add more complex filtering in order to print node id and node name in output,
832
844
  # as these two values are sent only in the first element of node's processes list
833
- unless (filter_pattern.nil? || !options["filter"])
845
+ unless (filter_pattern.nil? || !options["filter"])
834
846
  node_id = ""
835
- node_name = ""
847
+ node_name = ""
836
848
  filtered.reject! do |r|
837
849
  match = r.to_s.include?(filter_pattern)
838
850
  if r["node_id"] && r["node_id"] != node_id
839
851
  node_id = r["node_id"]
840
852
  node_name = r["node_name"]
841
853
  end
842
-
854
+
843
855
  if match && !node_id.empty?
844
856
  r["node_id"] = node_id
845
857
  r["node_name"] = node_name
@@ -847,7 +859,7 @@ module DTK::Client
847
859
  node_name = ""
848
860
  end
849
861
  !match
850
- end
862
+ end
851
863
  end
852
864
 
853
865
  response.set_data(*filtered)
@@ -865,9 +877,9 @@ module DTK::Client
865
877
  else
866
878
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:option_1!,:option_2!,:option_3]
867
879
  end
868
-
880
+
869
881
  assembly_or_workspace_id,node_identifier,log_path,grep_option = context_params.retrieve_arguments(mapping,method_argument_names)
870
-
882
+
871
883
  last_line = nil
872
884
  begin
873
885
 
@@ -929,7 +941,7 @@ module DTK::Client
929
941
 
930
942
  unless output.empty?
931
943
  file_ready = true
932
- tail_temp_file << output
944
+ tail_temp_file << output
933
945
  tail_temp_file.flush
934
946
  end
935
947
 
@@ -963,7 +975,7 @@ module DTK::Client
963
975
  t1.exit()
964
976
  end
965
977
  end
966
-
978
+
967
979
  t1.join()
968
980
  t2.join()
969
981
  rescue Interrupt
@@ -974,7 +986,7 @@ module DTK::Client
974
986
  end
975
987
  end
976
988
 
977
- def grep_aux(context_params)
989
+ def grep_aux(context_params)
978
990
  if context_params.is_there_identifier?(:node)
979
991
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:option_1!,:node_id!,:option_2!]
980
992
  else
@@ -982,7 +994,7 @@ module DTK::Client
982
994
  end
983
995
 
984
996
  assembly_or_workspace_id,log_path,node_pattern,grep_pattern = context_params.retrieve_arguments(mapping,method_argument_names)
985
-
997
+
986
998
  begin
987
999
  post_body = {
988
1000
  :assembly_id => assembly_or_workspace_id,
@@ -1023,7 +1035,7 @@ module DTK::Client
1023
1035
  end
1024
1036
 
1025
1037
  raise DTK::Client::DtkError, "Error while logging there was no successful response after 3 tries." unless response.data(:is_complete)
1026
-
1038
+
1027
1039
  console_width = ENV["COLUMNS"].to_i
1028
1040
 
1029
1041
  response.data(:results).each do |r|
@@ -1032,7 +1044,7 @@ module DTK::Client
1032
1044
  message_colorized = DTK::Client::OsUtil.colorize(r[0].inspect, :green)
1033
1045
 
1034
1046
  if r[1]["output"].empty?
1035
- puts "NODE-ID #{message_colorized} - Log does not contain data that matches you pattern #{grep_pattern}!"
1047
+ puts "NODE-ID #{message_colorized} - Log does not contain data that matches you pattern #{grep_pattern}!"
1036
1048
  else
1037
1049
  puts "\n"
1038
1050
  console_width.times do
@@ -1048,7 +1060,7 @@ module DTK::Client
1048
1060
  end
1049
1061
  end
1050
1062
 
1051
- def assembly_start(workspace_id, node_pattern_filter)
1063
+ def assembly_start(workspace_id, node_pattern_filter)
1052
1064
  post_body = {
1053
1065
  :assembly_id => workspace_id,
1054
1066
  :node_pattern => node_pattern_filter
@@ -1058,7 +1070,7 @@ module DTK::Client
1058
1070
  response = post rest_url("assembly/start"), post_body
1059
1071
  return response unless response.ok?()
1060
1072
  raise DTK::Client::DtkValidationError, response.data(:errors).first if response.data(:errors)
1061
-
1073
+
1062
1074
  task_id = response.data(:task_id)
1063
1075
  post rest_url("task/execute"), "task_id" => task_id
1064
1076
  end
@@ -1076,7 +1088,7 @@ module DTK::Client
1076
1088
  response
1077
1089
  end
1078
1090
 
1079
- def list_aux(context_params)
1091
+ def list_aux(context_params,opts={})
1080
1092
  assembly_or_workspace_id, node_id, component_id, attribute_id, about = context_params.retrieve_arguments([[:service_id!, :workspace_id],:node_id,:component_id,:attribute_id,:option_1],method_argument_names)
1081
1093
  detail_to_include = nil
1082
1094
  format = nil
@@ -1099,7 +1111,7 @@ module DTK::Client
1099
1111
  data_type = :component
1100
1112
  if options.deps?
1101
1113
  detail_to_include = [:component_dependencies]
1102
- end
1114
+ end
1103
1115
  when "attributes"
1104
1116
  data_type = (options.links? ? :workspace_attribute_w_link : :workspace_attribute)
1105
1117
  edit_attr_format = context_params.get_forwarded_options()[:format] if context_params.get_forwarded_options()
@@ -1109,6 +1121,9 @@ module DTK::Client
1109
1121
  elsif options.links?
1110
1122
  detail_to_include = [:attribute_links]
1111
1123
  end
1124
+ if opts[:attribute_type]
1125
+ post_options.merge!(:attribute_type => opts[:attribute_type])
1126
+ end
1112
1127
  when "modules"
1113
1128
  detail_to_include = [:version_info]
1114
1129
  data_type = nil #TODO: DynamicDatatype
@@ -1116,7 +1131,7 @@ module DTK::Client
1116
1131
  data_type = :task
1117
1132
  else
1118
1133
  raise_validation_error_method_usage('list')
1119
- end
1134
+ end
1120
1135
  end
1121
1136
 
1122
1137
  post_body = {
@@ -1129,7 +1144,7 @@ module DTK::Client
1129
1144
  post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
1130
1145
  rest_endpoint = "assembly/info_about"
1131
1146
 
1132
- if context_params.is_last_command_eql_to?(:attribute)
1147
+ if context_params.is_last_command_eql_to?(:attribute)
1133
1148
  raise DTK::Client::DtkError, "Not supported command for current context level." if attribute_id
1134
1149
  about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
1135
1150
  elsif context_params.is_last_command_eql_to?(:component)
@@ -1147,7 +1162,7 @@ module DTK::Client
1147
1162
  else
1148
1163
  if assembly_or_workspace_id
1149
1164
  about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes", "modules","tasks"])
1150
-
1165
+
1151
1166
  if data_type.to_s.eql?("component")
1152
1167
  data_type = nil #DynamicDatatype
1153
1168
  end
@@ -1159,7 +1174,7 @@ module DTK::Client
1159
1174
  data_type = :assembly
1160
1175
  post_body = { :subtype => 'instance', :detail_level => 'nodes' }
1161
1176
  rest_endpoint = "assembly/list"
1162
- end
1177
+ end
1163
1178
  end
1164
1179
 
1165
1180
  post_body[:about] = about
@@ -9,16 +9,18 @@ module DTK::Client
9
9
  # This will change behaviour of method
10
10
  # module_type: will be :component_module or :service_module
11
11
 
12
- def clone_aux(module_type,module_id,version,internal_trigger,omit_output=false,opts={})
13
- module_name,repo_url,branch,not_ok_response = workspace_branch_info(module_type,module_id,version,opts)
12
+ def clone_aux(module_type, module_id,version,internal_trigger,omit_output=false,opts={})
13
+ module_name,module_namespace,repo_url,branch,not_ok_response = workspace_branch_info(module_type,module_id,version,opts)
14
+ full_module_name = ModuleUtil.resolve_name(module_name, module_namespace)
15
+
14
16
  return not_ok_response if not_ok_response
15
- response = Helper(:git_repo).create_clone_with_branch(module_type,module_name,repo_url,branch,version,opts)
17
+ response = Helper(:git_repo).create_clone_with_branch(module_type,module_name,repo_url,branch,version,module_namespace,opts)
16
18
 
17
19
  if response.ok?
18
- puts "Module '#{module_name}' has been successfully cloned!" unless omit_output
20
+ puts "Module '#{full_module_name}' has been successfully cloned!" unless omit_output
19
21
  unless internal_trigger
20
22
  if Console.confirmation_prompt("Would you like to edit cloned module now?")
21
- context_params_for_module = create_context_for_module(module_name, module_type.to_s.gsub!(/\_/,'-').to_sym)
23
+ context_params_for_module = create_context_for_module(full_module_name, module_type)
22
24
  return edit(context_params_for_module)
23
25
  # if module_type.to_s.eql?("service_module")
24
26
  # context_params_for_module = create_context_for_module(module_name, :"service-module")
@@ -33,9 +35,9 @@ module DTK::Client
33
35
  response
34
36
  end
35
37
 
36
- def create_context_for_module(module_name, module_type)
38
+ def create_context_for_module(full_module_name, module_type)
37
39
  context_params_for_module = DTK::Shell::ContextParams.new
38
- context_params_for_module.add_context_to_params(module_name, module_type, module_name)
40
+ context_params_for_module.add_context_to_params(full_module_name, module_type.to_s.gsub!(/\_/,'-').to_sym, full_module_name)
39
41
  return context_params_for_module
40
42
  end
41
43
  end
@@ -1,19 +1,26 @@
1
1
  module DTK::Client
2
2
  module CommonMixin
3
3
  private
4
- #returns module_name,repo_url,branch,not_ok_response( only if error)
4
+ # returns module_name,module_namespace,repo_url,branch,not_ok_response( only if error)
5
5
  def workspace_branch_info(module_type, module_id, version, opts={})
6
+ # shortcut if have info about workspace branch already
6
7
  if info = opts[:workspace_branch_info]
7
- [info[:module_name],info[:repo_url],info[:branch]]
8
- else
9
- post_body = get_workspace_branch_info_post_body(module_type,module_id,version,opts)
10
- response = post(rest_url("#{module_type}/get_workspace_branch_info"),post_body)
11
- unless response.ok?
12
- [nil,nil,nil,response]
13
- else
14
- response.data(:module_name,:repo_url,:workspace_branch)
8
+ name_or_full_module_name = info[:module_name]
9
+ module_namespace,module_name = ModuleUtil.full_module_name_parts?(name_or_full_module_name)
10
+ module_namespace ||= info[:module_namespace]
11
+ ret = [module_name,module_namespace,info[:repo_url],info[:branch]]
12
+ unless ret.find{|r|r.nil?}
13
+ return ret
15
14
  end
16
15
  end
16
+
17
+ post_body = get_workspace_branch_info_post_body(module_type,module_id,version,opts)
18
+ response = post(rest_url("#{module_type}/get_workspace_branch_info"),post_body)
19
+ unless response.ok?
20
+ [nil,nil,nil,nil,response]
21
+ else
22
+ response.data(:module_name,:module_namespace,:repo_url,:workspace_branch)
23
+ end
17
24
  end
18
25
 
19
26
  def get_workspace_branch_info_post_body(module_type, module_id, version_explicit, opts={})
@@ -23,7 +30,7 @@ module DTK::Client
23
30
  }
24
31
  assembly_module = opts[:assembly_module]
25
32
  if version = version_explicit||(assembly_module && assembly_module[:version])
26
- post_body.merge!(:version => version)
33
+ post_body.merge!(:version => version)
27
34
  end
28
35
  if assembly_module
29
36
  post_body.merge!(:assembly_module => true,:assembly_name => assembly_module[:assembly_name])