hybrid_platforms_conductor 32.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,56 @@
1
+ module HybridPlatformsConductor
2
+
3
+ module HpcPlugins
4
+
5
+ module Test
6
+
7
+ # Test that the vulnerabilities Spectre and Meltdown are patched
8
+ class Spectre < HybridPlatformsConductor::Test
9
+
10
+ VULNERABILITIES_TO_CHECK = {
11
+ 'CVE-2017-5753' => 'Spectre Variant 1',
12
+ 'CVE-2017-5715' => 'Spectre Variant 2',
13
+ 'CVE-2017-5754' => 'Meltdown'
14
+ }
15
+
16
+ SPECTRE_CMD = <<~EOS
17
+ sudo /bin/bash <<'EOAction'
18
+ #{File.read("#{__dir__}/spectre-meltdown-checker.sh")}
19
+ EOAction
20
+ EOS
21
+
22
+ # Check my_test_plugin.rb.sample documentation for signature details.
23
+ def test_on_node
24
+ {
25
+ SPECTRE_CMD => {
26
+ validator: proc do |stdout|
27
+ VULNERABILITIES_TO_CHECK.each do |id, name|
28
+ id_regexp = /#{Regexp.escape(id)}/
29
+ status_idx = stdout.index { |line| line =~ id_regexp }
30
+ if status_idx.nil?
31
+ error "Unable to find vulnerability section #{id}"
32
+ else
33
+ while !stdout[status_idx].nil? && !(stdout[status_idx] =~ /STATUS:[^A-Z]+([A-Z ]+)/)
34
+ status_idx += 1
35
+ end
36
+ if stdout[status_idx].nil?
37
+ error "Unable to find vulnerability status for #{id}"
38
+ else
39
+ status = $1.strip
40
+ error "Status for #{name}: #{status}" if status != 'NOT VULNERABLE'
41
+ end
42
+ end
43
+ end
44
+ end,
45
+ timeout: 30
46
+ }
47
+ }
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,31 @@
1
+ module HybridPlatformsConductor
2
+
3
+ module HpcPlugins
4
+
5
+ module Test
6
+
7
+ # Test that VEIDs are assigned correctly
8
+ class Veids < HybridPlatformsConductor::Test
9
+
10
+ # Check my_test_plugin.rb.sample documentation for signature details.
11
+ def test
12
+ # Get a map of VEIDs per node
13
+ @nodes_handler.prefetch_metadata_of @nodes_handler.known_nodes, :veid
14
+ veids = Hash[@nodes_handler.
15
+ known_nodes.
16
+ map { |node| [node, @nodes_handler.get_veid_of(node) ? @nodes_handler.get_veid_of(node).to_i : nil] }
17
+ ]
18
+
19
+ # Check there are no duplicates
20
+ veids.group_by { |_node, veid| veid }.each do |veid, nodes|
21
+ error "VEID #{veid} is used by the following nodes: #{nodes.map { |node, _veid| node }.join(', ')}" if !veid.nil? && nodes.size > 1
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,159 @@
1
+ require 'nokogiri'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module Test
8
+
9
+ # Test that the node has not known vulnerabilities.
10
+ # Check this by using OVAL files published by vendors.
11
+ # For example, RedHat publishes them here: https://www.redhat.com/security/data/oval/v2/RHEL7/
12
+ # This test uses an oval.json file stored in the OS images folder, having the following structure:
13
+ # * *urls* (Array<String>): List of URLs pointing to OVAL files [default: []]
14
+ # Each URL can be directly an XML file, either raw or compressed with .gz or .bz2.
15
+ # * *repo_urls* (Array<String>): List of URLs pointing to repositories of OVAL files [default: []]
16
+ # The last HTML link of each repo URL is followed until an OVAL file is found.
17
+ # Each final OVAL URL can be directly an XML file, either raw or compressed with .gz or .bz2.
18
+ # This is useful to follow repository links, such as jFrog or web servers serving common file systems structure storing several versions of the OVAL file.
19
+ # * *reported_severities* (Array<String> or nil): List of severities to report, if any (use Unknown when the severity is not known), or nil for all [default: nil]
20
+ class Vulnerabilities < HybridPlatformsConductor::Test
21
+
22
+ # Known compression methods, per file extension, and their corresponding uncompress bash script
23
+ KNOWN_COMPRESSIONS = {
24
+ bz2: {
25
+ cmd: proc { |file| "if [ ! -f \"#{File.basename(file, '.bz2')}\" ] ; then bunzip2 \"#{file}\" ; fi" },
26
+ packages: ['bzip2']
27
+ },
28
+ gz: {
29
+ cmd: proc { |file| "if [ ! -f \"#{File.basename(file, '.gz')}\" ] ; then gunzip \"#{file}\" ; fi" },
30
+ packages: ['gzip']
31
+ }
32
+ }
33
+
34
+ # Check my_test_plugin.rb.sample documentation for signature details.
35
+ def test_on_node
36
+ # Get the image name for this node
37
+ image = @nodes_handler.get_image_of(@node).to_sym
38
+ # Find if we have such an image registered
39
+ if @config.known_os_images.include?(image)
40
+ oval_file = "#{@config.os_image_dir(image)}/oval.json"
41
+ if File.exist?(oval_file)
42
+ oval_info = JSON.parse(File.read(oval_file))
43
+ # Get all URLs
44
+ urls = oval_info['urls'] || []
45
+ urls.concat(
46
+ (oval_info['repo_urls'] || []).map do |artifactory_url|
47
+ # Follow the last link recursively until we find a .xml or compressed file
48
+ current_url = artifactory_url
49
+ loop do
50
+ current_url = "#{current_url}#{current_url.end_with?('/') ? '' : '/'}#{Nokogiri::HTML.parse(URI.open(current_url)).css('a').last['href']}"
51
+ break if current_url.end_with?('.xml') || KNOWN_COMPRESSIONS.keys.any? { |file_ext| current_url.end_with?(".#{file_ext}") }
52
+ log_debug "Follow last link to #{current_url}"
53
+ end
54
+ current_url
55
+ end
56
+ )
57
+ Hash[urls.map do |url|
58
+ # 1. Get the OVAL file on the node to be tested (uncompress it if needed)
59
+ # 2. Make sure oscap is installed
60
+ # 3. Generate the report for this OVAL file using oscap
61
+ # 4. Get back the report here to analyze it
62
+ local_oval_file = File.basename(url)
63
+ uncompress_cmds = []
64
+ packages_to_install = []
65
+ KNOWN_COMPRESSIONS.each do |file_ext, compress_info|
66
+ file_ending = ".#{file_ext}"
67
+ if local_oval_file.end_with?(file_ending)
68
+ uncompress_cmds << compress_info[:cmd].call(local_oval_file)
69
+ packages_to_install.concat(compress_info[:packages])
70
+ local_oval_file = File.basename(local_oval_file, file_ending)
71
+ end
72
+ end
73
+ cmds = <<~EOS
74
+ #{
75
+ case image
76
+ when :centos_7
77
+ "sudo yum install -y wget openscap-scanner #{packages_to_install.join(' ')}"
78
+ when :debian_9
79
+ "sudo apt install -y wget libopenscap8 #{packages_to_install.join(' ')}"
80
+ when :debian_10
81
+ # On Debian 10 we have to compile it from sources, as the packaged official version has core dumps.
82
+ # cf https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1688223.html
83
+ # TODO: Remove this Debian 10 specificity when the official libopenscap8 will be corrected
84
+ <<~EOS2
85
+ if [ ! -x "$(command -v oscap)" ] || [ "$(oscap --version | head -n 1 | awk '{print $6}')" != "1.3.4" ]; then
86
+ rm -rf openscap
87
+ git clone --recurse-submodules https://github.com/OpenSCAP/openscap.git
88
+ cd openscap
89
+ sudo apt install -y cmake libdbus-1-dev libdbus-glib-1-dev libcurl4-openssl-dev libgcrypt20-dev libselinux1-dev libxslt1-dev libgconf2-dev libacl1-dev libblkid-dev libcap-dev libxml2-dev libldap2-dev libpcre3-dev python-dev swig libxml-parser-perl libxml-xpath-perl libperl-dev libbz2-dev librpm-dev g++ libapt-pkg-dev libyaml-dev
90
+ cd build
91
+ cmake ../
92
+ make
93
+ sudo make install
94
+ fi
95
+ sudo apt install -y wget #{packages_to_install.join(' ')}
96
+ EOS2
97
+ else
98
+ raise "Non supported image: #{image}. Please adapt this test's code."
99
+ end
100
+ }
101
+ rm -rf hpc_vulnerabilities_test
102
+ mkdir -p hpc_vulnerabilities_test
103
+ cd hpc_vulnerabilities_test
104
+ wget -N #{url}
105
+ #{uncompress_cmds.join("\n")}
106
+ sudo oscap oval eval --skip-valid --results "#{local_oval_file}.results.xml" "#{local_oval_file}"
107
+ echo "===== RESULTS ====="
108
+ cat "#{local_oval_file}.results.xml"
109
+ cd ..
110
+ EOS
111
+ [
112
+ cmds,
113
+ {
114
+ validator: proc do |stdout|
115
+ idx_results = stdout.index('===== RESULTS =====')
116
+ if idx_results.nil?
117
+ error 'No results given by the oscap run', stdout.join("\n")
118
+ else
119
+ results = Nokogiri::XML(stdout[idx_results + 1..-1].join("\n"))
120
+ results.remove_namespaces!
121
+ oval_definitions = results.css('oval_results oval_definitions definitions definition')
122
+ results.css('results system definitions definition').each do |definition_xml|
123
+ if definition_xml['result'] == 'true'
124
+ # Just found an OVAL item to be patched.
125
+ definition_id = definition_xml['definition_id']
126
+ oval_definition = oval_definitions.find { |el| el['id'] == definition_id }
127
+ # We don't forcefully want to report all missing patches. Only the most important ones.
128
+ severity = oval_definition.css('metadata advisory severity').text
129
+ severity = 'Unknown' if severity.empty?
130
+ if !oval_info.key?('reported_severities') || oval_info['reported_severities'].include?(severity)
131
+ # Only consider the first line of the description, as sometimes it's very long
132
+ error "Non-patched #{severity} vulnerability found: #{oval_definition.css('metadata title').text} - #{oval_definition.css('metadata description').text.split("\n").first}"
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end,
138
+ # Increase timeout in case we have to install a lot of dependencies (like for Debian 10)
139
+ timeout: 240
140
+ }
141
+ ]
142
+ end]
143
+ else
144
+ error "No OVAL file defined for image #{image} at #{oval_file}"
145
+ {}
146
+ end
147
+ else
148
+ error "Unknown OS image #{image} defined for node #{@node}"
149
+ {}
150
+ end
151
+ end
152
+
153
+ end
154
+
155
+ end
156
+
157
+ end
158
+
159
+ end
@@ -0,0 +1,122 @@
1
+ require 'cgi'
2
+ require 'erubis'
3
+ require 'hybrid_platforms_conductor/confluence'
4
+ require 'hybrid_platforms_conductor/common_config_dsl/confluence'
5
+
6
+ module HybridPlatformsConductor
7
+
8
+ module HpcPlugins
9
+
10
+ module TestReport
11
+
12
+ # Report tests results on a generated Confluence page
13
+ class Confluence < HybridPlatformsConductor::TestReport
14
+
15
+ self.extend_config_dsl_with CommonConfigDsl::Confluence, :init_confluence
16
+
17
+ # Maximum errors to be reported by item
18
+ MAX_ERROR_ITEMS_DISPLAYED = 10
19
+
20
+ # Maximal length of an error message to be reported
21
+ MAX_ERROR_MESSAGE_LENGTH_DISPLAYED = 4096
22
+
23
+ # Number of cells in the nodes list's progress status bars
24
+ NBR_CELLS_IN_STATUS_BARS = 28
25
+
26
+ # Handle tests reports
27
+ def report
28
+ confluence_info = @config.confluence_info
29
+ if confluence_info
30
+ if confluence_info[:tests_report_page_id]
31
+ HybridPlatformsConductor::Confluence.with_confluence(confluence_info[:url], @logger, @logger_stderr) do |confluence|
32
+ # Get previous percentages for the evolution
33
+ @previous_success_percentages = confluence.page_storage_format(confluence_info[:tests_report_page_id]).
34
+ at('h1:contains("Evolution")').
35
+ search('~ structured-macro:first-of-type').
36
+ css('table td').
37
+ map { |td_element| td_element.text }.
38
+ each_slice(2).
39
+ to_a.
40
+ map { |(time_str, value_str)| [Time.parse("#{time_str} UTC"), value_str.to_f] }
41
+ @nbr_cells_in_status_bars = NBR_CELLS_IN_STATUS_BARS
42
+ log_error 'Unable to extract previous percentages from Confluence page' if @previous_success_percentages.empty?
43
+ confluence.update_page(confluence_info[:tests_report_page_id], render('confluence'))
44
+ end
45
+ out "Inventory report Confluence page updated. Please visit #{confluence_info[:url]}/pages/viewpage.action?pageId=#{confluence_info[:tests_report_page_id]}"
46
+ else
47
+ log_warn 'No tests_report_page_id in the Confluence information defined. Ignoring the Confluence report.'
48
+ end
49
+ else
50
+ log_warn 'No Confluence information defined. Ignoring the Confluence report.'
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ TEMPLATES_PATH = File.expand_path("#{File.dirname(__FILE__)}/templates")
57
+
58
+ # Render a given ERB template into a String
59
+ #
60
+ # Parameters::
61
+ # * *template* (String): Template name
62
+ # Result::
63
+ # * String: Rendered template
64
+ def render(template)
65
+ Erubis::Eruby.new(File.read("#{TEMPLATES_PATH}/#{template}.html.erb")).result(binding)
66
+ end
67
+
68
+ # Render a status to be integrated in a Confluence page for a given test
69
+ #
70
+ # Parameters::
71
+ # * *test_name* (String): Test name
72
+ # * *test_criteria* (Hash<Symbol,Object>): Test criteria
73
+ # Result::
74
+ # * String: Rendered status
75
+ def render_status(test_name, test_criteria)
76
+ @status_test_name = test_name
77
+ @status_test_criteria = test_criteria
78
+ @max_errors = MAX_ERROR_ITEMS_DISPLAYED
79
+ @max_error_message_length = MAX_ERROR_MESSAGE_LENGTH_DISPLAYED
80
+ render '_confluence_errors_status'
81
+ end
82
+
83
+ # Render a gauge displaying statuses of tests.
84
+ #
85
+ # Parameters::
86
+ # * *info* (Hash<Symbol,Object>): The info about tests to render gauge for (check classify_tests to know about info)
87
+ def render_gauge(info)
88
+ @gauge_success = info[:success].size
89
+ @gauge_unexpected_error = info[:unexpected_error].size
90
+ @gauge_expected_error = info[:expected_error].size
91
+ @gauge_not_run = info[:not_run].size
92
+ render '_confluence_gauge'
93
+ end
94
+
95
+ # Return the color linked to a status
96
+ #
97
+ # Parameters::
98
+ # * *status* (Symbol): Status (check classify_tests to know about possible statuses)
99
+ # Result::
100
+ # * String: Corresponding color
101
+ def status_color(status)
102
+ case status
103
+ when :success
104
+ 'Green'
105
+ when :unexpected_error
106
+ 'Red'
107
+ when :expected_error
108
+ 'Yellow'
109
+ when :not_run
110
+ 'Grey'
111
+ else
112
+ raise "Unknown status: #{status}"
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+ end
121
+
122
+ end
@@ -0,0 +1,48 @@
1
+ require 'hybrid_platforms_conductor/test_report'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module TestReport
8
+
9
+ class MyTestReport < HybridPlatformsConductor::TestReport
10
+
11
+ # Are dependencies met before using this plugin?
12
+ # [API] - This method is optional
13
+ #
14
+ # Result::
15
+ # * Boolean: Are dependencies met before using this plugin?
16
+ def self.valid?
17
+ true
18
+ end
19
+
20
+ # Add a Mixin to the DSL parsing the platforms configuration file.
21
+ # This can be used by any plugin to add plugin-specific configuration getters and setters, accessible later from NodesHandler instances.
22
+ # An optional initializer can also be given.
23
+ # [API] - Those calls are optional
24
+ module MyDSLExtension
25
+
26
+ attr_accessor :my_property
27
+
28
+ # Initialize the DSL
29
+ def init_my_dsl_extension
30
+ @my_property = 42
31
+ end
32
+
33
+ end
34
+ self.extend_config_dsl_with MyDSLExtension, :init_my_dsl_extension
35
+
36
+ # Handle tests reports
37
+ def report
38
+ puts "#{@tested_nodes.size} nodes have been tested."
39
+ puts "#{@tests.select { |test| !test.errors.empty? }.size} tests have failed."
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,120 @@
1
+ require 'terminal-table'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module TestReport
8
+
9
+ # Report tests results on stdout
10
+ class Stdout < HybridPlatformsConductor::TestReport
11
+
12
+ # Size of the progress bar, in characters
13
+ PROGRESS_BAR_SIZE = 41
14
+
15
+ # Handle tests reports
16
+ def report
17
+ out
18
+ out "========== Error report of #{@tests.size} tests run on #{@tested_nodes.size} nodes"
19
+ out
20
+
21
+ errors = group_errors(global_tests, :test_name, filter: :only_as_non_expected)
22
+ out "======= #{errors.size} unexpected failing global tests:"
23
+ out
24
+ errors.each do |test_name, test_errors|
25
+ out "===== #{test_name} found #{test_errors.size} errors:"
26
+ test_errors.each do |error|
27
+ out " - #{error}"
28
+ end
29
+ out
30
+ end
31
+ out
32
+
33
+ errors = group_errors(platform_tests, :test_name, :platform, filter: :only_as_non_expected)
34
+ out "======= #{errors.size} unexpected failing platform tests:"
35
+ out
36
+ errors.each do |test_name, errors_by_platform|
37
+ out "===== #{test_name} found #{errors_by_platform.size} platforms having errors:"
38
+ errors_by_platform.each do |platform, test_errors|
39
+ out " * [ #{platform.repository_path} ] - #{test_errors.size} errors:"
40
+ test_errors.each do |error|
41
+ out " - #{error}"
42
+ end
43
+ end
44
+ out
45
+ end
46
+ out
47
+
48
+ errors = group_errors(node_tests, :test_name, :node, filter: :only_as_non_expected)
49
+ out "======= #{errors.size} unexpected failing node tests:"
50
+ out
51
+ errors.each do |test_name, errors_by_node|
52
+ out "===== #{test_name} found #{errors_by_node.size} nodes having errors:"
53
+ errors_by_node.each do |node, test_errors|
54
+ out " * [ #{node} ] - #{test_errors.size} errors:"
55
+ test_errors.each do |error|
56
+ out " - #{error}"
57
+ end
58
+ end
59
+ out
60
+ end
61
+ out
62
+
63
+ errors = group_errors(platform_tests, :platform, :test_name, filter: :only_as_non_expected)
64
+ out "======= #{errors.size} unexpected failing platforms:"
65
+ out
66
+ errors.each do |platform, errors_by_test|
67
+ out "===== #{platform.repository_path} has #{errors_by_test.size} failing tests:"
68
+ errors_by_test.each do |test_name, test_errors|
69
+ out " * [ #{test_name} ] - #{test_errors.size} errors:"
70
+ test_errors.each do |error|
71
+ out " - #{error}"
72
+ end
73
+ end
74
+ out
75
+ end
76
+ out
77
+
78
+ errors = group_errors(node_tests, :node, :test_name, filter: :only_as_non_expected)
79
+ out "======= #{errors.size} unexpected failing nodes:"
80
+ out
81
+ errors.each do |node, errors_by_test|
82
+ out "===== #{node} has #{errors_by_test.size} failing tests:"
83
+ errors_by_test.each do |test_name, test_errors|
84
+ out " * [ #{test_name} ] - #{test_errors.size} errors:"
85
+ test_errors.each do |error|
86
+ out " - #{error}"
87
+ end
88
+ end
89
+ out
90
+ end
91
+ out
92
+
93
+ out '========== Stats by nodes list:'
94
+ out
95
+ out(Terminal::Table.new(headings: ['List name', '# nodes', '% tested', '% expected success', '% success', '[Expected] '.yellow.bold + '[Error] '.red.bold + '[Success] '.green.bold + '[Non tested]'.white.bold]) do |table|
96
+ nodes_by_nodes_list.each do |nodes_list, nodes_info|
97
+ table << [
98
+ nodes_list,
99
+ nodes_info[:nodes].size,
100
+ nodes_info[:nodes].empty? ? '' : "#{(nodes_info[:tested_nodes].size*100.0/nodes_info[:nodes].size).to_i} %",
101
+ nodes_info[:tested_nodes].empty? ? '' : "#{((nodes_info[:tested_nodes].size - nodes_info[:tested_nodes_in_error_as_expected].size) * 100.0 / nodes_info[:tested_nodes].size).to_i} %",
102
+ nodes_info[:tested_nodes].empty? ? '' : "#{((nodes_info[:tested_nodes].size - nodes_info[:tested_nodes_in_error].size) * 100.0 / nodes_info[:tested_nodes].size).to_i} %",
103
+ nodes_info[:nodes].empty? ? '' :
104
+ ('=' * ((nodes_info[:tested_nodes_in_error_as_expected].size * PROGRESS_BAR_SIZE.to_f) / nodes_info[:nodes].size).round).yellow.bold +
105
+ ('=' * (((nodes_info[:tested_nodes_in_error].size - nodes_info[:tested_nodes_in_error_as_expected].size).abs * PROGRESS_BAR_SIZE.to_f) / nodes_info[:nodes].size).round).red.bold +
106
+ ('=' * (((nodes_info[:tested_nodes].size - nodes_info[:tested_nodes_in_error].size) * PROGRESS_BAR_SIZE.to_f) / nodes_info[:nodes].size).round).green.bold +
107
+ ('=' * (((nodes_info[:nodes].size - nodes_info[:tested_nodes].size) * PROGRESS_BAR_SIZE.to_f) / nodes_info[:nodes].size).round).white.bold
108
+ ]
109
+ end
110
+ end)
111
+
112
+ end
113
+
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+ end