dtk-client 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/Gemfile +1 -3
  4. data/README.md +2 -121
  5. data/Rakefile +44 -0
  6. data/bin/dtk +10 -88
  7. data/dtk-client.gemspec +21 -44
  8. data/examples/simple/dtk.module.yaml +32 -0
  9. data/{lib/git-logs/git.log → examples/simple/test/README.md} +0 -0
  10. data/examples/spark/dtk.module.yaml +120 -0
  11. data/examples/with_repo_content/deploy/puppet/manifests/hostname.pp +54 -0
  12. data/examples/with_repo_content/dtk.module.yaml +49 -0
  13. data/examples/with_repo_content/test/README.txt +0 -0
  14. data/features/dtk.feature +8 -0
  15. data/features/step_definitions/dtk_steps.rb +6 -0
  16. data/features/support/env.rb +15 -0
  17. data/lib/cli/command/mixin.rb +101 -0
  18. data/lib/cli/command/module/clone.rb +42 -0
  19. data/lib/cli/command/module/install.rb +52 -0
  20. data/lib/cli/command/module/list.rb +31 -0
  21. data/lib/cli/command/module/list_assemblies.rb +39 -0
  22. data/lib/cli/command/module/push.rb +34 -0
  23. data/lib/cli/command/module/uninstall.rb +46 -0
  24. data/lib/cli/command/module.rb +33 -0
  25. data/lib/cli/command/options.rb +33 -0
  26. data/lib/cli/command/service/cancel_task.rb +33 -0
  27. data/lib/cli/command/service/converge.rb +37 -0
  28. data/lib/{parser/adapters/thor/common_option_defs.rb → cli/command/service/create_workspace.rb} +13 -17
  29. data/lib/cli/command/service/destroy.rb +47 -0
  30. data/lib/cli/command/service/edit.rb +47 -0
  31. data/lib/cli/command/service/exec.rb +42 -0
  32. data/lib/cli/command/service/exec_sync.rb +53 -0
  33. data/lib/cli/command/service/list.rb +30 -0
  34. data/lib/cli/command/service/list_actions.rb +39 -0
  35. data/lib/cli/command/service/list_attributes.rb +44 -0
  36. data/lib/cli/command/service/list_component_links.rb +33 -0
  37. data/lib/cli/command/service/list_components.rb +39 -0
  38. data/lib/cli/command/service/list_dependent_modules.rb +33 -0
  39. data/lib/cli/command/service/list_nodes.rb +33 -0
  40. data/lib/cli/command/service/list_violations.rb +33 -0
  41. data/lib/cli/command/service/pull.rb +32 -0
  42. data/lib/cli/command/service/push.rb +37 -0
  43. data/lib/{shell/parse_monkey_patch.rb → cli/command/service/set_default_target.rb} +9 -17
  44. data/lib/cli/command/service/set_required_attributes.rb +32 -0
  45. data/lib/cli/command/service/ssh.rb +42 -0
  46. data/lib/cli/command/service/stage.rb +55 -0
  47. data/lib/cli/command/service/start.rb +33 -0
  48. data/lib/{shell/context_aux.rb → cli/command/service/stop.rb} +10 -23
  49. data/lib/cli/command/service/task_status.rb +39 -0
  50. data/lib/cli/command/service.rb +55 -0
  51. data/lib/{commands.rb → cli/command/subcommand.rb} +22 -25
  52. data/lib/{bundler_monkey_patch.rb → cli/command/token/arg.rb} +6 -6
  53. data/lib/cli/command/token/class_mixin.rb +96 -0
  54. data/lib/cli/command/token/flag.rb +42 -0
  55. data/lib/{execute/command/rest_call.rb → cli/command/token/mixin.rb} +23 -14
  56. data/lib/cli/command/token/switch.rb +35 -0
  57. data/lib/cli/command/token.rb +76 -0
  58. data/lib/cli/command.rb +46 -0
  59. data/lib/cli/context/attributes.rb +50 -0
  60. data/lib/cli/context/type/module.rb +34 -0
  61. data/lib/{commands/thor/state_change.rb → cli/context/type/service.rb} +11 -5
  62. data/lib/cli/context/type/top.rb +32 -0
  63. data/lib/cli/context/type.rb +42 -0
  64. data/lib/cli/context.rb +174 -0
  65. data/lib/cli/directory_parser/file_system.rb +105 -0
  66. data/lib/{execute/command.rb → cli/directory_parser.rb} +14 -17
  67. data/lib/{execute.rb → cli/file_obj.rb} +13 -9
  68. data/lib/cli/processor/plugin/gli.rb +70 -0
  69. data/lib/cli/processor.rb +60 -0
  70. data/lib/cli/runner/dtkn_access.rb +75 -0
  71. data/lib/cli/runner.rb +58 -0
  72. data/lib/cli/version.rb +8 -0
  73. data/lib/{config → client/config}/cacert.pem +0 -0
  74. data/lib/client/config/default.conf +20 -0
  75. data/lib/client/config.rb +106 -0
  76. data/lib/client/configurator.rb +182 -0
  77. data/lib/client/conn.rb +197 -0
  78. data/lib/client/content_generator.rb +127 -0
  79. data/lib/client/error/subclasses.rb +105 -0
  80. data/lib/client/error.rb +98 -0
  81. data/lib/client/git_repo/adapter/git_gem/error_handler.rb +70 -0
  82. data/lib/client/git_repo/adapter/git_gem.rb +179 -0
  83. data/lib/client/git_repo.rb +122 -0
  84. data/lib/client/logger.rb +136 -0
  85. data/lib/client/operation/account.rb +66 -0
  86. data/lib/client/operation/client_module_dir/git_repo.rb +286 -0
  87. data/lib/client/operation/client_module_dir.rb +138 -0
  88. data/lib/client/operation/module/clone_module.rb +52 -0
  89. data/lib/client/operation/module/install/common_module.rb +58 -0
  90. data/lib/client/operation/module/install/external_module.rb +122 -0
  91. data/lib/client/operation/module/install.rb +91 -0
  92. data/lib/client/operation/module/install_from_catalog.rb +76 -0
  93. data/lib/client/operation/module/list.rb +34 -0
  94. data/lib/client/operation/module/list_assemblies.rb +35 -0
  95. data/lib/client/operation/module/push.rb +62 -0
  96. data/lib/client/operation/module/uninstall.rb +44 -0
  97. data/lib/client/operation/module.rb +58 -0
  98. data/lib/{commands/common/thor/reparse.rb → client/operation/module_service_common.rb} +27 -16
  99. data/lib/client/operation/service/cancel_task.rb +29 -0
  100. data/lib/client/operation/service/commit_and_push.rb +128 -0
  101. data/lib/client/operation/service/converge.rb +50 -0
  102. data/lib/{util/common_util.rb → client/operation/service/create_workspace.rb} +13 -13
  103. data/lib/client/operation/service/destroy.rb +42 -0
  104. data/lib/client/operation/service/edit.rb +54 -0
  105. data/lib/client/operation/service/exec.rb +73 -0
  106. data/lib/client/operation/service/list.rb +32 -0
  107. data/lib/client/operation/service/list_actions.rb +34 -0
  108. data/lib/{commands/thor/dependency.rb → client/operation/service/list_attributes.rb} +16 -12
  109. data/lib/client/operation/service/list_component_links.rb +29 -0
  110. data/lib/{commands/common/thor/pull_clone_changes.rb → client/operation/service/list_components.rb} +13 -7
  111. data/lib/client/operation/service/list_dependent_modules.rb +29 -0
  112. data/lib/client/operation/service/list_nodes.rb +29 -0
  113. data/lib/{commands/thor/project.rb → client/operation/service/list_violations.rb} +8 -13
  114. data/lib/client/operation/service/pull.rb +37 -0
  115. data/lib/client/operation/service/set_default_target.rb +31 -0
  116. data/lib/client/operation/service/set_required_attributes.rb +41 -0
  117. data/lib/client/operation/service/ssh.rb +118 -0
  118. data/lib/client/operation/service/stage.rb +54 -0
  119. data/lib/client/operation/service/start.rb +29 -0
  120. data/lib/client/operation/service/stop.rb +30 -0
  121. data/lib/{task_status → client/operation/service/task_status}/refresh_mode.rb +15 -25
  122. data/lib/{task_status → client/operation/service/task_status}/snapshot_mode.rb +4 -5
  123. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/format.rb +1 -1
  124. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/action.rb +1 -1
  125. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/components.rb +1 -1
  126. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/node_level.rb +1 -1
  127. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result.rb +4 -4
  128. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
  129. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
  130. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
  131. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps.rb +4 -4
  132. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task.rb +3 -3
  133. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/no_results.rb +1 -1
  134. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/render.rb +1 -1
  135. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage/render.rb +1 -1
  136. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage.rb +3 -3
  137. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_end.rb +1 -1
  138. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_start.rb +1 -1
  139. data/lib/{task_status → client/operation/service/task_status}/stream_mode/element.rb +13 -13
  140. data/lib/{task_status → client/operation/service/task_status}/stream_mode.rb +5 -9
  141. data/lib/client/operation/service/task_status.rb +77 -0
  142. data/lib/client/operation/service.rb +54 -0
  143. data/lib/client/operation.rb +67 -0
  144. data/lib/client/operation_args.rb +40 -0
  145. data/lib/{execute/execute_context/result_store.rb → client/render/view/simple.rb} +15 -14
  146. data/lib/client/render/view/table/processor.rb +248 -0
  147. data/lib/client/render/view/table.rb +75 -0
  148. data/lib/client/render.rb +113 -0
  149. data/lib/client/response/error_handler.rb +97 -0
  150. data/lib/client/response/render_helper.rb +78 -0
  151. data/lib/client/response/subclasses.rb +62 -0
  152. data/lib/client/response.rb +83 -0
  153. data/lib/client/session.rb +62 -0
  154. data/lib/client/util/auxiliary.rb +34 -0
  155. data/lib/client/util/console.rb +81 -0
  156. data/lib/client/util/disk_cacher.rb +66 -0
  157. data/lib/client/util/dtk_path.rb +28 -0
  158. data/lib/{search_hash.rb → client/util/hash_with_optional_keys.rb} +29 -21
  159. data/lib/client/util/interactive_wizard.rb +84 -0
  160. data/lib/client/util/module_ref.rb +92 -0
  161. data/lib/client/util/os_util/print.rb +121 -0
  162. data/lib/client/util/os_util.rb +122 -0
  163. data/lib/{commands/thor/utils.rb → client/util/post_body.rb} +1 -1
  164. data/lib/{execute/error_usage.rb → client/util/query_string_hash.rb} +2 -2
  165. data/lib/client/util/remote_dependency.rb +67 -0
  166. data/lib/client/util/ssh_util.rb +89 -0
  167. data/lib/client/util/validation.rb +28 -0
  168. data/lib/client/util.rb +18 -0
  169. data/lib/{util/permission_util.rb → dtk_cli.rb} +10 -9
  170. data/lib/dtk_client.rb +18 -14
  171. data/test/default_test.rb +14 -0
  172. data/test/test_helper.rb +9 -0
  173. metadata +196 -307
  174. data/Gemfile_dev +0 -13
  175. data/bin/dtk-execute +0 -32
  176. data/bin/dtk-shell +0 -31
  177. data/lib/auxiliary.rb +0 -61
  178. data/lib/client.rb +0 -58
  179. data/lib/command_helper.rb +0 -33
  180. data/lib/command_helpers/git_repo/merge.rb +0 -153
  181. data/lib/command_helpers/git_repo.rb +0 -589
  182. data/lib/command_helpers/jenkins_client/config_xml.rb +0 -288
  183. data/lib/command_helpers/jenkins_client.rb +0 -106
  184. data/lib/command_helpers/service_importer.rb +0 -251
  185. data/lib/command_helpers/service_link.rb +0 -33
  186. data/lib/command_helpers/test_module_creator.rb +0 -69
  187. data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +0 -10
  188. data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +0 -10
  189. data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +0 -5
  190. data/lib/commands/common/thor/access_control.rb +0 -133
  191. data/lib/commands/common/thor/action_result_handler.rb +0 -74
  192. data/lib/commands/common/thor/assembly_template.rb +0 -92
  193. data/lib/commands/common/thor/assembly_workspace.rb +0 -1638
  194. data/lib/commands/common/thor/base_command_helper.rb +0 -59
  195. data/lib/commands/common/thor/clone.rb +0 -82
  196. data/lib/commands/common/thor/common.rb +0 -88
  197. data/lib/commands/common/thor/common_base.rb +0 -49
  198. data/lib/commands/common/thor/create_target.rb +0 -70
  199. data/lib/commands/common/thor/edit.rb +0 -255
  200. data/lib/commands/common/thor/inventory_parser.rb +0 -98
  201. data/lib/commands/common/thor/list_diffs.rb +0 -128
  202. data/lib/commands/common/thor/module/import.rb +0 -215
  203. data/lib/commands/common/thor/module.rb +0 -1011
  204. data/lib/commands/common/thor/node.rb +0 -53
  205. data/lib/commands/common/thor/poller.rb +0 -65
  206. data/lib/commands/common/thor/pull_from_remote.rb +0 -152
  207. data/lib/commands/common/thor/puppet_forge.rb +0 -72
  208. data/lib/commands/common/thor/purge_clone.rb +0 -101
  209. data/lib/commands/common/thor/push_clone_changes.rb +0 -162
  210. data/lib/commands/common/thor/push_to_remote.rb +0 -94
  211. data/lib/commands/common/thor/remotes.rb +0 -71
  212. data/lib/commands/common/thor/set_required_attributes.rb +0 -46
  213. data/lib/commands/thor/account.rb +0 -239
  214. data/lib/commands/thor/assembly.rb +0 -361
  215. data/lib/commands/thor/attribute.rb +0 -79
  216. data/lib/commands/thor/component.rb +0 -70
  217. data/lib/commands/thor/component_module.rb +0 -501
  218. data/lib/commands/thor/component_template.rb +0 -174
  219. data/lib/commands/thor/developer.rb +0 -144
  220. data/lib/commands/thor/dtk.rb +0 -152
  221. data/lib/commands/thor/library.rb +0 -125
  222. data/lib/commands/thor/node.rb +0 -504
  223. data/lib/commands/thor/node_group.rb +0 -203
  224. data/lib/commands/thor/node_template.rb +0 -94
  225. data/lib/commands/thor/provider.rb +0 -233
  226. data/lib/commands/thor/remotes.rb +0 -49
  227. data/lib/commands/thor/service.rb +0 -932
  228. data/lib/commands/thor/service_module.rb +0 -900
  229. data/lib/commands/thor/target.rb +0 -250
  230. data/lib/commands/thor/task.rb +0 -116
  231. data/lib/commands/thor/test_module.rb +0 -310
  232. data/lib/commands/thor/workspace.rb +0 -698
  233. data/lib/config/client.conf.header +0 -20
  234. data/lib/config/configuration.rb +0 -99
  235. data/lib/config/default.conf +0 -16
  236. data/lib/config/disk_cacher.rb +0 -80
  237. data/lib/configurator.rb +0 -176
  238. data/lib/context_router.rb +0 -44
  239. data/lib/core.rb +0 -489
  240. data/lib/domain/git_adapter.rb +0 -412
  241. data/lib/domain/git_error_handler.rb +0 -64
  242. data/lib/domain/response/error_handler.rb +0 -86
  243. data/lib/domain/response.rb +0 -285
  244. data/lib/dtk-client/version.rb +0 -20
  245. data/lib/dtk_constants.rb +0 -40
  246. data/lib/dtk_error.rb +0 -114
  247. data/lib/dtk_logger.rb +0 -113
  248. data/lib/error.rb +0 -85
  249. data/lib/execute/cli_pure/cli_rerouter.rb +0 -102
  250. data/lib/execute/command/api_call/map.rb +0 -60
  251. data/lib/execute/command/api_call/service.rb +0 -91
  252. data/lib/execute/command/api_call/translation_term.rb +0 -119
  253. data/lib/execute/command/api_call.rb +0 -60
  254. data/lib/execute/command_processor/rest_call.rb +0 -59
  255. data/lib/execute/command_processor.rb +0 -30
  256. data/lib/execute/execute_context.rb +0 -86
  257. data/lib/execute/script/add_tenant.rb +0 -121
  258. data/lib/execute/script.rb +0 -64
  259. data/lib/parser/adapters/option_parser.rb +0 -70
  260. data/lib/parser/adapters/thor.rb +0 -555
  261. data/lib/require_first.rb +0 -104
  262. data/lib/shell/context.rb +0 -1064
  263. data/lib/shell/domain/active_context.rb +0 -186
  264. data/lib/shell/domain/context_entity.rb +0 -89
  265. data/lib/shell/domain/context_params.rb +0 -223
  266. data/lib/shell/domain/override_tasks.rb +0 -88
  267. data/lib/shell/domain/shadow_entity.rb +0 -76
  268. data/lib/shell/header_shell.rb +0 -44
  269. data/lib/shell/help_monkey_patch.rb +0 -283
  270. data/lib/shell/interactive_wizard.rb +0 -256
  271. data/lib/shell/message_queue.rb +0 -63
  272. data/lib/shell/status_monitor.rb +0 -124
  273. data/lib/shell.rb +0 -261
  274. data/lib/task_status.rb +0 -83
  275. data/lib/util/console.rb +0 -235
  276. data/lib/util/dtk_puppet.rb +0 -65
  277. data/lib/util/module_util.rb +0 -66
  278. data/lib/util/os_util.rb +0 -385
  279. data/lib/util/remote_dependency_util.rb +0 -84
  280. data/lib/util/ssh_util.rb +0 -94
  281. data/lib/view_processor/augmented_simple_list.rb +0 -44
  282. data/lib/view_processor/hash_pretty_print.rb +0 -123
  283. data/lib/view_processor/simple_list.rb +0 -156
  284. data/lib/view_processor/table_print.rb +0 -309
  285. data/lib/view_processor.rb +0 -129
  286. data/puppet/manifests/init.pp +0 -72
  287. data/puppet/manifests/params.pp +0 -16
  288. data/puppet/r8meta.puppet.yml +0 -35
  289. data/puppet/templates/bash_profile.erb +0 -2
  290. data/puppet/templates/client.conf.erb +0 -1
  291. data/puppet/templates/dtkclient.erb +0 -2
  292. data/spec/component_module_spec.rb +0 -34
  293. data/spec/dependency_spec.rb +0 -6
  294. data/spec/dtk_shell_spec.rb +0 -13
  295. data/spec/dtk_spec.rb +0 -33
  296. data/spec/lib/spec_helper.rb +0 -10
  297. data/spec/lib/spec_thor.rb +0 -108
  298. data/spec/node_template_spec.rb +0 -24
  299. data/spec/project_spec.rb +0 -6
  300. data/spec/repo_spec.rb +0 -7
  301. data/spec/response_spec.rb +0 -52
  302. data/spec/service_module_spec.rb +0 -38
  303. data/spec/service_spec.rb +0 -50
  304. data/spec/state_change_spec.rb +0 -7
  305. data/spec/table_print_spec.rb +0 -48
  306. data/spec/target_spec.rb +0 -57
  307. data/spec/task_spec.rb +0 -28
  308. data/views/assembly/augmented_simple_list.rb +0 -12
  309. data/views/assembly_template/augmented_simple_list.rb +0 -12
  310. data/views/list_task/augmented_simple_list.rb +0 -12
@@ -1,932 +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
- require 'rest_client'
19
- require 'json'
20
- require 'colorize'
21
-
22
- dtk_require_from_base('dtk_logger')
23
- dtk_require_from_base('util/os_util')
24
- dtk_require_from_base('command_helper')
25
- dtk_require_from_base('task_status')
26
- dtk_require_common_commands('thor/set_required_attributes')
27
- dtk_require_common_commands('thor/edit')
28
- dtk_require_common_commands('thor/purge_clone')
29
- dtk_require_common_commands('thor/assembly_workspace')
30
- dtk_require_common_commands('thor/action_result_handler')
31
-
32
- LOG_SLEEP_TIME = DTK::Configuration.get(:tail_log_frequency)
33
- DEBUG_SLEEP_TIME = DTK::Configuration.get(:debug_task_frequency)
34
-
35
- module DTK::Client
36
- class Service < CommandBaseThor
37
- no_tasks do
38
- include TaskStatusMixin
39
- include SetRequiredParamsMixin
40
- include EditMixin
41
- include PurgeCloneMixin
42
- include AssemblyWorkspaceMixin
43
- include ActionResultHandler
44
-
45
- def get_assembly_name(assembly_id)
46
- get_name_from_id_helper(assembly_id)
47
- end
48
-
49
- def get_assembly_id(assembly_name)
50
- assembly_id = nil
51
- list = CommandBaseThor.get_cached_response(:service, "assembly/list", {})
52
-
53
- list.data.each do |item|
54
- if item["display_name"] == assembly_name
55
- assembly_id = item["id"]
56
- break
57
- end
58
- end
59
-
60
- raise DtkError,"[ERROR] Illegal name (#{assembly_name}) for service." unless assembly_id
61
- assembly_id
62
- end
63
-
64
- end
65
-
66
- def self.whoami()
67
- return :service, "assembly/list", {:subtype => 'instance'}
68
- end
69
-
70
- def self.pretty_print_cols()
71
- PPColumns.get(:assembly)
72
- end
73
-
74
- def self.valid_children()
75
- [:utils]
76
- end
77
-
78
- def self.invisible_context()
79
- [:node]
80
- end
81
-
82
- # using extended_context when we want to use autocomplete from other context
83
- # e.g. we are in assembly/apache context and want to create-component we will use extended context to add
84
- # component-templates to autocomplete
85
- def self.extended_context()
86
- {
87
- :context => {
88
- :create_node => "node_template",
89
- :create_node_group => "node_template",
90
- :add_component_dependency => "component_template"
91
- },
92
- :command => {
93
- :add_component => {
94
- :endpoint => "component_template",
95
- :url => "component/list",
96
- :opts => {:subtype=>"template", :ignore => "test_module", :hide_assembly_cmps => "true"}
97
- },
98
- :edit_component_module => {
99
- :endpoint => "assembly",
100
- :url => "assembly/info_about",
101
- :opts => {:subtype=>"instance", :about=>"modules"}
102
- },
103
- :push_component_module_updates => {
104
- :endpoint => "assembly",
105
- :url => "assembly/info_about",
106
- :opts => {:subtype=>"instance", :about=>"modules"}
107
- },
108
- :delete_node => {
109
- :endpoint => "assembly",
110
- :url => "assembly/get_nodes_without_node_groups"
111
- },
112
- :delete_node_group => {
113
- :endpoint => "assembly",
114
- :url => "assembly/get_node_groups"
115
- },
116
- :pull_base_component_module => {
117
- :endpoint => "assembly",
118
- :url => "assembly/info_about",
119
- :opts => {:subtype=>"instance", :about=>"modules"}
120
- },
121
- :action_info => {
122
- :endpoint => "assembly",
123
- :url => "assembly/task_action_list"
124
- },
125
- :exec => {
126
- :endpoint => "assembly",
127
- :url => "assembly/list_actions"
128
- },
129
- :exec_sync => {
130
- :endpoint => "assembly",
131
- :url => "assembly/list_actions"
132
- }
133
- # TODO: DEPRECATE execute_workflow
134
- # :execute_workflow => {
135
- # :endpoint => "assembly",
136
- # :url => "assembly/task_action_list"
137
- # }
138
- }
139
- }
140
- end
141
-
142
- # this includes children of children
143
- def self.all_children()
144
- # [:node, :component, :attribute]
145
- [:node]
146
- end
147
-
148
- def self.multi_context_children()
149
- [[:utils],[:node, :utils]]
150
- end
151
-
152
- def self.valid_child?(name_of_sub_context)
153
- return Service.valid_children().include?(name_of_sub_context.to_sym)
154
- end
155
-
156
- def self.validation_list(context_params)
157
- get_cached_response(:service, "assembly/list", {})
158
- end
159
-
160
- # TODO: Hack which is necessery for the specific problem (DTK-541), something to reconsider down the line
161
- # at this point not sure what would be clenear solution
162
-
163
- # :all => include both for commands with command and identifier
164
- # :command_only => only on command level
165
- # :identifier_only => only on identifier level for given entity (command)
166
- #
167
- def self.override_allowed_methods()
168
- override_methods = {
169
- :all => {
170
- # :node => [
171
- # ['delete-component',"delete-component COMPONENT-ID","# Delete component from assembly's node"],
172
- # ['list-components',"list-components","# List components associated with assembly's node."],
173
- # ['list-attributes',"list-attributes","# List attributes associated with assembly's node."]
174
- # ],
175
- :component => [
176
- ['list-attributes',"list-attributes","# List attributes associated with given component."]
177
- ]
178
- },
179
- :command_only => {
180
- :attribute => [
181
- ['list-attributes',"list-attributes","# List attributes."]
182
- ],
183
- :node => [
184
- ['delete',"delete NODE-NAME/ID [-y] ","# Delete node, terminating it if the node has been spun up."],
185
- ['list',"list","# List nodes."]
186
- ],
187
- :component => [
188
- ['delete',"delete COMPONENT-NAME/ID [-y] ","# Delete component from workspace."],
189
- ['list-components',"list-components","# List components."]
190
- ],
191
- :utils => [
192
- # TODO: DTK-2027 might subsume by the dtk actions; currently server changes does not support this command
193
- # ['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
194
- ['get-netstats',"get-netstats","# Get netstats."],
195
- ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
196
- ['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
197
- ['tail',"tail NODE-NAME LOG-PATH [REGEX-PATTERN] [--more]","# Tail log from specified node."]
198
- ],
199
- :node_utils => [
200
- ['get-netstats',"get-netstats","# Get netstats."],
201
- ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
202
- ['grep',"grep LOG-PATH GREP-PATTERN [--first]","# Grep log from node. --first option returns first match (latest log entry)."],
203
- ['tail',"tail LOG-PATH [REGEX-PATTERN] [--more]","# Tail log from node."]
204
- ]
205
- },
206
- :identifier_only => {
207
- :node => [
208
- ['add-component',"add-component COMPONENT","# Add a component to the node."],
209
- ['delete-component',"delete-component COMPONENT-NAME [-y]","# Delete component from service's node"],
210
- ['info',"info","# Return info about node instance belonging to given workspace."],
211
- ['list-attributes',"list-attributes","# List attributes associated with service's node."],
212
- ['list-components',"list-components","# List components associated with service's node."],
213
- ['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
214
- ['start', "start", "# Start node instance."],
215
- ['stop', "stop", "# Stop node instance."],
216
- ['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# SSH into node, optional parameters are path to identity file."]
217
- ],
218
- :node_group => [
219
- ['start', "start", "# 2Start node instance."],
220
- ['stop', "stop", "# 2Stop node instance."],
221
- ['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# 2SSH into node, optional parameters are path to identity file."]
222
- ],
223
- :component => [
224
- ['info',"info","# Return info about component instance belonging to given node."],
225
- ['edit',"edit","# Edit component module related to given component."],
226
- ['link-components',"link-components ANTECEDENT-CMP-NAME [DEPENDENCY-NAME]","#Link components to satisfy component dependency relationship."],
227
- ['list-component-links',"list-component-links","# List component's links to other components."],
228
- ['unlink-components',"unlink-components SERVICE-TYPE","# Delete service link on component."]
229
- ],
230
- :attribute => [
231
- ['info',"info","# Return info about attribute instance belonging to given component."]
232
- ]
233
- }
234
- }
235
-
236
- if ::DTK::Configuration.get(:development_mode)
237
- override_methods[:identifier_only][:node] << ['test-action-agent', "test-action-agent BASH-COMMAND-LINE", "Run bash command on test action agent"]
238
- end
239
-
240
- return DTK::Shell::OverrideTasks.new(override_methods, [:utils])
241
- end
242
-
243
- desc "SERVICE-NAME/ID destroy-and-reset-nodes [-y]", "Terminates all nodes, but keeps config state so they can be spun up from scratch."
244
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
245
- def destroy_and_reset_nodes(context_params)
246
- destroy_and_reset_nodes_aux(context_params)
247
- end
248
-
249
- desc "SERVICE-NAME/ID start [NODE-NAME]", "Starts all the service nodes. A single node can be selected."
250
- def start(context_params)
251
- start_aux(context_params)
252
- end
253
-
254
- desc "SERVICE-NAME/ID stop [NODE-NAME]", "Stops all the service nodes. A single node can be selected."
255
- def stop(context_params)
256
- stop_aux(context_params)
257
- end
258
-
259
-
260
- desc "SERVICE-NAME/ID cancel-task [TASK_ID]", "Cancels an executing task. If task id is omitted, this command cancels the most recent executing task."
261
- def cancel_task(context_params)
262
- cancel_task_aux(context_params)
263
- end
264
-
265
- desc "SERVICE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME [-m DESCRIPTION]", "Create a new assembly from this service instance in the designated service module."
266
- method_option "description",:aliases => "-m" ,
267
- :type => :string,
268
- :banner => "DESCRIPTION"
269
- def create_assembly(context_params)
270
- assembly_id, service_module_name, assembly_template_name = context_params.retrieve_arguments([:service_id!,:option_1!,:option_2!],method_argument_names)
271
-
272
- # need default_namespace for create-assembly because need to check if local service-module directory existst in promote_assembly_aux
273
- resp = post rest_url("namespace/default_namespace_name")
274
- return resp unless resp.ok?
275
- default_namespace = resp.data
276
-
277
- opts = {:default_namespace => default_namespace}
278
- opts.merge!(:description => options.description) if options.description
279
- response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name,opts)
280
- return response unless response.ok?
281
-
282
- @@invalidate_map << :assembly
283
- @@invalidate_map << :service
284
-
285
- Response::Ok.new()
286
- end
287
-
288
- desc "SERVICE-NAME/ID exec [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action asynchronously"
289
- def exec(context_params)
290
- exec_aux(context_params)
291
- end
292
-
293
- desc "SERVICE-NAME/ID exec-sync [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action synchronously"
294
- def exec_sync(context_params)
295
- exec_sync_aux(context_params)
296
- end
297
-
298
- # desc "SERVICE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action", :hide => true
299
- # method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
300
- # def exec(context_params)
301
- # opts = {}
302
- # opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
303
- # converge_aux(context_params, opts)
304
- # end
305
-
306
- # TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
307
- # desc "SERVICE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
308
- # method_option "commit_msg",:aliases => "-m" ,
309
- # :type => :string,
310
- # :banner => "COMMIT-MSG",
311
- # :desc => "Commit message"
312
- # def execute_workflow(context_params)
313
- # OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
314
- # converge(context_params)
315
- # end
316
-
317
- desc "SERVICE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge service instance."
318
- method_option "commit_msg",:aliases => "-m" ,
319
- :type => :string,
320
- :banner => "COMMIT-MSG",
321
- :desc => "Commit message"
322
- method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
323
- def converge(context_params)
324
- opts = {}
325
- opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
326
- converge_aux(context_params, opts)
327
- end
328
-
329
- # desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]", "Converge the component or execute tha action on the component.", :hide => true
330
- # def execute_action(context_params)
331
- # execute_ad_hoc_action_aux(context_params)
332
- # end
333
-
334
- desc "SERVICE-NAME/ID list-actions [--type TYPE]", "List the actions defined on components in the service instance."
335
- method_option :type, :aliases => '-t'
336
- def list_actions(context_params)
337
- list_actions_aux(context_params)
338
- end
339
-
340
- desc "SERVICE-NAME/ID push-assembly-updates [NAMESPACE:SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
341
- def push_assembly_updates(context_params)
342
- assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!, :option_1], method_argument_names)
343
- service_module_name, assembly_template_name =
344
- if qualified_assembly_name
345
- if qualified_assembly_name =~ /(^[^\/]*)\/([^\/]*$)/
346
- [$1,$2]
347
- else
348
- raise DtkError, "The term (#{qualified_assembly_name}) must have form SERVICE-MODULE-NAME/ASSEMBLY-NAME"
349
- end
350
- else
351
- [nil, nil]
352
- end
353
-
354
- response = promote_assembly_aux(:update, assembly_id, service_module_name, assembly_template_name, :use_module_namespace => true)
355
- return response unless response.ok?
356
- @@invalidate_map << :assembly
357
- Response::Ok.new()
358
- end
359
-
360
- desc "SERVICE-NAME/ID pull-base-component-module COMPONENT-MODULE-NAME [--force] [--revert]", "Pull base component module changes to component module in the service"
361
- method_option :force, :type => :boolean, :default => false, :aliases => '-f'
362
- method_option :revert, :type => :boolean, :default => false, :aliases => '-r'
363
- def pull_base_component_module(context_params)
364
- pull_base_component_module_aux(context_params)
365
- end
366
-
367
- desc "SERVICE-NAME/ID push-component-module-updates COMPONENT-MODULE-NAME [--force]", "Push changes made to a component module in the service to its base component module."
368
- method_option :force, :type => :boolean, :default => false, :aliases => '-f'
369
- def push_component_module_updates(context_params)
370
- push_module_updates_aux(context_params)
371
- end
372
-
373
- desc "SERVICE-NAME/ID edit-component-module COMPONENT-MODULE-NAME", "Edit a component module used in the service."
374
- def edit_component_module(context_params)
375
- edit_module_aux(context_params)
376
- end
377
-
378
- # desc "SERVICE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the service instance."
379
- # method_option :from, :type => :string
380
- # def create_workflow(context_params)
381
- # edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
382
- # end
383
-
384
- desc "SERVICE-NAME/ID edit-action [SERVICE-LEVEL-ACTION]", "Edit action in the service instance."
385
- def edit_action(context_params)
386
- edit_or_create_workflow_aux(context_params)
387
- end
388
-
389
- desc "SERVICE-NAME/ID edit-attributes [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]", "Edit service's attributes."
390
- method_option :node, :aliases => '-n'
391
- method_option :component, :aliases => '-c'
392
- method_option :attribute, :aliases => '-a'
393
- def edit_attributes(context_params)
394
- response = edit_attributes_aux(context_params)
395
-
396
- @@invalidate_map << :assembly
397
- @@invalidate_map << :assembly_node
398
- @@invalidate_map << :service
399
- @@invalidate_map << :service_node
400
-
401
- response
402
- end
403
-
404
- =begin
405
- TODO: will put in dot release and will rename to 'extend'
406
- desc "ASSEMBLY-NAME/ID add EXTENSION-TYPE [-n COUNT]", "Adds a sub assembly template to the assembly"
407
- method_option "count",:aliases => "-n" ,
408
- :type => :string, #integer
409
- :banner => "COUNT",
410
- :desc => "Number of sub-assemblies to add"
411
- def add_node(context_params)
412
- assembly_id,service_add_on_name = context_params.retrieve_arguments([:assembly_id!,:option_1!],method_argument_names)
413
-
414
- # create task
415
- post_body = {
416
- :assembly_id => assembly_id,
417
- :service_add_on_name => service_add_on_name
418
- }
419
-
420
- post_body.merge!(:count => options.count) if options.count
421
-
422
- response = post rest_url("assembly/add__service_add_on"), post_body
423
- # when changing context send request for getting latest assemblies instead of getting from cache
424
- @@invalidate_map << :assembly
425
-
426
- return response
427
- end
428
-
429
- =end
430
-
431
- # TODO: deprecating --wait since subsubsumed by mode
432
- # desc "SERVICE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running service task."
433
- desc "SERVICE-NAME/ID task-status [--mode MODE] [--summarize]", "Get the task status of the running or last running service task."
434
- method_option "mode",:aliases => "-m" ,
435
- :type => :string,
436
- :banner => "MODE",
437
- :desc => "Mode in which task status display; one of [stream,snapshot,refresh]; default is 'snapshot'"
438
- method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
439
- # TODO: leaving --wait in for backwards compatability
440
- method_option :wait, :type => :boolean, :default => false
441
- def task_status(context_params)
442
- task_status_aw_aux(context_params)
443
- end
444
-
445
- desc "SERVICE-NAME/ID task-action-detail", "Get the task info of the running or last running service task."
446
- def task_action_detail(context_params)
447
- task_action_detail_aw_aux(context_params)
448
- end
449
-
450
- desc "SERVICE-NAME/ID list-nodes","List nodes associated with service."
451
- def list_nodes(context_params)
452
- list_nodes_aux(context_params)
453
- end
454
-
455
- desc "SERVICE-NAME/ID list-component-links","List component links."
456
- def list_component_links(context_params)
457
- list_component_links_aux(context_params)
458
- end
459
-
460
- desc "SERVICE-NAME/ID list-components [--deps]","List components associated with service."
461
- method_option :deps, :type => :boolean, :default => false, :aliases => '-l'
462
- def list_components(context_params)
463
- list_components_aux(context_params)
464
- end
465
-
466
- desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links] [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]","List attributes associated with service."
467
- method_option :format, :aliases => '-f'
468
- method_option :tags, :aliases => '-t'
469
- method_option :links, :type => :boolean, :default => false, :aliases => '-l'
470
- method_option :node, :aliases => '-n'
471
- method_option :component, :aliases => '-c'
472
- method_option :attribute, :aliases => '-a'
473
- def list_attributes(context_params)
474
- list_attributes_aux(context_params)
475
- end
476
-
477
- desc "SERVICE-NAME/ID list-component-modules","List component modules associated with service."
478
- def list_component_modules(context_params)
479
- list_modules_aux(context_params)
480
- end
481
-
482
- desc "SERVICE-NAME/ID list-tasks","List tasks associated with service."
483
- def list_tasks(context_params)
484
- list_tasks_aux(context_params)
485
- end
486
-
487
- desc "SERVICE-NAME/ID list-violations", "Finds violations in the service that will prevent a converge operation."
488
- def list_violations(context_params)
489
- list_violations_aux(context_params)
490
- end
491
-
492
- desc "SERVICE-NAME/ID print-includes", "Finds includes in the service."
493
- def print_includes(context_params)
494
- print_includes_aux(context_params)
495
- end
496
-
497
- desc "SERVICE-NAME/ID action-info [SERVICE-LEVEL-ACTION]", "Get the contents of action associated with the service."
498
- def action_info(context_params)
499
- action_info_aux(context_params)
500
- end
501
-
502
- # desc "SERVICE-NAME/ID list-workflows", "List the workflows associated with the service.", :hide => true
503
- # def list_workflows(context_params)
504
- # workflow_list_aux(context_params)
505
- # end
506
-
507
- desc "list","List services."
508
- def list(context_params)
509
- assembly_id, node_id, component_id, attribute_id, about = context_params.retrieve_arguments([:service_id,:node_id,:component_id,:attribute_id,:option_1],method_argument_names)
510
- detail_to_include = nil
511
-
512
- if about
513
- case about
514
- when "nodes"
515
- data_type = :node
516
- when "components"
517
- data_type = :component
518
- detail_to_include = [:component_dependencies]
519
- when "attributes"
520
- data_type = :attribute
521
- detail_to_include = [:attribute_links]
522
- when "tasks"
523
- data_type = :task
524
- else
525
- raise_validation_error_method_usage('list')
526
- end
527
- end
528
-
529
- post_body = {
530
- :assembly_id => assembly_id,
531
- :node_id => node_id,
532
- :component_id => component_id,
533
- :subtype => 'instance'
534
- }
535
- post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
536
- rest_endpoint = "assembly/info_about"
537
-
538
- if context_params.is_last_command_eql_to?(:attribute)
539
- raise DtkError, "Not supported command for current context level." if attribute_id
540
- about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
541
- elsif context_params.is_last_command_eql_to?(:component)
542
- if component_id
543
- about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
544
- else
545
- about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
546
- end
547
- elsif context_params.is_last_command_eql_to?(:node)
548
- if node_id
549
- about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
550
- else
551
- about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes"])
552
- end
553
- else
554
- if assembly_id
555
- about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes", "tasks"])
556
- else
557
- data_type = :assembly
558
- post_body = { :subtype => 'instance', :detail_level => 'nodes',:include_namespaces => true}
559
- rest_endpoint = "assembly/list"
560
- end
561
- end
562
-
563
- post_body[:about] = about
564
- response = post rest_url(rest_endpoint), post_body
565
-
566
- # set render view to be used
567
- response.render_table(data_type)
568
-
569
- return response
570
- end
571
-
572
- desc "SERVICE-NAME/ID list-diffs COMPONENT-MODULE-NAME", "List diffs between module in service instance and base module."
573
- def list_diffs(context_params)
574
- list_remote_module_diffs(context_params)
575
- end
576
-
577
- desc "SERVICE-NAME/ID grant-access USER-ACCOUNT PUB-KEY-NAME [PATH-TO-PUB-KEY] [--nodes NODE-NAMES]", "Grants ssh access to user account USER-ACCOUNT for nodes in service instance"
578
- method_option :nodes, :type => :string, :default => nil
579
- def grant_access(context_params)
580
- grant_access_aux(context_params)
581
- end
582
-
583
- desc "SERVICE-NAME/ID revoke-access USER-ACCOUNT PUB-KEY-NAME [PATH-TO-PUB-KEY] [--nodes NODE-NAMES]", "Revokes ssh access to user account USER-ACCOUNT for nodes in service instance"
584
- method_option :nodes, :type => :string, :default => nil
585
- def revoke_access(context_params)
586
- revoke_access_aux(context_params)
587
- end
588
-
589
- desc "SERVICE-NAME/ID list-ssh-access", "List SSH access for each of the nodes"
590
- def list_ssh_access(context_params)
591
- list_ssh_access_aux(context_params)
592
- end
593
-
594
- desc "SERVICE-NAME/ID info", "Get info about content of the service."
595
- def info(context_params)
596
- info_aux(context_params)
597
- end
598
-
599
- desc "SERVICE-NAME/ID link-attributes TARGET-ATTR SOURCE-ATTR", "Link the value of the target attribute to the source attribute."
600
- def link_attributes(context_params)
601
- link_attributes_aux(context_params)
602
- end
603
-
604
- desc "delete-and-destroy NAME/ID [-y]", "Delete service instance, terminating any nodes that have been spun up."
605
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
606
- def delete_and_destroy(context_params)
607
- assembly_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
608
-
609
- if assembly_name.to_s =~ /^[0-9]+$/
610
- assembly_id = assembly_name
611
- else
612
- assembly_id = get_assembly_id(assembly_name)
613
- end
614
-
615
- unless options.force?
616
- # Ask user if really want to delete assembly, if not then return to dtk-shell without deleting
617
- # used form "+'?' because ?" confused emacs ruby rendering
618
- return unless Console.confirmation_prompt("Are you sure you want to delete and destroy service '#{assembly_name}' and its nodes"+'?')
619
- end
620
-
621
- unsaved_modules = check_if_unsaved_cmp_module_changes(assembly_id)
622
- unless unsaved_modules.empty?
623
- return unless Console.confirmation_prompt("Deleting this service will cause unsaved changes in component module(s) '#{unsaved_modules.join(',')}' to be lost. Do you still want to proceed"+'?')
624
- end
625
-
626
- assembly_changed = check_if_unsaved_assembly_changes(assembly_id, assembly_name)
627
- if assembly_changed == true
628
- return unless Console.confirmation_prompt("You made some changes in assembly or it's workflow that will be lost if you delete this service. Do you still want to proceed"+'?')
629
- end
630
-
631
- # purge local clone
632
- response = purge_clone_aux(:all,:assembly_module => {:assembly_name => assembly_name})
633
- return response unless response.ok?
634
-
635
- post_body = {
636
- :assembly_id => assembly_id,
637
- :subtype => :instance
638
- }
639
-
640
- response = post rest_url("assembly/delete"), post_body
641
-
642
- # when changing context send request for getting latest assemblies instead of getting from cache
643
- @@invalidate_map << :service
644
- @@invalidate_map << :assembly
645
- response
646
- end
647
-
648
- desc "SERVICE-NAME/ID set-attribute ATTRIBUTE-NAME [VALUE] [-u] [-c] [-n]", "(Un)Set attribute value. The option -u will unset the attribute's value, -c to set component-attribute, -n to set node-attribute."
649
- method_option :unset, :aliases => '-u', :type => :boolean, :default => false
650
- method_option :component_attribute, :aliases => '-c', :type => :boolean, :default => false
651
- method_option :node_attribute, :aliases => '-n', :type => :boolean, :default => false
652
- def set_attribute(context_params)
653
- response = set_attribute_aux(context_params)
654
- return response unless response.ok?
655
-
656
- @@invalidate_map << :assembly
657
- @@invalidate_map << :assembly_node
658
- @@invalidate_map << :service
659
- @@invalidate_map << :service_node
660
-
661
- response
662
- end
663
-
664
- desc "SERVICE-NAME/ID create-attribute ATTRIBUTE-NAME [VALUE] [--type DATATYPE] [--required] [--dynamic]", "Create a new attribute and optionally assign it a value."
665
- method_option :required, :type => :boolean, :default => false
666
- method_option :dynamic, :type => :boolean, :default => false
667
- method_option "type",:aliases => "-t"
668
- def create_attribute(context_params)
669
- create_attribute_aux(context_params)
670
- end
671
-
672
- # using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
673
- desc "SERVICE-NAME/ID create-node ^^NODE-NAME NODE-TEMPLATE", "Add (stage) a new node in the service."
674
- def create_node(context_params)
675
- response = create_node_aux(context_params)
676
- return response unless response.ok?
677
-
678
- @@invalidate_map << :assembly
679
- @@invalidate_map << :assembly_node
680
- @@invalidate_map << :service
681
- @@invalidate_map << :service_node
682
- @@invalidate_map << :workspace
683
- @@invalidate_map << :workspace_node
684
-
685
- message = "Created node '#{response.data["display_name"]}'."
686
- OsUtil.print(message, :yellow)
687
- end
688
-
689
- desc "SERVICE-NAME/ID create-node-group ^^NODE-GROUP-NAME NODE-TEMPLATE [-n CARDINALITY]", "Add (stage) a new node group in the service."
690
- method_option :cardinality, :aliases => '-n', :type => :string, :default => 1
691
- def create_node_group(context_params)
692
- response = create_node_group_aux(context_params)
693
- return response unless response.ok?
694
-
695
- @@invalidate_map << :assembly
696
- @@invalidate_map << :assembly_node
697
- @@invalidate_map << :service
698
- @@invalidate_map << :service_node
699
- @@invalidate_map << :workspace
700
- @@invalidate_map << :workspace_node
701
-
702
- message = "Created node group '#{response.data["display_name"]}'."
703
- OsUtil.print(message, :yellow)
704
- end
705
-
706
- desc "SERVICE-NAME/ID link-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]","Link the target component to the source component."
707
- def link_components(context_params)
708
- link_components_aux(context_params)
709
- end
710
-
711
- # only supported at node-level
712
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
713
- desc "SERVICE-NAME/ID add-component COMPONENT [--auto-complete]", "Add a component to the service. Use --auto-complete to link components automatically"
714
- method_option :auto_complete, :type => :boolean, :default => true
715
- def add_component(context_params)
716
- response = create_component_aux(context_params)
717
-
718
- @@invalidate_map << :service
719
- @@invalidate_map << :service_node
720
-
721
- response
722
- end
723
-
724
- # using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
725
- desc "SERVICE-NAME/ID delete-node ^^NODE-NAME [-y]","Delete node, terminating it if the node has been spun up."
726
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
727
- def delete_node(context_params)
728
- response = delete_node_aux(context_params)
729
-
730
- @@invalidate_map << :assembly
731
- @@invalidate_map << :assembly_node
732
- @@invalidate_map << :service
733
- @@invalidate_map << :service_node
734
- @@invalidate_map << :workspace
735
- @@invalidate_map << :workspace_node
736
-
737
- return response
738
- end
739
-
740
- desc "SERVICE-NAME/ID delete-node-group ^^NODE-NAME [-y]","Delete node group and all nodes that are part of that group."
741
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
742
- def delete_node_group(context_params)
743
- response = delete_node_group_aux(context_params)
744
-
745
- @@invalidate_map << :assembly
746
- @@invalidate_map << :assembly_node
747
- @@invalidate_map << :service
748
- @@invalidate_map << :service_node
749
- @@invalidate_map << :workspace
750
- @@invalidate_map << :workspace_node
751
-
752
- return response
753
- end
754
-
755
- desc "HIDE_FROM_BASE delete NAME/ID [-y]","Delete node, terminating it if the node has been spun up."
756
- def delete(context_params)
757
- if context_params.is_last_command_eql_to?(:node)
758
- response = delete_node_aux(context_params)
759
- return response unless response.ok?
760
- @@invalidate_map << :service_node
761
-
762
- response
763
- elsif context_params.is_last_command_eql_to?(:component)
764
- response = delete_component_aux(context_params)
765
- return response unless response.ok?
766
- @@invalidate_map << :assembly_node_component
767
-
768
- response
769
- end
770
- end
771
-
772
- desc "SERVICE-NAME/ID unlink-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]", "Remove a component link."
773
- def unlink_components(context_params)
774
- unlink_components_aux(context_params)
775
- end
776
-
777
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
778
- desc "SERVICE-NAME/ID delete-component COMPONENT-NAME [-y]","Delete component from the service."
779
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
780
- def delete_component(context_params)
781
- response = delete_component_aux(context_params)
782
-
783
- @@invalidate_map << :service
784
- @@invalidate_map << :service_node
785
- @@invalidate_map << :service_node_component
786
-
787
- response
788
- end
789
-
790
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
791
- desc "HIDE_FROM_BASE get-netstats", "Get netstats"
792
- def get_netstats(context_params)
793
- get_netstats_aux(context_params)
794
- end
795
-
796
- =begin
797
- # TODO: DTK-2027 might subsume by the dtk actions; currently server changes does not support this command
798
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
799
- desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
800
- method_option :component, :type => :string, :desc => "Component name"
801
- method_option :timeout, :type => :string, :desc => "Timeout"
802
- def execute_tests(context_params)
803
- execute_tests_aux(context_params)
804
- end
805
- =end
806
-
807
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
808
- desc "HIDE_FROM_BASE get-ps [--filter PATTERN]", "Get ps"
809
- method_option :filter, :type => :boolean, :default => false, :aliases => '-f'
810
- def get_ps(context_params)
811
- get_ps_aux(context_params)
812
- end
813
-
814
- desc "SERVICE-NAME/ID set-required-attributes", "Interactive dialog to set required attributes that are not currently set"
815
- def set_required_attributes(context_params)
816
- assembly_id = context_params.retrieve_arguments([:service_id!],method_argument_names)
817
- set_required_attributes_aux(assembly_id,:assembly,:instance)
818
- end
819
-
820
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
821
- desc "HIDE_FROM_BASE tail NODE-NAME LOG-PATH [REGEX-PATTERN] [--more]","Tail specified number of lines from log"
822
- method_option :more, :type => :boolean, :default => false
823
- def tail(context_params)
824
- tail_aux(context_params)
825
- end
826
-
827
- # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
828
- desc "HIDE_FROM_BASE grep LOG-PATH NODES-ID-PATTERN GREP-PATTERN [--first]","Grep log from multiple nodes. --first option returns first match (latest log entry)."
829
- method_option :first, :type => :boolean, :default => false
830
- def grep(context_params)
831
- grep_aux(context_params)
832
- end
833
-
834
- desc "stage ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Stage assembly in target."
835
- method_option "in-target", :aliases => "-t", :type => :string, :banner => "TARGET-NAME/ID", :desc => "Target (id) to create assembly in"
836
- method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
837
- method_option :parent_service, :type => :string, :aliases => '-t'
838
- version_method_option
839
- #hidden option
840
- method_option "instance-bindings", :type => :string
841
- def stage(context_params)
842
- stage_aux(context_params)
843
- end
844
-
845
- desc "set-default-target INSTANCE-NAME/ID", "Set default target service instance."
846
- def set_default_target(context_params)
847
- set_default_target_aux(context_params)
848
- end
849
-
850
- desc "stage-target ASSEMBLY-TEMPLATE [INSTANCE-NAME] -t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Stage assembly as target instance."
851
- method_option :settings, :type => :string, :aliases => '-s'
852
- method_option :auto_complete, :type => :boolean, :default => true
853
- method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
854
- method_option :parent_service, :type => :string, :aliases => '-t'
855
- version_method_option
856
- #hidden options
857
- method_option "instance-bindings", :type => :string
858
- method_option :is_target, :type => :boolean, :default => true
859
- def stage_target(context_params)
860
- response = stage_aux(context_params)
861
- return response unless response.ok?
862
-
863
- # when changing context send request for getting latest assemblies instead of getting from cache
864
- @@invalidate_map << :service
865
- @@invalidate_map << :assembly
866
-
867
- return response
868
- end
869
-
870
- desc "deploy-target ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-v VERSION] [--no-auto-complete] [--stream-results]", "Deploy assembly as target instance."
871
- method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
872
- method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
873
- version_method_option
874
- #hidden options
875
- method_option "instance-bindings", :type => :string
876
- method_option :is_target, :type => :boolean, :default => true
877
- # method_option :settings, :type => :string, :aliases => '-s'
878
- def deploy_target(context_params)
879
- response = deploy_aux(context_params)
880
- return response unless response.ok?
881
-
882
- @@invalidate_map << :service
883
- @@invalidate_map << :assembly
884
-
885
- response
886
- end
887
-
888
- desc "deploy ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Deploy assembly in target."
889
- method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
890
- method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
891
- method_option :parent_service, :type => :string, :aliases => '-t'
892
- version_method_option
893
- #hidden options
894
- method_option "instance-bindings", :type => :string
895
- # method_option :settings, :type => :string, :aliases => '-s'
896
- def deploy(context_params)
897
- response = deploy_aux(context_params)
898
- return response unless response.ok?
899
-
900
- @@invalidate_map << :service
901
- @@invalidate_map << :assembly
902
-
903
- response
904
- end
905
-
906
- desc "SERVICE-NAME/ID set-required-attributes-and-converge", "Interactive dialog to set required attributes that are not currently set", :hide => true
907
- def set_required_attributes_and_converge(context_params)
908
- begin
909
- response = set_required_attributes_converge_aux(context_params)
910
- rescue DTK::Client::DtkError::InteractiveWizardError => e
911
- @@invalidate_map << :service
912
- @@invalidate_map << :assembly
913
-
914
- # if skip correction wizzard still go to newly created service instance
915
- if instance_name = (context_params.get_forwarded_options()||{})[:instance_name]
916
- MainContext.get_context.change_context(["/service/#{instance_name}"])
917
- end
918
-
919
- raise e
920
- end
921
-
922
- @@invalidate_map << :service
923
- @@invalidate_map << :assembly
924
-
925
- # if instance_name = opts[:instance_name]
926
- # MainContext.get_context.change_context([instance_name])
927
- # end
928
-
929
- response
930
- end
931
- end
932
- end