dtk-client 0.10.7 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/dtk-client.gemspec +2 -2
- data/lib/cli/command/module/install.rb +5 -5
- data/lib/cli/command/service/eject.rb +44 -0
- data/lib/cli/command/service/list_attributes.rb +5 -2
- data/lib/cli/command/service/uninstall.rb +4 -1
- data/lib/cli/command/service.rb +5 -5
- data/lib/cli/command/token.rb +6 -3
- data/lib/cli/version.rb +1 -1
- data/lib/client/conn.rb +6 -1
- data/lib/client/operation/module/install/dependent_modules.rb +2 -2
- data/lib/client/operation/module/install.rb +13 -5
- data/lib/client/operation/module/pull_dtkn.rb +5 -6
- data/lib/client/operation/module/push_dtkn.rb +4 -8
- data/lib/client/operation/service/delete.rb +3 -2
- data/lib/client/operation/service/eject.rb +48 -0
- data/lib/client/operation/service/exec.rb +10 -0
- data/lib/client/operation/service/list_attributes.rb +20 -5
- data/lib/client/operation/service/ssh.rb +14 -16
- data/lib/client/operation/service/uninstall.rb +15 -5
- data/lib/client/operation/service.rb +2 -1
- data/lib/client/render/view/table/processor.rb +15 -6
- metadata +17 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MzliN2I5MzNjMTFkM2Y0OWRhNjM4ZmE3MTYwZWMyMzUzMTNhMzFmMA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3489e815d77b396a9795163b8ce45dd40b7a5ce8
|
4
|
+
data.tar.gz: de1620b5c1de32244743ff3b6f0eedbc6a5d36dd
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDgwNjY3MDE1MzM5NGM5YjBkZGViMTNmZDYyOWE2ZWVhMjQ2ZTk3YjdiNzky
|
11
|
-
YzU1OWU3NmExYjA0NmY5MzRjNDZmMjhiM2MzMWY2OWYzMTY4Y2U=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NWUxNzQ4MWU4NDNiOWQyMDk2NTZkNjE0M2FhYWY2NmE2YjdhOTJhZDA0OGY2
|
14
|
-
YzlhN2E1M2IxYTc3ZDNmM2ViOTVkYWVjY2Y0M2I5ZjBmMzFlMmRlNjU2ZmZj
|
15
|
-
ODc5ZmYyY2RlOTYxM2VlNDFmNmY2ZGRlNzRmYjFlY2U0YzZjNTQ=
|
6
|
+
metadata.gz: 2b9378cf3c0b696f24434c0b0426c2f16a2e319f912d88cfc641d7eb5c826320e3a4d3f5adc8107704260dd5fca51a4a008ce33a4e1a0ef5255fc4ae0e229dfe
|
7
|
+
data.tar.gz: c6cf8079566421eda45d057c9c30ee45a3a1b3a640aa48b751d8490df8e1a8280fc68739fb94684053a9191f03bf27d5c9b629ba0e3a65ed63b07541e981e974
|
data/dtk-client.gemspec
CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
|
20
|
-
spec.add_dependency 'dtk-common-core','0.
|
20
|
+
spec.add_dependency 'dtk-common-core','0.11.0'
|
21
21
|
spec.add_dependency 'gli', '2.13.4'
|
22
22
|
spec.add_dependency 'highline', '1.7.8'
|
23
23
|
spec.add_dependency 'colorize', '0.7.7'
|
24
24
|
spec.add_dependency 'git', '1.2.9'
|
25
25
|
spec.add_dependency 'hirb', '0.7.3'
|
26
26
|
spec.add_dependency 'mime-types', '~> 2.99.3'
|
27
|
-
spec.add_dependency 'dtk-dsl', '~> 1.
|
27
|
+
spec.add_dependency 'dtk-dsl', '~> 1.1.0'
|
28
28
|
|
29
29
|
end
|
@@ -23,14 +23,14 @@ module DTK::Client
|
|
23
23
|
command_body c, :install, 'Install a module on the server from a client directory or from the DTK remote catalog (DTKN)' do |sc|
|
24
24
|
sc.flag Token.version
|
25
25
|
sc.flag Token.directory_path, :desc => 'Absolute or relative path to directory containing content to install'
|
26
|
-
sc.switch Token.
|
26
|
+
sc.switch Token.update_deps
|
27
27
|
|
28
28
|
sc.action do |_global_options, options, args|
|
29
29
|
directory_path = options[:directory_path]
|
30
30
|
version = options[:version]
|
31
|
-
|
32
|
-
|
31
|
+
update_deps = options[:update_deps]
|
33
32
|
has_remote_repo = false
|
33
|
+
|
34
34
|
if module_name = args[0]
|
35
35
|
# reached if installing from dtkn
|
36
36
|
# installs content from dtkn (later probably from other remote catalogs) onto client machine
|
@@ -53,8 +53,8 @@ module DTK::Client
|
|
53
53
|
:module_ref => module_ref,
|
54
54
|
:base_dsl_file_obj => @base_dsl_file_obj,
|
55
55
|
:has_directory_param => !options["d"].nil?,
|
56
|
-
:
|
57
|
-
:
|
56
|
+
:has_remote_repo => has_remote_repo,
|
57
|
+
:update_deps => update_deps
|
58
58
|
}
|
59
59
|
Operation::Module.install(operation_args)
|
60
60
|
end
|
@@ -0,0 +1,44 @@
|
|
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
|
20
|
+
module Service
|
21
|
+
subcommand_def 'eject' do |c|
|
22
|
+
c.arg Token::Arg.component_ref
|
23
|
+
command_body c, :eject, 'Unmanage component ref' do |sc|
|
24
|
+
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory; not need if in the service instance directory'
|
25
|
+
sc.action do |_global_options, options, args|
|
26
|
+
|
27
|
+
service_instance = service_instance_in_options_or_context(options)
|
28
|
+
|
29
|
+
component_ref = args[0]
|
30
|
+
directory_path = options[:d] || @base_dsl_file_obj.parent_dir
|
31
|
+
|
32
|
+
args = {
|
33
|
+
:service_instance => service_instance,
|
34
|
+
:component_ref => component_ref,
|
35
|
+
:directory_path => directory_path
|
36
|
+
}
|
37
|
+
|
38
|
+
Operation::Service.eject(args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -22,8 +22,9 @@ module DTK::Client; module CLI
|
|
22
22
|
command_body c, 'list-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
|
+
sc.flag Token.format
|
25
26
|
sc.flag Token.component, :desc => 'Filter attributes by component'
|
26
|
-
|
27
|
+
#sc.switch Token.all, :desc => 'Get all attributes'
|
27
28
|
sc.switch Token.links, :desc => 'Display attribute links'
|
28
29
|
|
29
30
|
sc.action do |_global_options, options, _args|
|
@@ -33,7 +34,9 @@ module DTK::Client; module CLI
|
|
33
34
|
:service_instance => service_instance,
|
34
35
|
:links => options[:links]||nil,
|
35
36
|
:node => options[:node],
|
36
|
-
:component => options[:component]
|
37
|
+
:component => options[:component],
|
38
|
+
#:all => options[:all],
|
39
|
+
:format => options[:format]
|
37
40
|
}
|
38
41
|
Operation::Service.list_attributes(args)
|
39
42
|
end
|
@@ -26,10 +26,12 @@ module DTK::Client; module CLI
|
|
26
26
|
sc.switch Token.purge, :desc => 'Delete the service instance directory on the client'
|
27
27
|
sc.switch Token.delete, :desc => 'Removes service instance with all nodes and modules'
|
28
28
|
sc.switch Token.recursive, :desc => 'Delete dependent service instances'
|
29
|
+
sc.switch Token.force, :desc => 'Ignore errors and delete service instance. This will not terminate aws instances, you will have to do that manually'
|
29
30
|
sc.action do |_global_options, options, args|
|
30
31
|
directory_path = options[:directory_path]
|
31
32
|
purge = options[:purge]
|
32
33
|
delete = options[:delete]
|
34
|
+
force = options[:f]
|
33
35
|
recursive = options[:recursive]
|
34
36
|
name = options[:uninstall_name]
|
35
37
|
|
@@ -49,7 +51,8 @@ module DTK::Client; module CLI
|
|
49
51
|
:directory_path => directory_path,
|
50
52
|
:purge => purge,
|
51
53
|
:delete => delete,
|
52
|
-
:recursive => recursive
|
54
|
+
:recursive => recursive,
|
55
|
+
:force => force
|
53
56
|
}
|
54
57
|
Operation::Service.uninstall(args)
|
55
58
|
end
|
data/lib/cli/command/service.rb
CHANGED
@@ -37,17 +37,17 @@ module DTK::Client
|
|
37
37
|
'list-components',
|
38
38
|
'list-nodes',
|
39
39
|
'list-violations',
|
40
|
-
'start',
|
41
|
-
'stop',
|
40
|
+
# 'start',
|
41
|
+
# 'stop',
|
42
42
|
'cancel-task',
|
43
43
|
'ssh',
|
44
44
|
'set-required-attributes',
|
45
45
|
'set-attribute',
|
46
46
|
'exec',
|
47
47
|
'exec-sync',
|
48
|
-
'set-default-target'
|
49
|
-
|
50
|
-
|
48
|
+
'set-default-target',
|
49
|
+
'eject'
|
50
|
+
]
|
51
51
|
command_def :desc => 'Subcommands for creating and interacting with DTK service instances'
|
52
52
|
ALL_SUBCOMMANDS.each { |subcommand| require_relative("service/#{subcommand.gsub(/-/,'_')}") }
|
53
53
|
end
|
data/lib/cli/command/token.rb
CHANGED
@@ -48,7 +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
|
-
|
51
|
+
:format => Flag.new(:format, 'FORMAT', 'Choose in which format to display data (ex. TABLE, YAML)'),
|
52
52
|
|
53
53
|
# switches
|
54
54
|
# Switch constructor args order: key, desc, opts={}
|
@@ -62,7 +62,8 @@ module DTK::Client
|
|
62
62
|
:links => Switch.new(:links, 'Links'),
|
63
63
|
:dependencies => Switch.new(:deps, 'Dependencies'),
|
64
64
|
:u => Switch.new([:u, :unset], 'Unset attribute'),
|
65
|
-
:recursive => Switch.new(:r, 'Recursive')
|
65
|
+
:recursive => Switch.new(:r, 'Recursive'),
|
66
|
+
:update_deps => Switch.new('update-deps', "Skip prompt and update all dependencies or skip prompt and don't update all dependencies (on master)", :negatable => true, :default_value => 'prompt')
|
66
67
|
}
|
67
68
|
|
68
69
|
ARG_TOKENS = {
|
@@ -77,7 +78,9 @@ module DTK::Client
|
|
77
78
|
:target_directory => 'TARGET-DIRECTORY',
|
78
79
|
:attribute_name => 'ATTRIBUTE-NAME',
|
79
80
|
:keypair_name => 'KEYPAIR-NAME',
|
80
|
-
:attribute_value => 'VALUE'
|
81
|
+
:attribute_value => 'VALUE',
|
82
|
+
:component_ref => 'COMPONENT-REF',
|
83
|
+
:format => 'FORMAT'
|
81
84
|
}
|
82
85
|
|
83
86
|
end
|
data/lib/cli/version.rb
CHANGED
data/lib/client/conn.rb
CHANGED
@@ -90,7 +90,8 @@ module DTK::Client
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def connection_refused_error_code?
|
93
|
-
error_code? == 'connection_refused'
|
93
|
+
error_code? == 'connection_refused' or
|
94
|
+
(original_exception? and original_exception?.kind_of?(::Errno::EPIPE))
|
94
95
|
end
|
95
96
|
|
96
97
|
private
|
@@ -99,6 +100,10 @@ module DTK::Client
|
|
99
100
|
connection_error['errors'].first['code'] rescue nil
|
100
101
|
end
|
101
102
|
|
103
|
+
def original_exception?
|
104
|
+
connection_error['errors'].first['original_exception'] rescue nil
|
105
|
+
end
|
106
|
+
|
102
107
|
REST_VERSION = 'v1'
|
103
108
|
REST_PREFIX = "rest/api/#{REST_VERSION}"
|
104
109
|
# REST_PREFIX = "rest"
|
@@ -26,14 +26,14 @@ module DTK::Client
|
|
26
26
|
|
27
27
|
BaseRoute = "modules"
|
28
28
|
# opts can have keys:
|
29
|
-
# :
|
29
|
+
# :update_deps
|
30
30
|
def initialize(base_module_ref, component_module_refs, opts = {})
|
31
31
|
# TODO: DTK-2766: in an later release will changes this so iterating over module_refs, which could have component and service info,
|
32
32
|
# not just component modules
|
33
33
|
@base_module_ref = base_module_ref
|
34
34
|
@component_module_refs = component_module_refs
|
35
35
|
@print_helper = PrintHelper.new(:module_ref => @base_module_ref, :source => :remote)
|
36
|
-
@prompt_helper = PromptHelper.new(:update_all => opts[:
|
36
|
+
@prompt_helper = PromptHelper.new(:update_all => opts[:update_deps], :update_none => opts[:update_none] || opts[:no_update_deps])
|
37
37
|
@opts = opts
|
38
38
|
end
|
39
39
|
private :initialize
|
@@ -39,8 +39,15 @@ module DTK::Client
|
|
39
39
|
module_ref = args.required(:module_ref)
|
40
40
|
base_dsl_file_obj = args.required(:base_dsl_file_obj)
|
41
41
|
has_directory_param = args[:has_directory_param]
|
42
|
-
skip_prompt = args[:skip_prompt]
|
43
42
|
has_remote_repo = args[:has_remote_repo]
|
43
|
+
update_deps = args[:update_deps]
|
44
|
+
|
45
|
+
case update_deps
|
46
|
+
when "prompt"
|
47
|
+
update_deps = nil
|
48
|
+
when false
|
49
|
+
no_update_deps = true
|
50
|
+
end
|
44
51
|
|
45
52
|
if has_directory_param
|
46
53
|
file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content_flag(:module_ref)
|
@@ -48,12 +55,13 @@ module DTK::Client
|
|
48
55
|
file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content
|
49
56
|
end
|
50
57
|
|
51
|
-
new(file_obj, module_ref, has_remote_repo).install(:
|
58
|
+
new(file_obj, module_ref, has_remote_repo).install(:update_deps => update_deps, :no_update_deps => no_update_deps)
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
55
62
|
# opts can have keys:
|
56
|
-
# :
|
63
|
+
# :update_deps
|
64
|
+
# :no_update_deps
|
57
65
|
def install(opts = {})
|
58
66
|
unless @base_module_ref
|
59
67
|
raise Error::Usage, "No base module reference #{dsl_path_ref}"
|
@@ -66,9 +74,9 @@ module DTK::Client
|
|
66
74
|
unless dependent_modules.empty?
|
67
75
|
begin
|
68
76
|
if @has_remote_repo
|
69
|
-
DependentModules.install(@base_module_ref, dependent_modules,
|
77
|
+
DependentModules.install(@base_module_ref, dependent_modules, opts)
|
70
78
|
else
|
71
|
-
DependentModules.install_with_local(@base_module_ref, dependent_modules,
|
79
|
+
DependentModules.install_with_local(@base_module_ref, dependent_modules, opts)
|
72
80
|
end
|
73
81
|
rescue TerminateInstall
|
74
82
|
@print_helper.print_terminated_installation
|
@@ -24,10 +24,13 @@ module DTK::Client
|
|
24
24
|
@module_ref = module_ref
|
25
25
|
@directory_path = directory_path
|
26
26
|
@target_repo_dir = directory_path || base_dsl_file_obj.parent_dir
|
27
|
-
@version = version
|
27
|
+
@version = version || 'master'
|
28
28
|
@base_dsl_file_obj = base_dsl_file_obj
|
29
29
|
@parsed_module = base_dsl_file_obj.parse_content(:common_module_summary)
|
30
30
|
@print_helper = Install::PrintHelper.new(:module_ref => module_ref, :source => :remote)
|
31
|
+
|
32
|
+
@module_ref.version ||= @version
|
33
|
+
|
31
34
|
end
|
32
35
|
private :initialize
|
33
36
|
|
@@ -68,14 +71,10 @@ module DTK::Client
|
|
68
71
|
:module_name => @module_ref.module_name,
|
69
72
|
:namespace => @module_ref.namespace,
|
70
73
|
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
71
|
-
:version
|
74
|
+
:version => @version
|
72
75
|
)
|
73
76
|
remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
|
74
77
|
|
75
|
-
unless @version
|
76
|
-
@version = remote_module_info.required(:version)
|
77
|
-
@module_ref.version = @version
|
78
|
-
end
|
79
78
|
|
80
79
|
unless dependent_modules.empty?
|
81
80
|
begin
|
@@ -26,8 +26,10 @@ module DTK::Client
|
|
26
26
|
@module_ref = module_ref
|
27
27
|
@directory_path = directory_path
|
28
28
|
@target_repo_dir = directory_path || base_dsl_file_obj.parent_dir
|
29
|
-
@version = version
|
29
|
+
@version = version || 'master'
|
30
30
|
@base_dsl_file_obj = base_dsl_file_obj
|
31
|
+
|
32
|
+
@module_ref.version ||= @version
|
31
33
|
end
|
32
34
|
private :initialize
|
33
35
|
|
@@ -58,16 +60,10 @@ module DTK::Client
|
|
58
60
|
:module_name => @module_ref.module_name,
|
59
61
|
:namespace => @module_ref.namespace,
|
60
62
|
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
61
|
-
:version
|
63
|
+
:version => @version
|
62
64
|
)
|
63
|
-
|
64
65
|
remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
|
65
66
|
|
66
|
-
unless @version
|
67
|
-
@version = remote_module_info.required(:version)
|
68
|
-
@module_ref.version = @version
|
69
|
-
end
|
70
|
-
|
71
67
|
ConvertSource.transform_and_commit(remote_module_info, self)
|
72
68
|
nil
|
73
69
|
end
|
@@ -42,11 +42,12 @@ module DTK::Client
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# TODO: DTK-2938: below need sto be upgraded to be consistent with node as a component
|
45
46
|
def self.display_node_info(nodes, message = '')
|
46
47
|
if nodes.size > 0
|
47
48
|
nodes.each do |node|
|
48
|
-
return if
|
49
|
-
message += "#{node[
|
49
|
+
return if node['instance_id'].nil?
|
50
|
+
message += "#{node['display_name']} - #{node['instance_id']}\n"
|
50
51
|
end
|
51
52
|
OsUtil.print("Nodes that will be deleted: \n" + message)
|
52
53
|
end
|
@@ -0,0 +1,48 @@
|
|
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 Eject < self
|
21
|
+
def self.execute(args = Args.new)
|
22
|
+
wrap_operation(args) do |args|
|
23
|
+
service_instance = args.required(:service_instance)
|
24
|
+
component_ref = args.required(:component_ref)
|
25
|
+
directory_path = args[:directory_path]
|
26
|
+
|
27
|
+
post_body = PostBody.new(
|
28
|
+
:service_instance => service_instance,
|
29
|
+
:component_ref => component_ref
|
30
|
+
)
|
31
|
+
response = rest_post("#{BaseRoute}/#{service_instance}/eject", post_body)
|
32
|
+
|
33
|
+
if repo_updated = response.data["repo_updated"]
|
34
|
+
repo_info_args = Args.new(
|
35
|
+
:service_instance => service_instance,
|
36
|
+
:branch => response.required(:branch, :name),
|
37
|
+
:repo_url => response.required(:repo, :url)
|
38
|
+
)
|
39
|
+
|
40
|
+
ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args)
|
41
|
+
end
|
42
|
+
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -28,6 +28,16 @@ module DTK::Client
|
|
28
28
|
# parse params and return format { 'p_name1' => 'p_value1' , 'p_name2' => 'p_value2' }
|
29
29
|
task_params = parse_params?(action_params)||{}
|
30
30
|
|
31
|
+
# this is temporary fix to handle new node as component format ec2::node[node_name]/action
|
32
|
+
# will transform ec2::node[node_name]/action to node_name/action
|
33
|
+
action_node, action_name = (action||"").split('/')
|
34
|
+
if action_node && action_name
|
35
|
+
if action_node_match = action_node.match(/^ec2::node\[(.*)\]/)
|
36
|
+
matched_node = $1
|
37
|
+
action = "#{matched_node}/#{action_name}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
# match if sent node/component
|
32
42
|
if task_action_match = action.match(/(^[\w\-\:]*)\/(.*)/)
|
33
43
|
node, action = $1, $2
|
@@ -24,14 +24,29 @@ module DTK::Client
|
|
24
24
|
links = args[:links]
|
25
25
|
node = args[:node]
|
26
26
|
component = args[:component]
|
27
|
+
all = args[:all]
|
28
|
+
format = args[:format] || 'table'
|
29
|
+
format.downcase!
|
27
30
|
|
28
31
|
query_string_hash = QueryStringHash.new(
|
29
|
-
:links?
|
30
|
-
:node_id?
|
31
|
-
:
|
32
|
+
:links? => links,
|
33
|
+
:node_id? => node,
|
34
|
+
:all => all,
|
35
|
+
:filter_component? => component,
|
36
|
+
:format => format
|
32
37
|
)
|
33
|
-
|
34
|
-
|
38
|
+
|
39
|
+
response = rest_get("#{BaseRoute}/#{service_instance}/attributes", query_string_hash)
|
40
|
+
|
41
|
+
case format
|
42
|
+
when 'table'
|
43
|
+
response.set_render_as_table!
|
44
|
+
when 'yaml'
|
45
|
+
response
|
46
|
+
else
|
47
|
+
raise Error::Usage, "Please enter valid format: TABLE, YAML"
|
48
|
+
end
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -53,28 +53,26 @@ module DTK::Client
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.get_node_info_for_ssh_login(node_name, service_instance)
|
56
|
-
|
56
|
+
info_hash = {}
|
57
57
|
|
58
|
-
|
58
|
+
response = rest_get("#{BaseRoute}/#{service_instance}/nodes")
|
59
|
+
unless node_info = response.data.find{ |node| node_name == node['display_name'] }
|
59
60
|
raise Error::Usage, "The node '#{node_name}' does not exist"
|
60
61
|
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if public_dns = node_properties['ec2_public_address']
|
66
|
-
data.merge!(:public_dns => public_dns)
|
63
|
+
if dns_address = node_info['dns_address']
|
64
|
+
info_hash.merge!(:dns_address => dns_address)
|
67
65
|
end
|
68
66
|
|
69
|
-
if default_login_user = default_login_user?(
|
70
|
-
|
67
|
+
if default_login_user = default_login_user?(node_info)
|
68
|
+
info_hash.merge!(:default_login_user => default_login_user)
|
71
69
|
end
|
72
|
-
|
73
|
-
|
70
|
+
pp info_hash
|
71
|
+
info_hash
|
74
72
|
end
|
75
73
|
|
76
|
-
def self.default_login_user?(
|
77
|
-
if os_type =
|
74
|
+
def self.default_login_user?(node_info)
|
75
|
+
if os_type = node_info['os_type']
|
78
76
|
DefaultLoginByOSType[os_type]
|
79
77
|
end
|
80
78
|
end
|
@@ -85,7 +83,7 @@ module DTK::Client
|
|
85
83
|
}
|
86
84
|
|
87
85
|
def self.connect(node_info, identity_file, remote_user)
|
88
|
-
unless
|
86
|
+
unless dns_address = node_info[:dns_address]
|
89
87
|
raise Error::Usage, "Not able to resolve instance address, has instance been stopped?"
|
90
88
|
end
|
91
89
|
|
@@ -93,13 +91,13 @@ module DTK::Client
|
|
93
91
|
raise Error::Usage, "Retry command with a specfic login user (a default login user could not be computed)"
|
94
92
|
end
|
95
93
|
|
96
|
-
connection_string = "#{remote_user}@#{
|
94
|
+
connection_string = "#{remote_user}@#{dns_address}"
|
97
95
|
|
98
96
|
ssh_command =
|
99
97
|
if identity_file
|
100
98
|
# provided PEM key
|
101
99
|
"ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{identity_file} #{connection_string}"
|
102
|
-
elsif SSHUtil.ssh_reachable?(remote_user,
|
100
|
+
elsif SSHUtil.ssh_reachable?(remote_user, dns_address)
|
103
101
|
# it has PUB key access
|
104
102
|
"ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" #{connection_string}"
|
105
103
|
end
|
@@ -23,6 +23,7 @@ module DTK::Client
|
|
23
23
|
service_instance = args.required(:service_instance)
|
24
24
|
recursive = args.required(:recursive)
|
25
25
|
delete = args.required(:delete)
|
26
|
+
force = args.required(:force)
|
26
27
|
path = args[:directory_path]
|
27
28
|
node = []
|
28
29
|
|
@@ -33,19 +34,28 @@ module DTK::Client
|
|
33
34
|
post_body = PostBody.new(
|
34
35
|
:service_instance => service_instance,
|
35
36
|
:recursive? => recursive,
|
36
|
-
:delete => delete
|
37
|
+
:delete => delete,
|
38
|
+
:force => force
|
37
39
|
)
|
38
40
|
response = rest_post("#{BaseRoute}/uninstall", post_body)
|
39
41
|
|
40
42
|
ClientModuleDir.rm_f(path) if args[:purge]
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
if delete
|
45
|
+
if message = response.data(:message)
|
46
|
+
OsUtil.print_info(message)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
msg = "DTK module '#{service_instance}' has been uninstalled successfully."
|
50
|
+
if force
|
51
|
+
msg += "\nNote: this will not terminate aws instances, you will have to do that manually!"
|
52
|
+
end
|
53
|
+
OsUtil.print_info(msg)
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
47
57
|
|
48
58
|
|
49
59
|
end
|
50
60
|
end
|
51
|
-
end
|
61
|
+
end
|
@@ -40,12 +40,13 @@ module DTK::Client
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def initialize(table_definition)
|
43
|
-
@order_definition
|
44
|
-
@table_mapping
|
45
|
-
@evaluated_data
|
46
|
-
@error_data
|
47
|
-
@action_data
|
48
|
-
@footnote
|
43
|
+
@order_definition = table_definition.order_definition
|
44
|
+
@table_mapping = table_definition.mapping
|
45
|
+
@evaluated_data = []
|
46
|
+
@error_data = []
|
47
|
+
@action_data = []
|
48
|
+
@footnote = nil
|
49
|
+
@failed_components = []
|
49
50
|
end
|
50
51
|
private :initialize
|
51
52
|
|
@@ -78,6 +79,9 @@ module DTK::Client
|
|
78
79
|
begin
|
79
80
|
if print_error_table && k.include?('error')
|
80
81
|
error_message = value_of(structured_element, v)
|
82
|
+
if failed_component = value_of(structured_element, 'failed_component')
|
83
|
+
@failed_components << "- #{failed_component.gsub('__','::')}"
|
84
|
+
end
|
81
85
|
|
82
86
|
# due to problems with space we have special way of handling error columns
|
83
87
|
# in such a way that those error will be specially printed later on
|
@@ -165,6 +169,11 @@ module DTK::Client
|
|
165
169
|
printf " \n"
|
166
170
|
printf "%15s %s\n", "INFO:".colorize(:yellow), @footnote.colorize(:yellow)
|
167
171
|
end
|
172
|
+
|
173
|
+
unless @failed_components.empty?
|
174
|
+
printf " \n"
|
175
|
+
printf "%15s %s\n", "INFO:".colorize(:yellow), "Following components could not be deleted:\n\t#{@failed_components.uniq.join(', ').colorize(:yellow)}\nYou can use the command 'dtk service eject COMPONENT' to remove any of these component(s) from dtk management. However, when using the eject command, you will need to manually remove the actual resources, such as an ec2 instance.".colorize(:yellow)
|
176
|
+
end
|
168
177
|
end
|
169
178
|
|
170
179
|
|
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.
|
4
|
+
version: 0.11.0
|
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-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dtk-common-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.11.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,30 +98,30 @@ dependencies:
|
|
98
98
|
name: mime-types
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 2.99.3
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.99.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: dtk-dsl
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.1.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.1.0
|
125
125
|
description: Command line tool to interact with a DTK Server and DTK Service Catalog.
|
126
126
|
email: support@reactor8.com
|
127
127
|
executables:
|
@@ -130,8 +130,8 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .license_header
|
133
|
+
- ".gitignore"
|
134
|
+
- ".license_header"
|
135
135
|
- Gemfile
|
136
136
|
- LICENSE
|
137
137
|
- README.md
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/cli/command/service/delete.rb
|
180
180
|
- lib/cli/command/service/destroy.rb
|
181
181
|
- lib/cli/command/service/edit.rb
|
182
|
+
- lib/cli/command/service/eject.rb
|
182
183
|
- lib/cli/command/service/exec.rb
|
183
184
|
- lib/cli/command/service/exec_sync.rb
|
184
185
|
- lib/cli/command/service/list.rb
|
@@ -288,6 +289,7 @@ files:
|
|
288
289
|
- lib/client/operation/service/delete.rb
|
289
290
|
- lib/client/operation/service/destroy.rb
|
290
291
|
- lib/client/operation/service/edit.rb
|
292
|
+
- lib/client/operation/service/eject.rb
|
291
293
|
- lib/client/operation/service/exec.rb
|
292
294
|
- lib/client/operation/service/list.rb
|
293
295
|
- lib/client/operation/service/list_actions.rb
|
@@ -377,17 +379,17 @@ require_paths:
|
|
377
379
|
- lib
|
378
380
|
required_ruby_version: !ruby/object:Gem::Requirement
|
379
381
|
requirements:
|
380
|
-
- -
|
382
|
+
- - ">="
|
381
383
|
- !ruby/object:Gem::Version
|
382
384
|
version: 1.9.3
|
383
385
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
384
386
|
requirements:
|
385
|
-
- -
|
387
|
+
- - ">="
|
386
388
|
- !ruby/object:Gem::Version
|
387
389
|
version: '0'
|
388
390
|
requirements: []
|
389
391
|
rubyforge_project:
|
390
|
-
rubygems_version: 2.
|
392
|
+
rubygems_version: 2.4.1
|
391
393
|
signing_key:
|
392
394
|
specification_version: 4
|
393
395
|
summary: DTK CLI client for DTK server interaction.
|