dtk-client 0.11.4 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/command/module/delete_from_remote.rb +3 -2
- data/lib/cli/command/module/stage.rb +18 -21
- data/lib/cli/command/module/uninstall.rb +3 -1
- data/lib/cli/command/module.rb +6 -6
- data/lib/cli/command/service.rb +19 -16
- data/lib/cli/command/token.rb +18 -19
- data/lib/cli/version.rb +1 -1
- data/lib/client/operation/module/delete_from_remote.rb +2 -3
- data/lib/client/operation/module/stage.rb +6 -6
- data/lib/client/operation/module/uninstall.rb +2 -1
- data/lib/client/operation/module.rb +6 -6
- data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result/action.rb +1 -0
- data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result/components.rb +1 -0
- data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result.rb +33 -1
- data/lib/client/operation/service/task_status/stream_mode/element/render.rb +8 -0
- data/lib/client/operation/service/task_status/stream_mode/element/stage.rb +8 -4
- data/lib/client/operation/service/task_status/stream_mode/element.rb +25 -2
- data/lib/client/operation/service.rb +16 -15
- data/lib/client/util/validation.rb +23 -4
- metadata +2 -4
- data/lib/cli/command/service/stage.rb +0 -59
- data/lib/client/operation/service/stage.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de7ced1e236b8558747c61de9dbb0bd99bdec16
|
4
|
+
data.tar.gz: 00233bc8aaaa577b2edfdbf494ba39e332004ada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb0de210ec0f760c6c36fdea20b740ad197d4d546b36ce66b8d740e523d9b144b22d27fc242805fb11bb8f873fdd323d97e1472d3c69fd9e009db9c25a4ceee
|
7
|
+
data.tar.gz: f710986718de80dba1c001cb7e7429dc84ee3c7634e45c9ab57424088ff25cee77e4194c6717651285771d6855b831a7bbab570c13490a524ca925bd541d7f2c
|
@@ -23,13 +23,14 @@ module DTK::Client
|
|
23
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
|
+
sc.switch Token.force, :desc => 'Force delete'
|
26
27
|
|
27
28
|
sc.action do |_global_options, options, args|
|
28
29
|
module_ref = module_ref_object_from_options_or_context?(:module_ref => args[0], :version => options[:version])
|
29
30
|
operation_args = {
|
30
31
|
:module_ref => module_ref,
|
31
|
-
:skip_prompt => options[:skip_prompt]
|
32
|
-
|
32
|
+
:skip_prompt => options[:skip_prompt],
|
33
|
+
:force => options[:f]
|
33
34
|
}
|
34
35
|
Operation::Module.delete_from_remote(operation_args)
|
35
36
|
end
|
@@ -23,33 +23,30 @@ module DTK::Client
|
|
23
23
|
command_body c, :stage, 'Create a new service instance to refer to staged infrastructure that then can be deployed' do |sc|
|
24
24
|
sc.flag Token.directory_path, :desc => 'Path to module directory where assembly is being staged from; not needed if in the module directory'
|
25
25
|
sc.flag Token.service_name, :desc => 'If specified, name to use for new service instance; otherwise service instance name is auto-generated'
|
26
|
-
sc.flag Token.
|
26
|
+
sc.flag Token.comma_seperated_contexts
|
27
27
|
sc.switch Token.force
|
28
28
|
sc.switch Token.base
|
29
|
-
#sc.switch Token.target
|
30
|
-
# on useful for testing in dev mode
|
31
|
-
# sc.switch Token.purge, :desc => 'Overwrite any content that presently exists in the service instance directory to be created'
|
32
|
-
# sc.flag Token.version
|
33
29
|
sc.action do |_global_options, options, args|
|
34
|
-
module_ref
|
35
|
-
assembly_name
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
module_ref = module_ref_object_from_options_or_context(options)
|
31
|
+
assembly_name = args[0]
|
32
|
+
service_name = options[:service_name]
|
33
|
+
version = options[:version] || module_ref.version
|
34
|
+
directory_path = options[:directory_path] || @base_dsl_file_obj.parent_dir
|
35
|
+
comma_seperated_contexts = options[:context]
|
40
36
|
|
37
|
+
context_service_names = comma_seperated_contexts && Validation.process_comma_seperated_contexts(comma_seperated_contexts)
|
41
38
|
Validation.validate_name(service_name) if service_name
|
42
39
|
|
43
40
|
args = {
|
44
|
-
:module_ref
|
45
|
-
:assembly_name
|
46
|
-
:service_name
|
47
|
-
:version
|
48
|
-
:
|
49
|
-
:remove_existing
|
50
|
-
:
|
51
|
-
:force
|
52
|
-
:directory_path
|
41
|
+
:module_ref => module_ref,
|
42
|
+
:assembly_name => assembly_name,
|
43
|
+
:service_name => service_name,
|
44
|
+
:version => version,
|
45
|
+
:context_service_names => context_service_names,
|
46
|
+
:remove_existing => options[:purge],
|
47
|
+
:is_base => options[:base],
|
48
|
+
:force => options[:f],
|
49
|
+
:directory_path => directory_path
|
53
50
|
}
|
54
51
|
Operation::Module.stage(args)
|
55
52
|
end
|
@@ -57,4 +54,4 @@ module DTK::Client
|
|
57
54
|
end
|
58
55
|
end
|
59
56
|
end
|
60
|
-
end
|
57
|
+
end
|
@@ -25,8 +25,10 @@ module DTK::Client
|
|
25
25
|
sc.flag Token.directory_path
|
26
26
|
sc.flag Token.version
|
27
27
|
sc.flag Token.uninstall_name
|
28
|
+
sc.switch Token.force
|
28
29
|
sc.action do |_global_options, options, args|
|
29
30
|
version = options[:version]
|
31
|
+
force = options["force"]
|
30
32
|
|
31
33
|
module_refs_opts = {:ignore_parsing_errors => true}
|
32
34
|
if options[:uninstall_name].nil?
|
@@ -42,7 +44,7 @@ module DTK::Client
|
|
42
44
|
|
43
45
|
raise Error::Usage, "You can use version only with 'namespace/name' provided" if version && module_name.nil?
|
44
46
|
|
45
|
-
Operation::Module.uninstall(:module_ref => module_ref, :skip_prompt => options[:skip_prompt], :name => options[:uninstall_name] || module_name, :version => version)
|
47
|
+
Operation::Module.uninstall(:module_ref => module_ref, :force => force, :skip_prompt => options[:skip_prompt], :name => options[:uninstall_name] || module_name, :version => version)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
data/lib/cli/command/module.rb
CHANGED
@@ -22,19 +22,19 @@ module DTK::Client
|
|
22
22
|
include Command::Mixin
|
23
23
|
|
24
24
|
ALL_SUBCOMMANDS = [
|
25
|
+
'delete-from-remote',
|
25
26
|
'install',
|
26
27
|
'list',
|
27
28
|
'list-assemblies',
|
28
|
-
'push',
|
29
|
-
'uninstall',
|
30
|
-
# 'clone',
|
31
29
|
'list-remotes',
|
30
|
+
'publish',
|
31
|
+
'pull-dtkn',
|
32
|
+
'push',
|
32
33
|
'push-dtkn',
|
33
34
|
'stage',
|
34
|
-
'
|
35
|
-
'publish',
|
36
|
-
'delete-from-remote'
|
35
|
+
'uninstall'
|
37
36
|
]
|
37
|
+
|
38
38
|
command_def :desc => 'Subcommands for interacting with DTK modules'
|
39
39
|
ALL_SUBCOMMANDS.each { |subcommand| require_relative("module/#{subcommand.gsub(/-/,'_')}") }
|
40
40
|
end
|
data/lib/cli/command/service.rb
CHANGED
@@ -23,34 +23,37 @@ module DTK::Client
|
|
23
23
|
|
24
24
|
include Command::Mixin
|
25
25
|
ALL_SUBCOMMANDS = [
|
26
|
+
'cancel-task',
|
26
27
|
'clone',
|
28
|
+
'converge',
|
27
29
|
'delete',
|
28
|
-
'uninstall',
|
29
30
|
'edit',
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
31
|
+
'eject',
|
32
|
+
'exec',
|
33
|
+
'exec-sync',
|
34
|
+
'link',
|
34
35
|
'list',
|
35
36
|
'list-actions',
|
36
37
|
'list-attributes',
|
37
38
|
'list-component-links',
|
38
|
-
'list-dependencies',
|
39
39
|
'list-components',
|
40
|
+
'list-dependencies',
|
40
41
|
'list-nodes',
|
41
42
|
'list-violations',
|
42
|
-
'
|
43
|
-
|
44
|
-
# 'stop',
|
45
|
-
'cancel-task',
|
46
|
-
'ssh',
|
47
|
-
'set-required-attributes',
|
43
|
+
'pull',
|
44
|
+
'push',
|
48
45
|
'set-attribute',
|
49
|
-
'exec',
|
50
|
-
'exec-sync',
|
51
46
|
'set-default-target',
|
52
|
-
'
|
53
|
-
|
47
|
+
'set-required-attributes',
|
48
|
+
'ssh',
|
49
|
+
# TODO: put back in
|
50
|
+
# 'start',
|
51
|
+
# 'stop',
|
52
|
+
|
53
|
+
'task-status',
|
54
|
+
'uninstall'
|
55
|
+
]
|
56
|
+
|
54
57
|
command_def :desc => 'Subcommands for creating and interacting with DTK service instances'
|
55
58
|
ALL_SUBCOMMANDS.each { |subcommand| require_relative("service/#{subcommand.gsub(/-/,'_')}") }
|
56
59
|
end
|
data/lib/cli/command/token.rb
CHANGED
@@ -32,25 +32,24 @@ module DTK::Client
|
|
32
32
|
TOKENS = {
|
33
33
|
# flags
|
34
34
|
# Flag constructor args order: key, arg_name, desc, opts={}
|
35
|
-
:commit_message
|
36
|
-
:directory_path
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:format => Flag.new(:format, 'FORMAT', 'Choose in which format to display data (ex. TABLE, YAML)'),
|
35
|
+
:commit_message => Flag.new(:m, 'COMMIT-MSG', 'Commit message'),
|
36
|
+
:directory_path => Flag.new(:d, 'DIRECTORY-PATH', 'Directory path'),
|
37
|
+
:comma_seperated_contexts => Flag.new(:context, 'CONTEXT1,CONTEXT2,...' ,'Comma-seperated context service instance(s); if not specified, the default service instance serves as the context'),
|
38
|
+
:module_ref => Flag.new(:m, ModuleRef::NamespaceModuleName.legal_form, 'Module name with namespace; not needed if command is executed from within the module directory'),
|
39
|
+
:relative_path => Flag.new(:f, 'RELATIVE-FILE-PATH', 'Relative file path'),
|
40
|
+
:service_instance => Flag.new(:s, 'SERVICE-INSTANCE', 'Service instance name'),
|
41
|
+
:service_name => Flag.new(:n, 'SERVICE-NAME', 'Service name'),
|
42
|
+
:version => Flag.new(:v, 'VERSION', 'Version'),
|
43
|
+
:type => Flag.new(:type, 'TYPE', 'Type'),
|
44
|
+
:node => Flag.new(:n, 'NODE', 'Node'),
|
45
|
+
:component => Flag.new(:c, 'COMPONENT', 'Component'),
|
46
|
+
:remote_user => Flag.new(:u, 'REMOTE-USER', 'Remote user'),
|
47
|
+
:identity_file => Flag.new(:i, 'PATH-TO-PEM', 'Path to pem file'),
|
48
|
+
:mode => Flag.new(:mode, 'MODE', 'Mode'),
|
49
|
+
:namespace => Flag.new(:n, 'NAMESPACE', 'Namespace'),
|
50
|
+
:uninstall_name => Flag.new(:name, 'NAME', 'Module name to uninstall'),
|
51
|
+
:link_name => Flag.new([:l, :link_name], 'link-name', 'Specify link name'),
|
52
|
+
:format => Flag.new(:format, 'FORMAT', 'Choose in which format to display data (ex. TABLE, YAML)'),
|
54
53
|
|
55
54
|
# switches
|
56
55
|
# Switch constructor args order: key, desc, opts={}
|
data/lib/cli/version.rb
CHANGED
@@ -37,8 +37,8 @@ module DTK::Client
|
|
37
37
|
query_string_hash = QueryStringHash.new(
|
38
38
|
:module_name => module_ref.module_name,
|
39
39
|
:namespace => module_ref.namespace,
|
40
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content
|
41
|
-
|
40
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
41
|
+
:force? => opts[:force]
|
42
42
|
)
|
43
43
|
|
44
44
|
unless version = module_ref.version
|
@@ -67,7 +67,6 @@ module DTK::Client
|
|
67
67
|
module_ref_opts.merge!(:version => version) unless version.eql?('all')
|
68
68
|
return unless Console.prompt_yes_no("Are you sure you want to delete module '#{DTK::Common::PrettyPrintForm.module_ref(module_ref.module_name, module_ref_opts)}' from repo manager?", :add_options => true)
|
69
69
|
end
|
70
|
-
|
71
70
|
rest_post "#{BaseRoute}/delete_from_remote", query_string_hash
|
72
71
|
|
73
72
|
nil
|
@@ -27,12 +27,12 @@ module DTK::Client
|
|
27
27
|
directory_path = args[:directory_path]
|
28
28
|
|
29
29
|
post_body = PostBody.new(
|
30
|
-
:namespace
|
31
|
-
:module_name
|
32
|
-
:assembly_name?
|
33
|
-
:version?
|
34
|
-
:
|
35
|
-
:
|
30
|
+
:namespace => module_ref.namespace,
|
31
|
+
:module_name => module_ref.module_name,
|
32
|
+
:assembly_name? => args.required(:assembly_name),
|
33
|
+
:version? => args[:version],
|
34
|
+
:context_service_names? => args[:context_service_names],
|
35
|
+
:is_base? => args[:is_base]
|
36
36
|
)
|
37
37
|
|
38
38
|
error_msg = "To allow stage to go through, invoke 'dtk push' to push the changes to server before invoking stage again"
|
@@ -23,6 +23,7 @@ module DTK::Client
|
|
23
23
|
module_ref = args.required(:module_ref)
|
24
24
|
name = args.required(:name)
|
25
25
|
version = args.required(:version)
|
26
|
+
force = args.required(:force)
|
26
27
|
|
27
28
|
unless name.nil?
|
28
29
|
query_string_hash = QueryStringHash.new(
|
@@ -46,8 +47,8 @@ module DTK::Client
|
|
46
47
|
end
|
47
48
|
|
48
49
|
end
|
49
|
-
|
50
50
|
post_body = module_ref_post_body(module_ref)
|
51
|
+
post_body.merge!(:force => force)
|
51
52
|
rest_post("#{BaseRoute}/delete", post_body)
|
52
53
|
|
53
54
|
error_msg =
|
@@ -19,19 +19,19 @@ module DTK::Client
|
|
19
19
|
class Operation
|
20
20
|
class Module < self
|
21
21
|
OPERATIONS = [
|
22
|
+
:clone_module,
|
23
|
+
:delete_from_remote,
|
22
24
|
:install,
|
25
|
+
:install_from_catalog,
|
23
26
|
:list,
|
24
27
|
:list_assemblies,
|
25
28
|
:list_remotes,
|
29
|
+
:publish,
|
30
|
+
:pull_dtkn,
|
26
31
|
:push,
|
27
|
-
:uninstall,
|
28
|
-
:clone_module,
|
29
|
-
:install_from_catalog,
|
30
32
|
:push_dtkn,
|
31
33
|
:stage,
|
32
|
-
:
|
33
|
-
:publish,
|
34
|
-
:delete_from_remote
|
34
|
+
:uninstall
|
35
35
|
]
|
36
36
|
OPERATIONS.each { |operation| require_relative("module/#{operation}") }
|
37
37
|
|
data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result.rb
CHANGED
@@ -25,6 +25,7 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode::Element
|
|
25
25
|
def initialize(element, hash)
|
26
26
|
super
|
27
27
|
@errors = hash['errors'] || []
|
28
|
+
@info = hash['info'] || []
|
28
29
|
end
|
29
30
|
|
30
31
|
# This can be over-written
|
@@ -42,6 +43,7 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode::Element
|
|
42
43
|
protected
|
43
44
|
|
44
45
|
attr_reader :errors
|
46
|
+
attr_reader :info
|
45
47
|
|
46
48
|
def render_errors(results_per_node)
|
47
49
|
return unless results_per_node.find { |result| not result.errors.empty?}
|
@@ -55,12 +57,38 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode::Element
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
60
|
+
def render_info(results_per_node)
|
61
|
+
return unless results_per_node.find do |result|
|
62
|
+
not result.info.empty? and result.errors.empty?
|
63
|
+
end
|
64
|
+
# { |result| not result.errors.empty?}
|
65
|
+
first_time = true
|
66
|
+
results_per_node.each do |result|
|
67
|
+
if first_time
|
68
|
+
render_line 'INFO:'
|
69
|
+
first_time = false
|
70
|
+
end
|
71
|
+
result.render_node_info
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
58
75
|
def render_node_errors
|
59
76
|
return if @errors.empty?
|
60
77
|
render_node_term
|
61
78
|
@errors.each do |error|
|
62
79
|
if err_msg = error['message']
|
63
|
-
render_error_line err_msg
|
80
|
+
render_error_line err_msg
|
81
|
+
render_empty_line
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def render_node_info
|
87
|
+
return if @info.empty? || !@errors.empty?
|
88
|
+
@info.each do |info|
|
89
|
+
if err_msg = info[1]
|
90
|
+
#err_msg.colorize(:yellow)
|
91
|
+
render_info_line err_msg
|
64
92
|
render_empty_line
|
65
93
|
end
|
66
94
|
end
|
@@ -69,6 +97,10 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode::Element
|
|
69
97
|
def render_error_line(line, opts = {})
|
70
98
|
render_line(line, ErrorRenderOpts.merge(opts))
|
71
99
|
end
|
100
|
+
|
101
|
+
def render_info_line(line, opts = {})
|
102
|
+
render_line(line)
|
103
|
+
end
|
72
104
|
ErrorRenderOpts = { :tabs => 1}
|
73
105
|
|
74
106
|
end
|
@@ -32,6 +32,14 @@ class DTK::Client::Operation::Service::TaskStatus::StreamMode::Element
|
|
32
32
|
@formatter.formatted_duration?(field?(:duration))
|
33
33
|
end
|
34
34
|
|
35
|
+
def current_status
|
36
|
+
if @response_element["status"] == 'debugging' && @response_element["type"].include?("stage_end")
|
37
|
+
return true
|
38
|
+
else
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
def render_duration_line
|
36
44
|
render_line(@formatter.duration_msg?(field?(:duration)))
|
37
45
|
end
|
@@ -31,8 +31,7 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode
|
|
31
31
|
def self.get_and_render_stages(task_status_handle, opts = {})
|
32
32
|
unless wait = opts[:wait]
|
33
33
|
raise Error, "opts[:wait] must be set"
|
34
|
-
end
|
35
|
-
|
34
|
+
end
|
36
35
|
cursor = Cursor.new
|
37
36
|
until cursor.task_end? do
|
38
37
|
elements = get_single_stage(task_status_handle, cursor.stage, {:wait_for => cursor.wait_for}.merge(opts))
|
@@ -41,10 +40,15 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode
|
|
41
40
|
next
|
42
41
|
end
|
43
42
|
render_elements(elements)
|
44
|
-
|
43
|
+
# Can there be more than 1 element in elements array?
|
44
|
+
if elements.first.current_status
|
45
|
+
cursor.advance!(true)
|
46
|
+
else
|
47
|
+
cursor.advance!(task_end?(elements))
|
48
|
+
end
|
45
49
|
end
|
46
50
|
end
|
47
|
-
|
51
|
+
|
48
52
|
class Cursor
|
49
53
|
def initialize
|
50
54
|
@stage = 1
|
@@ -55,7 +55,7 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode
|
|
55
55
|
# opts can have
|
56
56
|
# :ignore_stage_level_info - Boolean
|
57
57
|
def self.create_elements(response, opts = {})
|
58
|
-
response_elements = response.data
|
58
|
+
response_elements = response.data
|
59
59
|
unless response_elements.kind_of?(Array)
|
60
60
|
raise Error.new("Unexpected that response.data no at array")
|
61
61
|
end
|
@@ -82,8 +82,31 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode
|
|
82
82
|
elements.find{|el|el.kind_of?(NoResults)}
|
83
83
|
end
|
84
84
|
|
85
|
+
def self.debug_mode?(response)
|
86
|
+
debug_mode_rows(response).size > 0
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.debug_mode_rows(response)
|
90
|
+
response['data'].select do |data_row|
|
91
|
+
data_row['status'] == 'debugging'
|
92
|
+
end
|
93
|
+
#{ |data_row| data_row['status'] == 'debugging' }
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.add_info_if_debug_mode!(response)
|
97
|
+
debug_info_rows = debug_mode_rows(response).select { |row| (row['info'] || {}) }
|
98
|
+
if debug_info_rows.size > 0
|
99
|
+
info_message = debug_info_rows.last['info']['message']
|
100
|
+
#response.set_render_as_table!(nil, info_message)
|
101
|
+
else
|
102
|
+
#response.set_render_as_table!
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
85
106
|
def self.render_elements(elements)
|
86
|
-
elements.each{ |el| el.render }
|
107
|
+
elements.each do |el| #{ |el| el.render }
|
108
|
+
el.render
|
109
|
+
end
|
87
110
|
end
|
88
111
|
|
89
112
|
def render_stage_steps(subtasks)
|
@@ -18,34 +18,35 @@
|
|
18
18
|
module DTK::Client
|
19
19
|
class Operation
|
20
20
|
class Service < self
|
21
|
+
# TODO: remove deprecated operations
|
21
22
|
OPERATIONS = [
|
22
|
-
:
|
23
|
+
:cancel_task,
|
23
24
|
:clone_service,
|
25
|
+
:commit_and_push,
|
26
|
+
:converge,
|
27
|
+
# :create_workspace TODO: put this back in
|
24
28
|
:delete,
|
25
|
-
:uninstall,
|
26
29
|
:edit,
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
+
:eject,
|
31
|
+
:exec,
|
32
|
+
:link,
|
30
33
|
:list,
|
31
34
|
:list_actions,
|
32
35
|
:list_attributes,
|
33
36
|
:list_component_links,
|
34
|
-
:list_dependencies,
|
35
37
|
:list_components,
|
38
|
+
:list_dependencies,
|
36
39
|
:list_nodes,
|
37
40
|
:list_violations,
|
38
|
-
:
|
39
|
-
:start,
|
40
|
-
:stop,
|
41
|
-
:cancel_task,
|
42
|
-
:ssh,
|
43
|
-
:set_required_attributes,
|
41
|
+
:pull,
|
44
42
|
:set_attribute,
|
45
|
-
:exec,
|
46
43
|
:set_default_target,
|
47
|
-
:
|
48
|
-
|
44
|
+
:set_required_attributes,
|
45
|
+
:ssh,
|
46
|
+
:start,
|
47
|
+
:stop,
|
48
|
+
:task_status,
|
49
|
+
:uninstall
|
49
50
|
]
|
50
51
|
OPERATIONS.each { |operation| require_relative("service/#{operation}") }
|
51
52
|
|
@@ -17,12 +17,31 @@
|
|
17
17
|
#
|
18
18
|
module DTK::Client
|
19
19
|
module Validation
|
20
|
-
ValidNameCharacters = ['letters', 'numbers', '-', '_', '.']
|
21
|
-
|
22
20
|
def self.validate_name(name)
|
23
|
-
unless name
|
24
|
-
|
21
|
+
raise Error::Usage, "Name '#{name}' contains invalid characters! Valid characters are: #{valid_characters}" unless valid_name?(name)
|
22
|
+
name
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.process_comma_seperated_contexts(comma_seperated_contexts)
|
26
|
+
if comma_seperated_contexts
|
27
|
+
comma_seperated_contexts.split(',').map do |service_instance_name|
|
28
|
+
service_instance_name.gsub!(' ', '')
|
29
|
+
raise Error::Usage, "Name '#{name}' in context contains invalid characters! Valid characters are: #{valid_characters}" unless valid_name?(service_instance_name)
|
30
|
+
service_instance_name
|
31
|
+
end.reject(&:empty?)
|
25
32
|
end
|
26
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def self.valid_name?(name)
|
38
|
+
name.to_s.match(/\A[\w\-\.]+\z/)
|
39
|
+
end
|
40
|
+
|
41
|
+
VALID_NAME_CHARACTERS = ['letters', 'numbers', '-', '_', '.']
|
42
|
+
def self.valid_characters
|
43
|
+
VALID_NAME_CHARACTERS.join("', '")
|
44
|
+
end
|
45
|
+
|
27
46
|
end
|
28
47
|
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.5
|
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-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dtk-common-core
|
@@ -197,7 +197,6 @@ files:
|
|
197
197
|
- lib/cli/command/service/set_default_target.rb
|
198
198
|
- lib/cli/command/service/set_required_attributes.rb
|
199
199
|
- lib/cli/command/service/ssh.rb
|
200
|
-
- lib/cli/command/service/stage.rb
|
201
200
|
- lib/cli/command/service/start.rb
|
202
201
|
- lib/cli/command/service/stop.rb
|
203
202
|
- lib/cli/command/service/task_status.rb
|
@@ -307,7 +306,6 @@ files:
|
|
307
306
|
- lib/client/operation/service/set_default_target.rb
|
308
307
|
- lib/client/operation/service/set_required_attributes.rb
|
309
308
|
- lib/client/operation/service/ssh.rb
|
310
|
-
- lib/client/operation/service/stage.rb
|
311
309
|
- lib/client/operation/service/start.rb
|
312
310
|
- lib/client/operation/service/stop.rb
|
313
311
|
- lib/client/operation/service/task_status.rb
|
@@ -1,59 +0,0 @@
|
|
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 'stage' do |c|
|
22
|
-
c.arg Token::Arg.assembly_name, :optional => true
|
23
|
-
command_body c, :stage, 'Create a new service instance to refer to staged infrastructure that then can be deployed' do |sc|
|
24
|
-
sc.flag Token.directory_path, :desc => 'Path to module directory where assembly is being staged from; not needed if in the module directory'
|
25
|
-
sc.flag Token.service_name, :desc => 'If specified, name to use for new service instance; otherwise service instance name is auto-generated'
|
26
|
-
sc.flag Token.parent_service_instance
|
27
|
-
sc.switch Token.force
|
28
|
-
sc.switch Token.target
|
29
|
-
# on useful for testing in dev mode
|
30
|
-
# sc.switch Token.purge, :desc => 'Overwrite any content that presently exists in the service instance directory to be created'
|
31
|
-
# sc.flag Token.version
|
32
|
-
sc.action do |_global_options, options, args|
|
33
|
-
module_ref = module_ref_object_from_options_or_context(options)
|
34
|
-
assembly_name = args[0]
|
35
|
-
version = options[:version] || module_ref.version
|
36
|
-
service_name = options[:service_name]
|
37
|
-
force = options[:f]
|
38
|
-
directory_path = options[:directory_path]
|
39
|
-
|
40
|
-
Validation.validate_name(service_name) if service_name
|
41
|
-
|
42
|
-
args = {
|
43
|
-
:module_ref => module_ref,
|
44
|
-
:assembly_name => assembly_name,
|
45
|
-
:service_name => service_name,
|
46
|
-
:version => version,
|
47
|
-
:target_service => options[:parent_service_instance],
|
48
|
-
:remove_existing => options[:purge],
|
49
|
-
:is_target => options[:target],
|
50
|
-
:force => force,
|
51
|
-
:directory_path => directory_path
|
52
|
-
}
|
53
|
-
Operation::Service.stage(args)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,64 +0,0 @@
|
|
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 Stage < self
|
21
|
-
def self.execute(args = Args.new)
|
22
|
-
wrap_operation(args) do |args|
|
23
|
-
module_ref = args.required(:module_ref)
|
24
|
-
remove_existing = args[:remove_existing]
|
25
|
-
service_name = args[:service_name]
|
26
|
-
force = args[:force]
|
27
|
-
directory_path = args[:directory_path]
|
28
|
-
|
29
|
-
post_body = PostBody.new(
|
30
|
-
:namespace => module_ref.namespace,
|
31
|
-
:module_name => module_ref.module_name,
|
32
|
-
:assembly_name? => args.required(:assembly_name),
|
33
|
-
:version? => args[:version],
|
34
|
-
:target_service? => args[:target_service],
|
35
|
-
:is_target? => args[:is_target]
|
36
|
-
)
|
37
|
-
|
38
|
-
GitRepo.modified?(directory_path || OsUtil.current_dir) unless force
|
39
|
-
service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
|
40
|
-
base_path = ClientModuleDir.ret_base_path(:service, service_name)
|
41
|
-
|
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
|
-
|
44
|
-
post_body.merge!(:service_name => service_name)
|
45
|
-
response = rest_post("#{BaseRoute}/create", post_body)
|
46
|
-
|
47
|
-
service_instance = response.required(:service, :name)
|
48
|
-
|
49
|
-
clone_args = {
|
50
|
-
:module_ref => module_ref,
|
51
|
-
:repo_url => response.required(:repo, :url),
|
52
|
-
:branch => response.required(:branch, :name),
|
53
|
-
:service_instance => service_instance,
|
54
|
-
:remove_existing => remove_existing
|
55
|
-
}
|
56
|
-
message = ClientModuleDir::GitRepo.clone_service_repo(clone_args)
|
57
|
-
target_dir = message.data(:target_repo_dir)
|
58
|
-
|
59
|
-
OsUtil.print_info("Service instance '#{service_instance}' has been created. In order to work with service instance, please navigate to: #{target_dir}")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|