hybrid_platforms_conductor 32.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +7 -0
  2. data/bin/check-node +24 -0
  3. data/bin/deploy +12 -0
  4. data/bin/dump_nodes_json +12 -0
  5. data/bin/free_ips +23 -0
  6. data/bin/free_veids +17 -0
  7. data/bin/get_impacted_nodes +43 -0
  8. data/bin/last_deploys +56 -0
  9. data/bin/nodes_to_deploy +104 -0
  10. data/bin/report +10 -0
  11. data/bin/run +39 -0
  12. data/bin/setup +11 -0
  13. data/bin/ssh_config +14 -0
  14. data/bin/test +13 -0
  15. data/bin/topograph +54 -0
  16. data/lib/hybrid_platforms_conductor/action.rb +82 -0
  17. data/lib/hybrid_platforms_conductor/actions_executor.rb +307 -0
  18. data/lib/hybrid_platforms_conductor/bitbucket.rb +123 -0
  19. data/lib/hybrid_platforms_conductor/cmd_runner.rb +188 -0
  20. data/lib/hybrid_platforms_conductor/cmdb.rb +34 -0
  21. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +78 -0
  22. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +43 -0
  23. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +110 -0
  24. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +38 -0
  25. data/lib/hybrid_platforms_conductor/config.rb +263 -0
  26. data/lib/hybrid_platforms_conductor/confluence.rb +119 -0
  27. data/lib/hybrid_platforms_conductor/connector.rb +84 -0
  28. data/lib/hybrid_platforms_conductor/credentials.rb +127 -0
  29. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +42 -0
  30. data/lib/hybrid_platforms_conductor/deployer.rb +598 -0
  31. data/lib/hybrid_platforms_conductor/executable.rb +145 -0
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb +44 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/action/interactive.rb +44 -0
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/action/my_action.rb.sample +79 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +63 -0
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/action/ruby.rb +69 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +61 -0
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +78 -0
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +104 -0
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +114 -0
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/my_cmdb.rb.sample +129 -0
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +66 -0
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +156 -0
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +702 -0
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +292 -0
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +148 -0
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/my_provisioner.rb.sample +103 -0
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +125 -0
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +522 -0
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +707 -0
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +122 -0
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +69 -0
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +164 -0
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/report/my_report_plugin.rb.sample +88 -0
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +61 -0
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/templates/confluence_inventory.html.erb +33 -0
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +137 -0
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/can_be_checked.rb +21 -0
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +112 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_from_scratch.rb +35 -0
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +28 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +44 -0
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_from_scratch.rb +36 -0
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +49 -0
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +25 -0
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +46 -0
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +45 -0
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +45 -0
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +25 -0
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +77 -0
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +38 -0
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +56 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +54 -0
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +47 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +82 -0
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +120 -0
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/my_test_plugin.rb.sample +143 -0
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +74 -0
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +85 -0
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +38 -0
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +38 -0
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre-meltdown-checker.sh +1930 -0
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +56 -0
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +31 -0
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +159 -0
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +122 -0
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/my_test_report.rb.sample +48 -0
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +120 -0
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_errors_status.html.erb +46 -0
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_gauge.html.erb +49 -0
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/confluence.html.erb +242 -0
  92. data/lib/hybrid_platforms_conductor/io_router.rb +70 -0
  93. data/lib/hybrid_platforms_conductor/json_dumper.rb +88 -0
  94. data/lib/hybrid_platforms_conductor/logger_helpers.rb +319 -0
  95. data/lib/hybrid_platforms_conductor/mutex_dir +76 -0
  96. data/lib/hybrid_platforms_conductor/nodes_handler.rb +597 -0
  97. data/lib/hybrid_platforms_conductor/parallel_threads.rb +97 -0
  98. data/lib/hybrid_platforms_conductor/platform_handler.rb +188 -0
  99. data/lib/hybrid_platforms_conductor/platforms_handler.rb +118 -0
  100. data/lib/hybrid_platforms_conductor/plugin.rb +53 -0
  101. data/lib/hybrid_platforms_conductor/plugins.rb +101 -0
  102. data/lib/hybrid_platforms_conductor/provisioner.rb +181 -0
  103. data/lib/hybrid_platforms_conductor/report.rb +31 -0
  104. data/lib/hybrid_platforms_conductor/reports_handler.rb +84 -0
  105. data/lib/hybrid_platforms_conductor/services_handler.rb +274 -0
  106. data/lib/hybrid_platforms_conductor/test.rb +141 -0
  107. data/lib/hybrid_platforms_conductor/test_by_service.rb +22 -0
  108. data/lib/hybrid_platforms_conductor/test_report.rb +282 -0
  109. data/lib/hybrid_platforms_conductor/tests_runner.rb +590 -0
  110. data/lib/hybrid_platforms_conductor/thycotic.rb +92 -0
  111. data/lib/hybrid_platforms_conductor/topographer.rb +859 -0
  112. data/lib/hybrid_platforms_conductor/topographer/plugin.rb +20 -0
  113. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +127 -0
  114. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +72 -0
  115. data/lib/hybrid_platforms_conductor/topographer/plugins/my_topographer_output_plugin.rb.sample +37 -0
  116. data/lib/hybrid_platforms_conductor/topographer/plugins/svg.rb +30 -0
  117. data/lib/hybrid_platforms_conductor/version.rb +5 -0
  118. data/spec/hybrid_platforms_conductor_test.rb +159 -0
  119. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +43 -0
  120. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +18 -0
  121. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +102 -0
  122. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +108 -0
  123. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +79 -0
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +199 -0
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +212 -0
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +125 -0
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +50 -0
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +28 -0
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +448 -0
  130. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +313 -0
  131. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +32 -0
  132. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +134 -0
  133. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +256 -0
  134. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +338 -0
  135. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +101 -0
  136. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +165 -0
  137. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +238 -0
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +9 -0
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +243 -0
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +104 -0
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +131 -0
  142. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +10 -0
  143. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +123 -0
  144. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +211 -0
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +126 -0
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +290 -0
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +43 -0
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +60 -0
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/proxmox.json +3 -0
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +82 -0
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +786 -0
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +112 -0
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +190 -0
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +200 -0
  155. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +35 -0
  156. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +67 -0
  157. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +79 -0
  158. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +28 -0
  159. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +41 -0
  160. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +33 -0
  161. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +64 -0
  162. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +133 -0
  163. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +19 -0
  164. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +446 -0
  165. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +127 -0
  166. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +318 -0
  167. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +132 -0
  168. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +60 -0
  169. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +58 -0
  170. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +97 -0
  171. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +104 -0
  172. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +243 -0
  173. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +44 -0
  174. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +121 -0
  175. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +142 -0
  176. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +101 -0
  177. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +388 -0
  178. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +274 -0
  179. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +264 -0
  180. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +194 -0
  181. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +37 -0
  182. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +194 -0
  183. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +137 -0
  184. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +257 -0
  185. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +110 -0
  186. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +367 -0
  187. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +111 -0
  188. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +29 -0
  189. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +166 -0
  190. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb2.rb +93 -0
  191. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +60 -0
  192. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others2.rb +58 -0
  193. data/spec/hybrid_platforms_conductor_test/executables/check-node_spec.rb +35 -0
  194. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +35 -0
  195. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +158 -0
  196. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +173 -0
  197. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +283 -0
  198. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +28 -0
  199. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +28 -0
  200. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +67 -0
  201. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +251 -0
  202. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +111 -0
  203. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +71 -0
  204. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +54 -0
  205. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +139 -0
  206. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +60 -0
  207. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +173 -0
  208. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +35 -0
  209. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +41 -0
  210. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +98 -0
  211. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +92 -0
  212. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +37 -0
  213. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +20 -0
  214. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +130 -0
  215. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +149 -0
  216. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +812 -0
  217. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +96 -0
  218. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +20 -0
  219. data/spec/hybrid_platforms_conductor_test/helpers/platform_handler_helpers.rb +35 -0
  220. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +127 -0
  221. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +48 -0
  222. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +789 -0
  223. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +29 -0
  224. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +20 -0
  225. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +38 -0
  226. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id1.rb +22 -0
  227. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id2.rb +22 -0
  228. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/test_plugin_id3.rb +26 -0
  229. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type2/test_plugin_id4.rb +26 -0
  230. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +225 -0
  231. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test2.rb +11 -0
  232. data/spec/hybrid_platforms_conductor_test/report_plugin.rb +35 -0
  233. data/spec/hybrid_platforms_conductor_test/test_action.rb +66 -0
  234. data/spec/hybrid_platforms_conductor_test/test_connector.rb +151 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +30 -0
  236. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +53 -0
  237. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +47 -0
  238. data/spec/hybrid_platforms_conductor_test/test_plugins/node_ssh.rb +42 -0
  239. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +50 -0
  240. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +50 -0
  241. data/spec/hybrid_platforms_conductor_test/test_provisioner.rb +95 -0
  242. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +49 -0
  243. data/spec/spec_helper.rb +111 -0
  244. metadata +566 -0
@@ -0,0 +1,97 @@
1
+ require 'thread'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ # Provide utilities to handle parallel threads
6
+ module ParallelThreads
7
+
8
+ # Iterate over a list of objects.
9
+ # Provide a mechanism to multithread this iteration (in such case the iterating code has to be thread-safe).
10
+ # In case of multithreaded run, a progress bar is being displayed.
11
+ #
12
+ # Parameters::
13
+ # * *list* (Array<Object>): List of objects to iterate over
14
+ # * *parallel* (Boolean): Iterate in a multithreaded way? [default: false]
15
+ # * *nbr_threads_max* (Integer or nil): Maximum number of threads to be used in case of parallel, or nil for no limit [default: nil]
16
+ # * *progress* (String or nil): Name of a progress bar to follow the progression, or nil for no progress bar [default: 'Progress']
17
+ # * Proc: The code called for each node being iterated on.
18
+ # * Parameters::
19
+ # * *element* (Object): The object
20
+ def for_each_element_in(list, parallel: false, nbr_threads_max: nil, progress: 'Process')
21
+ if parallel
22
+ # Threads to wait for
23
+ threads_to_join = []
24
+ # Spread elements evenly among the threads.
25
+ # Use a shared pool of elements to be handled by threads.
26
+ pools = {
27
+ to_process: list.dup,
28
+ processing: [],
29
+ processed: []
30
+ }
31
+ nbr_total = list.size
32
+ # Protect access to the pools using a mutex
33
+ pools_semaphore = Mutex.new
34
+ # Spawn the threads, each one responsible for handling its list
35
+ (nbr_threads_max.nil? || nbr_threads_max > nbr_total ? nbr_total : nbr_threads_max).times do
36
+ threads_to_join << Thread.new do
37
+ # As exceptions are logged anyway whatever the Thread setting is, only turn it on for debug.
38
+ # That will keep tests execution cleaner.
39
+ Thread.current.report_on_exception = log_debug?
40
+ begin
41
+ loop do
42
+ # Modify the list while processing it, so that reporting can be done.
43
+ element = nil
44
+ pools_semaphore.synchronize do
45
+ element = pools[:to_process].shift
46
+ pools[:processing] << element unless element.nil?
47
+ end
48
+ break if element.nil?
49
+ begin
50
+ yield element
51
+ ensure
52
+ pools_semaphore.synchronize do
53
+ pools[:processing].delete(element)
54
+ pools[:processed] << element
55
+ end
56
+ end
57
+ end
58
+ rescue
59
+ log_error "Unhandled exception occurred in thread #{Thread.current.object_id}: #{$!}\n#{$!.backtrace.join("\n")}"
60
+ raise
61
+ end
62
+ end
63
+ end
64
+ if progress
65
+ # Here the main thread just reports progression
66
+ nbr_to_process = nil
67
+ nbr_processing = nil
68
+ nbr_processed = nil
69
+ with_progress_bar(nbr_total, name: progress) do |progress_bar|
70
+ loop do
71
+ pools_semaphore.synchronize do
72
+ nbr_to_process = pools[:to_process].size
73
+ nbr_processing = pools[:processing].size
74
+ nbr_processed = pools[:processed].size
75
+ end
76
+ progress_bar.title = "Queue: #{nbr_to_process} - Processing: #{nbr_processing} - Done: #{nbr_processed} - Total: #{nbr_total}"
77
+ progress_bar.progress = nbr_processed
78
+ break if nbr_processed == nbr_total
79
+ sleep 0.5
80
+ end
81
+ end
82
+ end
83
+ # Wait for threads to be joined
84
+ threads_to_join.each do |thread|
85
+ thread.join
86
+ end
87
+ else
88
+ # Execute synchronously
89
+ list.each do |element|
90
+ yield element
91
+ end
92
+ end
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,188 @@
1
+ require 'json'
2
+ require 'hybrid_platforms_conductor/plugin'
3
+
4
+ module HybridPlatformsConductor
5
+
6
+ # Common ancestor to any platform handler
7
+ class PlatformHandler < Plugin
8
+
9
+ # Make it so that we can sort lists of platforms
10
+ include Comparable
11
+
12
+ # Callback called when a subclass inherits this class.
13
+ #
14
+ # Parameters::
15
+ # * *subclass* (Class): The inheriting class
16
+ def self.inherited(subclass)
17
+ # Make sure we define automatically a helper for such a platform
18
+ mixin = Module.new
19
+ platform_type = subclass.name.split('::').last.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym
20
+ mixin.define_method("#{platform_type}_platform".to_sym) do |path: nil, git: nil, branch: 'master', &platform_config_code|
21
+ repository_path =
22
+ if !path.nil?
23
+ path
24
+ elsif !git.nil?
25
+ # Clone in a local repository
26
+ local_repository_path = "#{@git_platforms_dir}/#{File.basename(git)[0..-File.extname(git).size - 1]}"
27
+ unless File.exist?(local_repository_path)
28
+ branch = "refs/heads/#{branch}" unless branch.include?('/')
29
+ local_ref = "refs/remotes/origin/#{branch.split('/').last}"
30
+ section "Cloning #{git} (#{branch} => #{local_ref}) into #{local_repository_path}" do
31
+ git_repo = Git.init(local_repository_path, )
32
+ git_repo.add_remote('origin', git).fetch(ref: "#{branch}:#{local_ref}")
33
+ git_repo.checkout local_ref
34
+ end
35
+ end
36
+ local_repository_path
37
+ else
38
+ raise 'The platform has to be defined with either a path or a git URL'
39
+ end
40
+ @platform_dirs[platform_type] = [] unless @platform_dirs.key?(platform_type)
41
+ @platform_dirs[platform_type] << repository_path
42
+ platform_config_code.call(repository_path) unless platform_config_code.nil?
43
+ end
44
+ # Register this new mixin in the Config DSL
45
+ extend_config_dsl_with(mixin)
46
+ super
47
+ end
48
+
49
+ # Repository path
50
+ # String
51
+ attr_reader :repository_path
52
+
53
+ # Platform type
54
+ # Symbol
55
+ attr_reader :platform_type
56
+
57
+ # Before deploying, need to set some components in case the plugins need them
58
+ attr_accessor :nodes_handler, :actions_executor
59
+
60
+ # Constructor
61
+ #
62
+ # Parameters::
63
+ # * *platform_type* (Symbol): Platform type
64
+ # * *repository_path* (String): Repository path
65
+ # * *logger* (Logger): Logger to be used [default: Logger.new(STDOUT)]
66
+ # * *logger_stderr* (Logger): Logger to be used for stderr [default: Logger.new(STDERR)]
67
+ # * *config* (Config): Config to be used. [default: Config.new]
68
+ # * *cmd_runner* (CmdRunner): Command executor to be used. [default: CmdRunner.new]
69
+ def initialize(
70
+ platform_type,
71
+ repository_path,
72
+ logger: Logger.new(STDOUT),
73
+ logger_stderr: Logger.new(STDERR),
74
+ config: Config.new,
75
+ cmd_runner: CmdRunner.new
76
+ )
77
+ super(logger: logger, logger_stderr: logger_stderr, config: config)
78
+ @platform_type = platform_type
79
+ @repository_path = repository_path
80
+ @cmd_runner = cmd_runner
81
+ self.init if self.respond_to?(:init)
82
+ end
83
+
84
+ # Return the name of the platform
85
+ #
86
+ # Result::
87
+ # * String: Name of the platform
88
+ def name
89
+ info[:repo_name]
90
+ end
91
+
92
+ # Get the list of impacted nodes and services from a files diff.
93
+ # [API] - This is the default implementation, and is meant to be overriden by Platform Handlers.
94
+ #
95
+ # Parameters::
96
+ # * *files_diffs* (Hash< String, Hash< Symbol, Object > >): List of diffs info, per file name having a diff. Diffs info have the following properties:
97
+ # * *moved_to* (String): The new file path, in case it has been moved [optional]
98
+ # * *diff* (String): The diff content
99
+ # Result::
100
+ # * Array<String>: The list of nodes impacted by this diff
101
+ # * Array<String>: The list of services impacted by this diff
102
+ # * Boolean: Are there some files that have a global impact (meaning all nodes are potentially impacted by this diff)?
103
+ def impacts_from(files_diffs)
104
+ # By default, consider all nodes of the platform are impacted by whatever diff.
105
+ [
106
+ [],
107
+ [],
108
+ true
109
+ ]
110
+ end
111
+
112
+ # Get some information from this platform.
113
+ # This information identifies the code level that is currently checked out.
114
+ #
115
+ # Result::
116
+ # * Hash<Symbol,Object>: Description of this platform:
117
+ # * *repo_name* (String): The repository name
118
+ # * *commit* (Hash<Symbol,Object>): Information on the checked out Git commit
119
+ # * *id* (String): Commit ID
120
+ # * *ref* (String): Associated reference
121
+ # * *message* (String): Associated message
122
+ # * *date* (Time): Commit date in UTC
123
+ # * *author* (Hash<Symbol,Object>): Information on the author:
124
+ # * *name* (String): Name of the commit author
125
+ # * *email* (String): Email of the commit author
126
+ # * *status* (Hash<Symbol,Object>): Information on the checked out Git status
127
+ # * *changed_files* (Array<String>): List of changed files
128
+ # * *added_files* (Array<String>): List of added files
129
+ # * *deleted_files* (Array<String>): List of deleted files
130
+ # * *untracked_files* (Array<String>): List of untracked files
131
+ def info
132
+ # Keep info in a memory cache, so that we don't query git for nothing
133
+ unless defined?(@info)
134
+ git = nil
135
+ begin
136
+ git = Git.open(@repository_path)
137
+ rescue
138
+ log_debug "Platform #{@repository_path} is not a git repository"
139
+ end
140
+ @info =
141
+ if git
142
+ git_status = git.status
143
+ git_commit = git.log.first
144
+ {
145
+ repo_name: File.basename(git.remotes.first.url).gsub(/\.git$/, ''),
146
+ commit: {
147
+ id: git_commit.sha,
148
+ ref: git_commit.name,
149
+ message: git_commit.message,
150
+ date: git_commit.date.utc,
151
+ author: {
152
+ name: git_commit.author.name,
153
+ email: git_commit.author.email
154
+ }
155
+ },
156
+ status: {
157
+ changed_files: git_status.changed.keys,
158
+ added_files: git_status.added.keys,
159
+ deleted_files: git_status.deleted.keys,
160
+ untracked_files: git_status.untracked.keys
161
+ }
162
+ }
163
+ else
164
+ {
165
+ repo_name: File.basename(@repository_path)
166
+ }
167
+ end
168
+ end
169
+ @info
170
+ end
171
+
172
+ # Order relation
173
+ #
174
+ # Parameters::
175
+ # * *other* (Object): Other object to compare to
176
+ # Result::
177
+ # * Integer: -1, 0, or +1 depending on whether the receiver is less than, equal to, or greater than the other object
178
+ def <=>(other)
179
+ if other.is_a?(PlatformHandler)
180
+ name <=> other.name
181
+ else
182
+ super
183
+ end
184
+ end
185
+
186
+ end
187
+
188
+ end
@@ -0,0 +1,118 @@
1
+ require 'hybrid_platforms_conductor/logger_helpers'
2
+ require 'hybrid_platforms_conductor/platform_handler'
3
+
4
+ module HybridPlatformsConductor
5
+
6
+ # Provide an API to access information given by Platform Handlers
7
+ class PlatformsHandler
8
+
9
+ module ConfigDSLExtension
10
+
11
+ # List of platforms repository directories, per platform type
12
+ # Hash<Symbol, Array<String> >
13
+ attr_reader :platform_dirs
14
+
15
+ # Mixin initializer
16
+ def init_platforms_handler
17
+ @platform_dirs = {}
18
+ # Directory in which platforms are cloned
19
+ @git_platforms_dir = "#{@hybrid_platforms_dir}/cloned_platforms"
20
+ end
21
+
22
+ end
23
+ Config.extend_config_dsl_with ConfigDSLExtension, :init_platforms_handler
24
+
25
+ include LoggerHelpers
26
+
27
+ # Constructor
28
+ #
29
+ # Parameters::
30
+ # * *logger* (Logger): Logger to be used [default: Logger.new(STDOUT)]
31
+ # * *logger_stderr* (Logger): Logger to be used for stderr [default: Logger.new(STDERR)]
32
+ # * *config* (Config): Config to be used. [default: Config.new]
33
+ # * *cmd_runner* (CmdRunner): Command executor to be used. [default: CmdRunner.new]
34
+ def initialize(
35
+ logger: Logger.new(STDOUT),
36
+ logger_stderr: Logger.new(STDERR),
37
+ config: Config.new,
38
+ cmd_runner: CmdRunner.new
39
+ )
40
+ init_loggers(logger, logger_stderr)
41
+ @config = config
42
+ @cmd_runner = cmd_runner
43
+ @platform_types = Plugins.new(:platform_handler, logger: @logger, logger_stderr: @logger_stderr)
44
+ # Keep a list of instantiated platform handlers per platform type
45
+ # Hash<Symbol, Array<PlatformHandler> >
46
+ @platform_handlers = {}
47
+ # Read all platforms from the config
48
+ @config.platform_dirs.each do |platform_type, repositories|
49
+ repositories.each do |repository_path|
50
+ platform_handler = @platform_types[platform_type].new(
51
+ platform_type,
52
+ repository_path,
53
+ logger: @logger,
54
+ logger_stderr: @logger_stderr,
55
+ config: @config,
56
+ cmd_runner: @cmd_runner
57
+ )
58
+ # Check that this platform has unique name
59
+ raise "Platform name #{platform_handler.name} is declared several times." if @platform_handlers.values.flatten.any? { |known_platform| known_platform.name == platform_handler.name }
60
+ @platform_handlers[platform_type] = [] unless @platform_handlers.key?(platform_type)
61
+ @platform_handlers[platform_type] << platform_handler
62
+ end
63
+ end
64
+ end
65
+
66
+ # The list of registered platform handler classes, per platform type.
67
+ #
68
+ # Result::
69
+ # * Hash<Symbol,Class>: The list of registered platform handler classes, per platform type.
70
+ def platform_types
71
+ @platform_types.to_hash
72
+ end
73
+
74
+ # Get the list of known platforms
75
+ #
76
+ # Parameters::
77
+ # * *platform_type* (Symbol or nil): Filter only platforms of a given platform type, or nil for all platforms [default: nil]
78
+ # Result::
79
+ # * Array<PlatformHandler>: List of platform handlers
80
+ def known_platforms(platform_type: nil)
81
+ (platform_type.nil? ? @platform_handlers.keys : [platform_type]).map { |platform_type| (@platform_handlers[platform_type] || []) }.flatten
82
+ end
83
+
84
+ # Return the platform handler for a given platform name
85
+ #
86
+ # Parameters::
87
+ # * *platform_name* (String): The platform name
88
+ # Result::
89
+ # * PlatformHandler or nil: Corresponding platform handler, or nil if none
90
+ def platform(platform_name)
91
+ @platform_handlers.values.flatten.find { |known_platform| known_platform.name == platform_name }
92
+ end
93
+
94
+ # Inject dependencies that can't be set at initialization time.
95
+ # This is due to the fact that a PlatformHandler is a single plugin handling both inventory and services from a single repository.
96
+ # If we split those plugins into an inventory-type plugin and service-type plugin, each part could be initialized without having cyclic dependencies.
97
+ # The inventory-type part does not need NodesHandler nor ActionsExecutor (as it would be used by NodesHandler).
98
+ # The service-type part would use NodesHandler and ActionsExecutor given to its initializer.
99
+ # TODO: Split this plugin type in 2 to avoid this late dependency injection.
100
+ #
101
+ # Parameters::
102
+ # * *nodes_handler* (NodesHandler): Nodes handler to be used. [default: NodesHandler.new]
103
+ # * *actions_executor* (ActionsExecutor): Actions Executor to be used. [default: ActionsExecutor.new]
104
+ def inject_dependencies(
105
+ nodes_handler: NodesHandler.new,
106
+ actions_executor: ActionsExecutor.new
107
+ )
108
+ @nodes_handler = nodes_handler
109
+ @actions_executor = actions_executor
110
+ @platform_handlers.values.flatten.each do |platform|
111
+ platform.nodes_handler = @nodes_handler
112
+ platform.actions_executor = @actions_executor
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+ end
@@ -0,0 +1,53 @@
1
+ module HybridPlatformsConductor
2
+
3
+ # Base class for all plugins
4
+ class Plugin
5
+
6
+ include LoggerHelpers
7
+
8
+ class << self
9
+
10
+ include LoggerHelpers
11
+
12
+ # Class loggers
13
+ attr_accessor :logger, :logger_stderr
14
+
15
+ # Are dependencies met before using this plugin?
16
+ # This method can be overriden by any plugin
17
+ #
18
+ # Result::
19
+ # * Boolean: Are dependencies met before using this plugin?
20
+ def valid?
21
+ true
22
+ end
23
+
24
+ # Extend the config DSL used when parsing the hpc_config.rb file with a given Mixin.
25
+ # This can be used by any plugin to add plugin-specific configuration in the hpc_config.rb file.
26
+ #
27
+ # Parameters::
28
+ # * *mixin* (Module): Mixin to add to the Platforms DSL
29
+ # * *init_method* (Symbol or nil): The initializer method of this Mixin, or nil if none [default = nil]
30
+ def extend_config_dsl_with(mixin, init_method = nil)
31
+ Config.extend_config_dsl_with(mixin, init_method)
32
+ end
33
+
34
+ end
35
+
36
+ # Constructor
37
+ #
38
+ # Parameters::
39
+ # * *logger* (Logger): Logger to be used [default: Logger.new(STDOUT)]
40
+ # * *logger_stderr* (Logger): Logger to be used for stderr [default: Logger.new(STDERR)]
41
+ # * *config* (Config): Config to be used. [default: Config.new]
42
+ def initialize(
43
+ logger: Logger.new(STDOUT),
44
+ logger_stderr: Logger.new(STDERR),
45
+ config: Config.new
46
+ )
47
+ init_loggers(logger, logger_stderr)
48
+ @config = config
49
+ end
50
+
51
+ end
52
+
53
+ end