dtk-client 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dtk +12 -1
- data/dtk-client.gemspec +1 -1
- data/lib/command_helpers/git_repo/merge.rb +139 -0
- data/lib/command_helpers/git_repo.rb +29 -51
- data/lib/command_helpers/service_importer.rb +1 -1
- data/lib/commands/common/thor/assembly_workspace.rb +55 -42
- data/lib/commands/common/thor/pull_from_remote.rb +11 -3
- data/lib/commands/common/thor/puppet_forge.rb +1 -1
- data/lib/commands/thor/component_module.rb +3 -1
- data/lib/commands/thor/developer.rb +25 -4
- data/lib/commands/thor/node.rb +5 -2
- data/lib/commands/thor/node_group.rb +1 -1
- data/lib/commands/thor/service.rb +39 -23
- data/lib/commands/thor/workspace.rb +48 -11
- data/lib/domain/git_adapter.rb +8 -0
- data/lib/dtk-client/version.rb +1 -1
- data/lib/execute/cli_pure/cli_rerouter.rb +3 -0
- data/lib/parser/adapters/thor.rb +1 -1
- data/lib/shell/context.rb +1 -1
- data/lib/{commands/common/thor/task_status → task_status}/refresh_mode.rb +0 -0
- data/lib/{commands/common/thor/task_status → task_status}/snapshot_mode.rb +0 -0
- data/lib/task_status/stream_mode/element/format.rb +86 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +76 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/components.rb +9 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb +9 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +55 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +37 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +36 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +25 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +17 -0
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +83 -0
- data/lib/{commands/common/thor/task_status → task_status}/stream_mode/element/no_results.rb +0 -0
- data/lib/task_status/stream_mode/element/render.rb +42 -0
- data/lib/task_status/stream_mode/element/stage/render.rb +59 -0
- data/lib/task_status/stream_mode/element/stage.rb +67 -0
- data/lib/task_status/stream_mode/element/task_end.rb +19 -0
- data/lib/task_status/stream_mode/element/task_start.rb +21 -0
- data/lib/task_status/stream_mode/element.rb +85 -0
- data/lib/{commands/common/thor/task_status → task_status}/stream_mode.rb +5 -5
- data/lib/{commands/common/thor/task_status.rb → task_status.rb} +15 -12
- data/lib/util/os_util.rb +8 -0
- metadata +26 -14
- data/lib/commands/common/thor/task_status/stream_mode/element/render.rb +0 -88
- data/lib/commands/common/thor/task_status/stream_mode/element/stage.rb +0 -13
- data/lib/commands/common/thor/task_status/stream_mode/element/task_end.rb +0 -10
- data/lib/commands/common/thor/task_status/stream_mode/element/task_start.rb +0 -10
- data/lib/commands/common/thor/task_status/stream_mode/element.rb +0 -90
@@ -11,7 +11,7 @@ module DTK::Client
|
|
11
11
|
:module_namespace? => namespace
|
12
12
|
}
|
13
13
|
|
14
|
-
raise DtkError, "Puppet forge module name should be in format
|
14
|
+
raise DtkError, "Puppet forge module name should be in format NAMESPACE-MODULENAME" unless pf_module_name.match(NAME_REGEX)
|
15
15
|
|
16
16
|
response = poller_response do
|
17
17
|
post rest_url("component_module/install_puppet_forge_modules"), PostBody.new(post_body_hash)
|
@@ -336,7 +336,9 @@ module DTK::Client
|
|
336
336
|
# version_method_option
|
337
337
|
desc "COMPONENT-MODULE-NAME/ID clone [-n]", "Locally clone component module and component files. Use -n to skip edit prompt"
|
338
338
|
method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
|
339
|
-
|
339
|
+
# DEBUG SNIPPET >>> REMOVE <<<
|
340
|
+
# REMOVE TRIGGER!!!!
|
341
|
+
def clone(context_params, internal_trigger=true)
|
340
342
|
clone_module_aux(context_params, internal_trigger)
|
341
343
|
end
|
342
344
|
|
@@ -1,15 +1,20 @@
|
|
1
1
|
require 'base64'
|
2
|
+
dtk_require_common_commands('thor/action_result_handler')
|
2
3
|
|
3
4
|
module DTK::Client
|
4
5
|
class Developer < CommandBaseThor
|
5
6
|
|
7
|
+
no_tasks do
|
8
|
+
include ActionResultHandler
|
9
|
+
end
|
10
|
+
|
6
11
|
MATCH_FILE_NAME = /[a-zA-Z0-9_]+\.[a-zA-Z]+$/
|
7
12
|
GIT_LOG_LOCATION = File.expand_path('../../../lib/git-logs/git.log', File.dirname(__FILE__))
|
8
13
|
PROJECT_ROOT = File.expand_path('../../../', File.dirname(__FILE__))
|
9
14
|
|
10
|
-
desc "upload-agent PATH-TO-AGENT[.rb,.dll] NODE-ID-PATTERN", "Uploads agent and ddl file to requested nodes, pattern is regexp for filtering node ids."
|
15
|
+
desc "upload-agent PATH-TO-AGENT[.rb,.dll] NODE-ID-PATTERN", "Uploads agent and ddl file to requested nodes, pattern is regexp for filtering node ids."
|
11
16
|
def upload_agent(context_params)
|
12
|
-
agent, node_pattern = context_params.retrieve_arguments([:option_1!, :option_2!],method_argument_names)
|
17
|
+
agent, node_pattern = context_params.retrieve_arguments([:option_1!, :option_2!], method_argument_names)
|
13
18
|
|
14
19
|
nodes = post rest_url("node/list"), { :is_list_all => true }
|
15
20
|
|
@@ -20,7 +25,7 @@ module DTK::Client
|
|
20
25
|
|
21
26
|
# if it doesn't contain extension upload both *.rb and *.ddl
|
22
27
|
files = (agent.match(MATCH_FILE_NAME) ? [agent] : ["#{agent}.rb","#{agent}.ddl"])
|
23
|
-
|
28
|
+
|
24
29
|
# read require files and encode them
|
25
30
|
request_body = {}
|
26
31
|
files.each do |file_name|
|
@@ -36,6 +41,22 @@ module DTK::Client
|
|
36
41
|
return response
|
37
42
|
end
|
38
43
|
|
44
|
+
# run-agent haris1 dev_manager inject_agent "{ 'action_agent_branch': 'master', 'action_agent_url': 'git@github.com:rich-reactor8/dtk-action-agent.git' }"
|
45
|
+
desc "run-agent SERVICE-NAME AGENT-NAME AGENT-METHOD PARAMS", "Updates DTK Action Agent to provided branch, example: dev_manager inject_agent \"{ 'action_agent_branch': 'master', 'action_agent_url': 'url' }\""
|
46
|
+
def run_agent(context_params)
|
47
|
+
service_name, agent_name, agent_method, action_params = context_params.retrieve_arguments([:option_1!, :option_2!, :option_3!, :option_4], method_argument_names)
|
48
|
+
|
49
|
+
action_params ||= "{}"
|
50
|
+
action_params.gsub!("'",'"')
|
51
|
+
|
52
|
+
response = post_file rest_url("developer/run_agent"), { :service_name => service_name, :agent_name => agent_name, :agent_method => agent_method, :agent_params => action_params }
|
53
|
+
|
54
|
+
action_results_id = response.data(:action_results_id)
|
55
|
+
print_action_results(action_results_id)
|
56
|
+
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
39
60
|
desc "remove-from-system SERVICE-NAME", "Removes objects associated with service, but does not destroy target isnatnces"
|
40
61
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
41
62
|
def remove_from_system(context_params)
|
@@ -98,7 +119,7 @@ module DTK::Client
|
|
98
119
|
puts File.open(fname).readlines
|
99
120
|
DTK::Client::OsUtil.print("*"*header.size, :yellow)
|
100
121
|
end
|
101
|
-
end
|
122
|
+
end
|
102
123
|
|
103
124
|
end
|
104
125
|
end
|
data/lib/commands/thor/node.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
dtk_require_from_base('task_status')
|
2
2
|
dtk_require_common_commands('thor/set_required_attributes')
|
3
|
+
dtk_require_common_commands('thor/assembly_workspace')
|
3
4
|
|
4
5
|
module DTK::Client
|
5
6
|
class Node < CommandBaseThor
|
@@ -115,8 +116,10 @@ module DTK::Client
|
|
115
116
|
end
|
116
117
|
|
117
118
|
context_params.forward_options({ :json_return => true })
|
119
|
+
# TODO: should call something taht just returns info about nodes, rather than info_aux
|
120
|
+
# also info that comes back should indicate whether a node group and if so error message is that
|
121
|
+
# ssh cannot be called on node group
|
118
122
|
response = info_aux(context_params)
|
119
|
-
|
120
123
|
if response.ok?
|
121
124
|
node_info = {}
|
122
125
|
response.data['nodes'].each do |node|
|
@@ -2,10 +2,10 @@ require 'rest_client'
|
|
2
2
|
require 'json'
|
3
3
|
require 'colorize'
|
4
4
|
|
5
|
-
dtk_require_from_base(
|
6
|
-
dtk_require_from_base(
|
7
|
-
dtk_require_from_base(
|
8
|
-
|
5
|
+
dtk_require_from_base('dtk_logger')
|
6
|
+
dtk_require_from_base('util/os_util')
|
7
|
+
dtk_require_from_base('command_helper')
|
8
|
+
dtk_require_from_base('task_status')
|
9
9
|
dtk_require_common_commands('thor/set_required_attributes')
|
10
10
|
dtk_require_common_commands('thor/edit')
|
11
11
|
dtk_require_common_commands('thor/purge_clone')
|
@@ -96,6 +96,19 @@ module DTK::Client
|
|
96
96
|
:endpoint => "assembly",
|
97
97
|
:url => "assembly/info_about",
|
98
98
|
:opts => {:subtype=>"instance", :about=>"modules"}
|
99
|
+
},
|
100
|
+
:workflow_info => {
|
101
|
+
:endpoint => "assembly",
|
102
|
+
:url => "assembly/task_action_list"
|
103
|
+
},
|
104
|
+
:exec => {
|
105
|
+
:endpoint => "assembly",
|
106
|
+
:url => "assembly/task_action_list"
|
107
|
+
},
|
108
|
+
# TODO: DEPRECATE execute_workflow
|
109
|
+
:execute_workflow => {
|
110
|
+
:endpoint => "assembly",
|
111
|
+
:url => "assembly/task_action_list"
|
99
112
|
}
|
100
113
|
}
|
101
114
|
}
|
@@ -247,25 +260,34 @@ module DTK::Client
|
|
247
260
|
Response::Ok.new()
|
248
261
|
end
|
249
262
|
|
250
|
-
desc "SERVICE-NAME/ID
|
263
|
+
desc "SERVICE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action"
|
264
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
265
|
+
def exec(context_params)
|
266
|
+
opts = {}
|
267
|
+
opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
|
268
|
+
converge_aux(context_params, opts)
|
269
|
+
end
|
270
|
+
# TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
|
271
|
+
desc "SERVICE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
|
251
272
|
method_option "commit_msg",:aliases => "-m" ,
|
252
273
|
:type => :string,
|
253
274
|
:banner => "COMMIT-MSG",
|
254
275
|
:desc => "Commit message"
|
255
276
|
def execute_workflow(context_params)
|
277
|
+
OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
|
256
278
|
converge(context_params)
|
257
279
|
end
|
258
|
-
|
280
|
+
|
281
|
+
desc "SERVICE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge service instance."
|
259
282
|
method_option "commit_msg",:aliases => "-m" ,
|
260
283
|
:type => :string,
|
261
284
|
:banner => "COMMIT-MSG",
|
262
285
|
:desc => "Commit message"
|
286
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
263
287
|
def converge(context_params)
|
264
|
-
opts =
|
265
|
-
if context_params.pure_cli_mode
|
266
|
-
|
267
|
-
end
|
268
|
-
converge_aux(context_params,opts)
|
288
|
+
opts = {}
|
289
|
+
opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
|
290
|
+
converge_aux(context_params, opts)
|
269
291
|
end
|
270
292
|
|
271
293
|
desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]", "Converge the component or execute tha action on the component."
|
@@ -333,12 +355,6 @@ module DTK::Client
|
|
333
355
|
edit_attributes_aux(context_params)
|
334
356
|
end
|
335
357
|
|
336
|
-
# desc "ASSEMBLY-NAME/ID promote-module-updates COMPONENT-MODULE-NAME [--force]", "Promotes changes made to component module in assembly to base component module"
|
337
|
-
# method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
338
|
-
# def promote_module_updates(context_params)
|
339
|
-
# promote_module_updates_aux(context_params)
|
340
|
-
# end
|
341
|
-
|
342
358
|
=begin
|
343
359
|
TODO: will put in dot release and will rename to 'extend'
|
344
360
|
desc "ASSEMBLY-NAME/ID add EXTENSION-TYPE [-n COUNT]", "Adds a sub assembly template to the assembly"
|
@@ -374,7 +390,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
374
390
|
:banner => "MODE",
|
375
391
|
:desc => "Mode in which task status display; one of [stream,snapshot,refresh]; default is 'snapshot'"
|
376
392
|
method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
|
377
|
-
# leaving --wait in for backwards compatability
|
393
|
+
# TODO: leaving --wait in for backwards compatability
|
378
394
|
method_option :wait, :type => :boolean, :default => false
|
379
395
|
def task_status(context_params)
|
380
396
|
task_status_aw_aux(context_params)
|
@@ -434,8 +450,8 @@ TODO: will put in dot release and will rename to 'extend'
|
|
434
450
|
workflow_info_aux(context_params)
|
435
451
|
end
|
436
452
|
|
437
|
-
desc "SERVICE-NAME/ID
|
438
|
-
def
|
453
|
+
desc "SERVICE-NAME/ID list-workflows", "List the workflows associated with the service."
|
454
|
+
def list_workflows(context_params)
|
439
455
|
workflow_list_aux(context_params)
|
440
456
|
end
|
441
457
|
|
@@ -471,7 +487,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
471
487
|
rest_endpoint = "assembly/info_about"
|
472
488
|
|
473
489
|
if context_params.is_last_command_eql_to?(:attribute)
|
474
|
-
raise
|
490
|
+
raise DtkError, "Not supported command for current context level." if attribute_id
|
475
491
|
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
476
492
|
elsif context_params.is_last_command_eql_to?(:component)
|
477
493
|
if component_id
|
@@ -610,7 +626,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
610
626
|
@@invalidate_map << :workspace_node
|
611
627
|
|
612
628
|
message = "Created node '#{response.data["display_name"]}'."
|
613
|
-
|
629
|
+
OsUtil.print(message, :yellow)
|
614
630
|
end
|
615
631
|
|
616
632
|
desc "SERVICE-NAME/ID create-node-group ^^NODE-GROUP-NAME NODE-TEMPLATE [-n CARDINALITY]", "Add (stage) a new node group in the service."
|
@@ -627,7 +643,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
627
643
|
@@invalidate_map << :workspace_node
|
628
644
|
|
629
645
|
message = "Created node group '#{response.data["display_name"]}'."
|
630
|
-
|
646
|
+
OsUtil.print(message, :yellow)
|
631
647
|
end
|
632
648
|
|
633
649
|
desc "SERVICE-NAME/ID link-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]","Link the target component to the source component."
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rest_client'
|
2
2
|
require 'json'
|
3
3
|
require 'colorize'
|
4
|
-
dtk_require_from_base(
|
5
|
-
dtk_require_from_base(
|
6
|
-
dtk_require_from_base(
|
7
|
-
|
4
|
+
dtk_require_from_base('dtk_logger')
|
5
|
+
dtk_require_from_base('util/os_util')
|
6
|
+
dtk_require_from_base('command_helper')
|
7
|
+
dtk_require_from_base('task_status')
|
8
8
|
dtk_require_common_commands('thor/edit')
|
9
9
|
dtk_require_common_commands('thor/purge_clone')
|
10
10
|
dtk_require_common_commands('thor/assembly_workspace')
|
@@ -77,6 +77,19 @@ module DTK::Client
|
|
77
77
|
:endpoint => "assembly",
|
78
78
|
:url => "assembly/info_about",
|
79
79
|
:opts => {:subtype=>"instance", :about=>"modules"}
|
80
|
+
},
|
81
|
+
:workflow_info => {
|
82
|
+
:endpoint => "assembly",
|
83
|
+
:url => "assembly/task_action_list"
|
84
|
+
},
|
85
|
+
:exec => {
|
86
|
+
:endpoint => "assembly",
|
87
|
+
:url => "assembly/task_action_list"
|
88
|
+
},
|
89
|
+
# TODO: DEPRECATE execute_workflow
|
90
|
+
:execute_workflow => {
|
91
|
+
:endpoint => "assembly",
|
92
|
+
:url => "assembly/task_action_list"
|
80
93
|
}
|
81
94
|
}
|
82
95
|
}
|
@@ -181,22 +194,36 @@ module DTK::Client
|
|
181
194
|
# clear_tasks_aux(context_params)
|
182
195
|
#end
|
183
196
|
|
184
|
-
desc "WORKSPACE-NAME/ID
|
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"
|
199
|
+
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
|
+
end
|
204
|
+
|
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
|
185
207
|
method_option "commit_msg",:aliases => "-m",
|
186
208
|
:type => :string,
|
187
209
|
:banner => "COMMIT-MSG",
|
188
210
|
:desc => "Commit message"
|
189
211
|
def execute_workflow(context_params)
|
212
|
+
OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
|
190
213
|
converge_aux(context_params)
|
191
214
|
end
|
192
215
|
|
193
|
-
|
216
|
+
|
217
|
+
desc "WORKSPACE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge workspace instance."
|
194
218
|
method_option "commit_msg",:aliases => "-m" ,
|
195
219
|
:type => :string,
|
196
220
|
:banner => "COMMIT-MSG",
|
197
221
|
:desc => "Commit message"
|
222
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
198
223
|
def converge(context_params)
|
199
|
-
|
224
|
+
opts = {}
|
225
|
+
opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
|
226
|
+
converge_aux(context_params, opts)
|
200
227
|
end
|
201
228
|
|
202
229
|
desc "WORKSPACE-NAME/ID push-component-module-updates COMPONENT-MODULE-NAME [--force]", "Push changes made to a component module in the workspace to its base component module."
|
@@ -508,8 +535,8 @@ module DTK::Client
|
|
508
535
|
workflow_info_aux(context_params)
|
509
536
|
end
|
510
537
|
|
511
|
-
desc "WORKSPACE-NAME/ID
|
512
|
-
def
|
538
|
+
desc "WORKSPACE-NAME/ID list-workflows", "List the workflows associated with the workspace."
|
539
|
+
def list_workflows(context_params)
|
513
540
|
workflow_list_aux(context_params)
|
514
541
|
end
|
515
542
|
|
@@ -573,13 +600,23 @@ module DTK::Client
|
|
573
600
|
tail_aux(context_params)
|
574
601
|
end
|
575
602
|
|
576
|
-
desc "WORKSPACE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running workspace task."
|
577
|
-
|
603
|
+
#desc "WORKSPACE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running workspace task."
|
604
|
+
desc "WORKSPACE-NAME/ID task-status [--mode MODE] [--summarize]", "Get the task status of the running or last running workspace task."
|
605
|
+
method_option "mode",:aliases => "-m" ,
|
606
|
+
:type => :string,
|
607
|
+
:banner => "MODE",
|
608
|
+
:desc => "Mode in which task status display; one of [stream,snapshot,refresh]; default is 'snapshot'"
|
578
609
|
method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
|
610
|
+
# TODO: leaving --wait in for backwards compatability
|
611
|
+
method_option :wait, :type => :boolean, :default => false
|
612
|
+
|
579
613
|
def task_status(context_params)
|
580
614
|
task_status_aw_aux(context_params)
|
581
615
|
end
|
582
616
|
|
617
|
+
|
618
|
+
|
619
|
+
|
583
620
|
desc "WORKSPACE-NAME/ID task-action-detail", "Get the task info of the running or last running workspace task."
|
584
621
|
def task_action_detail(context_params)
|
585
622
|
task_action_detail_aw_aux(context_params)
|
data/lib/domain/git_adapter.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
require 'git'
|
2
|
+
# monkey patch
|
3
|
+
class Git::Lib
|
4
|
+
public :command
|
5
|
+
end
|
2
6
|
|
3
7
|
module DTK
|
4
8
|
module Client
|
@@ -19,6 +23,10 @@ module DTK
|
|
19
23
|
@local_branch_name = local_branch_name
|
20
24
|
end
|
21
25
|
|
26
|
+
def command(*args, &block)
|
27
|
+
@git_repo.lib.command(*args, &block)
|
28
|
+
end
|
29
|
+
|
22
30
|
def changed?
|
23
31
|
(!(changed().empty? && untracked().empty? && deleted().empty?) || staged_commits?)
|
24
32
|
end
|
data/lib/dtk-client/version.rb
CHANGED
@@ -6,6 +6,9 @@ module DTK
|
|
6
6
|
{ :regex => /service-module (?<service_module_id>[\w:\-]+) (?<method_name>stage) (?<assembly_id>[\w:\-]+) (?<instance_name>[\w:\-\.\:]+)/, :entity => 'assembly' },
|
7
7
|
{ :regex => /service-module (?<service_module_id>[\w:\-]+) (?<method_name>deploy) (?<assembly_id>[\w:\-]+) (?<instance_name>[\w:\-\.\:]+)/ }
|
8
8
|
],
|
9
|
+
:component_module => [
|
10
|
+
{ :regex => /component-module (?<component_module_id>[\w:\-]+) (?<method_name>clone)/ }
|
11
|
+
],
|
9
12
|
:service => [
|
10
13
|
{ :regex => /service (?<service_id>[\w:\-]+) (?<method_name>set-attribute) (?<name>[\w:\-\.\:]+) (?<value>[\w:\-\.\:]+)/ },
|
11
14
|
{ :regex => /service (?<service_id>[\w:\-]+) (?<method_name>converge)/ },
|
data/lib/parser/adapters/thor.rb
CHANGED
@@ -7,7 +7,7 @@ require 'digest/sha1'
|
|
7
7
|
dtk_require("../../shell/interactive_wizard")
|
8
8
|
dtk_require("../../util/os_util")
|
9
9
|
dtk_require("../../util/console")
|
10
|
-
|
10
|
+
dtk_require_from_base('task_status')
|
11
11
|
dtk_require_from_base("command_helper")
|
12
12
|
dtk_require("../../context_router")
|
13
13
|
dtk_require_common_commands('thor/poller')
|
data/lib/shell/context.rb
CHANGED
@@ -132,7 +132,7 @@ module DTK
|
|
132
132
|
warning_message = restricted[:message]
|
133
133
|
node_specific = restricted[:node_specific]
|
134
134
|
|
135
|
-
DTK::Client::OsUtil.
|
135
|
+
DTK::Client::OsUtil.print_warning(warning_messag) if warning_message
|
136
136
|
# end
|
137
137
|
|
138
138
|
# Validate and change context
|
File without changes
|
File without changes
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class DTK::Client::TaskStatus::StreamMode::Element
|
2
|
+
class Format < ::Hash
|
3
|
+
Settings = {
|
4
|
+
:task_start => {
|
5
|
+
},
|
6
|
+
:task_end => {
|
7
|
+
},
|
8
|
+
:stage => {
|
9
|
+
},
|
10
|
+
:stage_start => {
|
11
|
+
:border_symbol => '=',
|
12
|
+
},
|
13
|
+
:stage_end => {
|
14
|
+
:border_symbol => '-',
|
15
|
+
},
|
16
|
+
:default => {
|
17
|
+
:border_symbol => '=',
|
18
|
+
:border_size => 60,
|
19
|
+
:bracket_symbol => '=',
|
20
|
+
:bracket_size => 25,
|
21
|
+
:duration_accuracy => 1, # how many decimal places accuracy
|
22
|
+
:include_start_time => true,
|
23
|
+
:tab_size => 2, # how many spaces each tab has
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
def initialize(type)
|
28
|
+
super()
|
29
|
+
@type = type && type.to_sym
|
30
|
+
replace(Settings[:default].merge(Settings[@type] || {}))
|
31
|
+
end
|
32
|
+
|
33
|
+
def format(msg, params = {})
|
34
|
+
aug_msg = augment(msg, params)
|
35
|
+
params[:bracket] ? bracket(aug_msg) : aug_msg
|
36
|
+
end
|
37
|
+
|
38
|
+
def border
|
39
|
+
border_symbol = self[:border_symbol]
|
40
|
+
border_size = self[:border_size]
|
41
|
+
"#{border_symbol * border_size}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def start_time_msg?(started_at)
|
45
|
+
if started_at
|
46
|
+
"TIME START: #{started_at}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def formatted_duration?(duration)
|
51
|
+
if duration
|
52
|
+
"#{duration.round(self[:duration_accuracy])}s"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def duration_msg?(duration)
|
57
|
+
if formatted_duration = formatted_duration?(duration)
|
58
|
+
"DURATION: #{formatted_duration}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def bracket(aug_msg)
|
65
|
+
bracket_symbol = self[:bracket_symbol]
|
66
|
+
bracket_size = self[:bracket_size]
|
67
|
+
"#{bracket_symbol * bracket_size} #{aug_msg} #{bracket_symbol * bracket_size}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def augment(msg, params = {})
|
71
|
+
msg_prefix = ''
|
72
|
+
started_at = params[:started_at]
|
73
|
+
if started_at and self[:include_start_time]
|
74
|
+
msg_prefix << "#{started_at} "
|
75
|
+
end
|
76
|
+
ret = "#{msg_prefix}#{msg}"
|
77
|
+
if tabs = params[:tabs]
|
78
|
+
ident = ' ' * (tabs * self[:tab_size])
|
79
|
+
ret = ret.split("\n").map { |line| "#{ident}#{line}" }.join("\n")
|
80
|
+
end
|
81
|
+
ret
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module DTK::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
2
|
+
class Results
|
3
|
+
class Action < self
|
4
|
+
def initialize(element, hash)
|
5
|
+
super
|
6
|
+
@action_results = hash['action_results'] || []
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :action_results
|
10
|
+
|
11
|
+
def render_results(results_per_node)
|
12
|
+
if any_results?(results_per_node)
|
13
|
+
render_line 'RESULTS:'
|
14
|
+
render_empty_line
|
15
|
+
results_per_node.each { |result| result.render }
|
16
|
+
else
|
17
|
+
render_errors(results_per_node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def render
|
22
|
+
not_first_time = nil
|
23
|
+
render_node_term
|
24
|
+
@action_results.each do |action_result|
|
25
|
+
render_action_result_lines(action_result, :first_time => not_first_time.nil?)
|
26
|
+
not_first_time ||= true
|
27
|
+
end
|
28
|
+
render_empty_line
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def any_results?(results_per_node)
|
34
|
+
!!results_per_node.find { |results| !results.action_results.empty? }
|
35
|
+
end
|
36
|
+
|
37
|
+
def render_action_result_lines(action_result, opts = {})
|
38
|
+
stdout = action_result['stdout']
|
39
|
+
stderr = action_result['stderr']
|
40
|
+
unless opts[:first_time]
|
41
|
+
render_line '--'
|
42
|
+
end
|
43
|
+
if command = command?(action_result)
|
44
|
+
render_line command
|
45
|
+
end
|
46
|
+
if return_code = action_result['status']
|
47
|
+
render_line "RETURN CODE: #{return_code.to_s}"
|
48
|
+
end
|
49
|
+
if stdout && !stdout.empty?
|
50
|
+
render_line 'STDOUT:'
|
51
|
+
render_action_output stdout
|
52
|
+
end
|
53
|
+
if stderr && !stderr.empty?
|
54
|
+
render_line 'STDERR:'
|
55
|
+
render_action_output stderr
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def render_action_output(line)
|
60
|
+
render_line line, RenderActionLineOpts
|
61
|
+
end
|
62
|
+
RenderActionLineOpts = { :tabs => 1 }
|
63
|
+
|
64
|
+
def command?(action_result)
|
65
|
+
if command = action_result['description']
|
66
|
+
if match = command.match(/^(create )(.*)/)
|
67
|
+
"ADD: #{match[2]}"
|
68
|
+
else
|
69
|
+
"RUN: #{command}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end; end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module DTK::Client; class TaskStatus::StreamMode::Element
|
2
|
+
class HierarchicalTask
|
3
|
+
class Results < self
|
4
|
+
require File.expand_path('result/action', File.dirname(__FILE__))
|
5
|
+
require File.expand_path('result/components', File.dirname(__FILE__))
|
6
|
+
require File.expand_path('result/node_level', File.dirname(__FILE__))
|
7
|
+
|
8
|
+
def initialize(element, hash)
|
9
|
+
super
|
10
|
+
@errors = hash['errors'] || []
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def self.render(element, stage_subtasks)
|
15
|
+
results_per_node = base_subtasks(element, stage_subtasks)
|
16
|
+
return if results_per_node.empty?
|
17
|
+
# assumption is that if multipe results_per_node they are same type
|
18
|
+
results_per_node.first.render_results(results_per_node)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
attr_reader :errors
|
24
|
+
|
25
|
+
def render_errors(results_per_node)
|
26
|
+
return unless results_per_node.find { |result| not result.errors.empty?}
|
27
|
+
first_time = true
|
28
|
+
results_per_node.each do |result|
|
29
|
+
if first_time
|
30
|
+
render_line 'ERRORS:'
|
31
|
+
first_time = false
|
32
|
+
end
|
33
|
+
result.render_node_errors
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def render_node_errors
|
38
|
+
return if @errors.empty?
|
39
|
+
render_node_term
|
40
|
+
@errors.each do |error|
|
41
|
+
if err_msg = error['message']
|
42
|
+
render_error_line err_msg
|
43
|
+
render_empty_line
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_error_line(line, opts = {})
|
49
|
+
render_line(line, ErrorRenderOpts.merge(opts))
|
50
|
+
end
|
51
|
+
ErrorRenderOpts = { :tabs => 1}
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end; end
|