dtk-client 0.10.0.2 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/dtk-client.gemspec +1 -1
- data/lib/cli/command/module/install.rb +8 -4
- data/lib/cli/command/module/list_remotes.rb +39 -0
- data/lib/cli/command/module.rb +1 -1
- data/lib/cli/command/service/clone.rb +43 -0
- data/lib/cli/command/service/delete.rb +48 -0
- data/lib/cli/command/service/exec.rb +10 -1
- data/lib/cli/command/service/exec_sync.rb +8 -2
- data/lib/cli/command/service/set_attribute.rb +46 -0
- data/lib/cli/command/service/ssh.rb +1 -1
- data/lib/cli/command/service/uninstall.rb +53 -0
- data/lib/cli/command/service.rb +4 -1
- data/lib/cli/command/token.rb +7 -1
- data/lib/cli/context/type.rb +3 -2
- data/lib/cli/context.rb +4 -7
- data/lib/cli/directory_parser/file_system.rb +16 -12
- data/lib/cli/version.rb +1 -1
- data/lib/client/content_generator.rb +62 -3
- data/lib/client/operation/client_module_dir/git_repo.rb +2 -2
- data/lib/client/operation/client_module_dir.rb +4 -2
- data/lib/client/operation/module/clone_module.rb +0 -1
- data/lib/client/operation/module/install/external_module.rb +89 -15
- data/lib/client/operation/module/install.rb +6 -6
- data/lib/client/operation/module/install_from_catalog.rb +1 -1
- data/lib/client/operation/module/list_assemblies.rb +1 -1
- data/lib/client/operation/module/list_remotes.rb +37 -0
- data/lib/client/operation/module.rb +1 -1
- data/lib/client/operation/service/clone_service.rb +50 -0
- data/lib/client/operation/service/delete.rb +44 -0
- data/lib/client/operation/service/exec.rb +5 -0
- data/lib/client/operation/service/set_attribute.rb +47 -0
- data/lib/client/operation/service/set_required_attributes.rb +11 -1
- data/lib/client/operation/service/stage.rb +9 -2
- data/lib/client/operation/service/task_status/refresh_mode.rb +1 -0
- data/lib/client/operation/service/task_status/snapshot_mode.rb +1 -0
- data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result.rb +4 -0
- data/lib/client/operation/service/task_status.rb +3 -1
- data/lib/client/operation/service/uninstall.rb +46 -0
- data/lib/client/operation/service.rb +10 -1
- data/lib/client/render/view/table/processor.rb +2 -2
- data/lib/client/response/render_helper.rb +4 -0
- data/lib/client/util/console.rb +23 -0
- metadata +15 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9540610a410ba802ef78157c6781d4271ccfe04
|
4
|
+
data.tar.gz: 7a38732fc16295a3cad0f088483198746d776b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a1ed74ece609638c98e20ba20e2d3cb12364ecc1bc7cadf94fc5341837fda53c51226bc0529c63464c80cdf5ea3b96c3769fc070fc60233e950e0d208bda23f
|
7
|
+
data.tar.gz: 300e8bec9f03786c3867a0e473c8eff0d93b7c056148fc9bf70752220d1103c3e7d29eb37305890ad653fa7d16b5d4ca0bc5b8f14aa9f9c59a0329180ac7186c
|
data/.gitignore
CHANGED
data/dtk-client.gemspec
CHANGED
@@ -23,9 +23,12 @@ 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.skip_prompt
|
27
|
+
|
26
28
|
sc.action do |_global_options, options, args|
|
27
29
|
directory_path = options[:directory_path]
|
28
|
-
version
|
30
|
+
version = options[:version]
|
31
|
+
skip_prompt = options[:skip_prompt]
|
29
32
|
|
30
33
|
# install from dtkn (later probably from other remote catalogs)
|
31
34
|
if module_name = args[0]
|
@@ -40,9 +43,10 @@ module DTK::Client
|
|
40
43
|
end
|
41
44
|
|
42
45
|
install_opts = directory_path ? { :directory_path => directory_path, :version => (version || 'master') } : options
|
43
|
-
module_ref
|
44
|
-
flag
|
45
|
-
|
46
|
+
module_ref = module_ref_in_options_or_context?(install_opts)
|
47
|
+
flag = true unless options["d"].nil?
|
48
|
+
|
49
|
+
Operation::Module.install(:module_ref => module_ref, :base_dsl_file_obj => @base_dsl_file_obj, :flag => flag, :skip_prompt => skip_prompt)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -0,0 +1,39 @@
|
|
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 Module
|
21
|
+
subcommand_def 'list-remotes' do |c|
|
22
|
+
command_body c, 'list-remotes', 'List remote modules' do |sc|
|
23
|
+
sc.flag Token.namespace
|
24
|
+
sc.action do |_global_options, options, args|
|
25
|
+
arg = {}
|
26
|
+
unless options[:n].nil?
|
27
|
+
arg = {
|
28
|
+
:module_namespace => options[:n]
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
Operation::Module.list_remotes(arg)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/cli/command/module.rb
CHANGED
@@ -21,7 +21,7 @@ module DTK::Client
|
|
21
21
|
module Module
|
22
22
|
include Command::Mixin
|
23
23
|
|
24
|
-
ALL_SUBCOMMANDS = ['install', 'list', 'list-assemblies', 'push', 'uninstall', 'clone']
|
24
|
+
ALL_SUBCOMMANDS = ['install', 'list', 'list-assemblies', 'push', 'uninstall', 'clone', 'list-remotes']
|
25
25
|
command_def :desc => 'Subcommands for interacting with DTK modules'
|
26
26
|
ALL_SUBCOMMANDS.each { |subcommand| require_relative("module/#{subcommand.gsub(/-/,'_')}") }
|
27
27
|
end
|
@@ -0,0 +1,43 @@
|
|
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 'clone' do |c|
|
22
|
+
c.arg Token::Arg.service_instance
|
23
|
+
c.arg Token::Arg.target_directory, :optional => true
|
24
|
+
command_body c, :clone, 'Clone content of service module from server to client' do |sc|
|
25
|
+
sc.action do |_global_options, options, args|
|
26
|
+
service_name = args[0]
|
27
|
+
service_ref = service_instance_in_options_or_context(:service_instance => service_name, :version => options[:version])
|
28
|
+
|
29
|
+
arg = {
|
30
|
+
:service_ref => service_ref,
|
31
|
+
:service_name => service_name,
|
32
|
+
:target_directory => args[1]
|
33
|
+
}
|
34
|
+
|
35
|
+
Operation::Service.clone_service(arg)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -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; module CLI
|
19
|
+
module Command
|
20
|
+
module Service
|
21
|
+
subcommand_def 'delete' do |c|
|
22
|
+
command_body c, :delete, 'Destroys the running infrastructure associated with the service instance' do |sc|
|
23
|
+
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory associated; not needed if executed in service instance directory'
|
24
|
+
sc.switch Token.skip_prompt, :desc => 'Skip prompt that checks if user wants to delete the service instance'
|
25
|
+
sc.switch Token.recursive
|
26
|
+
# sc.switch Token.purge, :desc => 'Delete the service instance directory on the client'
|
27
|
+
sc.action do |_global_options, options, args|
|
28
|
+
directory_path = options[:directory_path]
|
29
|
+
purge = options[:purge]
|
30
|
+
recursive = options[:recursive]
|
31
|
+
# if purge && (!directory_path || (directory_path == @base_dsl_file_obj.parent_dir?))
|
32
|
+
# raise Error::Usage, "If use option '#{option_ref(:purge)}' then need to call from outside directory and use option '#{option_ref(:directory_path)}'"
|
33
|
+
# end
|
34
|
+
service_instance = service_instance_in_options_or_context(options)
|
35
|
+
|
36
|
+
args = {
|
37
|
+
:service_instance => service_instance,
|
38
|
+
:skip_prompt => options[:skip_prompt],
|
39
|
+
:directory_path => directory_path,
|
40
|
+
:recursive => recursive
|
41
|
+
}
|
42
|
+
Operation::Service.delete(args)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end; end
|
@@ -22,7 +22,9 @@ module DTK::Client
|
|
22
22
|
c.arg Token::Arg.action
|
23
23
|
c.arg Token::Arg.action_params, :optional => true
|
24
24
|
command_body c, :exec, 'Execute action asynchronously' do |sc|
|
25
|
+
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'
|
25
26
|
sc.action do |_global_options, options, args|
|
27
|
+
|
26
28
|
service_instance = service_instance_in_options_or_context(options)
|
27
29
|
|
28
30
|
action = args[0]
|
@@ -33,7 +35,14 @@ module DTK::Client
|
|
33
35
|
:action => action,
|
34
36
|
:action_params => action_params
|
35
37
|
}
|
36
|
-
|
38
|
+
|
39
|
+
response = Operation::Service.exec(args)
|
40
|
+
|
41
|
+
if violations = response.data(:violations)
|
42
|
+
response.set_data(violations)
|
43
|
+
response.data.flatten!
|
44
|
+
response.set_render_as_table!
|
45
|
+
end
|
37
46
|
end
|
38
47
|
end
|
39
48
|
end
|
@@ -22,6 +22,7 @@ module DTK::Client
|
|
22
22
|
c.arg Token::Arg.action
|
23
23
|
c.arg Token::Arg.action_params, :optional => true
|
24
24
|
command_body c, 'exec-sync', 'Execute action synchronously' do |sc|
|
25
|
+
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'
|
25
26
|
sc.action do |_global_options, options, args|
|
26
27
|
service_instance = service_instance_in_options_or_context(options)
|
27
28
|
|
@@ -34,13 +35,18 @@ module DTK::Client
|
|
34
35
|
:action_params => action_params
|
35
36
|
}
|
36
37
|
response = Operation::Service.exec(args)
|
38
|
+
|
37
39
|
unless response.ok?
|
38
40
|
response
|
39
41
|
else
|
40
42
|
# TODO: break if any exceptions
|
43
|
+
|
41
44
|
if response.data(:empty_workflow)
|
42
|
-
Response::Ok.new
|
43
|
-
|
45
|
+
Response::Ok.new
|
46
|
+
elsif violations = response.data(:violations)
|
47
|
+
response.set_data(violations)
|
48
|
+
response.data.flatten!
|
49
|
+
response.set_render_as_table!
|
44
50
|
else
|
45
51
|
Operation::Service.task_status(args.merge(:mode => 'stream'))
|
46
52
|
end
|
@@ -0,0 +1,46 @@
|
|
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 'set-attribute' do |c|
|
22
|
+
c.arg Token::Arg.attribute_name
|
23
|
+
c.arg Token::Arg.attribute_value, :optional => true
|
24
|
+
command_body c, 'set-attribute', 'Edit specific attribute.' do |sc|
|
25
|
+
sc.switch Token.u
|
26
|
+
sc.flag Token.directory_path
|
27
|
+
sc.action do |_global_options, options, _args|
|
28
|
+
|
29
|
+
service_instance = service_instance_in_options_or_context(options)
|
30
|
+
|
31
|
+
attribute_name = _args[0]
|
32
|
+
options[:u] ? attribute_value = nil : attribute_value = _args[1]
|
33
|
+
|
34
|
+
args = {
|
35
|
+
:attribute_name => attribute_name,
|
36
|
+
:service_instance => service_instance,
|
37
|
+
:attribute_value => attribute_value
|
38
|
+
}
|
39
|
+
|
40
|
+
Operation::Service.set_attribute(args)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end; end
|
@@ -20,7 +20,7 @@ module DTK::Client
|
|
20
20
|
module Service
|
21
21
|
subcommand_def 'ssh' do |c|
|
22
22
|
c.arg Token::Arg.node_name
|
23
|
-
command_body c, :ssh, '
|
23
|
+
command_body c, :ssh, 'SSH into service instance node.' do |sc|
|
24
24
|
sc.flag Token.remote_user
|
25
25
|
sc.flag Token.identity_file, :desc => 'Identity file used for connection, if not provided default is used'
|
26
26
|
|
@@ -0,0 +1,53 @@
|
|
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 'uninstall' do |c|
|
22
|
+
command_body c, :uninstall, 'Uninstalls the service instance from the server' do |sc|
|
23
|
+
sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory associated; not needed if executed in service instance directory'
|
24
|
+
sc.switch Token.skip_prompt, :desc => 'Skip prompt that checks if user wants to delete the service instance'
|
25
|
+
sc.switch Token.purge, :desc => 'Delete the service instance directory on the client'
|
26
|
+
sc.switch Token.force
|
27
|
+
sc.switch Token.recursive
|
28
|
+
sc.action do |_global_options, options, args|
|
29
|
+
directory_path = options[:directory_path]
|
30
|
+
purge = options[:purge]
|
31
|
+
force = options[:force]
|
32
|
+
recursive = options[:recursive]
|
33
|
+
|
34
|
+
if purge && (!directory_path || (directory_path == @base_dsl_file_obj.parent_dir?))
|
35
|
+
raise Error::Usage, "If use option '#{option_ref(:purge)}' then need to call from outside directory and use option '#{option_ref(:directory_path)}'"
|
36
|
+
end
|
37
|
+
service_instance = service_instance_in_options_or_context(options)
|
38
|
+
|
39
|
+
args = {
|
40
|
+
:service_instance => service_instance,
|
41
|
+
:skip_prompt => options[:skip_prompt],
|
42
|
+
:directory_path => directory_path,
|
43
|
+
:purge => purge,
|
44
|
+
:force => force,
|
45
|
+
:recursive => recursive
|
46
|
+
}
|
47
|
+
Operation::Service.uninstall(args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end; end
|
data/lib/cli/command/service.rb
CHANGED
@@ -21,8 +21,10 @@ module DTK::Client
|
|
21
21
|
module Service
|
22
22
|
include Command::Mixin
|
23
23
|
ALL_SUBCOMMANDS = [
|
24
|
+
'clone',
|
24
25
|
'stage',
|
25
|
-
'
|
26
|
+
'delete',
|
27
|
+
'uninstall',
|
26
28
|
'edit',
|
27
29
|
'push',
|
28
30
|
'pull',
|
@@ -41,6 +43,7 @@ module DTK::Client
|
|
41
43
|
'cancel-task',
|
42
44
|
'ssh',
|
43
45
|
'set-required-attributes',
|
46
|
+
'set-attribute',
|
44
47
|
'exec',
|
45
48
|
'exec-sync',
|
46
49
|
'set-default-target'
|
data/lib/cli/command/token.rb
CHANGED
@@ -46,6 +46,8 @@ module DTK::Client
|
|
46
46
|
:remote_user => Flag.new(:u, 'REMOTE-USER', 'Remote user'),
|
47
47
|
:identity_file => Flag.new(:i, 'PATH-TO-PEM', 'Path to pem file'),
|
48
48
|
:mode => Flag.new(:mode, 'MODE', 'Mode'),
|
49
|
+
:namespace => Flag.new(:n, 'NAMESPACE', 'Namespace'),
|
50
|
+
|
49
51
|
|
50
52
|
# switches
|
51
53
|
# Switch constructor args order: key, desc, opts={}
|
@@ -57,6 +59,8 @@ module DTK::Client
|
|
57
59
|
:target => Switch.new(:target, 'Create target service instance'),
|
58
60
|
:links => Switch.new(:links, 'Links'),
|
59
61
|
:dependencies => Switch.new(:deps, 'Dependencies'),
|
62
|
+
:u => Switch.new([:u, :unset], 'Unset attribute'),
|
63
|
+
:recursive => Switch.new(:r, 'Recursive')
|
60
64
|
}
|
61
65
|
|
62
66
|
ARG_TOKENS = {
|
@@ -68,7 +72,9 @@ module DTK::Client
|
|
68
72
|
:workspace_name => 'WORKSPACE-NAME',
|
69
73
|
:target_instance => 'TARGET-SERVICE-INSTANCE',
|
70
74
|
:module_name => 'NAMESPACE/MODULE-NAME',
|
71
|
-
:target_directory => 'TARGET-DIRECTORY'
|
75
|
+
:target_directory => 'TARGET-DIRECTORY',
|
76
|
+
:attribute_name => 'ATTRIBUTE-NAME',
|
77
|
+
:attribute_value => 'VALUE'
|
72
78
|
}
|
73
79
|
|
74
80
|
end
|
data/lib/cli/context/type.rb
CHANGED
@@ -25,13 +25,14 @@ module DTK::Client
|
|
25
25
|
# This function can have the side of updating base_dsl_file_obj
|
26
26
|
def self.create_context!(base_dsl_file_obj)
|
27
27
|
if path = base_dsl_file_obj.path?
|
28
|
-
|
28
|
+
top_level_type = base_dsl_file_obj.file_type.top_level_type
|
29
|
+
case top_level_type
|
29
30
|
when :common_module
|
30
31
|
Module.new(base_dsl_file_obj)
|
31
32
|
when :service_instance
|
32
33
|
Service.new(base_dsl_file_obj)
|
33
34
|
else
|
34
|
-
raise Error, "Unexpected
|
35
|
+
raise Error, "Unexpected top_level_type '#{top_level_type}'"
|
35
36
|
end
|
36
37
|
else
|
37
38
|
Top.new(base_dsl_file_obj)
|
data/lib/cli/context.rb
CHANGED
@@ -23,9 +23,6 @@ module DTK::Client
|
|
23
23
|
require_relative('context/attributes')
|
24
24
|
|
25
25
|
def self.determine_context
|
26
|
-
#testing stub
|
27
|
-
#dir_path = File.expand_path('../../examples/spark', File.dirname(__FILE__))
|
28
|
-
#base_dsl_file_obj = base_dsl_file_obj(:dir_path => dir_path)
|
29
26
|
base_dsl_file_obj = base_dsl_file_obj()
|
30
27
|
Type.create_context!(base_dsl_file_obj)
|
31
28
|
end
|
@@ -76,8 +73,8 @@ module DTK::Client
|
|
76
73
|
end
|
77
74
|
|
78
75
|
def service_instance_from_base_dsl_file?
|
79
|
-
#raise_error_when_missing_context(:service_instance) unless base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance
|
80
|
-
base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance
|
76
|
+
#raise_error_when_missing_context(:service_instance) unless base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top
|
77
|
+
base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top
|
81
78
|
base_dsl_file_obj.parse_content(:service_module_summary).val(:Name)
|
82
79
|
end
|
83
80
|
|
@@ -96,8 +93,8 @@ module DTK::Client
|
|
96
93
|
end
|
97
94
|
FILE_TYPES =
|
98
95
|
[
|
99
|
-
::DTK::DSL::FileType::CommonModule,
|
100
|
-
::DTK::DSL::FileType::ServiceInstance
|
96
|
+
::DTK::DSL::FileType::CommonModule::DSLFile::Top,
|
97
|
+
::DTK::DSL::FileType::ServiceInstance::DSLFile::Top
|
101
98
|
]
|
102
99
|
|
103
100
|
def module_ref_in_options_or_context(options)
|
@@ -60,8 +60,7 @@ module DTK::Client; module CLI
|
|
60
60
|
end
|
61
61
|
else
|
62
62
|
file_types.each do | file_type |
|
63
|
-
|
64
|
-
if path = most_nested_matching_file_path?(path_info, flag, :current_dir => opts[:dir_path])
|
63
|
+
if path = most_nested_matching_file_path?(file_type, flag, :current_dir => opts[:dir_path])
|
65
64
|
return [file_type, path]
|
66
65
|
end
|
67
66
|
end
|
@@ -69,22 +68,22 @@ module DTK::Client; module CLI
|
|
69
68
|
ret
|
70
69
|
end
|
71
70
|
|
72
|
-
# return either a string file path or of match to
|
73
|
-
# until base_path in
|
71
|
+
# return either a string file path or of match to file_type working from current directory and 'outwards'
|
72
|
+
# until base_path in file_type (if it exists)
|
74
73
|
# opts can have keys
|
75
74
|
# :current_dir if set means start from this dir; otherwise start from computed current dir
|
76
|
-
def most_nested_matching_file_path?(
|
77
|
-
base_dir =
|
75
|
+
def most_nested_matching_file_path?(file_type, flag, opts = {})
|
76
|
+
base_dir = file_type.base_dir || OsUtil.home_dir
|
78
77
|
current_dir = opts[:current_dir] || OsUtil.current_dir
|
79
|
-
check_match_recurse_on_failure?(
|
78
|
+
check_match_recurse_on_failure?(file_type, current_dir, base_dir, flag)
|
80
79
|
end
|
81
80
|
|
82
|
-
def check_match_recurse_on_failure?(
|
83
|
-
match = matching_file_paths(current_dir,
|
81
|
+
def check_match_recurse_on_failure?(file_type, current_dir, base_dir, flag)
|
82
|
+
match = matching_file_paths(current_dir, file_type)
|
84
83
|
if match.empty?
|
85
84
|
unless current_dir == base_dir
|
86
85
|
if parent_path = OsUtil.parent_dir?(current_dir)
|
87
|
-
check_match_recurse_on_failure?(
|
86
|
+
check_match_recurse_on_failure?(file_type, parent_path, base_dir, flag) unless flag
|
88
87
|
end
|
89
88
|
end
|
90
89
|
elsif match.size == 1
|
@@ -94,9 +93,14 @@ module DTK::Client; module CLI
|
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|
97
|
-
# returns an array of strings that are file paths
|
96
|
+
# returns an array of strings that are file paths; except bakup files (e.g. bak.dtk.service.yaml)
|
98
97
|
def matching_file_paths(dir_path, path_info)
|
99
|
-
Dir.glob("#{dir_path}/*").select { |file_path| File.file?(file_path) and path_info.matches?(file_path) }
|
98
|
+
Dir.glob("#{dir_path}/*").select { |file_path| File.file?(file_path) and !is_backup_file?(file_path) and path_info.matches?(file_path) }
|
99
|
+
end
|
100
|
+
|
101
|
+
def is_backup_file?(file_path)
|
102
|
+
regex = Regexp.new("\.bak\.dtk\.(service|module)\.(yml|yaml)$")
|
103
|
+
file_path =~ regex
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
data/lib/cli/version.rb
CHANGED
@@ -91,9 +91,14 @@ module DTK::Client
|
|
91
91
|
content_hash = convert_file_content_to_hash(assembly)
|
92
92
|
name = content_hash['name']
|
93
93
|
assembly_content = content_hash['assembly']
|
94
|
-
workflows = ret_workflows_hash(content_hash)
|
95
94
|
|
95
|
+
workflows = ret_workflows_hash(content_hash)
|
96
96
|
assembly_content.merge!('workflows' => workflows) if workflows
|
97
|
+
|
98
|
+
# convert node_bindings to node attributes
|
99
|
+
node_bindings = content_hash['node_bindings']
|
100
|
+
create_node_properties_from_node_bindings?(node_bindings, assembly_content)
|
101
|
+
|
97
102
|
assemblies.merge!(name => assembly_content)
|
98
103
|
end
|
99
104
|
|
@@ -114,17 +119,71 @@ module DTK::Client
|
|
114
119
|
def ret_dependencies_hash
|
115
120
|
if file_path = get_module_refs_file
|
116
121
|
module_refs_content = convert_file_content_to_hash(file_path)
|
117
|
-
dependencies =
|
122
|
+
dependencies = {}
|
118
123
|
|
119
124
|
if cmp_dependencies = module_refs_content['component_modules']
|
120
125
|
cmp_dependencies.each_pair do |name, namespace_h|
|
121
|
-
dependencies
|
126
|
+
dependencies.merge!({ "#{namespace_h['namespace']}/#{name}" => namespace_h['version']||'master' })
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
130
|
dependencies
|
126
131
|
end
|
127
132
|
end
|
133
|
+
|
134
|
+
def create_node_properties_from_node_bindings?(node_bindings, assembly_content = {})
|
135
|
+
return unless node_bindings
|
136
|
+
|
137
|
+
nodes = assembly_content['nodes']
|
138
|
+
return if nodes.empty?
|
139
|
+
|
140
|
+
node_bindings.each do |node, node_binding|
|
141
|
+
image, size = get_ec2_properties_from_node_binding(node_binding)
|
142
|
+
new_attrs = { 'image' => image, 'size' => size }
|
143
|
+
|
144
|
+
if node_content = nodes[node]
|
145
|
+
components = node_content['components']
|
146
|
+
components = components.is_a?(Array) ? components : [components]
|
147
|
+
|
148
|
+
if index = include_node_property_component?(components)
|
149
|
+
ec2_properties = components[index]
|
150
|
+
if ec2_properties.is_a?(Hash)
|
151
|
+
if attributes = ec2_properties.values.first['attributes']
|
152
|
+
attributes['image'] = image unless attributes['image']
|
153
|
+
attributes['size'] = size unless attributes['size']
|
154
|
+
else
|
155
|
+
ec2_properties.merge!('attributes' => new_attrs)
|
156
|
+
end
|
157
|
+
else
|
158
|
+
components[index] = { ec2_properties => { 'attributes' => new_attrs } }
|
159
|
+
end
|
160
|
+
elsif node_attributes = node_content['attributes']
|
161
|
+
node_attributes['image'] = image unless node_attributes['image']
|
162
|
+
node_attributes['size'] = size unless node_attributes['size']
|
163
|
+
else
|
164
|
+
node_content['attributes'] = new_attrs
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_ec2_properties_from_node_binding(node_binding)
|
171
|
+
image, size = node_binding.split('-')
|
172
|
+
[image, size]
|
173
|
+
end
|
174
|
+
|
175
|
+
def include_node_property_component?(components)
|
176
|
+
property_component = 'ec2::properties'
|
177
|
+
components.each do |component|
|
178
|
+
if component.is_a?(Hash)
|
179
|
+
return components.index(component) if component.keys.first.eql?(property_component)
|
180
|
+
else
|
181
|
+
return components.index(component) if component.eql?(property_component)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
false
|
186
|
+
end
|
128
187
|
end
|
129
188
|
end
|
130
189
|
|
@@ -137,12 +137,12 @@ module DTK::Client
|
|
137
137
|
|
138
138
|
def self.clone_service_repo(args)
|
139
139
|
repo_url = args.required(:repo_url)
|
140
|
-
module_ref = args.required(:module_ref)
|
141
140
|
branch = args.required(:branch)
|
142
141
|
service_instance = args.required(:service_instance)
|
143
142
|
remove_existing = args[:remove_existing]
|
143
|
+
repo_dir = args[:repo_dir]
|
144
144
|
|
145
|
-
target_repo_dir = create_service_dir(service_instance, :remove_existing => remove_existing)
|
145
|
+
target_repo_dir = create_service_dir(service_instance, :remove_existing => remove_existing, :path => repo_dir)
|
146
146
|
begin
|
147
147
|
git_repo.clone(repo_url, target_repo_dir, branch)
|
148
148
|
rescue => e
|
@@ -28,7 +28,8 @@ module DTK::Client
|
|
28
28
|
# :backup_if_exist - Boolean (default: false)
|
29
29
|
# :remove_existing - Boolean (default: false)
|
30
30
|
def self.create_service_dir(service_instance, opts = {})
|
31
|
-
path =
|
31
|
+
path = opts[:path]
|
32
|
+
path = "#{base_path(:service)}/#{service_instance}" if path.nil?
|
32
33
|
if File.exists?(path)
|
33
34
|
if opts[:remove_existing]
|
34
35
|
FileUtils.rm_rf(path)
|
@@ -42,7 +43,8 @@ module DTK::Client
|
|
42
43
|
# else
|
43
44
|
# raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or removed before retrying the command"
|
44
45
|
#end
|
45
|
-
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or removed before retrying the command"
|
46
|
+
raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or removed before retrying the command" unless (Dir.entries(path) - %w{ . .. }).empty?
|
47
|
+
return path
|
46
48
|
end
|
47
49
|
end
|
48
50
|
FileUtils.mkdir_p(path)
|