brpm_content 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +38 -0
  3. data/.travis.yml +14 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +21 -0
  6. data/README.md +308 -0
  7. data/Rakefile +24 -0
  8. data/TO_BE_MIGRATED.txt +8 -0
  9. data/architecture.png +0 -0
  10. data/brpm_content.gemspec +31 -0
  11. data/customers/demo/integrations/brpm/process_event_handler_event.rb +183 -0
  12. data/customers/demo/integrations/jenkins/spec/api/applications_spec.rb +89 -0
  13. data/customers/demo/integrations/jenkins/spec/api/plans_spec.rb +69 -0
  14. data/customers/demo/integrations/jenkins/spec/api/requests_spec.rb +57 -0
  15. data/customers/demo/integrations/jenkins/spec/spec_helper.rb +33 -0
  16. data/customers/demo/integrations/jira/process_webhook_event.rb +33 -0
  17. data/customers/demo/jira_mappings.rb +29 -0
  18. data/infrastructure/integrations/event_handler.rb +62 -0
  19. data/infrastructure/integrations/webhook_receiver.rb +49 -0
  20. data/infrastructure/shell_scripts/backup_database.sh +19 -0
  21. data/infrastructure/shell_scripts/create_bl_package.sh +34 -0
  22. data/infrastructure/shell_scripts/create_release_request.sh +34 -0
  23. data/infrastructure/shell_scripts/ddns.sh +10 -0
  24. data/infrastructure/shell_scripts/install_brpm.sh +63 -0
  25. data/infrastructure/shell_scripts/install_content_module.sh +66 -0
  26. data/infrastructure/shell_scripts/install_content_repo.sh +60 -0
  27. data/infrastructure/shell_scripts/install_module_from_gem.sh +80 -0
  28. data/infrastructure/shell_scripts/maintenance.sh +4 -0
  29. data/infrastructure/shell_scripts/patch_brpm.sh +90 -0
  30. data/infrastructure/shell_scripts/restore_database.sh +33 -0
  31. data/infrastructure/shell_scripts/run_event_handler.cmd +16 -0
  32. data/infrastructure/shell_scripts/run_event_handler.sh +20 -0
  33. data/infrastructure/shell_scripts/run_webhook_receiver.cmd +14 -0
  34. data/infrastructure/shell_scripts/run_webhook_receiver.sh +15 -0
  35. data/infrastructure/shell_scripts/update_content_repo.sh +21 -0
  36. data/infrastructure/silent_install_options_4.6.txt +93 -0
  37. data/infrastructure/silent_install_options_upgrade_4.6.txt +92 -0
  38. data/infrastructure/smtp_settings.rb +42 -0
  39. data/infrastructure/ssh_script_header_additions.rb +21 -0
  40. data/modules/ansible/automations/execute_role.rb +3 -0
  41. data/modules/ansible/automations/execute_role.txt +12 -0
  42. data/modules/ansible/config.yml +5 -0
  43. data/modules/ansible/lib/ansible.rb +41 -0
  44. data/modules/atrium_orchestrator/automations/execute_workflow.rb +12 -0
  45. data/modules/atrium_orchestrator/automations/execute_workflow.txt +25 -0
  46. data/modules/atrium_orchestrator/automations/reserve_ip_address.rb +22 -0
  47. data/modules/atrium_orchestrator/automations/reserve_ip_address.txt +21 -0
  48. data/modules/atrium_orchestrator/config.yml +7 -0
  49. data/modules/atrium_orchestrator/lib/ao_soap_client.rb +94 -0
  50. data/modules/bladelogic/automations/create_package.rb +29 -0
  51. data/modules/bladelogic/automations/create_package.txt +26 -0
  52. data/modules/bladelogic/automations/deploy_package.rb +137 -0
  53. data/modules/bladelogic/automations/deploy_package.txt +53 -0
  54. data/modules/bladelogic/config.yml +7 -0
  55. data/modules/bladelogic/lib/bl_rest/bsa_rest_client.rb +65 -0
  56. data/modules/bladelogic/lib/bl_soap/blpackage.rb +43 -0
  57. data/modules/bladelogic/lib/bl_soap/bsa_soap_base.rb +118 -0
  58. data/modules/bladelogic/lib/bl_soap/bsa_soap_client.rb +34 -0
  59. data/modules/bladelogic/lib/bl_soap/compliance_job.rb +155 -0
  60. data/modules/bladelogic/lib/bl_soap/deploy_job.rb +48 -0
  61. data/modules/bladelogic/lib/bl_soap/depot_group.rb +47 -0
  62. data/modules/bladelogic/lib/bl_soap/job.rb +376 -0
  63. data/modules/bladelogic/lib/bl_soap/job_group.rb +72 -0
  64. data/modules/bladelogic/lib/bl_soap/job_management.rb +22 -0
  65. data/modules/bladelogic/lib/bl_soap/job_result.rb +12 -0
  66. data/modules/bladelogic/lib/bl_soap/job_run.rb +271 -0
  67. data/modules/bladelogic/lib/bl_soap/login.rb +47 -0
  68. data/modules/bladelogic/lib/bl_soap/nsh_script_job.rb +14 -0
  69. data/modules/bladelogic/lib/bl_soap/patch_catalog.rb +178 -0
  70. data/modules/bladelogic/lib/bl_soap/patch_remediation_job.rb +137 -0
  71. data/modules/bladelogic/lib/bl_soap/patching_job.rb +250 -0
  72. data/modules/bladelogic/lib/bl_soap/server.rb +12 -0
  73. data/modules/bladelogic/lib/bl_soap/template.rb +13 -0
  74. data/modules/bladelogic/lib/bl_soap/utility.rb +99 -0
  75. data/modules/bladelogic/resource_automations/select_job.rb +33 -0
  76. data/modules/bladelogic/resource_automations/select_job.txt +15 -0
  77. data/modules/bladelogic/tests/create_package_spec.rb +28 -0
  78. data/modules/bladelogic/tests/deploy_package_spec.rb +23 -0
  79. data/modules/bladelogic/tests/spec_helper.rb +82 -0
  80. data/modules/brpm/automations/create_release_from_excel.rb +34 -0
  81. data/modules/brpm/automations/create_release_from_excel.txt +5 -0
  82. data/modules/brpm/automations/create_release_request.rb +100 -0
  83. data/modules/brpm/automations/create_release_request.txt +5 -0
  84. data/modules/brpm/automations/create_request.rb +73 -0
  85. data/modules/brpm/automations/create_request.txt +23 -0
  86. data/modules/brpm/automations/promote_request.rb +197 -0
  87. data/modules/brpm/automations/promote_request.txt +24 -0
  88. data/modules/brpm/automations/select_application_version.rb +22 -0
  89. data/modules/brpm/automations/select_application_version.txt +17 -0
  90. data/modules/brpm/automations/select_component_version.rb +12 -0
  91. data/modules/brpm/automations/select_component_version.txt +5 -0
  92. data/modules/brpm/automations/select_request_template.rb +6 -0
  93. data/modules/brpm/automations/select_request_template.txt +13 -0
  94. data/modules/brpm/automations/wait_for_step_in_other_request.rb +11 -0
  95. data/modules/brpm/automations/wait_for_step_in_other_request.txt +13 -0
  96. data/modules/brpm/automations/wait_till_promoted_request_is_completed.rb +9 -0
  97. data/modules/brpm/automations/wait_till_promoted_request_is_completed.txt +5 -0
  98. data/modules/brpm/config.yml +6 -0
  99. data/modules/brpm/lib/brpm_request.rb +207 -0
  100. data/modules/brpm/lib/brpm_rest.rb +312 -0
  101. data/modules/brpm/lib/brpm_rest_client.rb +1501 -0
  102. data/modules/brpm/resource_automations/select_application.rb +16 -0
  103. data/modules/brpm/resource_automations/select_application.txt +5 -0
  104. data/modules/brpm/resource_automations/select_environment.rb +14 -0
  105. data/modules/brpm/resource_automations/select_environment.txt +5 -0
  106. data/modules/brpm/resource_automations/select_request_template.rb +16 -0
  107. data/modules/brpm/resource_automations/select_request_template.txt +5 -0
  108. data/modules/brpm/resource_automations/select_step_in_request.rb +33 -0
  109. data/modules/brpm/resource_automations/select_step_in_request.txt +5 -0
  110. data/modules/brpm/sample_applications/e-finance.json +0 -0
  111. data/modules/brpm/tests/create_release_request_spec.rb +66 -0
  112. data/modules/brpm/tests/create_request_spec.rb +84 -0
  113. data/modules/brpm/tests/select_application_version_spec.rb +47 -0
  114. data/modules/brpm/tests/spec_helper.rb +63 -0
  115. data/modules/docker_brpm/automations/create_brpm_instance_input_params.rb +10 -0
  116. data/modules/docker_brpm/automations/create_brpm_instance_input_params.txt +17 -0
  117. data/modules/docker_brpm/automations/create_brpm_instance_one_shot.rb +60 -0
  118. data/modules/docker_brpm/automations/create_brpm_instance_one_shot.txt +14 -0
  119. data/modules/docker_brpm/automations/create_brpm_instance_show_results.rb +23 -0
  120. data/modules/docker_brpm/automations/create_brpm_instance_show_results.txt +13 -0
  121. data/modules/docker_brpm/automations/create_database.rb +24 -0
  122. data/modules/docker_brpm/automations/create_database.txt +3 -0
  123. data/modules/docker_brpm/automations/create_environment.rb +14 -0
  124. data/modules/docker_brpm/automations/create_environment.txt +3 -0
  125. data/modules/docker_brpm/automations/create_image_for_application.rb +23 -0
  126. data/modules/docker_brpm/automations/create_image_for_application.txt +6 -0
  127. data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.rb +7 -0
  128. data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.txt +8 -0
  129. data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.rb +7 -0
  130. data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.txt +8 -0
  131. data/modules/docker_brpm/automations/create_image_for_database_creator.rb +21 -0
  132. data/modules/docker_brpm/automations/create_image_for_database_creator.txt +6 -0
  133. data/modules/docker_brpm/automations/create_installed_component_for_application.rb +11 -0
  134. data/modules/docker_brpm/automations/create_installed_component_for_application.txt +3 -0
  135. data/modules/docker_brpm/automations/create_installed_component_for_database.rb +7 -0
  136. data/modules/docker_brpm/automations/create_installed_component_for_database.txt +3 -0
  137. data/modules/docker_brpm/automations/create_installed_component_for_database_creator.rb +8 -0
  138. data/modules/docker_brpm/automations/create_installed_component_for_database_creator.txt +3 -0
  139. data/modules/docker_brpm/automations/create_installed_component_for_utilities.rb +7 -0
  140. data/modules/docker_brpm/automations/create_installed_component_for_utilities.txt +3 -0
  141. data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.rb +13 -0
  142. data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.txt +6 -0
  143. data/modules/docker_brpm/automations/delete_brpm_instance.rb +38 -0
  144. data/modules/docker_brpm/automations/delete_brpm_instance.txt +8 -0
  145. data/modules/docker_brpm/automations/execute_test_run_in_jenkins.rb +43 -0
  146. data/modules/docker_brpm/automations/execute_test_run_in_jenkins.txt +13 -0
  147. data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.rb +5 -0
  148. data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.txt +9 -0
  149. data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.rb +27 -0
  150. data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.txt +3 -0
  151. data/modules/docker_brpm/automations/launch_test_run_request.rb +30 -0
  152. data/modules/docker_brpm/automations/launch_test_run_request.txt +14 -0
  153. data/modules/docker_brpm/automations/release_brpm_input_params.rb +7 -0
  154. data/modules/docker_brpm/automations/release_brpm_input_params.txt +8 -0
  155. data/modules/docker_brpm/automations/run_application_container.rb +27 -0
  156. data/modules/docker_brpm/automations/run_application_container.txt +3 -0
  157. data/modules/docker_brpm/automations/run_database_container.rb +14 -0
  158. data/modules/docker_brpm/automations/run_database_container.txt +3 -0
  159. data/modules/docker_brpm/automations/stop_application_container.rb +11 -0
  160. data/modules/docker_brpm/automations/stop_application_container.txt +3 -0
  161. data/modules/docker_brpm/automations/stop_database_container.rb +11 -0
  162. data/modules/docker_brpm/automations/stop_database_container.txt +3 -0
  163. data/modules/docker_brpm/automations/test_rest_api.rb +18 -0
  164. data/modules/docker_brpm/automations/test_rest_api.txt +3 -0
  165. data/modules/docker_brpm/automations/upgrade_database.rb +19 -0
  166. data/modules/docker_brpm/automations/upgrade_database.txt +8 -0
  167. data/modules/docker_brpm/config.yml +8 -0
  168. data/modules/docker_brpm/lib/docker.rb +39 -0
  169. data/modules/docker_brpm/lib/git.rb +16 -0
  170. data/modules/docker_brpm/sample_applications/dockerizedbrpm.json +0 -0
  171. data/modules/email/automations/send_notification.rb +48 -0
  172. data/modules/email/automations/send_notification.txt +27 -0
  173. data/modules/email/config.yml +6 -0
  174. data/modules/framework/automations/direct_execute.rb +10 -0
  175. data/modules/framework/automations/direct_execute.txt +16 -0
  176. data/modules/framework/automations/install_module.rb +13 -0
  177. data/modules/framework/automations/install_module.txt +16 -0
  178. data/modules/framework/bin/brpm_install +106 -0
  179. data/modules/framework/bin/event_handler +63 -0
  180. data/modules/framework/bin/webhook_receiver +49 -0
  181. data/modules/framework/brpm_auto.rb +307 -0
  182. data/modules/framework/brpm_framework.rb +88 -0
  183. data/modules/framework/brpm_script_executor.rb +146 -0
  184. data/modules/framework/config.yml +7 -0
  185. data/modules/framework/config/customer_include.rb +26 -0
  186. data/modules/framework/config/server.yml +3 -0
  187. data/modules/framework/customer_include_default.rb +25 -0
  188. data/modules/framework/lib/logging/brpm_logger.rb +39 -0
  189. data/modules/framework/lib/logging/logger_base.rb +36 -0
  190. data/modules/framework/lib/logging/simple_logger.rb +27 -0
  191. data/modules/framework/lib/params/all_params.rb +80 -0
  192. data/modules/framework/lib/params/integration_settings.rb +27 -0
  193. data/modules/framework/lib/params/params.rb +172 -0
  194. data/modules/framework/lib/params/params_base.rb +81 -0
  195. data/modules/framework/lib/params/request_params.rb +38 -0
  196. data/modules/framework/lib/resource_framework.rb +211 -0
  197. data/modules/framework/lib/rest_api.rb +155 -0
  198. data/modules/framework/lib/semaphore.rb +79 -0
  199. data/modules/framework/lib/utilities.rb +317 -0
  200. data/modules/framework/lib/version_control/git.rb +192 -0
  201. data/modules/framework/lib/version_control/svn.rb +221 -0
  202. data/modules/framework/log.html +39 -0
  203. data/modules/framework/tests/all_params_spec.rb +116 -0
  204. data/modules/framework/tests/brpm_auto_spec.rb +84 -0
  205. data/modules/framework/tests/customer_include/config/customer_include.rb +10 -0
  206. data/modules/framework/tests/customer_include/config/server.yml +3 -0
  207. data/modules/framework/tests/customer_include_spec.rb +29 -0
  208. data/modules/framework/tests/local_jirb.rb +15 -0
  209. data/modules/framework/tests/params_spec.rb +172 -0
  210. data/modules/framework/tests/request_params_spec.rb +86 -0
  211. data/modules/framework/tests/server_yaml_spec.rb +19 -0
  212. data/modules/framework/tests/spec_helper.rb +42 -0
  213. data/modules/framework/transport/dispatch_baa.rb +355 -0
  214. data/modules/framework/transport/dispatch_base.rb +345 -0
  215. data/modules/framework/transport/dispatch_nsh.rb +248 -0
  216. data/modules/framework/transport/dispatch_ssh.rb +154 -0
  217. data/modules/framework/transport/transport_baa.rb +1095 -0
  218. data/modules/framework/transport/transport_nsh.rb +359 -0
  219. data/modules/framework/transport/transport_ssh.rb +220 -0
  220. data/modules/framework/write_to.rb +1 -0
  221. data/modules/jenkins/automations/create_release.rb +4 -0
  222. data/modules/jenkins/automations/create_release.txt +23 -0
  223. data/modules/jenkins/automations/f2_downloadJenkinsArtifact.rb +126 -0
  224. data/modules/jenkins/config.yml +7 -0
  225. data/modules/jenkins/lib/jenkins.rb +300 -0
  226. data/modules/jenkins/resource_automations/f2_rsc_jenkinsJobs.rb +58 -0
  227. data/modules/jira/automations/add_comment.rb +4 -0
  228. data/modules/jira/automations/add_comment.txt +23 -0
  229. data/modules/jira/automations/create_release.rb +4 -0
  230. data/modules/jira/automations/create_release.txt +23 -0
  231. data/modules/jira/automations/delete_release.rb +4 -0
  232. data/modules/jira/automations/delete_release.txt +23 -0
  233. data/modules/jira/automations/transition_issue.rb +4 -0
  234. data/modules/jira/automations/transition_issue.txt +23 -0
  235. data/modules/jira/automations/transition_issues_for_request.rb +29 -0
  236. data/modules/jira/automations/transition_issues_for_request.txt +20 -0
  237. data/modules/jira/automations/transition_issues_for_run.rb +26 -0
  238. data/modules/jira/automations/transition_issues_for_run.txt +20 -0
  239. data/modules/jira/automations/update_release.rb +4 -0
  240. data/modules/jira/automations/update_release.txt +26 -0
  241. data/modules/jira/config.yml +7 -0
  242. data/modules/jira/lib/jira_rest_client.rb +185 -0
  243. data/modules/jira/tests/create_read_update_delete_release_spec.rb +39 -0
  244. data/modules/jira/tests/spec_helper.rb +39 -0
  245. data/modules/jira/tests/transition_issue_spec.rb +32 -0
  246. data/modules/patch_process_management/automations/execute_job/script.rb +105 -0
  247. data/modules/patch_process_management/automations/execute_job/wrapper.txt +39 -0
  248. data/modules/patch_process_management/automations/patch_analysis/script.rb +107 -0
  249. data/modules/patch_process_management/automations/patch_analysis/wrapper.txt +33 -0
  250. data/modules/patch_process_management/automations/patch_readiness/script.rb +89 -0
  251. data/modules/patch_process_management/automations/patch_readiness/wrapper.txt +33 -0
  252. data/modules/patch_process_management/automations/patch_remediation/script.rb +217 -0
  253. data/modules/patch_process_management/automations/patch_remediation/wrapper.txt +40 -0
  254. data/modules/patch_process_management/config.yml +10 -0
  255. data/modules/teamcity/automations/trigger_build.rb +4 -0
  256. data/modules/teamcity/automations/trigger_build.txt +14 -0
  257. data/modules/teamcity/config.yml +7 -0
  258. data/modules/teamcity/lib/teamcity_rest_client.rb +17 -0
  259. data/modules/teamcity/tests/spec_helper.rb +34 -0
  260. data/modules/teamcity/tests/trigger_build_spec.rb +27 -0
  261. data/modules/windows/automations/deploy_directory_over_windows_shares/script.rb +87 -0
  262. data/modules/windows/automations/deploy_directory_over_windows_shares/wrapper.txt +29 -0
  263. data/modules/windows/automations/deploy_file_over_windows_shares/script.rb +31 -0
  264. data/modules/windows/automations/deploy_file_over_windows_shares/wrapper.txt +24 -0
  265. data/modules/windows/config.yml +6 -0
  266. data/modules/windows/lib/samba.rb +29 -0
  267. metadata +397 -0
@@ -0,0 +1,146 @@
1
+ require_relative "brpm_auto"
2
+
3
+ class BrpmScriptExecutor
4
+ class << self
5
+ def execute_automation_script(modul, name, params)
6
+ begin
7
+ BrpmAuto.setup(params)
8
+
9
+ BrpmAuto.log ""
10
+ BrpmAuto.log ">>>>>>>>>>>>>> START automation #{name}"
11
+ start_time = Time.now
12
+
13
+ BrpmAuto.log "Loading the module and its dependencies..."
14
+ module_path = BrpmAuto.require_module(modul)
15
+ BrpmAuto.log "Finished loading the module."
16
+
17
+ automation_script_path = "#{module_path}/automations/#{name}.rb"
18
+
19
+ BrpmAuto.log "Loading the automation script #{automation_script_path}..."
20
+ load automation_script_path
21
+
22
+ rescue Exception => e
23
+ BrpmAuto.log_error "#{e}"
24
+ BrpmAuto.log e.backtrace.join("\n\t")
25
+
26
+ raise e
27
+ ensure
28
+ stop_time = Time.now
29
+ duration = 0
30
+ duration = stop_time - start_time unless start_time.nil?
31
+
32
+ BrpmAuto.log ">>>>>>>>>>>>>> STOP automation #{name} - total duration: #{Time.at(duration).utc.strftime("%H:%M:%S")}"
33
+ BrpmAuto.log ""
34
+
35
+ #load "#{File.dirname(__FILE__)}/write_to.rb" if BrpmAuto.params.run_from_brpm
36
+ end
37
+ end
38
+
39
+ def execute_resource_automation_script(modul, name, params, parent_id, offset, max_records)
40
+ begin
41
+ BrpmAuto.setup(params)
42
+
43
+ BrpmAuto.log ""
44
+ BrpmAuto.log ">>>>>>>>>>>>>> START resource automation #{name}"
45
+ start_time = Time.now
46
+
47
+ BrpmAuto.log "Loading the module and its dependencies..."
48
+ module_path = BrpmAuto.require_module(modul)
49
+ BrpmAuto.log "Finished loading the module."
50
+
51
+ automation_script_path = "#{module_path}/resource_automations/#{name}.rb"
52
+
53
+ BrpmAuto.log "Loading the resource automation script #{automation_script_path}..."
54
+ result = load automation_script_path
55
+
56
+ BrpmAuto.log "Calling execute_resource_automation_script(params, parent_id, offset, max_records)..."
57
+ execute_script(params, parent_id, offset, max_records)
58
+
59
+ rescue Exception => e
60
+ BrpmAuto.log_error "#{e}"
61
+ BrpmAuto.log e.backtrace.join("\n\t")
62
+
63
+ raise e
64
+ ensure
65
+ stop_time = Time.now
66
+ duration = stop_time - start_time
67
+
68
+ BrpmAuto.log ">>>>>>>>>>>>>> STOP resource automation #{name} - total duration: #{Time.at(duration).utc.strftime("%H:%M:%S")}"
69
+ BrpmAuto.log ""
70
+
71
+ #load "#{File.dirname(__FILE__)}/write_to.rb" if BrpmAuto.params.run_from_brpm
72
+ end
73
+ end
74
+
75
+ def execute_automation_script_from_gem(modul, name, params)
76
+ begin
77
+ BrpmAuto.setup(params)
78
+
79
+ BrpmAuto.log ""
80
+ BrpmAuto.log ">>>>>>>>>>>>>> START automation #{name}"
81
+ start_time = Time.now
82
+
83
+ BrpmAuto.log "Loading the module and its dependencies..."
84
+ module_path = BrpmAuto.require_module_from_gem(modul)
85
+ BrpmAuto.log "Finished loading the module."
86
+
87
+ automation_script_path = "#{module_path}/automations/#{name}.rb"
88
+
89
+ BrpmAuto.log "Loading the automation script #{automation_script_path}..."
90
+ load automation_script_path
91
+
92
+ rescue Exception => e
93
+ BrpmAuto.log_error "#{e}"
94
+ BrpmAuto.log e.backtrace.join("\n\t")
95
+
96
+ raise e
97
+ ensure
98
+ stop_time = Time.now
99
+ duration = 0
100
+ duration = stop_time - start_time unless start_time.nil?
101
+
102
+ BrpmAuto.log ">>>>>>>>>>>>>> STOP automation #{name} - total duration: #{Time.at(duration).utc.strftime("%H:%M:%S")}"
103
+ BrpmAuto.log ""
104
+
105
+ #load "#{File.dirname(__FILE__)}/write_to.rb" if BrpmAuto.params.run_from_brpm
106
+ end
107
+ end
108
+
109
+ def execute_resource_automation_script_from_gem(modul, name, params, parent_id, offset, max_records)
110
+ begin
111
+ BrpmAuto.setup(params)
112
+
113
+ BrpmAuto.log ""
114
+ BrpmAuto.log ">>>>>>>>>>>>>> START resource automation #{name}"
115
+ start_time = Time.now
116
+
117
+ BrpmAuto.log "Loading the module and its dependencies..."
118
+ module_path = BrpmAuto.require_module_from_gem(modul)
119
+ BrpmAuto.log "Finished loading the module."
120
+
121
+ automation_script_path = "#{module_path}/resource_automations/#{name}.rb"
122
+
123
+ BrpmAuto.log "Loading the resource automation script #{automation_script_path}..."
124
+ result = load automation_script_path
125
+
126
+ BrpmAuto.log "Calling execute_resource_automation_script(params, parent_id, offset, max_records)..."
127
+ execute_script(params, parent_id, offset, max_records)
128
+
129
+ rescue Exception => e
130
+ BrpmAuto.log_error "#{e}"
131
+ BrpmAuto.log e.backtrace.join("\n\t")
132
+
133
+ raise e
134
+ ensure
135
+ stop_time = Time.now
136
+ duration = stop_time - start_time
137
+
138
+ BrpmAuto.log ">>>>>>>>>>>>>> STOP resource automation #{name} - total duration: #{Time.at(duration).utc.strftime("%H:%M:%S")}"
139
+ BrpmAuto.log ""
140
+
141
+ #load "#{File.dirname(__FILE__)}/write_to.rb" if BrpmAuto.params.run_from_brpm
142
+ end
143
+ end
144
+ end
145
+ end
146
+
@@ -0,0 +1,7 @@
1
+ version: 0.1.16
2
+
3
+ author: Niek Bartholomeus
4
+ email: niek.bartholomeus@gmail.com
5
+ homepage: https://github.com/BMC-RLM/brpm_content
6
+ summary: BRPM Content Framework
7
+ description: The BRPM Content Framework is a lightweight framework that allows to run automation logic on top of BRPM in a modular, re-usable, testable and developer-friendly way
@@ -0,0 +1,26 @@
1
+ # This file should be located in BRPM_HOME/config
2
+ # See the README for more information on how to use this file
3
+
4
+ def get_customer_include_params
5
+ params = {}
6
+ # Hostname so nsh paths can be constructed from local paths
7
+ params["BAA_RPM_HOSTNAME"] = "localhost"
8
+ # set your own automation token
9
+ params["Token"] = "???"
10
+ # Hostname so nsh paths can be constructed from local paths
11
+ params["BAA_RPM_HOSTNAME"] = "localhost"
12
+ # Change this to set BAA base path
13
+ params["BAA_BASE_PATH"] = "/opt/bmc/bladelogic"
14
+ # This is the root path for use in BAA/BSA
15
+ params["BAA_BASE_GROUP"] = "BRPM"
16
+ # The location and name of the standard NSH script for script execution
17
+ params["BAA_FRAMEWORK_NSH_SCRIPT"] = "/BRPM/NSHScripts/FrameworkScriptExecute"
18
+ # Place your own global constants
19
+ params["DATA_CENTER_NAMES"] = ["HOU", "LEX", "PUNE"]
20
+
21
+ params
22
+ end
23
+
24
+ def my_custom_method(a, b)
25
+ a + b
26
+ end
@@ -0,0 +1,3 @@
1
+ # This file should be located in BRPM_HOME/config
2
+ # See the README for more information on how to use this file
3
+ my_parameter: "abc"
@@ -0,0 +1,25 @@
1
+ # = BRPM Automation Framework
2
+ # == Customer Include Automation
3
+ # BMC Software - BJB 9/16/2014
4
+ # ===== Use this routine to override and provide global methods for all your automation
5
+
6
+ # set your own automation token
7
+ Token = "a56d64cbcffcce91d306670489fa4cf51b53316c" #"<YOUR_AUTOMATION_TOKEN>" #decrypt_string_with_prefix(@params["SS_api_token"])
8
+ # Hostname so nsh paths can be constructed from local paths
9
+ BAA_RPM_HOSTNAME = "localhost"
10
+ # Change this to set BAA base path
11
+ BAA_BASE_PATH = "/opt/bmc/bladelogic"
12
+ # This is the root path for use in BAA/BSA
13
+ BAA_BASE_GROUP = "BRPM"
14
+ # The location and name of the standard NSH script for script execution
15
+ BAA_FRAMEWORK_NSH_SCRIPT = "/BRPM/NSHScripts/FrameworkScriptExecute"
16
+ # This path will get any files staged by the framework
17
+ RPM_STAGING_PATH = "/opt/bmc/staging"
18
+ # This defines a path for a library of automations (from Git or Svn for instance)
19
+ ACTION_LIBRARY_PATH = "/opt/bmc/RLM/persist/script_library"
20
+ # Custom Lib/Module directory (to add customer content to framework)
21
+ CUSTOMER_LIB_DIR = "/opt/bmc/RLM/persist/brpm_lib"
22
+ # Place your own global constants
23
+ DATA_CENTER_NAMES = ["HOU", "LEX", "PUNE"]
24
+
25
+
@@ -0,0 +1,39 @@
1
+ require_relative "logger_base"
2
+
3
+ class BrpmLogger < LoggerBase
4
+ attr_reader :request_log_file_path
5
+ attr_reader :step_run_log_file_path
6
+
7
+ def initialize
8
+ @step_number = BrpmAuto.params.step_number
9
+ @step_name = BrpmAuto.params.step_name
10
+
11
+ @request_log_file_path = "#{BrpmAuto.params.automation_results_dir}/#{BrpmAuto.params.request_id}.log"
12
+
13
+ # @step_run_log_file_path = "#{BrpmAuto.params.automation_results_dir}/#{BrpmAuto.params.request_id}_#{BrpmAuto.params.step_id}_#{BrpmAuto.params.run_key}.log"
14
+ @step_run_log_file_path = BrpmAuto.params.output_file
15
+
16
+ print "Logging to #{@step_run_log_file_path} and #{@request_log_file_path}\n" unless BrpmAuto.params.also_log_to_console
17
+ end
18
+
19
+ def log(message)
20
+ message = message.to_s # in case booleans or whatever are passed
21
+ timestamp = "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
22
+ log_message = ""
23
+
24
+ prefix = "#{timestamp}|#{'%2.2s' % @step_number}|#{'%-20.20s' % @step_name}|"
25
+ message.gsub!("\n", "\n" + (" " * prefix.length))
26
+
27
+ log_message = "#{prefix}#{message}\n"
28
+
29
+ File.open(@request_log_file_path, "a") do |log_file|
30
+ log_file.print(log_message)
31
+ end
32
+
33
+ File.open(@step_run_log_file_path, "a") do |log_file|
34
+ log_file.print(log_message)
35
+ end
36
+
37
+ print(log_message) if BrpmAuto.params.also_log_to_console
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ class LoggerBase
2
+ # Provides a pretty box for titles
3
+ #
4
+ # ==== Attributes
5
+ #
6
+ # * +msg+ - the text to output
7
+ # * +mtype+ - box type to display sep: a separator line, title a box around the message
8
+ def message_box(msg, mtype = "sep")
9
+ return "" if msg.nil? || msg.length < 1
10
+ tot = 72
11
+ msg = msg[0..64] if msg.length > 65
12
+
13
+ ilen = tot - msg.length
14
+
15
+ if mtype == "sep"
16
+ start = "##{"-" * (ilen/2).to_i} #{msg} "
17
+ res = "#{start}#{"-" * (tot- start.length + 1)}#"
18
+ else
19
+ res = "##{"-" * tot}#\n"
20
+ start = "##{" " * (ilen/2).to_i} #{msg} "
21
+ res += "#{start}#{" " * (tot- start.length + 1)}#\n"
22
+ res += "##{"-" * tot}#\n"
23
+ end
24
+
25
+ log(res)
26
+ end
27
+
28
+ def log_error(message)
29
+ log ""
30
+ log "******** ERROR ********"
31
+ log "An error has occurred"
32
+ log "#{message}"
33
+ log "***********************"
34
+ log ""
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "logger_base"
2
+
3
+ class SimpleLogger < LoggerBase
4
+ def initialize(log_file, also_log_to_console = false)
5
+ @log_file = log_file
6
+ @also_log_to_console = also_log_to_console
7
+
8
+ print "Logging to #{@log_file}\n" unless also_log_to_console
9
+ end
10
+
11
+ def log(message)
12
+ message = message.to_s # in case booleans or whatever are passed
13
+ timestamp = "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
14
+ log_message = ""
15
+
16
+ prefix = "#{timestamp}|"
17
+ message.gsub!("\n", "\n" + (" " * prefix.length))
18
+
19
+ log_message = "#{prefix}#{message}\n"
20
+
21
+ File.open(@log_file, "a") do |log_file|
22
+ log_file.print(log_message)
23
+ end
24
+
25
+ print(log_message) if @also_log_to_console
26
+ end
27
+ end
@@ -0,0 +1,80 @@
1
+ class AllParams < ParamsBase
2
+ def initialize(params, request_params)
3
+ @params = params
4
+ @request_params = request_params
5
+
6
+ # this class acts as a virtual hash on top of two real hashes for all write-related methods (which need to be overriden)
7
+ # the values from both hashes are also synchronized in this class to avoid having to override all read-related methods
8
+ self.merge!(@params)
9
+ self.merge!(@request_params)
10
+ end
11
+
12
+ alias :super_add :[]=
13
+
14
+ def []=(key,val)
15
+ raise RuntimeError.new("This is a virtual hash based on two physical hashes, use the add method instead.")
16
+ end
17
+
18
+ #TODO: refactor out the where functionality
19
+ # Test if a param is present
20
+ #
21
+ # ==== Attributes
22
+ #
23
+ # * +key_name+ - key to look for
24
+ # * +where+ - if true returns the hash where the key was found
25
+ #
26
+ # ==== Returns
27
+ #
28
+ # * the param hash name if where=true, otherwise true/false
29
+ def present?(key_name, where = false)
30
+ ans = nil
31
+ ans = "params" if @params.has_key?(key_name)
32
+ ans = "json" if @request_params.has_key?(key_name)
33
+ where ? ans : !ans.nil?
34
+ end
35
+
36
+ def present_json?(key_name)
37
+ @request_params.has_key?(key_name)
38
+ end
39
+
40
+ def present_local?(key_name)
41
+ @params.has_key?(key_name)
42
+ end
43
+
44
+ # Adds a key/value to the params
45
+ #
46
+ # ==== Attributes
47
+ #
48
+ # * +key_name+ - key name
49
+ # * +value+ - value to assign
50
+ # * +store+ - place to add params or json (default = params)
51
+ #
52
+ # ==== Returns
53
+ #
54
+ # * value added
55
+ def add(key, value, store = "params")
56
+ if store == "params"
57
+ @params[key] = value
58
+ elsif store == "json"
59
+ @request_params[key] = value
60
+ end
61
+ super_add(key, value)
62
+ end
63
+
64
+ # Adds a key/value to the params if not found
65
+ #
66
+ # ==== Attributes
67
+ #
68
+ # * +key_name+ - key name
69
+ # * +value+ - value to assign
70
+ # * +store+ - place to add params or json (default = params)
71
+ #
72
+ # ==== Returns
73
+ #
74
+ # * value of key
75
+ def find_or_add(key_name, value, store = "params")
76
+ ans = get(key_name)
77
+ add(key_name, value, store) if ans == ""
78
+ ans == "" ? value : ans
79
+ end
80
+ end
@@ -0,0 +1,27 @@
1
+ class IntegrationSettings
2
+ attr_reader :project_server
3
+ attr_reader :project_server_id
4
+ attr_reader :dns
5
+ attr_reader :username
6
+ attr_reader :password
7
+ attr_reader :details
8
+
9
+ def initialize(dns, username, password, details = nil, project_server = nil, project_server_id = nil)
10
+ @dns = dns
11
+ @username = username
12
+ @password = password
13
+ @details = details
14
+ @project_server = project_server
15
+ @project_server_id = project_server_id
16
+ end
17
+
18
+ def to_params
19
+ params = {}
20
+ params["SS_integration_dns"] = @dns
21
+ params["SS_integration_username"] = @username
22
+ params["SS_integration_password"] = @password
23
+ params["SS_integration_details"] = @details
24
+
25
+ params
26
+ end
27
+ end
@@ -0,0 +1,172 @@
1
+ class Params < ParamsBase
2
+ attr_reader :application
3
+ attr_reader :component
4
+ attr_reader :component_version
5
+
6
+ attr_reader :request_id
7
+ attr_reader :request_name
8
+ attr_reader :request_number
9
+ attr_reader :request_environment
10
+ attr_reader :request_scheduled_at
11
+ attr_reader :request_started_at
12
+ attr_reader :request_status
13
+
14
+ attr_reader :request_plan
15
+ attr_reader :request_plan_id
16
+ attr_reader :request_plan_member_id
17
+ attr_reader :request_plan_stage
18
+
19
+ attr_reader :request_run_id
20
+ attr_reader :request_run_name
21
+
22
+ attr_reader :step_id
23
+ attr_reader :step_number
24
+ attr_reader :step_name
25
+ attr_reader :step_description
26
+ attr_reader :step_estimate
27
+
28
+ attr_reader :step_version
29
+ attr_reader :step_version_artifact_url
30
+
31
+ attr_reader :servers
32
+
33
+ attr_reader :ticket_ids
34
+ attr_reader :tickets_foreign_ids
35
+
36
+ attr_reader :run_key
37
+
38
+ attr_reader :home_dir
39
+ attr_reader :automation_results_dir
40
+ attr_reader :output_dir
41
+ attr_reader :output_file
42
+ attr_reader :config_dir
43
+
44
+ attr_reader :log_file
45
+
46
+ attr_reader :brpm_url
47
+ attr_reader :brpm_api_token
48
+
49
+ attr_reader :run_from_brpm
50
+ attr_reader :also_log_to_console
51
+
52
+ attr_reader :private_params
53
+
54
+ def initialize(params)
55
+ self.merge!(params)
56
+
57
+ @application = params["application"]
58
+ @component = params["component"]
59
+ @component_version = params["component_version"]
60
+
61
+ @request_id = params["request_id"]
62
+ @request_name = params["request_name"]
63
+ @request_number = params["request_number"]
64
+ @request_environment = params["request_environment"]
65
+ @request_scheduled_at = params["request_scheduled_at"]
66
+ @request_started_at = params["request_started_at"]
67
+ @request_status = params["request_status"]
68
+
69
+ @request_plan = params["request_plan"]
70
+ @request_plan_id = params["request_plan_id"]
71
+ @request_plan_member_id = params["request_plan_member_id"]
72
+ @request_plan_stage = params["request_plan_stage"]
73
+
74
+ @request_run_id = params["request_run_id"]
75
+ @request_run_name = params["request_run_name"]
76
+
77
+ @step_id = params["step_id"]
78
+ @step_number = params["step_number"]
79
+ @step_name = params["step_name"]
80
+ @step_description = params["step_description"]
81
+ @step_estimate = params["step_estimate"]
82
+
83
+ @step_version = params["step_version"]
84
+ @step_version_artifact_url = params["step_version_artifact_url"]
85
+
86
+ @servers = get_server_list
87
+
88
+ @ticket_ids = params["ticket_ids"]
89
+ @tickets_foreign_ids = params["tickets_foreign_ids"]
90
+
91
+ @run_key = params["SS_run_key"] || params["run_key"]
92
+
93
+ if params["SS_automation_results_dir"]
94
+ @home_dir = params["SS_automation_results_dir"].sub("automation_results", "")
95
+ else
96
+ @home_dir = params["home_dir"] || Dir.pwd
97
+ end
98
+ @automation_results_dir = params["SS_automation_results_dir"]
99
+ @output_dir = params["SS_output_dir"] || params["output_dir"] || Dir.pwd
100
+ @output_file = params["SS_output_file"]
101
+ @config_dir = "#{@home_dir}/config"
102
+
103
+ @log_file = params["log_file"] || "#{@output_dir}/brpm_auto.log"
104
+
105
+ @brpm_url = params["SS_base_url"] || params["brpm_url"]
106
+ @brpm_api_token = params["SS_api_token"] || params["brpm_api_token"]
107
+
108
+ @run_from_brpm = (@run_key != nil)
109
+ @also_log_to_console = (params["also_log_to_console"] == "true" || params["also_log_to_console"] == 'true')
110
+
111
+ @private_params = {}
112
+ if self.run_from_brpm
113
+ params.each do |k,v|
114
+ if k.end_with?("_encrypt") || k.end_with?("_enc")
115
+ if k.end_with?("_encrypt")
116
+ key_decrypted = k.gsub("_encrypt","")
117
+ elsif k.end_with?("_enc")
118
+ key_decrypted = k.gsub("_enc","")
119
+ end
120
+ value_decrypted = decrypt_string_with_prefix(v)
121
+ @private_params[key_decrypted] = value_decrypted
122
+ end
123
+ end
124
+ end
125
+ self.merge!(@private_params)
126
+ end
127
+
128
+ # Servers in params need to be filtered by OS
129
+ def get_servers_by_os_platform(os_platform, alt_servers = nil)
130
+ servers = alt_servers || @servers
131
+ result = servers.select{|k,v| v["os_platform"].downcase =~ /#{os_platform}/ }
132
+ end
133
+
134
+ # Fetches the property value for a server
135
+ #
136
+ # ==== Returns
137
+ #
138
+ # * property value
139
+ def get_server_property(server, property)
140
+ ans = ""
141
+ ans = @servers[server][property] if @servers.has_key?(server) && @servers[server].has_key?(property)
142
+ ans
143
+ end
144
+
145
+ # Returns the request id for use in rest calls
146
+ #
147
+ def rest_request_id
148
+ (self["request_id"].to_i - 1000).to_s
149
+ end
150
+
151
+ private
152
+
153
+ def get_server_list()
154
+ rxp = /server\d+_/
155
+ slist = {}
156
+ lastcur = -1
157
+ curname = ""
158
+
159
+ self.sort.reject{ |k| k[0].scan(rxp).empty? }.each_with_index do |server, idx|
160
+ cur = (server[0].scan(rxp)[0].gsub("server","").to_i * 0.001).round * 1000
161
+ if cur == lastcur
162
+ prop = server[0].gsub(rxp, "")
163
+ slist[curname][prop] = server[1]
164
+ else # new server
165
+ lastcur = cur
166
+ curname = server[1].chomp("0")
167
+ slist[curname] = {}
168
+ end
169
+ end
170
+ return slist
171
+ end
172
+ end