dtk-client 0.10.0.2 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/dtk-client.gemspec +1 -1
  4. data/lib/cli/command/module/install.rb +8 -4
  5. data/lib/cli/command/module/list_remotes.rb +39 -0
  6. data/lib/cli/command/module.rb +1 -1
  7. data/lib/cli/command/service/clone.rb +43 -0
  8. data/lib/cli/command/service/delete.rb +48 -0
  9. data/lib/cli/command/service/exec.rb +10 -1
  10. data/lib/cli/command/service/exec_sync.rb +8 -2
  11. data/lib/cli/command/service/set_attribute.rb +46 -0
  12. data/lib/cli/command/service/ssh.rb +1 -1
  13. data/lib/cli/command/service/uninstall.rb +53 -0
  14. data/lib/cli/command/service.rb +4 -1
  15. data/lib/cli/command/token.rb +7 -1
  16. data/lib/cli/context/type.rb +3 -2
  17. data/lib/cli/context.rb +4 -7
  18. data/lib/cli/directory_parser/file_system.rb +16 -12
  19. data/lib/cli/version.rb +1 -1
  20. data/lib/client/content_generator.rb +62 -3
  21. data/lib/client/operation/client_module_dir/git_repo.rb +2 -2
  22. data/lib/client/operation/client_module_dir.rb +4 -2
  23. data/lib/client/operation/module/clone_module.rb +0 -1
  24. data/lib/client/operation/module/install/external_module.rb +89 -15
  25. data/lib/client/operation/module/install.rb +6 -6
  26. data/lib/client/operation/module/install_from_catalog.rb +1 -1
  27. data/lib/client/operation/module/list_assemblies.rb +1 -1
  28. data/lib/client/operation/module/list_remotes.rb +37 -0
  29. data/lib/client/operation/module.rb +1 -1
  30. data/lib/client/operation/service/clone_service.rb +50 -0
  31. data/lib/client/operation/service/delete.rb +44 -0
  32. data/lib/client/operation/service/exec.rb +5 -0
  33. data/lib/client/operation/service/set_attribute.rb +47 -0
  34. data/lib/client/operation/service/set_required_attributes.rb +11 -1
  35. data/lib/client/operation/service/stage.rb +9 -2
  36. data/lib/client/operation/service/task_status/refresh_mode.rb +1 -0
  37. data/lib/client/operation/service/task_status/snapshot_mode.rb +1 -0
  38. data/lib/client/operation/service/task_status/stream_mode/element/hierarchical_task/result.rb +4 -0
  39. data/lib/client/operation/service/task_status.rb +3 -1
  40. data/lib/client/operation/service/uninstall.rb +46 -0
  41. data/lib/client/operation/service.rb +10 -1
  42. data/lib/client/render/view/table/processor.rb +2 -2
  43. data/lib/client/response/render_helper.rb +4 -0
  44. data/lib/client/util/console.rb +23 -0
  45. metadata +15 -5
@@ -23,7 +23,6 @@ module DTK::Client
23
23
  module_ref = args.required(:module_ref)
24
24
  module_name = args.required(:module_name)
25
25
  target_directory = args[:target_directory]
26
-
27
26
  unless module_info = module_exists?(module_ref, :type => :common_module)
28
27
  raise Error::Usage, "DTK module '#{module_ref.print_form}' does not exist on server."
29
28
  end
@@ -21,25 +21,79 @@ module DTK::Client
21
21
  BaseRoute = "modules"
22
22
 
23
23
  def self.install_dependent_modules(module_refs, opts = {})
24
+ # if skip_prompt option is sent it means user wants to update_all
25
+ @update_all = opts[:skip_prompt]
26
+ @update_none = false
27
+ @print_dependency_newline = false
28
+
24
29
  module_refs.each do |module_ref|
25
30
  if module_exists?(module_ref, { :type => :component_module })
26
- OsUtil.print("Using module '#{module_ref.namespace}:#{module_ref.module_name}'" + (module_ref.version.nil? ? "" : " version: #{module_ref.version} "))
27
- # If component module is imported, still check to see if it's dependencies are imported
28
- find_and_install_component_module_dependency(module_ref, opts.merge(:skip_if_no_remote => true))
31
+ print_using_message(module_ref, opts)
32
+ pull_module?(module_ref, opts)
33
+ find_and_install_component_module_dependency(module_ref, opts.merge(:skip_if_no_remote => true, indent: " "))
29
34
  else
30
35
  install_module(module_ref, opts)
31
36
  end
32
37
  end
33
38
  end
34
39
 
40
+ def self.pull_dependent_modules?(module_refs, opts = {})
41
+ module_refs.each do |module_ref|
42
+ print_using_message(module_ref, opts)
43
+ pull_module?(module_ref, opts)
44
+ end
45
+ end
46
+
35
47
  private
36
48
 
49
+ def self.pull_module?(component_module, opts = {})
50
+ namespace = component_module.namespace
51
+ module_name = component_module.module_name
52
+ version = component_module.version
53
+ full_module_name = "#{namespace}:#{module_name}"
54
+
55
+ return if @update_none
56
+ options = %w(all none)
57
+ unless @update_all
58
+ update = Console.confirmation_prompt_additional_options("#{opts[:indent]}Do you want to update dependent module '#{full_module_name}' from the catalog?", options)
59
+
60
+ return unless update
61
+
62
+ if update.eql?('all')
63
+ @update_all = true
64
+ elsif update.eql?('none')
65
+ @update_none = true
66
+ return
67
+ end
68
+ end
69
+
70
+ print "#{opts[:indent]}Pulling component module content for '#{full_module_name}' ... "
71
+
72
+ post_body = {
73
+ :module_name => module_name,
74
+ :namespace => namespace,
75
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
76
+ :version? => version,
77
+ :full_module_name => full_module_name,
78
+ :json_diffs => ""
79
+ }
80
+ response = rest_post "#{BaseRoute}/update_dependency_from_remote", PostBody.new(post_body)
81
+
82
+ if custom_message = response.data[:custom_message]
83
+ OsUtil.print(custom_message)
84
+ elsif (response.data[:diffs].nil? || response.data[:diffs].empty?)
85
+ OsUtil.print("No changes to pull from remote.", :yellow) unless response['errors']
86
+ else
87
+ OsUtil.print("Changes pulled from remote", :green)
88
+ end
89
+ end
90
+
37
91
  def self.install_module(component_module, opts = {})
38
92
  namespace = component_module.namespace
39
93
  module_name = component_module.module_name
40
94
  version = component_module.version
41
95
 
42
- import_msg = "Importing module '#{namespace}:#{module_name}"
96
+ import_msg = "#{opts[:indent]}Importing module '#{namespace}:#{module_name}"
43
97
  import_msg += "(#{version})" if version && !version.eql?('master')
44
98
  import_msg += "' ... "
45
99
 
@@ -50,12 +104,12 @@ module DTK::Client
50
104
  post_body = {
51
105
  :module_name => module_name,
52
106
  :namespace => namespace,
53
- :rsa_pub_key => SSHUtil.rsa_pub_key_content(),
107
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
54
108
  :version? => version
55
109
  }
56
110
 
57
111
  unless opts[:skip_dependencies]
58
- find_and_install_component_module_dependency(component_module, opts.merge(:add_newline => true))
112
+ find_and_install_component_module_dependency(component_module, opts.merge(:add_newline => true, indent: " "))
59
113
  end
60
114
 
61
115
  response = rest_post "#{BaseRoute}/install_component_module", PostBody.new(post_body)
@@ -65,11 +119,16 @@ module DTK::Client
65
119
  :repo_url => response.required(:repo_url),
66
120
  :branch => response.required(:workspace_branch),
67
121
  :module_name => response.required(:full_module_name)
68
- # :remove_existing => remove_existing
69
122
  }
70
- ClientModuleDir::GitRepo.clone_module_repo(clone_args)
71
123
 
72
- OsUtil.print_info('Done.')
124
+ if opts[:add_newline]
125
+ print OsUtil.colorize("Done.", :yellow)
126
+ @print_dependency_newline = true
127
+ else
128
+ print "\n" if @print_dependency_newline
129
+ OsUtil.print('Done.', :yellow)
130
+ @print_dependency_newline = false
131
+ end
73
132
 
74
133
  response
75
134
  end
@@ -105,14 +164,29 @@ module DTK::Client
105
164
  return false unless Console.prompt_yes_no("Do you still want to proceed with import?", :add_options => true)
106
165
  end
107
166
 
108
- if missing_modules = dependencies.data(:missing_module_components)
109
- unless missing_modules.empty?
110
- dep_module_refs = (missing_modules || []).map do |ref_hash|
111
- ModuleRef.new(:namespace => ref_hash['namespace'], :module_name => ref_hash['name'], :version => ref_hash['version'])
112
- end
113
- install_dependent_modules(dep_module_refs, opts.merge(:skip_dependencies => true))
167
+ if (missing_modules = dependencies.data(:missing_module_components)) && !missing_modules.empty?
168
+ dep_module_refs = (missing_modules || []).map do |ref_hash|
169
+ ModuleRef.new(:namespace => ref_hash['namespace'], :module_name => ref_hash['name'], :version => ref_hash['version'])
170
+ end
171
+ install_dependent_modules(dep_module_refs, opts.merge(:skip_dependencies => true))
172
+ end
173
+
174
+ if (required_modules = dependencies.data(:required_modules)) && !required_modules.empty?
175
+ dep_module_refs = (required_modules || []).map do |ref_hash|
176
+ required_modules.uniq!
177
+ ModuleRef.new(:namespace => ref_hash['namespace'], :module_name => ref_hash['name'], :version => ref_hash['version'])
114
178
  end
179
+ pull_dependent_modules?(dep_module_refs, opts.merge(:skip_dependencies => true))
180
+ end
181
+ end
182
+
183
+ def self.print_using_message(module_ref, opts = {})
184
+ # special case where, after importing dependencies of dependency, comes a using message
185
+ if opts[:add_newline]
186
+ print "\n"
187
+ @print_dependency_newline = false
115
188
  end
189
+ OsUtil.print("#{opts[:indent]}Using module '#{module_ref.namespace}:#{module_ref.module_name}'" + (module_ref.version.nil? ? "" : " version: #{module_ref.version} "))
116
190
  end
117
191
 
118
192
  end
@@ -23,17 +23,17 @@ module DTK::Client
23
23
 
24
24
  def self.execute(args = Args.new)
25
25
  wrap_operation(args) do |args|
26
- base_module_ref = args.required(:module_ref)
27
26
  if args[:flag]
28
- file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content_flag(:module_ref)
27
+ file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content_flag(:module_ref)
29
28
  else
30
- file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content
29
+ file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content
31
30
  end
32
- new(file_obj, base_module_ref).install
31
+
32
+ new(file_obj, args.required(:module_ref)).install(:skip_prompt => args[:skip_prompt])
33
33
  end
34
34
  end
35
35
 
36
- def install
36
+ def install(opts = {})
37
37
  unless @base_module_ref
38
38
  raise Error::Usage, "No base module reference #{dsl_path_ref}"
39
39
  end
@@ -44,7 +44,7 @@ module DTK::Client
44
44
 
45
45
  unless dependent_modules.empty?
46
46
  OsUtil.print_info('Auto-importing dependencies')
47
- ExternalModule.install_dependent_modules(dependent_modules)
47
+ ExternalModule.install_dependent_modules(dependent_modules, opts)
48
48
  OsUtil.print_info("Successfully imported '#{@base_module_ref.namespace}:#{@base_module_ref.module_name}' version #{@base_module_ref.version}")
49
49
  end
50
50
 
@@ -52,7 +52,7 @@ module DTK::Client
52
52
  git_repo_args = {
53
53
  :repo_dir => target_repo_dir,
54
54
  :repo_url => module_info.required(:remote_repo_url),
55
- :remote_branch => @version ? "v#{@version}" : 'master'
55
+ :remote_branch => (@version && !@version.eql?('master')) ? "v#{@version}" : 'master'
56
56
  }
57
57
  ClientModuleDir::GitRepo.create_add_remote_and_pull(git_repo_args)
58
58
 
@@ -24,7 +24,7 @@ module DTK::Client
24
24
  if module_ref = args[:module_ref]
25
25
  query_string_hash = module_ref_query_string_hash(module_ref)
26
26
  end
27
- rest_get("#{BaseRoute}/list_assemblies", query_string_hash)
27
+ rest_get("#{BaseRoute}/assemblies", query_string_hash)
28
28
  end.set_render_as_table!
29
29
  end
30
30
 
@@ -0,0 +1,37 @@
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::Module
20
+ class ListRemotes < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |_args|
23
+
24
+ query_string_hash = QueryStringHash.new(
25
+ :detail_to_include => ['remotes', 'versions'],
26
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
27
+ :module_namespace? => args[:module_namespace]
28
+ )
29
+
30
+ rest_get("#{BaseRoute}/remote_modules", query_string_hash)
31
+ end.set_render_as_table!
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+
@@ -18,7 +18,7 @@
18
18
  module DTK::Client
19
19
  class Operation
20
20
  class Module < self
21
- OPERATIONS = [:install, :list, :list_assemblies, :push, :uninstall, :clone_module, :install_from_catalog]
21
+ OPERATIONS = [:install, :list, :list_assemblies, :list_remotes, :push, :uninstall, :clone_module, :install_from_catalog]
22
22
  OPERATIONS.each { |operation| require_relative("module/#{operation}") }
23
23
 
24
24
  BaseRoute = 'modules'
@@ -0,0 +1,50 @@
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 CloneService < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_ref = args.required(:service_ref)
24
+ service_name = args.required(:service_name)
25
+ target_directory = args[:target_directory]
26
+ unless service_info = service_exists?(service_ref)
27
+ raise Error::Usage, "DTK service '#{service_ref}' does not exist on server."
28
+ end
29
+
30
+ branch = service_info.required(:branch, :name)
31
+ repo_url = service_info.required(:repo, :url)
32
+ repo_name = service_info.required(:repo, :name)
33
+
34
+ clone_args = {
35
+ :repo_url => service_info.required(:repo, :url),
36
+ :branch => service_info.required(:branch, :name),
37
+ :service_instance => service_name,
38
+ #:service_name => service_name,
39
+ :repo_dir => target_directory || ClientModuleDir.ret_path_with_current_dir(service_name)
40
+ }
41
+
42
+ ret = ClientModuleDir::GitRepo.clone_service_repo(clone_args)
43
+ OsUtil.print_info("DTK service '#{service_ref}' has been successfully cloned into '#{ret.required(:target_repo_dir)}'")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+
@@ -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
+ class Operation::Service
20
+ class Delete < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_instance = args.required(:service_instance)
24
+ recursive = args.required(:recursive)
25
+
26
+ unless args[:skip_prompt]
27
+ return false unless Console.prompt_yes_no("Are you sure you want to delete the content of service instance '#{service_instance}' ?", :add_options => true)
28
+ end
29
+
30
+ post_body = PostBody.new(
31
+ :service_instance => service_instance,
32
+ :recursive? => recursive
33
+ )
34
+ rest_post("#{BaseRoute}/delete", post_body)
35
+
36
+ OsUtil.print_info("DTK module '#{service_instance}' has been deleted successfully.")
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+
@@ -51,6 +51,11 @@ module DTK::Client
51
51
  return Response::Ok.new('empty_workflow' => true)
52
52
  end
53
53
 
54
+ if response.data(:violations)
55
+ OsUtil.print_error("Cannot execute an action or workflow if there are violations:")
56
+ return response.set_render_as_table!
57
+ end
58
+
54
59
  response
55
60
  end
56
61
  end
@@ -0,0 +1,47 @@
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 SetAttribute < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_instance = args.required(:service_instance)
24
+ attribute_name = args[:attribute_name]
25
+ attribute_value = args[:attribute_value]
26
+
27
+ query_string_hash = QueryStringHash.new(
28
+ :pattern? => attribute_name,
29
+ :value? => attribute_value
30
+ )
31
+ response = rest_post("#{BaseRoute}/#{service_instance}/set_attribute", query_string_hash)
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
+ nil
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -28,11 +28,21 @@ module DTK::Client
28
28
  OsUtil.print_info("No parameters to set.")
29
29
  else
30
30
  param_bindings = InteractiveWizard.resolve_missing_params(required_attributes)
31
+
31
32
  post_body = PostBody.new(
32
33
  :service_instance => service_instance,
33
34
  :av_pairs_hash => param_bindings.inject(Hash.new){|h,r|h.merge(r[:id] => r[:value])}
34
35
  )
35
- rest_post "#{BaseRoute}/#{service_instance}/set_attributes", post_body
36
+ response = rest_post "#{BaseRoute}/#{service_instance}/set_attributes", post_body
37
+
38
+ repo_info_args = Args.new(
39
+ :service_instance => service_instance,
40
+ :branch => response.required(:branch, :name),
41
+ :repo_url => response.required(:repo, :url)
42
+ )
43
+ ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args)
44
+
45
+ nil
36
46
  end
37
47
  end
38
48
  end
@@ -22,16 +22,23 @@ module DTK::Client
22
22
  wrap_operation(args) do |args|
23
23
  module_ref = args.required(:module_ref)
24
24
  remove_existing = args[:remove_existing]
25
+ service_name = args[:service_name]
25
26
 
26
27
  post_body = PostBody.new(
27
28
  :namespace => module_ref.namespace,
28
29
  :module_name => module_ref.module_name,
29
30
  :assembly_name? => args.required(:assembly_name),
30
- :service_name? => args[:service_name],
31
31
  :version? => args[:version],
32
32
  :target_service? => args[:target_service],
33
33
  :is_target? => args[:is_target]
34
34
  )
35
+
36
+ service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
37
+ path = ClientModuleDir.ret_base_path(:service, service_name)
38
+
39
+ raise Error::Usage, "Directory '#{path}' is not empty; it must be deleted or removed before retrying the command" if ClientModuleDir.local_dir_exists?(:service, service_name)
40
+
41
+ post_body.merge!(:service_name => service_name)
35
42
  response = rest_post("#{BaseRoute}/create", post_body)
36
43
 
37
44
  service_instance = response.required(:service, :name)
@@ -42,7 +49,7 @@ module DTK::Client
42
49
  :branch => response.required(:branch, :name),
43
50
  :service_instance => service_instance,
44
51
  :remove_existing => remove_existing
45
- }
52
+ }
46
53
  message = ClientModuleDir::GitRepo.clone_service_repo(clone_args)
47
54
  target_dir = message.data(:target_repo_dir)
48
55
 
@@ -41,6 +41,7 @@ module DTK::Client
41
41
  system('clear')
42
42
  # response.print_error_table = true
43
43
  # response.render_table(:task_status)
44
+ response.print_error_table!(true)
44
45
  return response.set_render_as_table!
45
46
  end
46
47
  end
@@ -20,6 +20,7 @@ module DTK::Client
20
20
  class SnapshotMode < self
21
21
  def task_status(opts = {})
22
22
  response = rest_call(opts)
23
+ response.print_error_table!(true)
23
24
  response.set_render_as_table!
24
25
  end
25
26
  end
@@ -27,6 +27,10 @@ module DTK::Client; class Operation::Service::TaskStatus::StreamMode::Element
27
27
  @errors = hash['errors'] || []
28
28
  end
29
29
 
30
+ # This can be over-written
31
+ def action_results
32
+ []
33
+ end
30
34
 
31
35
  def self.render(element, stage_subtasks)
32
36
  results_per_node = base_subtasks(element, stage_subtasks)
@@ -35,7 +35,9 @@ module DTK::Client
35
35
  if task_status_mode
36
36
  task_status_with_mode(task_status_mode.to_sym, service_instance)
37
37
  else
38
- rest_call(service_instance).set_render_as_table!
38
+ response = rest_call(service_instance)
39
+ response.print_error_table!(true)
40
+ response.set_render_as_table!
39
41
  end
40
42
  end
41
43
  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
19
+ class Operation::Service
20
+ class Uninstall < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_instance = args.required(:service_instance)
24
+ recursive = args.required(:recursive)
25
+
26
+ unless args[:skip_prompt]
27
+ return false unless Console.prompt_yes_no("Are you sure you want to uninstall the infrastructure associated with '#{service_instance}' and delete this service instance from the server?", :add_options => true)
28
+ end
29
+
30
+ post_body = PostBody.new(
31
+ :service_instance => service_instance,
32
+ :recursive? => recursive
33
+ )
34
+ rest_post("#{BaseRoute}/uninstall", post_body)
35
+
36
+ ClientModuleDir.purge_service_instance_dir(args[:directory_path]) if args[:purge]
37
+
38
+ OsUtil.print_info("DTK module '#{service_instance}' has been uninstalled successfully.")
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+
46
+
@@ -20,7 +20,9 @@ module DTK::Client
20
20
  class Service < self
21
21
  OPERATIONS = [
22
22
  :commit_and_push,
23
- :destroy,
23
+ :clone_service,
24
+ :delete,
25
+ :uninstall,
24
26
  :edit,
25
27
  :pull,
26
28
  :stage,
@@ -39,6 +41,7 @@ module DTK::Client
39
41
  :cancel_task,
40
42
  :ssh,
41
43
  :set_required_attributes,
44
+ :set_attribute,
42
45
  :exec,
43
46
  :set_default_target
44
47
  # :create_workspace
@@ -49,6 +52,12 @@ module DTK::Client
49
52
 
50
53
  extend ModuleServiceCommon::ClassMixin
51
54
 
55
+ private
56
+
57
+ def self.service_exists?(service_ref, opts = {})
58
+ response = rest_get("#{BaseRoute}/#{service_ref}/repo_info")
59
+ response.data.empty? ? nil : response
60
+ end
52
61
  end
53
62
  end
54
63
  end
@@ -97,7 +97,7 @@ module DTK::Client
97
97
  # original table takes that index
98
98
  evaluated_element.send("#{k}=", error_index)
99
99
  # we set new error element
100
- set_error_element!(error_element)
100
+ set_error_element!(error_element, error_index, error_type, error_message)
101
101
 
102
102
  # add it with other
103
103
  @error_data << error_element
@@ -122,7 +122,7 @@ module DTK::Client
122
122
  end
123
123
  end
124
124
 
125
- def set_error_element!(error_element)
125
+ def set_error_element!(error_element, error_index, error_type, error_message)
126
126
  error_element.id = error_index
127
127
  case error_type
128
128
  when 'user_error'
@@ -60,6 +60,10 @@ module DTK::Client
60
60
  @skip_render = skip
61
61
  end
62
62
 
63
+ def print_error_table!(value)
64
+ @print_error_table = value
65
+ end
66
+
63
67
  private
64
68
 
65
69
  def semantic_datatype_in_payload
@@ -63,6 +63,29 @@ module DTK::Client
63
63
 
64
64
  private
65
65
 
66
+ # Display confirmation prompt and repeat message until expected answer is given
67
+ # options should be sent as array ['all', 'none']
68
+ def self.confirmation_prompt_additional_options(message, options = [])
69
+ raise DTK::Client::DtkValidationError, "Options should be sent as array: ['all', 'none']" unless options.is_a?(Array)
70
+
71
+ # used to disable skip with ctrl+c
72
+ trap("INT", "SIG_IGN")
73
+ message += " (yes/no#{options.empty? ? '' : ('/' + options.join('/'))})"
74
+
75
+ while line = Readline.readline("#{message}: ", true)
76
+ if line.eql?("yes") || line.eql?("y")
77
+ trap("INT",false)
78
+ return true
79
+ elsif line.eql?("no") || line.eql?("n")
80
+ trap("INT",false)
81
+ return false
82
+ elsif options.include?(line)
83
+ trap("INT",false)
84
+ return line
85
+ end
86
+ end
87
+ end
88
+
66
89
  # opts can have keys
67
90
  # :disable_ctrl_c - Boolean (default: true)
68
91
  def self.prompt_context(opts = {}, &body)