dtk-client 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dtk-puppet +3 -2
- data/lib/cli/command/module/delete_from_remote.rb +1 -1
- data/lib/cli/command/module/list_assemblies.rb +1 -1
- data/lib/cli/command/module/list_remotes.rb +1 -1
- data/lib/cli/command/module/pull_dtkn.rb +4 -3
- data/lib/cli/command/service.rb +3 -0
- data/lib/cli/command/service/converge.rb +6 -1
- data/lib/cli/command/service/delete.rb +1 -1
- data/lib/cli/command/service/exec.rb +4 -4
- data/lib/cli/command/service/exec_sync.rb +2 -6
- data/lib/cli/command/service/link.rb +52 -0
- data/lib/cli/command/service/list_actions.rb +1 -1
- data/lib/cli/command/service/list_attributes.rb +1 -1
- data/lib/cli/command/service/list_component_links.rb +1 -1
- data/lib/cli/command/service/list_components.rb +1 -1
- data/lib/cli/command/service/list_dependencies.rb +1 -1
- data/lib/cli/command/service/list_nodes.rb +1 -1
- data/lib/cli/command/service/list_violations.rb +1 -1
- data/lib/cli/command/service/violation.rb +33 -0
- data/lib/cli/command/token.rb +6 -1
- data/lib/cli/runner.rb +7 -2
- data/lib/cli/version.rb +1 -1
- data/lib/client/error.rb +7 -2
- data/lib/client/operation/client_module_dir.rb +4 -4
- data/lib/client/operation/module/install/dependent_modules.rb +2 -2
- data/lib/client/operation/module/pull_dtkn.rb +10 -2
- data/lib/client/operation/module/push.rb +13 -2
- data/lib/client/operation/module/stage.rb +2 -2
- data/lib/client/operation/service.rb +1 -0
- data/lib/client/operation/service/converge.rb +0 -15
- data/lib/client/operation/service/exec.rb +0 -5
- data/lib/client/operation/service/link.rb +51 -0
- data/lib/client/operation/service/stage.rb +1 -1
- data/lib/client/operation/service/uninstall.rb +7 -5
- data/lib/client/render.rb +32 -15
- data/lib/client/response.rb +4 -0
- data/lib/client/response/error_handler.rb +2 -2
- data/lib/client/service_and_component_info/transform_from/info.rb +11 -1
- data/lib/client/service_and_component_info/transform_from/info/component.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 254aaacc97b6cc8dde9c36ad4b06d0af2cda66b1
|
4
|
+
data.tar.gz: bb1fe62fcd2014f790ecab9a9b13aecbda698cd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7c6b9d6679aa46239b60d9db561a1532c658a10f19b1df5eb963f7f7d62ff3996944a8a33a13fddcd63b3525be8f4f008e238bea58d77533148e21a6157c68e
|
7
|
+
data.tar.gz: 18961ad5eb9205cfd73207d605469eeda4c0e16086a1fcbe630865cd9de40843db4871e768b8cc7034889701f8db686249cc6e7db0ad48cff765e4a013c9cf35
|
data/bin/dtk-puppet
CHANGED
@@ -25,7 +25,7 @@ module DTK
|
|
25
25
|
#dtk_dsl must be loaded after GlobalForDSL set
|
26
26
|
require 'dtk_dsl'
|
27
27
|
|
28
|
-
Client::Error.top_level_trap_error do
|
28
|
+
return_code = Client::Error.top_level_trap_error do
|
29
29
|
begin
|
30
30
|
require 'puppet'
|
31
31
|
rescue LoadError => e
|
@@ -35,4 +35,5 @@ module DTK
|
|
35
35
|
require_relative '../lib/dtk_puppet'
|
36
36
|
Puppet::Parser.parse(ARGV)
|
37
37
|
end
|
38
|
-
|
38
|
+
exit return_code
|
39
|
+
end
|
@@ -20,7 +20,7 @@ module DTK::Client
|
|
20
20
|
module Module
|
21
21
|
subcommand_def 'delete-from-remote' do |c|
|
22
22
|
c.arg Token::Arg.module_name
|
23
|
-
command_body c, 'delete-from-
|
23
|
+
command_body c, 'delete-from-dtkn', 'Delete module from the DTK remote catalog (DTKN)' do |sc|
|
24
24
|
sc.flag Token.version
|
25
25
|
sc.switch Token.skip_prompt
|
26
26
|
|
@@ -19,7 +19,7 @@ module DTK::Client
|
|
19
19
|
module CLI::Command
|
20
20
|
module Module
|
21
21
|
subcommand_def 'list-assemblies' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'assemblies', 'List assemblies from all modules or specified module' do |sc|
|
23
23
|
sc.switch Token.all, :desc => 'List assemblies from all modules'
|
24
24
|
sc.flag Token.directory_path
|
25
25
|
sc.action do |_global_options, options, _args|
|
@@ -19,7 +19,7 @@ module DTK::Client
|
|
19
19
|
module CLI::Command
|
20
20
|
module Module
|
21
21
|
subcommand_def 'list-remotes' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'dtkn', 'List remote modules' do |sc|
|
23
23
|
sc.flag Token.namespace
|
24
24
|
sc.action do |_global_options, options, args|
|
25
25
|
arg = {}
|
@@ -21,8 +21,8 @@ module DTK::Client
|
|
21
21
|
subcommand_def 'pull-dtkn' do |c|
|
22
22
|
command_body c, 'pull-dtkn', 'Pull content from repo manager to client module directory and push to server' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to module directory containing content to update; not need if in the module directory'
|
24
|
-
sc.switch Token.skip_prompt
|
25
24
|
sc.switch Token.force
|
25
|
+
sc.switch Token.update_deps
|
26
26
|
sc.action do |_global_options, options, _args|
|
27
27
|
module_ref = module_ref_object_from_options_or_context(options)
|
28
28
|
operation_args = {
|
@@ -30,8 +30,9 @@ module DTK::Client
|
|
30
30
|
:base_dsl_file_obj => @base_dsl_file_obj,
|
31
31
|
:has_directory_param => !options["d"].nil?,
|
32
32
|
:directory_path => options[:directory_path],
|
33
|
-
|
34
|
-
:force => options[:f]
|
33
|
+
#:skip_prompt => options[:skip_prompt],
|
34
|
+
:force => options[:f],
|
35
|
+
:update_deps => options[:update_deps]
|
35
36
|
}
|
36
37
|
Operation::Module.pull_dtkn(operation_args)
|
37
38
|
Operation::Module.push(operation_args.merge(:method => "pulled"))
|
data/lib/cli/command/service.rb
CHANGED
@@ -19,6 +19,8 @@ module DTK::Client
|
|
19
19
|
module CLI
|
20
20
|
module Command
|
21
21
|
module Service
|
22
|
+
require_relative('service/violation')
|
23
|
+
|
22
24
|
include Command::Mixin
|
23
25
|
ALL_SUBCOMMANDS = [
|
24
26
|
'clone',
|
@@ -37,6 +39,7 @@ module DTK::Client
|
|
37
39
|
'list-components',
|
38
40
|
'list-nodes',
|
39
41
|
'list-violations',
|
42
|
+
'link',
|
40
43
|
# 'start',
|
41
44
|
# 'stop',
|
42
45
|
'cancel-task',
|
@@ -30,7 +30,12 @@ module DTK::Client; module CLI
|
|
30
30
|
:force => force,
|
31
31
|
:module_dir => @base_dsl_file_obj.parent_dir
|
32
32
|
}
|
33
|
-
Operation::Service.converge(args)
|
33
|
+
response = Operation::Service.converge(args)
|
34
|
+
if violation_response = Violation.process_violations?(response)
|
35
|
+
violation_response
|
36
|
+
end
|
37
|
+
nil
|
38
|
+
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -29,7 +29,7 @@ module DTK::Client; module CLI
|
|
29
29
|
directory_path = options[:directory_path]
|
30
30
|
purge = options[:purge]
|
31
31
|
recursive = options[:recursive]
|
32
|
-
force = options[:
|
32
|
+
force = options[:f]
|
33
33
|
service_instance = service_instance_in_options_or_context(options)
|
34
34
|
|
35
35
|
args = {
|
@@ -41,11 +41,11 @@ module DTK::Client
|
|
41
41
|
|
42
42
|
response = Operation::Service.exec(args)
|
43
43
|
|
44
|
-
if
|
45
|
-
|
46
|
-
response.data.flatten!
|
47
|
-
response.set_render_as_table!
|
44
|
+
if violation_response = Violation.process_violations?(response)
|
45
|
+
violation_response
|
48
46
|
end
|
47
|
+
nil
|
48
|
+
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -42,14 +42,10 @@ module DTK::Client
|
|
42
42
|
unless response.ok?
|
43
43
|
response
|
44
44
|
else
|
45
|
-
# TODO: break if any exceptions
|
46
|
-
|
47
45
|
if response.data(:empty_workflow)
|
48
46
|
Response::Ok.new
|
49
|
-
elsif
|
50
|
-
|
51
|
-
response.data.flatten!
|
52
|
-
response.set_render_as_table!
|
47
|
+
elsif violation_response = Violation.process_violations?(response)
|
48
|
+
violation_response
|
53
49
|
else
|
54
50
|
Operation::Service.task_status(args.merge(:mode => 'stream'))
|
55
51
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::Client; module CLI
|
19
|
+
module Command
|
20
|
+
module Service
|
21
|
+
subcommand_def 'link' do |c|
|
22
|
+
c.arg Token::Arg.base_cmp
|
23
|
+
c.arg Token::Arg.deps_on_cmp
|
24
|
+
c.arg Token::Arg.service, :optional => true
|
25
|
+
command_body c, 'link', 'List component links in the service instance.' do |sc|
|
26
|
+
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
27
|
+
sc.flag Token.link_name
|
28
|
+
sc.switch Token.unlink
|
29
|
+
|
30
|
+
sc.action do |_global_options, options, _args|
|
31
|
+
base_component = _args[0]
|
32
|
+
dependent_component = _args[1]
|
33
|
+
service = _args[2]
|
34
|
+
service_instance = service_instance_in_options_or_context(options)
|
35
|
+
link_name = options[:l] unless options[:l].nil?
|
36
|
+
|
37
|
+
args = {
|
38
|
+
:service_instance => service_instance,
|
39
|
+
:unlink => options["u"],
|
40
|
+
:base_component => base_component,
|
41
|
+
:dependent_component => dependent_component,
|
42
|
+
:service => service,
|
43
|
+
:link_name => link_name
|
44
|
+
}
|
45
|
+
|
46
|
+
Operation::Service.link(args)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end; end
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-actions' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'actions', 'List the actions defined on components in the service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
sc.flag Token.type, :desc => 'Filter actions based on type (service, component)'
|
25
25
|
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-attributes' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'attributes', 'List attributes associated with service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
sc.flag Token.node, :desc => 'Filter attributes by node'
|
25
25
|
sc.flag Token.format
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-component-links' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'links', 'List component links in the service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
|
25
25
|
sc.action do |_global_options, options, _args|
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-components' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'components', 'List components associated with the service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
sc.switch Token.dependencies, :desc => 'Show dependencies'
|
25
25
|
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-dependencies' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'dependencies', 'List dependent modules associated with service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
|
25
25
|
sc.action do |_global_options, options, _args|
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-nodes' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'nodes', 'List nodes associated with the service instance.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
|
25
25
|
sc.action do |_global_options, options, _args|
|
@@ -19,7 +19,7 @@ module DTK::Client; module CLI
|
|
19
19
|
module Command
|
20
20
|
module Service
|
21
21
|
subcommand_def 'list-violations' do |c|
|
22
|
-
command_body c, '
|
22
|
+
command_body c, 'violations', ' Finds violations that must be corrected before converging the service instance or running the specified action.' do |sc|
|
23
23
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
|
24
24
|
|
25
25
|
sc.action do |_global_options, options, _args|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::Client
|
19
|
+
module CLI::Command::Service
|
20
|
+
module Violation
|
21
|
+
def self.process_violations?(response)
|
22
|
+
if violations = response.data(:violations)
|
23
|
+
OsUtil.print_error("Cannot execute an action or workflow if there are violations:")
|
24
|
+
response.set_data(violations)
|
25
|
+
response.data.flatten!
|
26
|
+
response.set_render_as_table!.render_data
|
27
|
+
Response::NotOk.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/cli/command/token.rb
CHANGED
@@ -48,6 +48,7 @@ module DTK::Client
|
|
48
48
|
:mode => Flag.new(:mode, 'MODE', 'Mode'),
|
49
49
|
:namespace => Flag.new(:n, 'NAMESPACE', 'Namespace'),
|
50
50
|
:uninstall_name => Flag.new(:name, 'NAME', 'Module name to uninstall'),
|
51
|
+
:link_name => Flag.new([:l, :link_name], 'link-name', 'Specify link name'),
|
51
52
|
:format => Flag.new(:format, 'FORMAT', 'Choose in which format to display data (ex. TABLE, YAML)'),
|
52
53
|
|
53
54
|
# switches
|
@@ -60,6 +61,7 @@ module DTK::Client
|
|
60
61
|
:skip_prompt => Switch.new(:y, 'Skip prompt'),
|
61
62
|
:target => Switch.new(:target, 'Create target service instance'),
|
62
63
|
:links => Switch.new(:links, 'Links'),
|
64
|
+
:unlink => Switch.new([:u, :unlink], 'unlink'),
|
63
65
|
:dependencies => Switch.new(:deps, 'Dependencies'),
|
64
66
|
:u => Switch.new([:u, :unset], 'Unset attribute'),
|
65
67
|
:recursive => Switch.new(:r, 'Recursive'),
|
@@ -80,7 +82,10 @@ module DTK::Client
|
|
80
82
|
:keypair_name => 'KEYPAIR-NAME',
|
81
83
|
:attribute_value => 'VALUE',
|
82
84
|
:component_ref => 'COMPONENT-REF',
|
83
|
-
:format => 'FORMAT'
|
85
|
+
:format => 'FORMAT',
|
86
|
+
:base_cmp => 'BASE-COMPONENT',
|
87
|
+
:deps_on_cmp => 'DEPENDS-ON-COMPONENT',
|
88
|
+
:service => 'SERVICE'
|
84
89
|
}
|
85
90
|
|
86
91
|
end
|
data/lib/cli/runner.rb
CHANGED
@@ -22,7 +22,8 @@ module DTK::Client
|
|
22
22
|
require_relative('runner/dtkn_access')
|
23
23
|
|
24
24
|
def self.run(argv)
|
25
|
-
Error.top_level_trap_error do
|
25
|
+
return_code = Error.top_level_trap_error do
|
26
|
+
ret = 0
|
26
27
|
Configurator.check_git
|
27
28
|
Configurator.create_missing_client_dirs
|
28
29
|
|
@@ -39,8 +40,12 @@ module DTK::Client
|
|
39
40
|
if response_obj = context.run_and_return_response_object(argv)
|
40
41
|
# render_response will raise Error in case of error response
|
41
42
|
render_response(response_obj)
|
43
|
+
# response_obj can have not ok stateto signal to exit with error
|
44
|
+
ret = Error::GENERIC_ERROR_RETURN_CODE if response_obj.notok?
|
42
45
|
end
|
46
|
+
ret
|
43
47
|
end
|
48
|
+
exit return_code
|
44
49
|
end
|
45
50
|
|
46
51
|
private
|
@@ -72,7 +77,7 @@ module DTK::Client
|
|
72
77
|
end
|
73
78
|
|
74
79
|
def self.render_response(response_obj)
|
75
|
-
Response::ErrorHandler.
|
80
|
+
Response::ErrorHandler.raise_if_error_info(response_obj)
|
76
81
|
response_obj.render_data
|
77
82
|
end
|
78
83
|
|
data/lib/cli/version.rb
CHANGED
data/lib/client/error.rb
CHANGED
@@ -26,22 +26,27 @@ module DTK::Client
|
|
26
26
|
@backtrace = opts[:backtrace]
|
27
27
|
end
|
28
28
|
|
29
|
+
GENERIC_ERROR_RETURN_CODE = 1
|
30
|
+
# returns return code
|
29
31
|
def self.top_level_trap_error(&body)
|
30
32
|
begin
|
31
33
|
yield
|
32
34
|
rescue InvalidConnection => e
|
33
35
|
e.print_warning
|
34
36
|
puts "\nDTK will now exit. Please set up your connection properly and try again."
|
35
|
-
|
37
|
+
GENERIC_ERROR_RETURN_CODE
|
38
|
+
rescue Error => e
|
36
39
|
# If vanilla error treat like client error
|
37
40
|
if e.class == Error
|
38
41
|
e = convert_to_client_error(e)
|
39
42
|
end
|
40
43
|
Logger.instance.error_pp(e.message, e.backtrace?)
|
44
|
+
GENERIC_ERROR_RETURN_CODE
|
41
45
|
rescue Exception => exception
|
42
46
|
# If treat like client error
|
43
47
|
e = convert_to_client_error(exception)
|
44
48
|
Logger.instance.error_pp(e.message, e.backtrace?)
|
49
|
+
GENERIC_ERROR_RETURN_CODE
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
@@ -55,7 +60,7 @@ module DTK::Client
|
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
58
|
-
def self.
|
63
|
+
def self.raise_if_error_info(response, opts = {})
|
59
64
|
# check for errors in response
|
60
65
|
error = response.error_info?(opts)
|
61
66
|
return unless error
|
@@ -41,9 +41,9 @@ module DTK::Client
|
|
41
41
|
# FileUtils.mv(target_repo_dir, backup_dir)
|
42
42
|
# OsUtil.print_warning("Backup of existing module directory moved to '#{backup_dir}'")
|
43
43
|
# else
|
44
|
-
# raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or
|
44
|
+
# raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or moved before retrying the command"
|
45
45
|
#end
|
46
|
-
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or
|
46
|
+
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or moved before retrying the command" unless (Dir.entries(path) - %w{ . .. }).empty?
|
47
47
|
return path
|
48
48
|
end
|
49
49
|
end
|
@@ -71,7 +71,7 @@ module DTK::Client
|
|
71
71
|
if opts[:remove_existing]
|
72
72
|
FileUtils.rm_rf(path)
|
73
73
|
else
|
74
|
-
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or
|
74
|
+
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or moved before retrying the command" unless (Dir.entries(path) - %w{ . .. }).empty?
|
75
75
|
return path
|
76
76
|
end
|
77
77
|
end
|
@@ -85,7 +85,7 @@ module DTK::Client
|
|
85
85
|
if opts[:remove_existing]
|
86
86
|
FileUtils.rm_rf(path)
|
87
87
|
else
|
88
|
-
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or
|
88
|
+
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or moved before retrying the command" unless (Dir.entries(path) - %w{ . .. }).empty?
|
89
89
|
return path
|
90
90
|
end
|
91
91
|
end
|
@@ -56,12 +56,12 @@ module DTK::Client
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def install
|
59
|
-
@print_helper.print_getting_dependencies
|
59
|
+
@print_helper.print_getting_dependencies unless @prompt_helper.update_none
|
60
60
|
unified_module_refs = get_unified_dependent_module_refs
|
61
61
|
unless unified_module_refs.empty?
|
62
62
|
case @opts[:mode]
|
63
63
|
when 'pull'
|
64
|
-
@print_helper.print_pulling_dependencies
|
64
|
+
@print_helper.print_pulling_dependencies unless @prompt_helper.update_none
|
65
65
|
else
|
66
66
|
@print_helper.print_installing_dependencies
|
67
67
|
end
|
@@ -43,6 +43,14 @@ module DTK::Client
|
|
43
43
|
has_directory_param = args[:has_directory_param]
|
44
44
|
skip_prompt = args[:skip_prompt]
|
45
45
|
force = args[:force]
|
46
|
+
update_deps = args[:update_deps]
|
47
|
+
|
48
|
+
case update_deps
|
49
|
+
when "prompt"
|
50
|
+
update_deps = nil
|
51
|
+
when false
|
52
|
+
no_update_deps = true
|
53
|
+
end
|
46
54
|
|
47
55
|
if has_directory_param
|
48
56
|
file_obj = base_dsl_file_obj.raise_error_if_no_content_flag(:module_ref)
|
@@ -50,7 +58,7 @@ module DTK::Client
|
|
50
58
|
file_obj = base_dsl_file_obj.raise_error_if_no_content
|
51
59
|
end
|
52
60
|
|
53
|
-
new('dtkn', module_ref, directory_path, version, file_obj).pull_dtkn(:
|
61
|
+
new('dtkn', module_ref, directory_path, version, file_obj).pull_dtkn(:update_deps => update_deps, :no_update_deps => no_update_deps, :force => force)
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -78,7 +86,7 @@ module DTK::Client
|
|
78
86
|
|
79
87
|
unless dependent_modules.empty?
|
80
88
|
begin
|
81
|
-
Install::DependentModules.install(@module_ref, dependent_modules, :
|
89
|
+
Install::DependentModules.install(@module_ref, dependent_modules, :update_deps => opts[:update_deps], :no_update_deps => opts[:no_update_deps] , :mode => 'pull')
|
82
90
|
# Install::DependentModules.install(@module_ref, dependent_modules, :skip_prompt => false, :mode => 'pull')
|
83
91
|
rescue Install::TerminateInstall
|
84
92
|
@print_helper.print_terminated_pulling
|
@@ -54,7 +54,10 @@ module DTK::Client
|
|
54
54
|
|
55
55
|
response = rest_post("#{BaseRoute}/update_from_repo", post_body)
|
56
56
|
|
57
|
+
existing_diffs = nil
|
58
|
+
print = nil
|
57
59
|
if missing_dependencies = response.data(:missing_dependencies)
|
60
|
+
force_parse = false
|
58
61
|
unless missing_dependencies.empty?
|
59
62
|
dependent_modules = missing_dependencies.map { |dependency| Install::ModuleRef.new(:namespace => dependency['namespace_name'], :module_name => dependency['display_name'], :version => dependency['version_info']) }
|
60
63
|
begin
|
@@ -63,10 +66,18 @@ module DTK::Client
|
|
63
66
|
@print_helper.print_terminated_installation
|
64
67
|
return nil
|
65
68
|
end
|
69
|
+
existing_diffs = response.data(:existing_diffs)
|
70
|
+
force_parse = true
|
66
71
|
end
|
67
|
-
response = rest_post("#{BaseRoute}/update_from_repo", post_body.merge(:skip_missing_check => true))
|
72
|
+
response = rest_post("#{BaseRoute}/update_from_repo", post_body.merge(:skip_missing_check => true, force_parse: force_parse))
|
73
|
+
end
|
74
|
+
|
75
|
+
diffs = response.data(:diffs)
|
76
|
+
if diffs && !diffs.empty?
|
77
|
+
print = process_semantic_diffs(diffs, method)
|
78
|
+
else
|
79
|
+
print = process_semantic_diffs(existing_diffs, method)
|
68
80
|
end
|
69
|
-
print = process_semantic_diffs(response.data(:diffs), method)
|
70
81
|
|
71
82
|
# if diffs is nil then indicate no diffs, otherwise render diffs in yaml
|
72
83
|
OsUtil.print_info("No Diffs to be #{method}.") if response.data(:diffs).nil? || !print
|
@@ -40,7 +40,7 @@ module DTK::Client
|
|
40
40
|
service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
|
41
41
|
base_path = ClientModuleDir.ret_base_path(:service, service_name)
|
42
42
|
|
43
|
-
raise Error::Usage, "Directory '#{base_path}' is not empty; it must be deleted or
|
43
|
+
raise Error::Usage, "Directory '#{base_path}' is not empty; it must be deleted or moved before retrying the command" if ClientModuleDir.local_dir_exists?(:service, service_name)
|
44
44
|
|
45
45
|
post_body.merge!(:service_name => service_name)
|
46
46
|
response = rest_post("#{BaseRoute}/stage", post_body)
|
@@ -62,4 +62,4 @@ module DTK::Client
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
-
end
|
65
|
+
end
|
@@ -30,25 +30,10 @@ module DTK::Client
|
|
30
30
|
|
31
31
|
error_msg = "To allow converge to go through, invoke 'dtk push' to push the changes to server before invoking converge again"
|
32
32
|
GitRepo.modified_with_diff?(module_dir, { :error_msg => error_msg, :command => 'converge' }) unless force
|
33
|
-
violations = find_violations(service_instance)
|
34
|
-
return violations if violations
|
35
33
|
|
36
34
|
rest_post("#{BaseRoute}/#{service_instance}/converge", post_body)
|
37
35
|
end
|
38
36
|
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def self.find_violations(service_instance)
|
43
|
-
violations_response = rest_get("#{BaseRoute}/#{service_instance}/violations")
|
44
|
-
|
45
|
-
if violations_response.data and violations_response.data.size > 0
|
46
|
-
OsUtil.print_error("The following violations were found; they must be corrected before workspace can be converged")
|
47
|
-
return violations_response.set_render_as_table!
|
48
|
-
end
|
49
|
-
|
50
|
-
nil
|
51
|
-
end
|
52
37
|
end
|
53
38
|
end
|
54
39
|
end
|
@@ -66,11 +66,6 @@ module DTK::Client
|
|
66
66
|
return Response::Ok.new('empty_workflow' => true)
|
67
67
|
end
|
68
68
|
|
69
|
-
if response.data(:violations)
|
70
|
-
OsUtil.print_error("Cannot execute an action or workflow if there are violations:")
|
71
|
-
return response.set_render_as_table!
|
72
|
-
end
|
73
|
-
|
74
69
|
response
|
75
70
|
end
|
76
71
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::Client
|
19
|
+
class Operation::Service
|
20
|
+
class Link < self
|
21
|
+
def self.execute(args = Args.new)
|
22
|
+
wrap_operation(args) do |args|
|
23
|
+
service_instance = args.required(:service_instance)
|
24
|
+
unlink = args.required(:unlink)
|
25
|
+
base_component = args.required(:base_component)
|
26
|
+
dependent_component = args.required(:dependent_component)
|
27
|
+
service = args[:service]
|
28
|
+
link_name = args[:link_name]
|
29
|
+
|
30
|
+
query_string_hash = QueryStringHash.new(
|
31
|
+
:unlink => unlink,
|
32
|
+
:base_component => base_component,
|
33
|
+
:dep_component => dependent_component,
|
34
|
+
:service => service,
|
35
|
+
:link_name => link_name
|
36
|
+
)
|
37
|
+
|
38
|
+
response = rest_post("#{BaseRoute}/#{service_instance}/link", query_string_hash)
|
39
|
+
|
40
|
+
repo_info_args = Args.new(
|
41
|
+
:service_instance => service_instance,
|
42
|
+
:branch => response.required(:branch, :name),
|
43
|
+
:repo_url => response.required(:repo, :url)
|
44
|
+
)
|
45
|
+
ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args)
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -39,7 +39,7 @@ module DTK::Client
|
|
39
39
|
service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
|
40
40
|
base_path = ClientModuleDir.ret_base_path(:service, service_name)
|
41
41
|
|
42
|
-
raise Error::Usage, "Directory '#{base_path}' is not empty; it must be deleted or
|
42
|
+
raise Error::Usage, "Directory '#{base_path}' is not empty; it must be deleted or moved before retrying the command" if ClientModuleDir.local_dir_exists?(:service, service_name)
|
43
43
|
|
44
44
|
post_body.merge!(:service_name => service_name)
|
45
45
|
response = rest_post("#{BaseRoute}/create", post_body)
|
@@ -26,9 +26,14 @@ module DTK::Client
|
|
26
26
|
force = args.required(:force)
|
27
27
|
path = args[:directory_path]
|
28
28
|
node = []
|
29
|
+
msg = "Are you sure you want to uninstall the infrastructure associated with '#{service_instance}' and delete this service instance from the server?"
|
30
|
+
|
31
|
+
if force
|
32
|
+
msg.prepend("Note: this will not terminate aws instances, you will have to do that manually!\n")
|
33
|
+
end
|
29
34
|
|
30
35
|
unless args[:skip_prompt]
|
31
|
-
return false unless Console.prompt_yes_no(
|
36
|
+
return false unless Console.prompt_yes_no(msg, :add_options => true)
|
32
37
|
end
|
33
38
|
|
34
39
|
post_body = PostBody.new(
|
@@ -46,10 +51,7 @@ module DTK::Client
|
|
46
51
|
OsUtil.print_info(message)
|
47
52
|
end
|
48
53
|
else
|
49
|
-
msg = "DTK
|
50
|
-
if force
|
51
|
-
msg += "\nNote: this will not terminate aws instances, you will have to do that manually!"
|
52
|
-
end
|
54
|
+
msg = "DTK service '#{service_instance}' has been uninstalled successfully."
|
53
55
|
OsUtil.print_info(msg)
|
54
56
|
end
|
55
57
|
end
|
data/lib/client/render.rb
CHANGED
@@ -49,26 +49,43 @@ module DTK::Client
|
|
49
49
|
#
|
50
50
|
# value returned is Boolean indicating whether any additional print needed
|
51
51
|
def self.render(ruby_obj, opts = {})
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
ruby_obj
|
65
|
-
|
66
|
-
|
52
|
+
wrap_to_handle_warning_message(ruby_obj) do |ruby_obj|
|
53
|
+
render_type = opts[:render_type]
|
54
|
+
if render_type == Type::TABLE
|
55
|
+
render_opts = {
|
56
|
+
:print_error_table => opts[:print_error_table],
|
57
|
+
:footnote => opts[:footnote]
|
58
|
+
}
|
59
|
+
get_adapter(Type::TABLE, opts).render(ruby_obj, render_opts)
|
60
|
+
elsif ruby_obj.kind_of?(::Hash)
|
61
|
+
get_adapter(render_type, opts).render(ruby_obj)
|
62
|
+
elsif ruby_obj.kind_of?(::Array)
|
63
|
+
get_adapter(render_type, opts).render(ruby_obj)
|
64
|
+
elsif ruby_obj.kind_of?(::String)
|
65
|
+
ruby_obj
|
66
|
+
else
|
67
|
+
raise Error.new('ruby_obj has unexpected type')
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
72
|
private
|
71
73
|
|
74
|
+
WARNING_KEY = 'warn'
|
75
|
+
def self.wrap_to_handle_warning_message(ruby_obj, &body)
|
76
|
+
warning_message = nil
|
77
|
+
passed_ruby_obj = ruby_obj
|
78
|
+
|
79
|
+
if ruby_obj.kind_of?(::Hash)
|
80
|
+
if warning_message = ruby_obj[WARNING_KEY]
|
81
|
+
# remove warning key
|
82
|
+
passed_ruby_obj = ruby_obj.inject({}) { |h, (k, v)| h.merge(k == WARNING_KEY ? {} : { k => v }) }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
body.call(passed_ruby_obj)
|
86
|
+
OsUtil.print_warning(warning_message) if warning_message
|
87
|
+
end
|
88
|
+
|
72
89
|
def render_text(text)
|
73
90
|
STDOUT << text
|
74
91
|
end
|
data/lib/client/response.rb
CHANGED
@@ -18,8 +18,8 @@
|
|
18
18
|
module DTK::Client
|
19
19
|
class Response
|
20
20
|
module ErrorHandler
|
21
|
-
def self.
|
22
|
-
Error.
|
21
|
+
def self.raise_if_error_info(response)
|
22
|
+
Error.raise_if_error_info(response)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.check_for_session_expiried(response)
|
@@ -54,11 +54,21 @@ module DTK::Client
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def module_refs_path
|
57
|
-
matches =
|
57
|
+
matches = dsl_file_matches { |path| module_ref_input_files_processor.match?(path) }
|
58
58
|
raise Error, "Unexpected that multiple module ref files" if matches.size > 1
|
59
59
|
matches.first
|
60
60
|
end
|
61
61
|
|
62
|
+
def dsl_file_matches(&block)
|
63
|
+
# TODO: maybe better to solve by restricting directory_file_paths to be least_nested_pos of 2
|
64
|
+
matches = directory_file_paths.select { |path| block.call(path) }
|
65
|
+
if matches.size > 1
|
66
|
+
least_nested_pos = matches.map { |match| match.split('/').size }.min
|
67
|
+
matches.reject! { |match| match.split('/').size != least_nested_pos }
|
68
|
+
end
|
69
|
+
matches
|
70
|
+
end
|
71
|
+
|
62
72
|
def module_ref_input_files_processor
|
63
73
|
@module_ref_input_files_processor ||= input_files_processor(:module_refs)
|
64
74
|
end
|
@@ -43,7 +43,7 @@ module DTK::Client
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def component_dsl_path
|
46
|
-
matches =
|
46
|
+
matches = dsl_file_matches { |path| component_dsl_input_files_processor.match?(path) }
|
47
47
|
raise Error::MissingDslFile, "Unexpected that there is not a unique component dsl file" if matches.size != 1
|
48
48
|
matches.first
|
49
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reactor8
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dtk-common-core
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/cli/command/service/eject.rb
|
183
183
|
- lib/cli/command/service/exec.rb
|
184
184
|
- lib/cli/command/service/exec_sync.rb
|
185
|
+
- lib/cli/command/service/link.rb
|
185
186
|
- lib/cli/command/service/list.rb
|
186
187
|
- lib/cli/command/service/list_actions.rb
|
187
188
|
- lib/cli/command/service/list_attributes.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- lib/cli/command/service/stop.rb
|
202
203
|
- lib/cli/command/service/task_status.rb
|
203
204
|
- lib/cli/command/service/uninstall.rb
|
205
|
+
- lib/cli/command/service/violation.rb
|
204
206
|
- lib/cli/command/subcommand.rb
|
205
207
|
- lib/cli/command/token.rb
|
206
208
|
- lib/cli/command/token/arg.rb
|
@@ -291,6 +293,7 @@ files:
|
|
291
293
|
- lib/client/operation/service/edit.rb
|
292
294
|
- lib/client/operation/service/eject.rb
|
293
295
|
- lib/client/operation/service/exec.rb
|
296
|
+
- lib/client/operation/service/link.rb
|
294
297
|
- lib/client/operation/service/list.rb
|
295
298
|
- lib/client/operation/service/list_actions.rb
|
296
299
|
- lib/client/operation/service/list_attributes.rb
|