dtk-client 0.6.8 → 0.7.0

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 (39) hide show
  1. checksums.yaml +8 -8
  2. data/bin/dtk +5 -1
  3. data/lib/auxiliary.rb +0 -1
  4. data/lib/commands/common/thor/assembly_workspace.rb +20 -1
  5. data/lib/commands/common/thor/inventory_parser.rb +1 -1
  6. data/lib/commands/common/thor/module/import.rb +41 -106
  7. data/lib/commands/common/thor/module.rb +13 -226
  8. data/lib/commands/common/thor/poller.rb +48 -0
  9. data/lib/commands/common/thor/puppet_forge.rb +7 -1
  10. data/lib/commands/common/thor/purge_clone.rb +2 -1
  11. data/lib/commands/common/thor/task_status.rb +15 -14
  12. data/lib/commands/common/thor/test_action_agent.rb +39 -0
  13. data/lib/commands/thor/component_module.rb +2 -2
  14. data/lib/commands/thor/node.rb +55 -14
  15. data/lib/commands/thor/node_group.rb +2 -26
  16. data/lib/commands/thor/service.rb +31 -11
  17. data/lib/commands/thor/service_module.rb +3 -1
  18. data/lib/commands/thor/workspace.rb +13 -3
  19. data/lib/core.rb +16 -6
  20. data/lib/domain/git_adapter.rb +0 -3
  21. data/lib/domain/response.rb +25 -13
  22. data/lib/dtk-client/version.rb +1 -1
  23. data/lib/parser/adapters/thor.rb +8 -5
  24. data/lib/shell/context.rb +8 -19
  25. data/lib/shell/domain/active_context.rb +169 -0
  26. data/lib/shell/domain/context_entity.rb +72 -0
  27. data/lib/shell/domain/context_params.rb +202 -0
  28. data/lib/shell/domain/override_tasks.rb +71 -0
  29. data/lib/shell/domain/shadow_entity.rb +59 -0
  30. data/lib/shell/help_monkey_patch.rb +76 -71
  31. data/lib/shell/message_queue.rb +2 -0
  32. data/lib/shell/status_monitor.rb +5 -3
  33. data/lib/shell.rb +4 -2
  34. data/lib/util/dtk_puppet.rb +8 -6
  35. data/lib/util/os_util.rb +5 -1
  36. data/lib/view_processor/table_print.rb +67 -12
  37. data/spec/lib/spec_thor.rb +5 -2
  38. metadata +9 -3
  39. data/lib/shell/domain.rb +0 -492
@@ -0,0 +1,48 @@
1
+ module DTK::Client
2
+ module Poller
3
+
4
+ PERIOD_WAIT_TIME = 1
5
+
6
+ def poller_response(wait_time = PERIOD_WAIT_TIME)
7
+ begin
8
+ response = nil
9
+ thread = Thread.new(self) do |main_thread|
10
+ begin
11
+ while true
12
+ messages_response = main_thread.get main_thread.rest_url("messages/retrieve")
13
+ print_response(messages_response.data) if messages_response.ok?
14
+ sleep(wait_time)
15
+ end
16
+ rescue => e
17
+ puts e.message
18
+ pp e.backtrace
19
+ end
20
+ end
21
+
22
+ response = yield
23
+ ensure
24
+ thread.kill
25
+ end
26
+ response
27
+ end
28
+
29
+ def print_response(message_array)
30
+ message_array.each do |msg|
31
+ DTK::Client::OsUtil.print(msg['message'], resolve_type(msg['type']))
32
+ end
33
+ end
34
+
35
+ def resolve_type(message_type)
36
+ case message_type.to_sym
37
+ when :info
38
+ :white
39
+ when :warning
40
+ :yellow
41
+ when :error
42
+ :red
43
+ else
44
+ :white
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,6 +1,8 @@
1
1
  module DTK::Client
2
2
  module PuppetForgeMixin
3
3
 
4
+ NAME_REGEX = /\w*\-\w/
5
+
4
6
  def puppet_forge_install_aux(context_params, pf_module_name, module_name, namespace, version, module_type)
5
7
  post_body_hash = {
6
8
  :puppetf_module_name => pf_module_name,
@@ -9,7 +11,11 @@ module DTK::Client
9
11
  :module_namespace? => namespace
10
12
  }
11
13
 
12
- response = post rest_url("component_module/install_puppet_forge_modules"),PostBody.new(post_body_hash)
14
+ raise DtkError, "Puppet forge module name should be in format USERNAME-NAME" unless pf_module_name.match(NAME_REGEX)
15
+
16
+ response = poller_response do
17
+ post rest_url("component_module/install_puppet_forge_modules"),PostBody.new(post_body_hash)
18
+ end
13
19
 
14
20
  return response unless response.ok?
15
21
 
@@ -33,7 +33,8 @@ module DTK::Client
33
33
 
34
34
  if response.ok?
35
35
  response.data.each do |cmp_mod|
36
- unsaved_modules << "#{cmp_mod['namespace_name']}:#{cmp_mod['display_name']}" if cmp_mod['local_copy_diff']
36
+ branch_relationship = cmp_mod['branch_relationship']||''
37
+ unsaved_modules << "#{cmp_mod['namespace_name']}:#{cmp_mod['display_name']}" if (cmp_mod['local_copy_diff'] && branch_relationship.eql?('local_ahead'))
37
38
  end
38
39
  end
39
40
 
@@ -1,18 +1,12 @@
1
1
  module DTK::Client
2
2
  module TaskStatusMixin
3
- def task_status_aux(id,type,wait_flag)
4
- id_field = "#{type}_id".to_sym
5
- if wait_flag
3
+ def task_status_aux(id,type,opts={})
4
+ if opts[:wait]
6
5
  # there will be infinite loop until intereputed with CTRL+C
7
6
  begin
8
7
  response = nil
9
8
  loop do
10
- post_body = {
11
- id_field => id,
12
- :format => :table
13
- }
14
- response = post rest_url("#{type}/task_status"), post_body
15
-
9
+ response = task_status_aux_post(id,type,opts)
16
10
  raise DTK::Client::DtkError, "[ERROR] #{response['errors'].first['message']}." if response["status"].eql?('notok')
17
11
 
18
12
  # stop pulling when top level task succeds, fails or timeout
@@ -57,11 +51,7 @@ module DTK::Client
57
51
  response.skip_render = true unless response.nil?
58
52
  end
59
53
  else
60
- post_body = {
61
- id_field => id,
62
- :format => :table
63
- }
64
- response = post rest_url("#{type}/task_status"), post_body
54
+ response = task_status_aux_post(id,type,opts)
65
55
  response.print_error_table = true
66
56
  response.render_table(:task_status)
67
57
  end
@@ -80,6 +70,17 @@ module DTK::Client
80
70
  response.override_command_class("list_task")
81
71
  puts response.render_data
82
72
  end
73
+
74
+ private
75
+ def task_status_aux_post(id,type,opts={})
76
+ id_field = "#{type}_id".to_sym
77
+ post_body_hash = {
78
+ id_field => id,
79
+ :format => :table,
80
+ :summarize_node_groups? => opts[:summarize]
81
+ }
82
+ post rest_url("#{type}/task_status"), PostBody.new(post_body_hash)
83
+ end
83
84
  end
84
85
 
85
86
  end
@@ -0,0 +1,39 @@
1
+ module DTK::Client
2
+ module TestActionAgent
3
+
4
+ def test_agent_aux(context_params)
5
+ service_id, node_id, bash_command = context_params.retrieve_arguments([:service_id!, :node_id!, :option_1!], method_argument_names)
6
+
7
+ post_body = {
8
+ :assembly_id => service_id,
9
+ :node_id => node_id,
10
+ :bash_command => bash_command
11
+ }
12
+
13
+ response = post(rest_url("assembly/initiate_action_agent"), post_body)
14
+ return response unless response.ok?
15
+
16
+
17
+ action_results_id = response.data(:action_results_id)
18
+ response = nil
19
+
20
+ loop do
21
+ post_body = {
22
+ :action_results_id => action_results_id,
23
+ :return_only_if_complete => true,
24
+ :disable_post_processing => false
25
+ }
26
+
27
+ response = post(rest_url("assembly/get_action_results"),post_body)
28
+
29
+ if response.data(:is_complete) || !response.ok?
30
+ break
31
+ else
32
+ sleep(1)
33
+ end
34
+ end
35
+
36
+ return response
37
+ end
38
+ end
39
+ end
@@ -281,8 +281,8 @@ module DTK::Client
281
281
 
282
282
  desc "COMPONENT-MODULE-NAME/ID add-collaborators", "Add collabrators users or groups comma seperated (--users or --groups)"
283
283
  method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
284
- method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
285
- method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
284
+ method_option "users", :aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
285
+ method_option "groups", :aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
286
286
  def add_collaborators(context_params)
287
287
  add_collaborators_module_aux(context_params)
288
288
  end
@@ -1,5 +1,7 @@
1
1
  dtk_require_common_commands('thor/task_status')
2
2
  dtk_require_common_commands('thor/set_required_params')
3
+ dtk_require_common_commands('thor/test_action_agent')
4
+
3
5
  module DTK::Client
4
6
  class Node < CommandBaseThor
5
7
 
@@ -8,6 +10,7 @@ module DTK::Client
8
10
  no_tasks do
9
11
  include TaskStatusMixin
10
12
  include SetRequiredParamsMixin
13
+ include TestActionAgent
11
14
  end
12
15
 
13
16
  def self.pretty_print_cols()
@@ -29,7 +32,7 @@ module DTK::Client
29
32
  end
30
33
 
31
34
  # using extended_context when we want to use autocomplete from other context
32
- # e.g. we are in assembly/apache context and want to create-component we will use extended context to add
35
+ # e.g. we are in assembly/apache context and want to create-component we will use extended context to add
33
36
  # component-templates to autocomplete
34
37
  def self.extended_context()
35
38
  {
@@ -52,7 +55,7 @@ module DTK::Client
52
55
 
53
56
  def self.validation_list(context_params)
54
57
  assembly_id, workspace_id = context_params.retrieve_arguments([:service_id, :workspace_id])
55
-
58
+
56
59
  if (assembly_id || workspace_id)
57
60
  # if assebmly_id is present we're loading nodes filtered by assembly_id
58
61
  post_body = {
@@ -81,7 +84,7 @@ module DTK::Client
81
84
  }
82
85
  })
83
86
  end
84
-
87
+
85
88
  desc "NODE-NAME/ID info","Info about node"
86
89
  def info(context_params)
87
90
  node_id = context_params.retrieve_arguments([:node_id!],method_argument_names)
@@ -93,6 +96,39 @@ module DTK::Client
93
96
  post rest_url("node/info"), post_body
94
97
  end
95
98
 
99
+ desc "NODE-NAME/ID test-action-agent BASH-COMMAND-LINE", "Run bash command on test action agent"
100
+ def test_action_agent(context_params)
101
+ response = test_agent_aux(context_params)
102
+ return response unless response.ok?
103
+
104
+ # this I will fix to have more clear output
105
+ data = response.data(:results)
106
+
107
+ datas = data.values.first['results']
108
+ errors = data.values.first['errors']
109
+
110
+
111
+ datas.each do |data|
112
+ OsUtil.print("Command: #{data['description']}, status: #{data['status']}", :yellow)
113
+ if data['stdout'] && !data['stdout'].empty?
114
+ print data['stdout']
115
+ end
116
+
117
+ if data['stderr'] && !data['stderr'].empty?
118
+ print data['stderr']
119
+ end
120
+ end
121
+
122
+ if errors && !errors.empty?
123
+ puts; puts;
124
+ OsUtil.print('Some errors have been detected', :white)
125
+ errors.each_with_index { |err, index| OsUtil.print("#{index+1}. #{err}", :red) }
126
+ end
127
+
128
+
129
+ return nil
130
+ end
131
+
96
132
  desc "NODE-NAME/ID ssh REMOTE-USER [-i PATH-TO-PEM]","SSH into node, optional parameters are path to indentity file."
97
133
  method_option "--identity-file",:aliases => '-i',:type => :string, :desc => "Identity-File used for connection, if not provided default is used", :banner => "IDENTITY-FILE"
98
134
  def ssh(context_params)
@@ -113,8 +149,12 @@ module DTK::Client
113
149
  response = info_aux(context_params)
114
150
 
115
151
  if response.ok?
116
- node_info = response.data['nodes'].find { |n| node_id == n['node_id'] }
117
- public_dns = node_info ? node_info['external_ref']['ec2_public_address'] : nil
152
+ node_info = {}
153
+ response.data['nodes'].each do |node|
154
+ properties = node['node_properties']
155
+ node_info = properties if node_id == properties['node_id']
156
+ end
157
+ public_dns = node_info ? node_info['ec2_public_address'] : nil
118
158
 
119
159
  raise ::DTK::Client::DtkError, "Not able to resolve instance address, has instance been stopped?" unless public_dns
120
160
 
@@ -123,7 +163,7 @@ module DTK::Client
123
163
  default_identity_file = OsUtil.dtk_identity_file_location()
124
164
 
125
165
  ssh_command = nil
126
-
166
+
127
167
  if identity_file_location
128
168
  # provided PEM key
129
169
  ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{identity_file_location} #{connection_string}"
@@ -165,7 +205,7 @@ module DTK::Client
165
205
  method_option :list, :type => :boolean, :default => false
166
206
  def list(context_params)
167
207
  node_id, about = context_params.retrieve_arguments([:node_id,:option_1],method_argument_names)
168
-
208
+
169
209
  if node_id.nil?
170
210
  response = post rest_url("node/list")
171
211
 
@@ -246,7 +286,7 @@ module DTK::Client
246
286
 
247
287
  desc "NODE-NAME/ID converge [-m COMMIT-MSG]", "Converges service instance"
248
288
  method_option "commit_msg",:aliases => "-m" ,
249
- :type => :string,
289
+ :type => :string,
250
290
  :banner => "COMMIT-MSG",
251
291
  :desc => "Commit message"
252
292
  def converge(context_params)
@@ -279,7 +319,7 @@ module DTK::Client
279
319
  method_option :wait, :type => :boolean, :default => false
280
320
  def task_status(context_params)
281
321
  node_id = context_params.retrieve_arguments([:node_id!],method_argument_names)
282
- task_status_aux(node_id,:node,options.wait?)
322
+ task_status_aux(node_id,:node,:wait => options.wait?)
283
323
  end
284
324
 
285
325
  desc "NODE-NAME/ID list-task-info", "Task status details of running or last service task"
@@ -334,7 +374,7 @@ module DTK::Client
334
374
  # Retrieving assembly_id to stop a node.. TODO create server side method that takes only node id
335
375
  #TODO: Rich: took this out; think it is a bug
336
376
  #assembly_id, node_id = get_assembly_and_node_id(context_params)
337
-
377
+
338
378
  node_stop(node_id)
339
379
  end
340
380
 
@@ -344,7 +384,7 @@ module DTK::Client
344
384
 
345
385
  post_body = {
346
386
  :node_id => node_id
347
- }
387
+ }
348
388
 
349
389
  response = post(rest_url("node/initiate_get_netstats"), post_body)
350
390
  return response unless response.ok?
@@ -375,6 +415,7 @@ module DTK::Client
375
415
  response.set_data(*response.data(:results))
376
416
  response.render_table(:netstat_data)
377
417
  end
418
+
378
419
  GETNETSTATSTRIES = 6
379
420
  GETNETSTATSSLEEP = 0.5
380
421
 
@@ -384,7 +425,7 @@ module DTK::Client
384
425
 
385
426
  post_body = {
386
427
  :node_id => node_id
387
- }
428
+ }
388
429
 
389
430
  response = post(rest_url("node/initiate_get_ps"), post_body)
390
431
  return response unless response.ok?
@@ -422,7 +463,7 @@ module DTK::Client
422
463
  GETPSSLEEP = 0.5
423
464
 
424
465
  no_tasks do
425
- def node_start(node_id)
466
+ def node_start(node_id)
426
467
  post_body = {
427
468
  :node_id => node_id
428
469
  }
@@ -472,7 +513,7 @@ module DTK::Client
472
513
  response = info(context_params)
473
514
  unless response.ok?
474
515
  raise DTK::Client::DtkError, "Unable to retrive node information, please try again."
475
- end
516
+ end
476
517
 
477
518
  return response.data(:assembly_id), response.data(:id)
478
519
  end
@@ -15,15 +15,6 @@ module DTK::Client
15
15
  return :node_group, "node_group/list", nil
16
16
  end
17
17
 
18
- # desc "list","List Node groups"
19
- # def list(context_params)
20
- # search_hash = SearchHash.new()
21
- # search_hash.cols = pretty_print_cols()
22
- # search_hash.filter = [:oneof, ":type", ["node_group_instance"]]
23
- # response = post rest_url("node_group/list"), search_hash.post_body_hash()
24
- # response.render_table(:node_group)
25
- # end
26
-
27
18
  desc "NODE-GROUP-NAME/ID set ATTRIBUTE-ID VALUE", "Set node group attribute value"
28
19
  def set(context_params)
29
20
  node_group_id, attr_id, value = context_params.retrieve_arguments([:node_group_id!, :option_1!, :option_2!],method_argument_names)
@@ -69,7 +60,7 @@ module DTK::Client
69
60
  node_group_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
70
61
  unless options.force?
71
62
  # Ask user if really want to delete node group, if not then return to dtk-shell without deleting
72
- return unless Console.confirmation_prompt("Are you sure you want to delete node group '#{node_group_id}'?")
63
+ return unless Console.confirmation_prompt("Are you sure you want to delete node group '#{node_group_id}'"+'?')
73
64
  end
74
65
 
75
66
  post_body = {:node_group_id => node_group_id}
@@ -188,23 +179,8 @@ module DTK::Client
188
179
  method_option :wait, :type => :boolean, :default => false
189
180
  def task_status(context_params)
190
181
  node_group_id = context_params.retrieve_arguments([:node_group_id!],method_argument_names)
191
- task_status_aux(node_group_id,:node_group,options.wait?)
192
- end
193
-
194
- #TODO: may deprecate
195
- =begin
196
- desc "set-profile NODE-GROUP-ID TEMPLATE-NODE-ID", "Set node group's default node template"
197
- def set_profile(node_group_id,template_node_id)
198
- post_body_hash = {:node_group_id => node_group_id, :template_node_id => template_node_id}
199
- post rest_url("node_group/set_default_template_node"),post_body_hash
200
- end
201
-
202
- desc "add-template-node NODE-GROUP-ID", "Copy template node from library and add to node group"
203
- def add_template_node(node_group_id)
204
- post_body_hash = {:node_group_id => node_group_id}
205
- post rest_url("node_group/clone_and_add_template_node"),post_body_hash
182
+ task_status_aux(node_group_id,:node_group,:wait => options.wait?)
206
183
  end
207
- =end
208
184
 
209
185
  end
210
186
  end
@@ -121,7 +121,7 @@ module DTK::Client
121
121
  # :identifier_only => only on identifier level for given entity (command)
122
122
  #
123
123
  def self.override_allowed_methods()
124
- return DTK::Shell::OverrideTasks.new({
124
+ override_methods = {
125
125
  :all => {
126
126
  # :node => [
127
127
  # ['delete-component',"delete-component COMPONENT-ID","# Delete component from assembly's node"],
@@ -130,10 +130,6 @@ module DTK::Client
130
130
  # ],
131
131
  :component => [
132
132
  ['list-attributes',"list-attributes","# List attributes associated with given component."]
133
- =begin
134
- TODO: overlaps with different meaning
135
- ['create-attribute',"create-attribute SERVICE-TYPE DEP-ATTR ARROW BASE-ATTR","# Create an attribute to service link."],
136
- =end
137
133
  ]
138
134
  },
139
135
  :command_only => {
@@ -161,7 +157,6 @@ TODO: overlaps with different meaning
161
157
  ['add-component',"add-component COMPONENT","# Add a component to the node."],
162
158
  ['delete-component',"delete-component COMPONENT-NAME [-y]","# Delete component from service's node"],
163
159
  ['info',"info","# Return info about node instance belonging to given workspace."],
164
- # ['link-attributes', "link-attributes TARGET-ATTR-TERM SOURCE-ATTR-TERM", "# Set TARGET-ATTR-TERM to SOURCE-ATTR-TERM."],
165
160
  ['list-attributes',"list-attributes","# List attributes associated with service's node."],
166
161
  ['list-components',"list-components","# List components associated with service's node."],
167
162
  ['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
@@ -169,10 +164,14 @@ TODO: overlaps with different meaning
169
164
  ['stop', "stop", "# Stop node instance."],
170
165
  ['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# SSH into node, optional parameters are path to identity file."]
171
166
  ],
167
+ :node_group => [
168
+ ['start', "start", "# 2Start node instance."],
169
+ ['stop', "stop", "# 2Stop node instance."],
170
+ ['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# 2SSH into node, optional parameters are path to identity file."]
171
+ ],
172
172
  :component => [
173
173
  ['info',"info","# Return info about component instance belonging to given node."],
174
174
  ['edit',"edit","# Edit component module related to given component."],
175
- # ['edit-dsl',"edit-dsl","# Edit component module dsl file related to given component."],
176
175
  ['link-components',"link-components ANTECEDENT-CMP-NAME [DEPENDENCY-NAME]","#Link components to satisfy component dependency relationship."],
177
176
  ['list-component-links',"list-component-links","# List component's links to other components."],
178
177
  ['unlink-components',"unlink-components SERVICE-TYPE","# Delete service link on component."]
@@ -181,7 +180,13 @@ TODO: overlaps with different meaning
181
180
  ['info',"info","# Return info about attribute instance belonging to given component."]
182
181
  ]
183
182
  }
184
- }, [:utils])
183
+ }
184
+
185
+ if ::DTK::Configuration.get(:development_mode)
186
+ override_methods[:identifier_only][:node] << ['test-action-agent', "test-action-agent BASH-COMMAND-LINE", "Run bash command on test action agent"]
187
+ end
188
+
189
+ return DTK::Shell::OverrideTasks.new(override_methods, [:utils])
185
190
  end
186
191
 
187
192
  desc "SERVICE-NAME/ID destroy-and-reset-nodes [-y]", "Terminates all nodes, but keeps config state so they can be spun up from scratch."
@@ -207,7 +212,10 @@ TODO: overlaps with different meaning
207
212
  cancel_task_aux(context_params)
208
213
  end
209
214
 
210
- desc "SERVICE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME", "Create a new assembly from this service instance in the designated service module."
215
+ desc "SERVICE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME [-m DESCRIPTION]", "Create a new assembly from this service instance in the designated service module."
216
+ method_option "description",:aliases => "-m" ,
217
+ :type => :string,
218
+ :banner => "DESCRIPTION"
211
219
  def create_assembly(context_params)
212
220
  assembly_id, service_module_name, assembly_template_name = context_params.retrieve_arguments([:service_id!,:option_1!,:option_2!],method_argument_names)
213
221
 
@@ -216,7 +224,9 @@ TODO: overlaps with different meaning
216
224
  return resp unless resp.ok?
217
225
  default_namespace = resp.data
218
226
 
219
- response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name,{:default_namespace=>default_namespace})
227
+ opts = {:default_namespace => default_namespace}
228
+ opts.merge!(:description => options.description) if options.description
229
+ response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name,opts)
220
230
  return response unless response.ok?
221
231
 
222
232
  @@invalidate_map << :assembly
@@ -318,12 +328,17 @@ TODO: will put in dot release and will rename to 'extend'
318
328
  end
319
329
  =end
320
330
 
321
- desc "SERVICE-NAME/ID task-status [--wait]", "Get the task status of the running or last running service task."
331
+ desc "SERVICE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running service task."
322
332
  method_option :wait, :type => :boolean, :default => false
333
+ method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
323
334
  def task_status(context_params)
324
335
  task_status_aw_aux(context_params)
325
336
  end
326
337
 
338
+ desc "SERVICE-NAME/ID task-action-detail", "Get the task info of the running or last running service task."
339
+ def task_action_detail(context_params)
340
+ task_action_detail_aw_aux(context_params)
341
+ end
327
342
 
328
343
  desc "SERVICE-NAME/ID list-nodes","List nodes associated with service."
329
344
  def list_nodes(context_params)
@@ -364,6 +379,11 @@ TODO: will put in dot release and will rename to 'extend'
364
379
  list_violations_aux(context_params)
365
380
  end
366
381
 
382
+ desc "SERVICE-NAME/ID print-includes", "Finds includes in the service."
383
+ def print_includes(context_params)
384
+ print_includes_aux(context_params)
385
+ end
386
+
367
387
  desc "SERVICE-NAME/ID workflow-info", "Get the structure of the workflow associated with service."
368
388
  def workflow_info(context_params)
369
389
  workflow_info_aux(context_params)
@@ -7,6 +7,7 @@ dtk_require_from_base("commands/thor/assembly")
7
7
  dtk_require_from_base('command_helpers/service_importer')
8
8
  dtk_require_common_commands('thor/common')
9
9
  dtk_require_common_commands('thor/module')
10
+ dtk_require_common_commands('thor/poller')
10
11
 
11
12
  module DTK::Client
12
13
  class ServiceModule < CommandBaseThor
@@ -17,6 +18,7 @@ module DTK::Client
17
18
  include ReparseMixin
18
19
  include ServiceImporter
19
20
  include ModuleMixin
21
+ include Poller
20
22
 
21
23
  def get_service_module_name(service_module_id)
22
24
  get_name_from_id_helper(service_module_id)
@@ -144,7 +146,7 @@ module DTK::Client
144
146
  end
145
147
  response = post rest_url("service_module/#{action}"), { :service_module_id => service_module_id }
146
148
  end
147
- return response unless response.ok?
149
+
148
150
  response.render_table(data_type) unless response.nil?
149
151
 
150
152
  response
@@ -198,9 +198,12 @@ module DTK::Client
198
198
  Response::Ok.new()
199
199
  end
200
200
 
201
- desc "WORKSPACE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME [-p]", "Create a new assembly from the workspace instance in the designated service module."
201
+ desc "WORKSPACE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME [-p] [-m DESCRIPTION]", "Create a new assembly from the workspace instance in the designated service module."
202
202
  # The option -p will purge the workspace after assembly creation."
203
203
  method_option :purge, :aliases => '-p', :type => :boolean, :default => false
204
+ method_option "description",:aliases => "-m" ,
205
+ :type => :string,
206
+ :banner => "DESCRIPTION"
204
207
  def create_assembly(context_params)
205
208
  workspace_id, service_module_full_name, assembly_template_name = context_params.retrieve_arguments([:workspace_id!,:option_1!,:option_2!],method_argument_names)
206
209
 
@@ -209,7 +212,9 @@ module DTK::Client
209
212
  return resp unless resp.ok?
210
213
  default_namespace = resp.data
211
214
 
212
- response = promote_assembly_aux(:create,workspace_id,service_module_full_name,assembly_template_name,{:default_namespace=>default_namespace})
215
+ opts = {:default_namespace => default_namespace}
216
+ opts.merge!(:description => options.description) if options.description
217
+ response = promote_assembly_aux(:create,workspace_id,service_module_full_name,assembly_template_name,opts)
213
218
  return response unless response.ok?
214
219
 
215
220
  if options.purge?
@@ -475,12 +480,17 @@ module DTK::Client
475
480
  tail_aux(context_params)
476
481
  end
477
482
 
478
- desc "WORKSPACE-NAME/ID task-status [--wait]", "Get the task status of the running or last running workspace task."
483
+ desc "WORKSPACE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running workspace task."
479
484
  method_option :wait, :type => :boolean, :default => false
485
+ method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
480
486
  def task_status(context_params)
481
487
  task_status_aw_aux(context_params)
482
488
  end
483
489
 
490
+ desc "WORKSPACE-NAME/ID task-action-detail", "Get the task info of the running or last running workspace task."
491
+ def task_action_detail(context_params)
492
+ task_action_detail_aw_aux(context_params)
493
+ end
484
494
  end
485
495
  end
486
496
 
data/lib/core.rb CHANGED
@@ -6,6 +6,10 @@ require 'restclient'
6
6
  require 'colorize'
7
7
  require 'json'
8
8
  require 'pp'
9
+
10
+ if ::DTK::Configuration.get(:development_mode)
11
+ require 'ap'
12
+ end
9
13
  #TODO: for testing; fix by pass in commadn line argument
10
14
  #RestClient.log = STDOUT
11
15
 
@@ -134,7 +138,10 @@ def resolve_direct_access(params, config_exists=nil)
134
138
  # setting up catalog credentials
135
139
  catalog_creds = DTK::Client::Configurator.ask_catalog_credentials()
136
140
  unless catalog_creds.empty?
137
- response = conn.post DTK::Client::CommandBase.class, conn.rest_url("account/set_catalog_credentials"), { :username => catalog_creds[:username], :password => catalog_creds[:password]}
141
+ response = conn.post DTK::Client::CommandBase.class, conn.rest_url("account/set_catalog_credentials"), { :username => catalog_creds[:username], :password => catalog_creds[:password], :validate => true}
142
+ if errors = response['errors']
143
+ DTK::Client::OsUtil.print("#{errors.first['message']} You will have to set catalog credentials manually ('dtk account set-catalog-credentials').", :yellow)
144
+ end
138
145
  end
139
146
  end
140
147
 
@@ -446,11 +453,14 @@ module DTK
446
453
  end
447
454
 
448
455
  def get_credentials()
449
- cred_file = Config::CRED_FILE
450
- raise DTK::Client::DtkError,"Authorization configuration file (#{cred_file}) does not exist" unless File.exists?(cred_file)
451
- ret = parse_key_value_file(cred_file)
452
- [:username,:password].each{|k|raise DTK::Client::DtkError,"cannot find #{k}" unless ret[k]}
453
- ret
456
+ unless @parsed_credentials
457
+ cred_file = Config::CRED_FILE
458
+ raise DTK::Client::DtkError,"Authorization configuration file (#{cred_file}) does not exist" unless File.exists?(cred_file)
459
+ ret = parse_key_value_file(cred_file)
460
+ [:username,:password].each{ |k| raise DTK::Client::DtkError,"cannot find #{k}" unless ret[k] }
461
+ @parsed_credentials = ret
462
+ end
463
+ @parsed_credentials
454
464
  end
455
465
 
456
466
  ####
@@ -140,9 +140,6 @@ module DTK
140
140
  when :remote_branch
141
141
  @git_repo.branches.remote.find { |r| "#{r.remote}/#{r.name}" == ref }
142
142
  when :local_branch
143
- # DEBUG SNIPPET >>>> REMOVE <<<<
144
- # TODO: HARIS LOOK INTO THIS
145
- # raise "Invalid ref #{ref}"
146
143
  @git_repo.branches.find { |b| b.name == ref }
147
144
  else
148
145
  raise Error.new("Illegal type parameter (#{type}) passed to merge_relationship")