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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80ce06a9a9d822a933c7613d0d2e608e68bf8ea
|
4
|
+
data.tar.gz: 516e42bae79455ea32c275236df7720ef683a4a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4df462ad21ae5516dfcb89de0949d7c6537814365d93b44a666a099853f17521b5f20c31aa1b286293dff22bffcaabff76bdd8aba9f655fbd879b53a546bd7
|
7
|
+
data.tar.gz: 28cd24c15adab48e77f888ff9205954b479866d9a532d69785218c638e51d57ccc69d62517d16109e7c8eac8f8a25f090e10c2625c0c1405bd4ec26df76661e0
|
data/bin/dtk
CHANGED
@@ -5,7 +5,7 @@ $shell_mode = false
|
|
5
5
|
|
6
6
|
require File.expand_path('../lib/client', File.dirname(__FILE__))
|
7
7
|
require File.expand_path('../lib/configurator', File.dirname(__FILE__))
|
8
|
-
require File.expand_path('../lib/parser/adapters/thor',
|
8
|
+
require File.expand_path('../lib/parser/adapters/thor', File.dirname(__FILE__))
|
9
9
|
require File.expand_path('../lib/shell/context', File.dirname(__FILE__))
|
10
10
|
require File.expand_path('../lib/shell/domain/context_entity', File.dirname(__FILE__))
|
11
11
|
require File.expand_path('../lib/shell/domain/active_context', File.dirname(__FILE__))
|
@@ -17,6 +17,17 @@ require File.expand_path('../lib/shell/parse_monkey_patch', File.dirname(__FILE_
|
|
17
17
|
require File.expand_path('../lib/shell/help_monkey_patch', File.dirname(__FILE__))
|
18
18
|
require File.expand_path('../lib/execute/cli_pure/cli_rerouter', File.dirname(__FILE__))
|
19
19
|
|
20
|
+
paths = []
|
21
|
+
paths << File.expand_path('../lib/commands/thor/*.rb', File.dirname(__FILE__))
|
22
|
+
paths << File.expand_path('../lib/commands/common/thor/*.rb', File.dirname(__FILE__))
|
23
|
+
|
24
|
+
paths.each do |path|
|
25
|
+
Dir[path].each do |thor_class_file|
|
26
|
+
require thor_class_file
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
20
31
|
|
21
32
|
require 'shellwords'
|
22
33
|
require 'json'
|
data/dtk-client.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.add_dependency 'hirb','~> 0.7.0'
|
30
30
|
gem.add_dependency 'thor','~> 0.15.4'
|
31
31
|
gem.add_dependency 'erubis','~> 2.7.0'
|
32
|
-
gem.add_dependency 'dtk-common-core','0.7.
|
32
|
+
gem.add_dependency 'dtk-common-core','0.7.3'
|
33
33
|
gem.add_dependency 'git','1.2.8'
|
34
34
|
gem.add_dependency 'colorize','~> 0.5.8'
|
35
35
|
gem.add_dependency 'highline', '1.6.16'
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module DTK; module Client; class CommandHelper
|
2
|
+
class GitRepo
|
3
|
+
class Merge
|
4
|
+
def initialize(repo, remote_branch_ref, opts = {})
|
5
|
+
@repo = repo
|
6
|
+
@remote_branch_ref = remote_branch_ref
|
7
|
+
@local_branch = repo.local_branch_name
|
8
|
+
# options
|
9
|
+
@opts_commit_sha = opts[:commit_sha]
|
10
|
+
@opts_force = opts[:force]
|
11
|
+
@opts_merge_if_no_conflict = opts[:merge_if_no_conflict]
|
12
|
+
@opts_ignore_dependency_merge_conflict = opts[:ignore_dependency_merge_conflict]
|
13
|
+
@opts_full_module_name = opts[:full_module_name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.merge(repo, remote_branch_ref, opts = {})
|
17
|
+
new(repo, remote_branch_ref, opts).merge
|
18
|
+
end
|
19
|
+
|
20
|
+
def merge
|
21
|
+
if @opts_force
|
22
|
+
merge_force()
|
23
|
+
else
|
24
|
+
# check if merge needed
|
25
|
+
merge_rel = merge_relationship()
|
26
|
+
case merge_rel
|
27
|
+
when :equal
|
28
|
+
response__no_diffs()
|
29
|
+
when :local_ahead, :branchpoint
|
30
|
+
merge_not_fast_forward(merge_rel)
|
31
|
+
when :local_behind
|
32
|
+
merge_simple()
|
33
|
+
else
|
34
|
+
raise Error.new("Unexpected merge_rel (#{merge_rel})")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def merge_force
|
42
|
+
diffs = compute_diffs()
|
43
|
+
# TODO: should put in a commit message that merged from remote repo
|
44
|
+
@repo.merge_theirs(@remote_branch_ref)
|
45
|
+
response(diffs)
|
46
|
+
end
|
47
|
+
|
48
|
+
def merge_not_fast_forward(merge_rel)
|
49
|
+
if @opts_merge_if_no_conflict
|
50
|
+
if any_conflicts?
|
51
|
+
msg = 'Unable to do pull-dtkn merge without conflicts. Options are:'
|
52
|
+
msg << " a) command 'pull-dtkn --force', but all local changes will be lost or"
|
53
|
+
msg << " b) use command 'edit' to get in linux shell and directly use git commands."
|
54
|
+
raise ErrorUsage.new(msg)
|
55
|
+
else
|
56
|
+
if merge_rel == :local_ahead
|
57
|
+
response__no_diffs(:custom_message => 'No op because local module is ahead')
|
58
|
+
else
|
59
|
+
merge_simple()
|
60
|
+
end
|
61
|
+
end
|
62
|
+
elsif @opts_force
|
63
|
+
merge_force()
|
64
|
+
elsif @opts_ignore_dependency_merge_conflict
|
65
|
+
custom_message = "Unable to do fast-forward merge. You can go to '#{@opts_full_module_name}' and pull with --force option but all changes will be lost."
|
66
|
+
# TODO: should this instead by ErrorUsage.new like below
|
67
|
+
response(:custom_message => :custom_message)
|
68
|
+
else
|
69
|
+
# this will only be reached if opts_merge_if_no_conflict is false
|
70
|
+
raise ErrorUsage.new('Unable to do fast-forward merge. You can use --force on pull-dtkn, but all local changes will be lost.')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def merge_simple
|
75
|
+
# see if any diffs between fetched remote and local branch
|
76
|
+
# this has be done after commit
|
77
|
+
diffs = compute_diffs()
|
78
|
+
return diffs unless diffs.any_diffs?()
|
79
|
+
|
80
|
+
safe_execute do
|
81
|
+
# TODO: should put in a commit message that merged from remote repo
|
82
|
+
@repo.merge(@remote_branch_ref)
|
83
|
+
end
|
84
|
+
|
85
|
+
if commit_sha = @opts_commit_sha
|
86
|
+
if commit_sha != @repo.head_commit_sha()
|
87
|
+
raise Error.new("Git synchronization problem: expected local head to have sha (#{commit_sha})")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
response(diffs)
|
92
|
+
end
|
93
|
+
|
94
|
+
def merge_relationship
|
95
|
+
@repo.merge_relationship(:remote_branch, @remote_branch_ref)
|
96
|
+
end
|
97
|
+
|
98
|
+
def any_conflicts?
|
99
|
+
# TODO: optimization is to combine this with mereg to have merge_if_no_conflics?
|
100
|
+
# and if no conflicts just commit and merge --no-commit
|
101
|
+
ret = nil
|
102
|
+
begin
|
103
|
+
@repo.command('merge',['--no-commit', @remote_branch_ref])
|
104
|
+
rescue ::Git::GitExecuteError
|
105
|
+
ret = true
|
106
|
+
ensure
|
107
|
+
safe_execute do
|
108
|
+
@repo.command('merge',['--abort'])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
ret
|
112
|
+
end
|
113
|
+
|
114
|
+
def response__no_diffs(opts_response = {})
|
115
|
+
response(diffs__no_diffs(), opts_response)
|
116
|
+
end
|
117
|
+
|
118
|
+
def response(diffs, opts_response = {})
|
119
|
+
{ :diffs => diffs, :commit_sha => @repo.head_commit_sha() }.merge(opts_response)
|
120
|
+
end
|
121
|
+
|
122
|
+
def diffs__no_diffs
|
123
|
+
GitRepo.diffs__no_diffs
|
124
|
+
end
|
125
|
+
|
126
|
+
def compute_diffs
|
127
|
+
GitRepo.compute_diffs(@repo, @remote_branch_ref)
|
128
|
+
end
|
129
|
+
|
130
|
+
def safe_execute(&block)
|
131
|
+
begin
|
132
|
+
yield
|
133
|
+
rescue Exception
|
134
|
+
nil
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end; end; end
|
@@ -7,7 +7,8 @@ dtk_require("../domain/git_error_handler")
|
|
7
7
|
|
8
8
|
module DTK; module Client; class CommandHelper
|
9
9
|
class GitRepo < self; class << self
|
10
|
-
|
10
|
+
dtk_require('git_repo/merge')
|
11
|
+
|
11
12
|
def create(repo_dir,branch=nil,opts={})
|
12
13
|
GitAdapter.new(repo_dir, branch)
|
13
14
|
end
|
@@ -357,8 +358,15 @@ module DTK; module Client; class CommandHelper
|
|
357
358
|
end
|
358
359
|
commit_sha = repo.find_remote_sha(remote_branch_ref)
|
359
360
|
else
|
360
|
-
where = opts[:where]||'server'
|
361
|
-
|
361
|
+
where = opts[:where] || 'server'
|
362
|
+
msg = "Merge needed before module (#{pp_module(repo)}) can be pushed to #{where}. "
|
363
|
+
if where.to_sym == :catalog
|
364
|
+
msg << " Either a merge into the local module can be done with pull-dtkn command, followed by push-dtkn or force"
|
365
|
+
else
|
366
|
+
msg << "Force"
|
367
|
+
end
|
368
|
+
msg << " push can be used with the '--force' option, but this will overwrite remote contents"
|
369
|
+
raise ErrorUsage.new(msg)
|
362
370
|
end
|
363
371
|
elsif merge_rel == :no_remote_ref
|
364
372
|
repo.push(remote_branch_ref)
|
@@ -447,16 +455,27 @@ module DTK; module Client; class CommandHelper
|
|
447
455
|
{ "diffs" => (diffs[:diffs]||"").to_s, "status" => repo.local_summary() }
|
448
456
|
end
|
449
457
|
|
458
|
+
|
459
|
+
def diffs__no_diffs
|
460
|
+
DiffSummary.new
|
461
|
+
end
|
462
|
+
def compute_diffs(repo, remote_branch_ref)
|
463
|
+
DiffSummary.diff(repo, repo.local_branch_name, remote_branch_ref)
|
464
|
+
end
|
465
|
+
public :diffs__no_diffs, :compute_diffs
|
466
|
+
|
450
467
|
def pull_repo_changes_aux(repo, opts = {})
|
451
|
-
|
452
|
-
|
468
|
+
# TODO: cleanup use of hard_reset and force
|
469
|
+
force = opts[:hard_reset] || opts[:force]
|
453
470
|
|
454
471
|
# default commit in case it is needed
|
455
|
-
|
472
|
+
if repo.changed?
|
473
|
+
repo.stage_and_commit('Commit prior to pull from remote')
|
474
|
+
end
|
456
475
|
|
457
476
|
if commit_sha = opts[:commit_sha]
|
458
477
|
# no op if at commit_sha
|
459
|
-
return
|
478
|
+
return diffs__no_diffs if (commit_sha == repo.head_commit_sha()) && !force
|
460
479
|
end
|
461
480
|
|
462
481
|
if opts[:remote_repo] && opts[:remote_repo_url]
|
@@ -464,50 +483,9 @@ module DTK; module Client; class CommandHelper
|
|
464
483
|
end
|
465
484
|
|
466
485
|
repo.fetch(remote(opts[:remote_repo]))
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
if hard_reset
|
471
|
-
diffs = DiffSummary.diff(repo, local_branch, remote_branch_ref)
|
472
|
-
repo.merge_theirs(remote_branch_ref)
|
473
|
-
return({ :diffs => diffs, :commit_sha => repo.head_commit_sha() })
|
474
|
-
end
|
475
|
-
|
476
|
-
# check if merge needed
|
477
|
-
merge_rel = repo.merge_relationship(:remote_branch, remote_branch_ref)
|
478
|
-
if merge_rel == :equal
|
479
|
-
{ :diffs => diffs, :commit_sha => repo.head_commit_sha() }
|
480
|
-
elsif [:branchpoint, :local_ahead].include?(merge_rel)
|
481
|
-
if opts[:force]
|
482
|
-
# TODO: right now just wiping out what is in repo
|
483
|
-
diffs = DiffSummary.diff(repo, local_branch, remote_branch_ref)
|
484
|
-
repo.merge_theirs(remote_branch_ref)
|
485
|
-
{ :diffs => diffs, :commit_sha => repo.head_commit_sha() }
|
486
|
-
elsif opts[:ignore_dependency_merge_conflict]
|
487
|
-
{ :diffs => diffs, :commit_sha => repo.head_commit_sha(), :custom_message => "Unable to do fast-forward merge. You can go to '#{opts[:full_module_name]}' and pull with --force option but all changes will be lost." }
|
488
|
-
else
|
489
|
-
raise Error.new('Unable to do fast-forward merge. You can use --force but all changes will be lost.')
|
490
|
-
end
|
491
|
-
elsif merge_rel == :local_behind
|
492
|
-
# see if any diffs between fetched remote and local branch
|
493
|
-
# this has be done after commit
|
494
|
-
diffs = DiffSummary.diff(repo, local_branch, remote_branch_ref)
|
495
|
-
return diffs unless diffs.any_diffs?()
|
496
|
-
|
497
|
-
begin
|
498
|
-
repo.merge(remote_branch_ref)
|
499
|
-
rescue Exception => e
|
500
|
-
puts e
|
501
|
-
end
|
502
|
-
|
503
|
-
if commit_sha && commit_sha != repo.head_commit_sha()
|
504
|
-
raise Error.new("Git synchronization problem: expected local head to have sha (#{commit_sha})")
|
505
|
-
end
|
506
|
-
|
507
|
-
{ :diffs => diffs, :commit_sha => repo.head_commit_sha() }
|
508
|
-
else
|
509
|
-
raise Error.new("Unexpected merge_rel (#{merge_rel})")
|
510
|
-
end
|
486
|
+
remote_branch_ref = remote_branch_ref(repo.local_branch_name, opts)
|
487
|
+
# TODO: cleanup use of hard_reset and force; Merge.merge just uses :force
|
488
|
+
Merge.merge(repo, remote_branch_ref, opts.merge(:force => force))
|
511
489
|
end
|
512
490
|
|
513
491
|
def remote(remote_repo=nil)
|
@@ -32,7 +32,7 @@ module DTK::Client
|
|
32
32
|
new_context_params.add_context_to_params(module_type, module_type)
|
33
33
|
new_context_params.add_context_name_to_params(module_type, module_type, module_name)
|
34
34
|
|
35
|
-
forwarded_opts = { skip_recursive_pull
|
35
|
+
forwarded_opts = { :skip_recursive_pull => true, :ignore_dependency_merge_conflict => true }
|
36
36
|
forwarded_opts.merge!(:do_not_raise => true) if opts[:do_not_raise]
|
37
37
|
new_context_params.forward_options(forwarded_opts)
|
38
38
|
|
@@ -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/set_required_attributes')
|
9
9
|
dtk_require_common_commands('thor/edit')
|
10
10
|
dtk_require_common_commands('thor/purge_clone')
|
@@ -89,6 +89,7 @@ module DTK::Client
|
|
89
89
|
# synchronize_clone will load new assembly template into service clone on workspace (if it exists)
|
90
90
|
commit_sha, workspace_branch, namespace, full_module_name, repo_url, version = response.data(:commit_sha, :workspace_branch, :module_namespace, :full_module_name, :repo_url, :version)
|
91
91
|
service_module_name ||= response.data(:module_name)
|
92
|
+
merge_warning_message = response.data(:merge_warning_message)
|
92
93
|
opts = { :local_branch => workspace_branch, :namespace => namespace }
|
93
94
|
|
94
95
|
if (mode == :update) || local_clone_dir_exists
|
@@ -98,7 +99,9 @@ module DTK::Client
|
|
98
99
|
end
|
99
100
|
return response unless response.ok?
|
100
101
|
|
101
|
-
|
102
|
+
OsUtil.print("New assembly template '#{assembly_template_name}' created in service module '#{full_module_name}'.", :yellow) if mode == :create
|
103
|
+
OsUtil.print(merge_warning_message, :yellow) if merge_warning_message
|
104
|
+
|
102
105
|
response
|
103
106
|
end
|
104
107
|
|
@@ -141,8 +144,8 @@ module DTK::Client
|
|
141
144
|
response = post rest_url("assembly/ad_hoc_action_execute"), post_body
|
142
145
|
return response unless response.ok?
|
143
146
|
|
144
|
-
task_status_stream(assembly_or_workspace_id)
|
145
|
-
|
147
|
+
task_status_stream(assembly_or_workspace_id, :ignore_stage_level_info => true)
|
148
|
+
nil
|
146
149
|
end
|
147
150
|
|
148
151
|
def converge_aux(context_params,opts={})
|
@@ -155,7 +158,7 @@ module DTK::Client
|
|
155
158
|
return response unless response.ok?
|
156
159
|
if response.data and response.data.size > 0
|
157
160
|
error_message = "The following violations were found; they must be corrected before workspace can be converged"
|
158
|
-
|
161
|
+
OsUtil.print(error_message, :red)
|
159
162
|
return response.render_table(:violation)
|
160
163
|
end
|
161
164
|
|
@@ -176,9 +179,14 @@ module DTK::Client
|
|
176
179
|
return response unless response.ok?
|
177
180
|
end
|
178
181
|
end
|
182
|
+
unless task_id = response.data(:task_id)
|
183
|
+
if message = response.data(:message)
|
184
|
+
OsUtil.print(message, :yellow)
|
185
|
+
end
|
186
|
+
return Response::Ok.new()
|
187
|
+
end
|
179
188
|
|
180
189
|
# execute task
|
181
|
-
task_id = response.data(:task_id)
|
182
190
|
response = post rest_url("task/execute"), "task_id" => task_id
|
183
191
|
return response unless response.ok?
|
184
192
|
|
@@ -319,7 +327,7 @@ module DTK::Client
|
|
319
327
|
return response unless response.ok?
|
320
328
|
return Response::Ok.new() unless response.data(:any_updates)
|
321
329
|
if dsl_parsing_errors = response.data(:dsl_parsing_errors)
|
322
|
-
error_message = "Module '#{component_module_name}' parsing errors found:\n#{dsl_parsing_errors}\nYou can fix errors using 'edit' command from
|
330
|
+
error_message = "Module '#{component_module_name}' parsing errors found:\n#{dsl_parsing_errors}\nYou can fix errors using 'edit' command from referenced service modules and then invoke 'push-component-module-updates' again from this context.\n"
|
323
331
|
OsUtil.print(error_message, :red)
|
324
332
|
return Response::NoOp.new()
|
325
333
|
end
|
@@ -341,10 +349,11 @@ module DTK::Client
|
|
341
349
|
:module_type => 'component_module'
|
342
350
|
}
|
343
351
|
post_body.merge!(:force => true) if options.force?
|
344
|
-
response = post(rest_url("assembly/
|
352
|
+
response = post(rest_url("assembly/prepare_for_pull_from_base"),post_body)
|
345
353
|
return response unless response.ok?
|
346
354
|
|
347
355
|
if dsl_parsing_errors = response.data(:dsl_parsing_errors)
|
356
|
+
# TODO: DTK-2206; think error message below is incorrect
|
348
357
|
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"
|
349
358
|
OsUtil.print(error_message, :red)
|
350
359
|
return Response::Error.new()
|
@@ -420,8 +429,13 @@ module DTK::Client
|
|
420
429
|
end
|
421
430
|
response = task_status_aux(mode,assembly_or_workspace_id,:assembly,:summarize => options.summarize?)
|
422
431
|
|
423
|
-
|
424
|
-
|
432
|
+
if mode == :stream
|
433
|
+
#no response if ok
|
434
|
+
response unless response.ok?
|
435
|
+
else
|
436
|
+
# TODO: Hack which is necessery for the specific problem (DTK-725),
|
437
|
+
# we don't get proper error message when there is a timeout doing converge
|
438
|
+
|
425
439
|
unless response == true
|
426
440
|
return response.merge("data" => [{ "errors" => {"message" => "Task does not exist for workspace."}}]) unless response["data"]
|
427
441
|
response["data"].each do |data|
|
@@ -430,9 +444,8 @@ module DTK::Client
|
|
430
444
|
end
|
431
445
|
end
|
432
446
|
end
|
447
|
+
response
|
433
448
|
end
|
434
|
-
|
435
|
-
response
|
436
449
|
end
|
437
450
|
|
438
451
|
def task_action_detail_aw_aux(context_params)
|
@@ -534,7 +547,6 @@ module DTK::Client
|
|
534
547
|
assembly_or_workspace_id, dep_cmp, antec_cmp, dependency_name = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID, :option_1!, :option_2!, :option_3], method_argument_names)
|
535
548
|
end
|
536
549
|
|
537
|
-
antec_cmp = "assembly_wide/#{antec_cmp}" unless antec_cmp.include?('/')
|
538
550
|
post_body = {
|
539
551
|
:assembly_id => assembly_or_workspace_id,
|
540
552
|
:input_component_id => dep_cmp,
|
@@ -706,10 +718,10 @@ module DTK::Client
|
|
706
718
|
:pattern => pattern
|
707
719
|
}
|
708
720
|
|
709
|
-
raise
|
721
|
+
raise DtkValidationError, 'Please use only component-attribute (-c) or node-attribute (-n) option' if options.component_attribute? && options.node_attribute?
|
710
722
|
|
711
723
|
# if try to set service instance attribute but using -n option to sepicify it is node attribute, say that node attribute does not exist
|
712
|
-
raise
|
724
|
+
raise DtkError, "[ERROR] Node attribute '#{pattern}' does not exist" if options.node_attribute? && !pattern.include?('/')
|
713
725
|
|
714
726
|
# make sure -c and -n are used only with node or cmp attributes directly on service instance
|
715
727
|
validate_service_instance_node_or_cmp_attrs(pattern, options) if options.component_attribute? || options.node_attribute?
|
@@ -725,7 +737,7 @@ module DTK::Client
|
|
725
737
|
if r_data.is_a?(Hash) && (ambiguous = r_data['ambiguous'])
|
726
738
|
unless ambiguous.empty?
|
727
739
|
msg = "It is ambiguous whether '#{ambiguous.join(', ')}' #{ambiguous.size == 1 ? 'is' : 'are'} node or component attribute(s). Run set-attribute again with one of options -c [--component-attribute] or -n [--node-attribute]."
|
728
|
-
raise
|
740
|
+
raise DtkError, msg
|
729
741
|
end
|
730
742
|
end
|
731
743
|
end
|
@@ -888,6 +900,7 @@ module DTK::Client
|
|
888
900
|
node_id, component_id = component_id.split('/')
|
889
901
|
node_name = node_id
|
890
902
|
else
|
903
|
+
# TODO: update server so dont have to pass in 'assembly_wide'
|
891
904
|
node_id = node_name = 'assembly_wide'
|
892
905
|
end
|
893
906
|
end
|
@@ -916,7 +929,7 @@ module DTK::Client
|
|
916
929
|
}
|
917
930
|
|
918
931
|
response = post(rest_url("assembly/initiate_get_netstats"),post_body)
|
919
|
-
raise
|
932
|
+
raise DtkValidationError, response.data(:errors) if response.data(:errors)
|
920
933
|
return response unless response.ok?
|
921
934
|
|
922
935
|
action_results_id = response.data(:action_results_id)
|
@@ -957,7 +970,7 @@ module DTK::Client
|
|
957
970
|
begin
|
958
971
|
execute_test_tries = Integer(options['timeout'])
|
959
972
|
rescue
|
960
|
-
raise
|
973
|
+
raise DtkValidationError, "Timeout value is not valid"
|
961
974
|
end
|
962
975
|
end
|
963
976
|
|
@@ -969,7 +982,7 @@ module DTK::Client
|
|
969
982
|
|
970
983
|
response = post(rest_url("assembly/initiate_execute_tests"),post_body)
|
971
984
|
|
972
|
-
raise
|
985
|
+
raise DtkValidationError, response.data(:errors) if response.data(:errors)
|
973
986
|
return response unless response.ok?
|
974
987
|
|
975
988
|
action_results_id = response.data(:action_results_id)
|
@@ -1004,9 +1017,9 @@ module DTK::Client
|
|
1004
1017
|
end
|
1005
1018
|
|
1006
1019
|
if (response.data(:results).empty? && options['timeout'].nil?)
|
1007
|
-
raise
|
1020
|
+
raise DtkValidationError, "Could not finish execution of tests in default timeframe (#{execute_test_tries} seconds). Try again with passing --timeout TIMEOUT parameter"
|
1008
1021
|
elsif (response.data(:results).empty? && !options['timeout'].nil?)
|
1009
|
-
raise
|
1022
|
+
raise DtkValidationError, "Could not finish execution of tests in set timeframe (#{execute_test_tries} seconds). Try again with increasing --timeout TIMEOUT parameter"
|
1010
1023
|
else
|
1011
1024
|
response.print_error_table = true
|
1012
1025
|
response.set_data(*response.data(:results))
|
@@ -1026,7 +1039,7 @@ module DTK::Client
|
|
1026
1039
|
}
|
1027
1040
|
|
1028
1041
|
response = post(rest_url("assembly/initiate_get_ps"),post_body)
|
1029
|
-
raise
|
1042
|
+
raise DtkValidationError, response.data(:errors) if response.data(:errors)
|
1030
1043
|
return response unless response.ok?
|
1031
1044
|
|
1032
1045
|
action_results_id = response.data(:action_results_id)
|
@@ -1114,10 +1127,10 @@ module DTK::Client
|
|
1114
1127
|
}
|
1115
1128
|
|
1116
1129
|
response = post rest_url("assembly/initiate_get_log"), post_body
|
1117
|
-
raise
|
1130
|
+
raise DtkValidationError, response.data(:errors) if response.data(:errors)
|
1118
1131
|
|
1119
1132
|
unless response.ok?
|
1120
|
-
raise
|
1133
|
+
raise DtkError, "Error while getting log from server, there was no successful response."
|
1121
1134
|
end
|
1122
1135
|
|
1123
1136
|
action_results_id = response.data(:action_results_id)
|
@@ -1134,7 +1147,7 @@ module DTK::Client
|
|
1134
1147
|
# server has found an error
|
1135
1148
|
unless response.data(:results).nil?
|
1136
1149
|
if response.data(:results)['error']
|
1137
|
-
raise
|
1150
|
+
raise DtkError, response.data(:results)['error']
|
1138
1151
|
end
|
1139
1152
|
end
|
1140
1153
|
|
@@ -1148,7 +1161,7 @@ module DTK::Client
|
|
1148
1161
|
response = response.data(:results).first[1]
|
1149
1162
|
|
1150
1163
|
unless response["error"].nil?
|
1151
|
-
raise
|
1164
|
+
raise DtkError, response["error"]
|
1152
1165
|
end
|
1153
1166
|
|
1154
1167
|
# removing invalid chars from log
|
@@ -1195,7 +1208,7 @@ module DTK::Client
|
|
1195
1208
|
t2.join()
|
1196
1209
|
rescue Interrupt
|
1197
1210
|
t2.exit()
|
1198
|
-
rescue
|
1211
|
+
rescue DtkError => e
|
1199
1212
|
t2.exit()
|
1200
1213
|
raise e
|
1201
1214
|
end
|
@@ -1222,10 +1235,10 @@ module DTK::Client
|
|
1222
1235
|
}
|
1223
1236
|
|
1224
1237
|
response = post rest_url("assembly/initiate_grep"), post_body
|
1225
|
-
raise
|
1238
|
+
raise DtkValidationError, response.data(:errors) if response.data(:errors)
|
1226
1239
|
|
1227
1240
|
unless response.ok?
|
1228
|
-
raise
|
1241
|
+
raise DtkError, "Error while getting log from server. Message: #{response['errors'][0]['message'].nil? ? 'There was no successful response.' : response['errors'].first['message']}"
|
1229
1242
|
end
|
1230
1243
|
|
1231
1244
|
action_results_id = response.data(:action_results_id)
|
@@ -1242,7 +1255,7 @@ module DTK::Client
|
|
1242
1255
|
# server has found an error
|
1243
1256
|
unless response.data(:results).nil?
|
1244
1257
|
if response.data(:results)['error']
|
1245
|
-
raise
|
1258
|
+
raise DtkError, response.data(:results)['error']
|
1246
1259
|
end
|
1247
1260
|
end
|
1248
1261
|
|
@@ -1251,14 +1264,14 @@ module DTK::Client
|
|
1251
1264
|
sleep(1)
|
1252
1265
|
end
|
1253
1266
|
|
1254
|
-
raise
|
1267
|
+
raise DtkError, "Error while logging there was no successful response after 3 tries." unless response.data(:is_complete)
|
1255
1268
|
|
1256
1269
|
console_width = ENV["COLUMNS"].to_i
|
1257
1270
|
|
1258
1271
|
response.data(:results).each do |r|
|
1259
|
-
raise
|
1272
|
+
raise DtkError, r[1]["error"] if r[1]["error"]
|
1260
1273
|
|
1261
|
-
message_colorized =
|
1274
|
+
message_colorized = OsUtil.colorize(r[0].inspect, :green)
|
1262
1275
|
|
1263
1276
|
if r[1]["output"].empty?
|
1264
1277
|
puts "NODE-ID #{message_colorized} - Log does not contain data that matches you pattern #{grep_pattern}!"
|
@@ -1272,7 +1285,7 @@ module DTK::Client
|
|
1272
1285
|
puts r[1]["output"].gsub(/`/,'\'')
|
1273
1286
|
end
|
1274
1287
|
end
|
1275
|
-
rescue
|
1288
|
+
rescue DtkError => e
|
1276
1289
|
raise e
|
1277
1290
|
end
|
1278
1291
|
end
|
@@ -1286,7 +1299,7 @@ module DTK::Client
|
|
1286
1299
|
# we expect action result ID
|
1287
1300
|
response = post rest_url("assembly/start"), post_body
|
1288
1301
|
return response unless response.ok?()
|
1289
|
-
raise
|
1302
|
+
raise DtkValidationError, response.data(:errors).first if response.data(:errors)
|
1290
1303
|
|
1291
1304
|
task_id = response.data(:task_id)
|
1292
1305
|
post rest_url("task/execute"), "task_id" => task_id
|
@@ -1300,7 +1313,7 @@ module DTK::Client
|
|
1300
1313
|
|
1301
1314
|
response = post rest_url("assembly/stop"), post_body
|
1302
1315
|
return response unless response.ok?()
|
1303
|
-
raise
|
1316
|
+
raise DtkValidationError, response.data(:errors).first if response.data(:errors)
|
1304
1317
|
|
1305
1318
|
response
|
1306
1319
|
end
|
@@ -1365,7 +1378,7 @@ module DTK::Client
|
|
1365
1378
|
rest_endpoint = "assembly/info_about"
|
1366
1379
|
|
1367
1380
|
if context_params.is_last_command_eql_to?(:attribute)
|
1368
|
-
raise
|
1381
|
+
raise DtkError, "Not supported command for current context level." if attribute_id
|
1369
1382
|
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
1370
1383
|
elsif context_params.is_last_command_eql_to?(:component)
|
1371
1384
|
if component_id
|
@@ -1420,9 +1433,9 @@ module DTK::Client
|
|
1420
1433
|
split_pattern = pattern.split('/')
|
1421
1434
|
return if split_pattern.size == 2
|
1422
1435
|
if options.node_attribute?
|
1423
|
-
raise
|
1436
|
+
raise DtkError, 'Please use -n option only with service instance node attributes (node_name/attribute_name)'
|
1424
1437
|
elsif options.component_attribute?
|
1425
|
-
raise
|
1438
|
+
raise DtkError, 'Please use -c option only with service instance component attributes (cmp_name/attribute_name)'
|
1426
1439
|
end
|
1427
1440
|
end
|
1428
1441
|
end
|
@@ -28,13 +28,21 @@ module DTK::Client
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# check whether a local module exists to determine whether pull from local clone or try to pull from server
|
31
|
-
OsUtil.print("Pulling changes from remote: #{remote_params[:remote_repo]} @ #{remote_params[:remote_repo_url]}")
|
31
|
+
# TODO: probably remove OsUtil.print("Pulling changes from remote: #{remote_params[:remote_repo]} @ #{remote_params[:remote_repo_url]}")
|
32
32
|
|
33
33
|
if Helper(:git_repo).local_clone_dir_exists?(module_type,module_name,:full_module_name=>full_module_name,:version=>version)
|
34
34
|
unless rsa_pub_key
|
35
35
|
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)"
|
36
36
|
end
|
37
|
-
|
37
|
+
# making :merge_if_no_conflict the default (when force not set)
|
38
|
+
merge_if_no_conflict = (opts[:force] ? nil : true)
|
39
|
+
opts_perform_locally = remote_params.merge(
|
40
|
+
:full_module_name => full_module_name,
|
41
|
+
:force => opts[:force],
|
42
|
+
:merge_if_no_conflict => merge_if_no_conflict,
|
43
|
+
:do_not_raise => opts[:do_not_raise],
|
44
|
+
:ignore_dependency_merge_conflict => opts[:ignore_dependency_merge_conflict]
|
45
|
+
)
|
38
46
|
PullFromRemote.perform_locally(self,module_type,module_id,module_name,opts_perform_locally)
|
39
47
|
else
|
40
48
|
# TODO: see if this works correctly
|
@@ -100,7 +108,7 @@ module DTK::Client
|
|
100
108
|
puts "Changes pulled from remote"
|
101
109
|
end
|
102
110
|
|
103
|
-
|
111
|
+
response
|
104
112
|
end
|
105
113
|
|
106
114
|
def self.perform_on_server(cmd_obj,module_type,module_id,module_name,remote_params)
|