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,250 +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
- dtk_require_common_commands('thor/common_base')
19
- dtk_require_common_commands('thor/inventory_parser')
20
- dtk_require_common_commands('thor/create_target')
21
- module DTK::Client
22
- class Target < CommandBaseThor
23
- include Commands
24
- include InventoryParserMixin
25
-
26
- def self.pretty_print_cols()
27
- PPColumns.get(:target)
28
- end
29
-
30
- def self.alternate_identifiers()
31
- return ['PROVIDER']
32
- end
33
-
34
- def self.extended_context()
35
- {
36
- :context => {
37
- # want auto complete for --provider option
38
- "--provider" => "provider"
39
- }
40
- }
41
- end
42
-
43
- desc "TARGET-NAME/ID list-nodes","Lists node instances in given targets."
44
- def list_nodes(context_params)
45
- context_params.method_arguments = ["nodes"]
46
- list(context_params)
47
- end
48
-
49
- desc "TARGET-NAME/ID info","Provides information about specified target"
50
- def info(context_params)
51
- target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
52
-
53
- post_body = {:target_id => target_id}
54
- post rest_url('target/info'), post_body
55
- end
56
-
57
- desc "TARGET-NAME/ID import-nodes --source SOURCE","Reads from inventory dsl and populates the node instance objects (SOURCE: file:/path/to/file.yaml)."
58
- method_option :source, :type => :string
59
- def import_nodes(context_params)
60
- target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
61
- source = context_params.retrieve_thor_options([:source!], options)
62
-
63
- parsed_source = source.match(/^(\w+):(.+)/)
64
- raise DtkValidationError, "Invalid source! Valid source should contain source_type:source_path (e.g. --source file:path/to/file.yaml)." unless parsed_source
65
-
66
- import_type = parsed_source[1]
67
- path = parsed_source[2]
68
-
69
- raise DtkValidationError, "We do not support '#{import_type}' as import source at the moment. Valid sources: #{ValidImportTypes}" unless ValidImportTypes.include?(import_type)
70
-
71
- post_body = {:target_id => target_id}
72
-
73
- if import_type.eql?('file')
74
- inventory_data = parse_inventory_file(path)
75
- post_body.merge!(:inventory_data => inventory_data)
76
- end
77
-
78
- response = post rest_url("target/import_nodes"), post_body
79
- return response unless response.ok?
80
-
81
- if response.data.empty?
82
- OsUtil.print("No new nodes to import!", :yellow)
83
- else
84
- OsUtil.print("Successfully imported nodes:", :yellow)
85
- response.data.each do |node|
86
- OsUtil.print("#{node}", :yellow)
87
- end
88
- end
89
- end
90
- ValidImportTypes = ["file"]
91
-
92
- desc "set-default-target TARGET-NAME","Sets the default target."
93
- def set_default_target(context_params)
94
- target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
95
- post rest_url("target/set_default"), { :target_id => target_id }
96
- end
97
-
98
- desc "TARGET-NAME/ID install-agents","Install node agents on imported physical nodes."
99
- def install_agents(context_params)
100
- target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
101
-
102
- post_body = {:target_id => target_id}
103
- post rest_url("target/install_agents"), post_body
104
- end
105
-
106
- desc "create-target-ec2-classic [TARGET-NAME] --provider PROVIDER --region REGION [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
107
- method_option :provider, :type => :string
108
- method_option :region, :type => :string
109
- method_option :keypair, :type => :string
110
- method_option :security_group, :type => :string, :aliases => '--security-groups'
111
- def create_target_ec2_classic(context_params)
112
- option_list = [:provider!, :region!, :keypair, :security_group]
113
- response = Common::CreateTarget.new(self, context_params).execute(:ec2_classic,option_list)
114
- @@invalidate_map << :target
115
- response
116
- end
117
-
118
- desc "create-target-ec2-vpc [TARGET-NAME] --provider PROVIDER --region REGION --subnet SUBNET-ID [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
119
- method_option :provider, :type => :string
120
- method_option :subnet, :type => :string
121
- method_option :region, :type => :string
122
- method_option :keypair, :type => :string
123
- method_option :security_group, :type => :string, :aliases => '--security-groups'
124
- def create_target_ec2_vpc(context_params)
125
- option_list = [:provider!, :subnet!, :region!, :keypair, :security_group]
126
- response = Common::CreateTarget.new(self, context_params).execute(:ec2_vpc,option_list)
127
- @@invalidate_map << :target
128
- response
129
- end
130
-
131
-
132
- desc "TARGET-NAME/ID list-services","Lists service instances in given targets."
133
- def list_services(context_params)
134
- context_params.method_arguments = ["assemblies"]
135
- list(context_params)
136
- end
137
-
138
- def self.validation_list(context_params)
139
- provider_id = context_params.retrieve_arguments([:provider_id])
140
-
141
- if provider_id
142
- # if assembly_id is present we're loading nodes filtered by assembly_id
143
- post_body = {
144
- :subtype => :instance,
145
- :parent_id => provider_id
146
- }
147
-
148
- response = get_cached_response(:provider_target, "target/list", post_body)
149
- else
150
- # otherwise, load all nodes
151
- response = get_cached_response(:target, "target/list", { :subtype => :instance })
152
- end
153
-
154
- response
155
- end
156
-
157
- desc "list","Lists available targets."
158
- def list(context_params)
159
- provider_id, target_id, about = context_params.retrieve_arguments([:provider_id, :target_id, :option_1],method_argument_names||="")
160
-
161
- if target_id.nil?
162
- post_body = {
163
- :subtype => :instance,
164
- :parent_id => provider_id
165
- }
166
- response = post rest_url("target/list"), post_body
167
-
168
- response.render_table(:target)
169
- else
170
- post_body = {
171
- :target_id => target_id,
172
- :about => about
173
- }
174
-
175
- case about
176
- when "nodes"
177
- response = post rest_url("target/info_about"), post_body
178
- data_type = :node
179
- when "assemblies"
180
- post_body.merge!(:detail_level => 'nodes', :include_workspace => true)
181
- response = post rest_url("target/info_about"), post_body
182
- data_type = :assembly
183
- else
184
- raise_validation_error_method_usage('list')
185
- end
186
-
187
- response.render_table(data_type)
188
- end
189
- end
190
-
191
- desc "delete-and-destroy TARGET-NAME [-y]","Deletes target or provider"
192
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
193
- def delete_and_destroy(context_params)
194
- target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
195
-
196
- unless options.force?
197
- return unless Console.confirmation_prompt("Are you sure you want to delete target '#{target_id}' (all services/nodes that belong to this target will be deleted as well)'"+'?')
198
- end
199
-
200
- post_body = {
201
- :target_id => target_id,
202
- :type => 'instance'
203
- }
204
-
205
- @@invalidate_map << :target
206
-
207
- response = post(rest_url("target/delete_and_destroy"),post_body)
208
- return response unless response.ok?
209
- if info_array = response.data['info']
210
- info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
211
- end
212
- Response::Ok.new()
213
- end
214
-
215
- =begin
216
- # TODO: DTK-2056: rewite
217
- also put in list property
218
- desc "TARGET-NAME/ID set-property PROPERTY VALUE
219
- method_option :keypair, :type => :string
220
- method_option :security_group, :type => :string, :aliases => '--security-groups'
221
- def set_property(context_params)
222
- raise "change so that param is seperated key value parts"
223
- target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
224
- keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
225
-
226
- raise ::DTK::Client::DtkValidationError.new("You have to provide security-group or keypair to edit target!") unless keypair || security_group
227
-
228
- security_groups, iaas_properties = [], {}
229
- iaas_properties.merge!(:keypair => keypair) if keypair
230
-
231
- if security_group
232
- raise ::DTK::Client::DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ") if security_group.end_with?(',')
233
- security_groups = security_group.split(',')
234
- if (security_groups.empty? || security_groups.size==1)
235
- iaas_properties.merge!(:security_group => security_group)
236
- else
237
- iaas_properties.merge!(:security_group_set => security_groups)
238
- end
239
- end
240
- @@invalidate_map << :target
241
-
242
- post_body = {
243
- :target_id => target_id,
244
- :iaas_properties => iaas_properties
245
- }
246
- post rest_url("target/set_properties"), post_body
247
- end
248
- =end
249
- end
250
- end
@@ -1,116 +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 Task < CommandBaseThor
20
-
21
- def self.whoami()
22
- return :task, "task/list", nil
23
- end
24
-
25
- # TODO: Current bug: Disable list method invocation from /task/111111> level
26
- desc "list [--list]","List tasks"
27
- method_option :list, :type => :boolean, :default => false
28
- def list(context_params)
29
-
30
- #TODO: just hard coded params now
31
- search_hash = SearchHash.new()
32
- search_hash.cols = [:commit_message,:status,:id,:created_at,:started_at,:ended_at]
33
- search_hash.filter = [:eq, ":task_id", nil] #just top level tasks
34
- search_hash.set_order_by!(:created_at,"DESC")
35
- response = post rest_url("task/list"), search_hash.post_body_hash()
36
-
37
- response.render_table(:task) unless options.list?
38
- return response
39
- end
40
-
41
- desc "[TASK-NAME/ID] status", "Return task status; if no TASK-ID then information about most recent task"
42
- method_option "detail-level",:default => "summary", :aliases => "-d", :desc => "detail level to report task status"
43
- def status(context_params)
44
- task_id = context_params.retrieve_arguments([:task_id],method_argument_names)
45
- detail_level = options["detail-level"]
46
- post_hash_body = Hash.new
47
- post_hash_body[:detail_level] = detail_level if detail_level
48
- post_hash_body[:task_id] = task_id if task_id
49
- post rest_url("task/status"),post_hash_body
50
- end
51
-
52
- desc "commit-changes", "Commit changes"
53
- def commit_changes(context_params)
54
- scope = context_params.retrieve_arguments([:option_1],method_argument_names)
55
- post_hash_body = Hash.new
56
- post_hash_body.merge!(:scope => scope) if scope
57
- post rest_url("task/create_task_from_pending_changes"),post_hash_body
58
- end
59
-
60
- desc "TASK-NAME/ID execute", "Execute task"
61
- def execute(context_params)
62
- task_id = context_params.retrieve_arguments([:task_id!],method_argument_names)
63
- post rest_url("task/execute"), :task_id => task_id
64
- end
65
-
66
- desc "commit-changes-and-execute", "Commit changes and execute task"
67
- def commit_changes_and_execute(context_params)
68
- response = commit_changes(context_params)
69
- if response.ok?
70
- execute(response.data(:task_id))
71
- else
72
- response
73
- end
74
- end
75
- #alias for commit-changes-and-execute
76
- desc "simple-run", "Commit changes and execute task"
77
- def simple_run(context_params)
78
- commit_changes_and_execute(context_params)
79
- end
80
-
81
- desc "converge-node NODE-ID", "(Re)Converge node"
82
- def converge_node(context_params)
83
- node_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
84
-
85
- scope = node_id && {:node_id => node_id}
86
- response = post(rest_url("task/create_converge_state_changes"),scope)
87
- return response unless response.ok?
88
- response = commit_changes_and_execute(scope)
89
- while not task_complete(response) do
90
- response = status()
91
- sleep(TASK_STATUS_POLLING_INTERVAL)
92
- end
93
- response
94
- end
95
-
96
- desc "converge-nodes", "(Re)Converge nodes"
97
- def converge_nodes()
98
- converge_node(nil)
99
- end
100
-
101
- private
102
-
103
- @@count = 0
104
-
105
- TASK_STATUS_POLLING_INTERVAL = 3
106
- TASK_STATUS_MAX_TIME = 60
107
-
108
- def task_complete(response)
109
- return true unless response.ok?
110
- @@count += 1
111
- return true if (@@count * TASK_STATUS_POLLING_INTERVAL) > TASK_STATUS_MAX_TIME
112
- %w{succeeded failed}.include?(response.data(:status))
113
- end
114
-
115
- end
116
- end
@@ -1,310 +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
- dtk_require_common_commands('thor/module')
19
- require 'fileutils'
20
-
21
- module DTK::Client
22
- class TestModule < CommandBaseThor
23
-
24
- no_tasks do
25
- include ModuleMixin
26
- end
27
-
28
- def self.valid_children()
29
- # [:"component-template"]
30
- [:component, :remotes]
31
- end
32
-
33
- # this includes children of children - has to be sorted by n-level access
34
- def self.all_children()
35
- # [:"component-template", :attribute] # Amar: attribute context commented out per Rich suggeston
36
- # [:"component-template"]
37
- [:component]
38
- end
39
-
40
- def self.multi_context_children()
41
- [[:component], [:remotes], [:component, :remotes]]
42
- end
43
-
44
- def self.valid_child?(name_of_sub_context)
45
- return TestModule.valid_children().include?(name_of_sub_context.to_sym)
46
- end
47
-
48
- def self.validation_list(context_params)
49
- get_cached_response(:test_module, "test_module/list", {})
50
- end
51
-
52
- def self.whoami()
53
- return :test_module, "test_module/list", nil
54
- end
55
-
56
- def self.override_allowed_methods()
57
- return DTK::Shell::OverrideTasks.new(
58
- {
59
- :command_only => {
60
- :remotes => [
61
- ["push-remote", "push-remote [REMOTE-NAME] [--force]", "# Push local changes to remote git repository"],
62
- ["list-remotes", "list-remotes", "# List git remotes for given module"],
63
- ["add-remote", "add-remote REMOTE-NAME REMOTE-URL", "# Add git remote for given module"],
64
- ["remove-remote", "remove-remote REPO-NAME [-y]", "# Remove git remote for given module"] ]
65
- }
66
- })
67
- end
68
-
69
- desc "delete TEST-MODULE-NAME [-y] [-p]", "Delete test module and all items contained in it. Optional parameter [-p] is to delete local directory."
70
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
71
- method_option :purge, :aliases => '-p', :type => :boolean, :default => false
72
- def delete(context_params,method_opts={})
73
- response = delete_module_aux(context_params, method_opts)
74
- @@invalidate_map << :test_module if response && response.ok?
75
-
76
- response
77
- end
78
-
79
- desc "TEST-MODULE-NAME/ID set-attribute ATTRIBUTE-ID VALUE", "Set value of test module attributes"
80
- def set_attribute(context_params)
81
- set_attribute_module_aux(context_params)
82
- end
83
-
84
- desc "list [--remote] [--diff] [-n NAMESPACE]", "List loaded or remote test modules. Use --diff to compare loaded and remote test modules."
85
- method_option :remote, :type => :boolean, :default => false
86
- method_option :diff, :type => :boolean, :default => false
87
- method_option :namespace, :aliases => "-n" ,
88
- :type => :string,
89
- :banner => "NAMESPACE",
90
- :desc => "List modules only in specific namespace."
91
- def list(context_params)
92
- return module_info_about(context_params, :components, :component) if context_params.is_there_command?(:"component")
93
-
94
- forwarded_remote = context_params.get_forwarded_options()["remote"] if context_params.get_forwarded_options()
95
- remote = options.remote? || forwarded_remote
96
- action = (remote ? "list_remote" : "list")
97
-
98
- post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
99
- post_body[:diff] = options.diff? ? options.diff : {}
100
- post_body.merge!(:module_namespace => options.namespace)
101
-
102
- response = post rest_url("test_module/#{action}"),post_body
103
-
104
- return response unless response.ok?
105
- response.render_table()
106
- end
107
-
108
- desc "TEST-MODULE-NAME/ID list-components", "List all components for given test module."
109
- def list_components(context_params)
110
- module_info_about(context_params, :components, :component)
111
- end
112
-
113
- desc "TEST-MODULE-NAME/ID list-attributes", "List all attributes for given test module."
114
- def list_attributes(context_params)
115
- module_info_about(context_params, :attributes, :attribute_without_link)
116
- end
117
-
118
- desc "TEST-MODULE-NAME/ID list-instances", "List all instances for given test module."
119
- def list_instances(context_params)
120
- module_info_about(context_params, :instances, :component)
121
- end
122
-
123
- desc "import [NAMESPACE:]TEST-MODULE-NAME", "Create new test module from local clone"
124
- def import(context_params)
125
- response = import_module_aux(context_params)
126
- @@invalidate_map << :test_module
127
-
128
- response
129
- end
130
-
131
- #
132
- # Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
133
- #
134
- desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]TEST-MODULE-NAME", "Create new local test module by importing from provided git repo URL"
135
- def import_git(context_params)
136
- response = import_git_module_aux(context_params)
137
- @@invalidate_map << :test_module
138
- response
139
- end
140
-
141
- desc "install NAMESPACE/REMOTE-TEST-MODULE-NAME","Install remote test module into local environment"
142
- method_option "repo-manager",:aliases => "-r" ,
143
- :type => :string,
144
- :banner => "REPO-MANAGER",
145
- :desc => "DTK Repo Manager from which to resolve requested module."
146
- def install(context_params)
147
- response = install_module_aux(context_params)
148
- @@invalidate_map << :test_module if response && response.ok?
149
-
150
- response
151
- end
152
-
153
- desc "create [NAMESPACE:]TEST-MODULE-NAME", "Create template test module and generate all needed test module helper files"
154
- def create(context_params)
155
- create_test_module_aux(context_params)
156
- end
157
-
158
- desc "delete-from-catalog NAMESPACE/REMOTE-TEST-MODULE-NAME [-y] [--force]", "Delete the test module from the DTK Network catalog"
159
- method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
160
- method_option :force, :type => :boolean, :default => false
161
- def delete_from_catalog(context_params)
162
- delete_from_catalog_aux(context_params)
163
- end
164
-
165
- desc "TEST-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-TEST-MODULE-NAME]", "Publish test module to remote repository."
166
- def publish(context_params)
167
- publish_module_aux(context_params)
168
- end
169
-
170
- desc "TEST-MODULE-NAME/ID update [-n NAMESPACE] [--force]", "Update local test module from remote repository."
171
- method_option :namespace,:aliases => '-n',
172
- :type => :string,
173
- :banner => "NAMESPACE",
174
- :desc => "Remote namespace"
175
- method_option :force,:aliases => '-f',
176
- :type => :boolean,
177
- :desc => "Force pull",
178
- :default => false
179
- def update(context_params)
180
- update_aux(context_params)
181
- end
182
-
183
- desc "TEST-MODULE-NAME/ID chmod PERMISSION-SELECTOR", "Update remote permissions e.g. ug+rw , user and group get RW permissions"
184
- method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
185
- def chmod(context_params)
186
- chmod_module_aux(context_params)
187
- end
188
-
189
- desc "TEST-MODULE-NAME/ID make-public", "Make this module public"
190
- method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
191
- def make_public(context_params)
192
- make_public_module_aux(context_params)
193
- end
194
-
195
- desc "TEST-MODULE-NAME/ID make-private", "Make this module private"
196
- method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
197
- def make_private(context_params)
198
- make_private_module_aux(context_params)
199
- end
200
-
201
- desc "TEST-MODULE-NAME/ID add-collaborators", "Add collabrators users or groups comma seperated (--users or --groups)"
202
- method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
203
- method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
204
- method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
205
- def add_collaborators(context_params)
206
- add_collaborators_module_aux(context_params)
207
- end
208
-
209
- desc "TEST-MODULE-NAME/ID remove-collaborators", "Remove collabrators users or groups comma seperated (--users or --groups)"
210
- method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
211
- method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
212
- method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
213
- def remove_collaborators(context_params)
214
- remove_collaborators_module_aux(context_params)
215
- end
216
-
217
- desc "TEST-MODULE-NAME/ID list-collaborators", "List collaborators for given module"
218
- method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
219
- def list_collaborators(context_params)
220
- list_collaborators_module_aux(context_params)
221
- end
222
-
223
- desc "TEST-MODULE-NAME/ID clone [-n]", "Locally clone test module and test files. Use -n to skip edit prompt"
224
- method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
225
- def clone(context_params, internal_trigger=false)
226
- clone_module_aux(context_params, internal_trigger)
227
- end
228
-
229
- desc "TEST-MODULE-NAME/ID edit","Switch to unix editing for given test module."
230
- def edit(context_params)
231
- edit_module_aux(context_params)
232
- end
233
-
234
- desc "TEST-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy of test module to server"
235
- version_method_option
236
- method_option "message",:aliases => "-m" ,
237
- :type => :string,
238
- :banner => "COMMIT-MSG",
239
- :desc => "Commit message"
240
- # hidden option for dev
241
- method_option 'force-parse', :aliases => '-f', :type => :boolean, :default => false
242
- method_option :force, :type => :boolean, :default => false
243
- method_option :docs, :type => :boolean, :default => false, :aliases => '-d'
244
- def push(context_params, internal_trigger=false)
245
- push_module_aux(context_params, internal_trigger)
246
- end
247
-
248
- desc "TEST-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [--force]", "Push changes from local copy of test module to remote repository (dtkn)."
249
- method_option "message",:aliases => "-m" ,
250
- :type => :string,
251
- :banner => "COMMIT-MSG",
252
- :desc => "Commit message"
253
- method_option "namespace",:aliases => "-n",
254
- :type => :string,
255
- :banner => "NAMESPACE",
256
- :desc => "Remote namespace"
257
- #hidden option for dev
258
- method_option :force, :type => :boolean, :default => false, :aliases => '-f'
259
- def push_dtkn(context_params, internal_trigger=false)
260
- push_dtkn_module_aux(context_params, internal_trigger)
261
- end
262
- PushCatalogs = ["origin", "dtkn"]
263
-
264
- desc "TEST-MODULE-NAME/ID list-diffs", "List diffs between module on server and remote repo"
265
- method_option :remote, :type => :boolean, :default => false
266
- def list_diffs(context_params)
267
- list_remote_module_diffs(context_params)
268
- # list_diffs_module_aux(context_params)
269
- end
270
-
271
- # REMOTE INTERACTION
272
-
273
- desc "HIDE_FROM_BASE push-remote [REMOTE-NAME] [--force]", "Push local changes to remote git repository"
274
- method_option :force, :type => :boolean, :default => false
275
- def push_remote(context_params)
276
- push_remote_module_aux(context_params)
277
- end
278
-
279
- desc "HIDE_FROM_BASE list-remotes", "List git remotes for given module"
280
- def list_remotes(context_params)
281
- remote_list_aux(context_params)
282
- end
283
-
284
- desc "HIDE_FROM_BASE add-remote REMOTE-NAME REMOTE-URL", "Add git remote for given module"
285
- def add_remote(context_params)
286
- remote_add_aux(context_params)
287
- end
288
-
289
- desc "HIDE_FROM_BASE remove-remote REPO-NAME [-y]", "Remove git remote for given module"
290
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
291
- def remove_remote(context_params)
292
- remote_remove_aux(context_params)
293
- end
294
-
295
- #
296
- # DEVELOPMENT MODE METHODS
297
- #
298
- if DTK::Configuration.get(:development_mode)
299
- desc "delete-all","Delete all service modules"
300
- def delete_all(context_params)
301
- return unless Console.confirmation_prompt("This will DELETE ALL test modules, are you sure"+'?')
302
- response = list(context_params)
303
-
304
- response.data().each do |e|
305
- run_shell_command("delete #{e['display_name']} -y -p")
306
- end
307
- end
308
- end
309
- end
310
- end