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,24 @@
1
+ ###
2
+ # request_template:
3
+ # name: request_template
4
+ # required: no
5
+ # source_stage:
6
+ # name: source_stage
7
+ # required: yes
8
+ # target_stage:
9
+ # name: target_stage
10
+ # required: yes
11
+ # target_env:
12
+ # name: target_env
13
+ # required: yes
14
+ # execute_target_request:
15
+ # name: execute_target_request
16
+ # required: yes
17
+ # type: in-list-single
18
+ # list_pairs: true,Yes|false,No
19
+ ###
20
+ params["direct_execute"] = "true"
21
+
22
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
23
+
24
+ BrpmScriptExecutor.execute_automation_script("brpm", "promote_request", params)
@@ -0,0 +1,22 @@
1
+ brpm_rest_client = BrpmRestClient.new
2
+
3
+ if BrpmAuto.request_params["auto_created"]
4
+ BrpmAuto.log "The request was created in an automated way, not overriding the request params from the manual input step."
5
+ application_version = BrpmAuto.request_params["application_version"]
6
+ else
7
+ BrpmAuto.log "Storing the input parameters ..."
8
+ BrpmAuto.request_params["application_version"] = BrpmAuto.params["application_version"]
9
+
10
+ application_version = BrpmAuto.params["application_version"]
11
+ end
12
+
13
+ BrpmAuto.log "Creating version tags for all components..."
14
+ application = brpm_rest_client.get_app_by_name(BrpmAuto.params["application"])
15
+
16
+ application["components"].each do |component|
17
+ application["environments"].each do |environment|
18
+ brpm_rest_client.create_version_tag(application["name"], component["name"], environment["name"], application_version)
19
+ end
20
+ end
21
+
22
+
@@ -0,0 +1,17 @@
1
+ ###
2
+ # application_id:
3
+ # name: Application
4
+ # position: A1:C1
5
+ # type: in-external-single-select
6
+ # external_resource: select_application
7
+ # required: yes
8
+ # application_version:
9
+ # name: Version
10
+ # position: A2:B2
11
+ # required: yes
12
+ ###
13
+ params["direct_execute"] = "true"
14
+
15
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
16
+
17
+ BrpmScriptExecutor.execute_automation_script("brpm", "select_application_version", params)
@@ -0,0 +1,12 @@
1
+ if BrpmAuto.request_params["auto_created"]
2
+ BrpmAuto.log "The request was created in an automated way, not overriding the request params from the manual input step."
3
+ else
4
+ params = BrpmAuto.params
5
+ component_versions = BrpmAuto.request_params["component_versions"] || {}
6
+
7
+ BrpmAuto.log "Adding component version '#{params["component"]}' '#{params["component_version"]}' to the request_params..."
8
+ component_versions[params["component"]] = params["component_version"]
9
+
10
+ BrpmAuto.request_params["component_versions"] = component_versions
11
+ end
12
+
@@ -0,0 +1,5 @@
1
+ params["direct_execute"] = "true"
2
+
3
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
4
+
5
+ BrpmScriptExecutor.execute_automation_script("brpm", "select_component_version", params)
@@ -0,0 +1,6 @@
1
+ params = BrpmAuto.params
2
+ request_params = BrpmAuto.request_params
3
+
4
+ BrpmAuto.log "Adding request template '#{params["request_template_id"]}' to the request_params..."
5
+ request_params["request_template_id"] = params["request_template_id"]
6
+
@@ -0,0 +1,13 @@
1
+ ###
2
+ # request_template_id:
3
+ # name: Request template
4
+ # position: A1:C1
5
+ # type: in-external-single-select
6
+ # external_resource: select_request_template
7
+ # required: yes
8
+ ###
9
+ params["direct_execute"] = "true"
10
+
11
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
12
+
13
+ BrpmScriptExecutor.execute_automation_script("brpm", "select_request_template", params)
@@ -0,0 +1,11 @@
1
+ brpm_rest_client = BrpmRestClient.new
2
+ params = BrpmAuto.params
3
+
4
+ req_step = params["other_request_step"].split("|")
5
+ request_id = req_step[0].to_i
6
+ step_id = req_step[1].to_i
7
+
8
+ BrpmAuto.log "Monitoring step #{step_id} of request #{request_id} ..."
9
+ brpm_rest_client.monitor_request(request_id, { :monitor_step_id => step_id })
10
+
11
+
@@ -0,0 +1,13 @@
1
+ ###
2
+ # other_request_step:
3
+ # name: other_request_step
4
+ # position: A1:F10
5
+ # type: in-external-single-select
6
+ # external_resource: select_step_in_request
7
+ # required: yes
8
+ ###
9
+ params["direct_execute"] = "true"
10
+
11
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
12
+
13
+ BrpmScriptExecutor.execute_automation_script("brpm", "wait_for_step_in_other_request", params)
@@ -0,0 +1,9 @@
1
+ brpm_rest_client = BrpmRestClient.new
2
+ request_params = BrpmAuto.request_params
3
+
4
+ BrpmAuto.log "Getting the request ..."
5
+ request = brpm_rest_client.get_request_by_id(request_params["promoted_request_id"])
6
+
7
+ BrpmAuto.log "Waiting until the request has finished ..."
8
+ brpm_rest_client.monitor_request(request["id"], { :max_time => 60 * 24})
9
+
@@ -0,0 +1,5 @@
1
+ params["direct_execute"] = "true"
2
+
3
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
4
+
5
+ BrpmScriptExecutor.execute_automation_script("brpm", "wait_till_promoted_request_is_completed", params)
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+
3
+ integration_servers:
4
+ - BRPM
5
+
6
+ version: 1.0.0
@@ -0,0 +1,207 @@
1
+ # Class for interacting with requests
2
+ class BrpmRequest < BrpmRest
3
+
4
+ # Initializes an instance of the class
5
+ #
6
+ # ==== Attributes
7
+ #
8
+ # * +id+ - id of the request to work with
9
+ # * +base_url+ - url of brpm server
10
+ # * +options+ - hash of options (see Rest.rest_call for description)
11
+ #
12
+ def initialize(id, base_url, options = {}, compat_options = {})
13
+ if options.has_key?("SS_output_dir")
14
+ BrpmAuto.log "Load for this class has changed, no longer necessary to send params as 2nd argument"
15
+ options = compat_options
16
+ end
17
+ @id = id
18
+ response = BrpmAuto.get("requests", @id)
19
+ @request = response["data"]
20
+ end
21
+
22
+ # Gets a list of requests based on a filter
23
+ #
24
+ # ==== Attributes
25
+ #
26
+ # * +filter_param+ - filter for requests there are extensive filter options
27
+ # ex: filters["planned_end_date"]>2013-04-22
28
+ #
29
+ # ==== Returns
30
+ #
31
+ # * array of request hashs
32
+ def get_list(filter_param)
33
+ response = Rest.rest_call(rest_url("requests", @id, filter_param), "get")
34
+ @request = response["data"]
35
+ end
36
+
37
+ # Returns the steps for the request
38
+ #
39
+ # ==== Returns
40
+ #
41
+ # * hash of steps from request
42
+ def steps
43
+ steps = @request["steps"]
44
+ end
45
+
46
+ # Updates the aasm state of the request
47
+ #
48
+ # ==== Attributes
49
+ #
50
+ # * +aasm_event+ - event name [plan, start, problem, resolve]
51
+ #
52
+ # ==== Returns
53
+ #
54
+ # * hash of uppdated request
55
+ def update_state(aasm_event)
56
+ request_info = {"request" => {"aasm_event" => aasm_event }}
57
+ result = update("requests", @id, request_info)
58
+ end
59
+
60
+ # Provides a host status for the passed targets
61
+ #
62
+ # ==== Returns
63
+ #
64
+ # * hash of request
65
+ def request
66
+ @request
67
+ end
68
+
69
+ # Gets the app associated with the request
70
+ #
71
+ # ==== Returns
72
+ #
73
+ # * hash of app information
74
+ def app
75
+ @request["apps"].first
76
+ end
77
+
78
+ # Gets the installed_components associated with request application
79
+ #
80
+ # ==== Returns
81
+ #
82
+ # * hash of installed_components
83
+ def installed_components
84
+ return @installed_components if defined?(@installed_components)
85
+ res = get("installed_components", nil, {"filters" => "filters[app_name]=#{url_encode(app["name"])}"})
86
+ @installed_components = res["data"]
87
+ end
88
+
89
+ # Gets the components associated with request application
90
+ #
91
+ # ==== Returns
92
+ #
93
+ # * hash of components
94
+ def app_components
95
+ installed_components unless defined?(@installed_components)
96
+ @installed_components.map{|l| l["application_component"]["component"]}.uniq
97
+ end
98
+
99
+ # Gets the components associated with request application
100
+ #
101
+ # ==== Returns
102
+ #
103
+ # * hash of components
104
+ def app_environments
105
+ installed_components unless defined?(@installed_components)
106
+ @installed_components.map{|l| l["application_environment"]["environment"]}.uniq
107
+ end
108
+
109
+ # Gets the owner of the request
110
+ #
111
+ # ==== Returns
112
+ #
113
+ # * username of request owner
114
+ def owner
115
+ request["owner"]
116
+ end
117
+
118
+ # Gets the requestor of the request
119
+ #
120
+ # ==== Returns
121
+ #
122
+ # * username of requestor
123
+ def requestor
124
+ request["requestor"]
125
+ end
126
+
127
+ # Gets the plan of the request
128
+ #
129
+ # ==== Returns
130
+ #
131
+ # * hash of plan or nil if not part of a plan
132
+ def plan
133
+ return nil if request["plan_member"].nil?
134
+ plan_id = request["plan_member"]["plan"]["id"]
135
+ res = get("plans", plan_id)
136
+ end
137
+
138
+ # Gets the stage of the plan the request is in
139
+ #
140
+ # ==== Returns
141
+ #
142
+ # * hash of stage
143
+ def stage
144
+ return nil if request["plan_member"].nil?
145
+ request["plan_member"]["stage"]
146
+ end
147
+
148
+ # Gets the routes available for the app/plan
149
+ #
150
+ # ==== Returns
151
+ #
152
+ # * array of hashes of plan routes
153
+ def plan_routes
154
+ return nil if request["plan_member"].nil?
155
+ plan["plan_routes"]
156
+ end
157
+
158
+ # Gets the routes available for the app
159
+ #
160
+ # ==== Returns
161
+ #
162
+ # * array of hashes of routes
163
+ def app_routes
164
+ res = get("apps", app["id"])
165
+ res["data"]["routes"]
166
+ end
167
+
168
+ # Gets the environments available for the route
169
+ #
170
+ # ==== Attributes
171
+ #
172
+ # * +route_id+ - id of the route
173
+ #
174
+ # ==== Returns
175
+ #
176
+ # * array of environments for the route
177
+ def route_environments(route_id)
178
+ # Returns environment list for a particular route
179
+ envs = {}
180
+ res = get("routes", route_id)
181
+ res["data"]["route_gates"].each_with_index do |gate,idx|
182
+ envs[gate["environment"]["name"]] = {"id" => gate["environment"]["id"], "position" => idx.to_s }
183
+ end
184
+ envs
185
+ end
186
+
187
+ # Gets the plan stages available for the plan
188
+ #
189
+ # ==== Returns
190
+ #
191
+ # * array of hashes of plan stages
192
+ def plan_stages
193
+ plan["plan_stages"]
194
+ end
195
+
196
+ # Gets the groups available
197
+ #
198
+ # ==== Returns
199
+ #
200
+ # * array of hashes of groups
201
+ def groups
202
+ result = get("groups")
203
+ end
204
+
205
+
206
+ end
207
+
@@ -0,0 +1,312 @@
1
+
2
+ # Base class for rest interactions
3
+ # optimized for rest calls to BRPM
4
+ class BrpmRest
5
+
6
+ # Initialize an instance of the brpmrest class
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +base_url+ - base url for rest calls
11
+ # * +options+ - hash of options, includes:
12
+ # token: a rest token for brpm
13
+ # output_file: file for BrpmAuto.log results (usually @p.SS_output_file)
14
+ #
15
+ def initialize(base_url, options = {}, compat_options = {})
16
+ self.extend Utilities
17
+ if options.has_key?("SS_output_dir")
18
+ BrpmAuto.log "Load for this class has changed, no longer necessary to send params as 2nd argument"
19
+ options = compat_options
20
+ end
21
+ @base_url = base_url
22
+ token = defined?(Token) ? Token : ""
23
+ @token = get_option(options, "token", token)
24
+ end
25
+
26
+ # Performs a get on the passed model
27
+ #
28
+ # ==== Attributes
29
+ #
30
+ # * +model_name+ - rpm model [requests, plans, steps, version_tags, etc]
31
+ # * +model_id+ - id of a specific item in the model (optional)
32
+ # * +options+ - hash of options includes
33
+ # +filters+ - string of the filter text: filters[BrpmAuto.login]=bbyrd
34
+ # includes all the Rest.rest_call options
35
+ #
36
+ # ==== Returns
37
+ #
38
+ # * hash of http response
39
+ def get(model_name, model_id = nil, options = {})
40
+ url = rest_url(model_name, model_id) if get_option(options, "filters") == ""
41
+ url = rest_url(model_name, nil, options["filters"]) if get_option(options, "filters") != ""
42
+ result = Rest.rest_call(url, "get", options)
43
+ end
44
+
45
+ # Performs a put on the passed model
46
+ # use this to update a single record
47
+ # ==== Attributes
48
+ #
49
+ # * +model_name+ - rpm model [requests, plans, steps, version_tags, etc]
50
+ # * +model_id+ - id of a specific item in the model (optional)
51
+ # * +data+ - hash of the put data
52
+ # * +options+ - hash of options includes
53
+ # includes all the Rest.rest_call options
54
+ #
55
+ # ==== Returns
56
+ #
57
+ # * hash of http response
58
+ def update(model_name, model_id, data, options = {})
59
+ url = rest_url(model_name, model_id)
60
+ options["data"] = data
61
+ result = Rest.rest_call(url, "put", options)
62
+ result
63
+ end
64
+
65
+ # Performs a post on the passed model
66
+ # use this to create a new record
67
+ # ==== Attributes
68
+ #
69
+ # * +model_name+ - rpm model [requests, plans, steps, version_tags, etc]
70
+ # * +data+ - hash of the put data
71
+ # * +options+ - hash of options includes
72
+ # includes all the Rest.rest_call options
73
+ #
74
+ # ==== Returns
75
+ #
76
+ # * hash of http response
77
+ def create(model_name, data, options = {})
78
+ options["data"] = data
79
+ url = rest_url(model_name)
80
+ result = Rest.rest_call(url, "post", options)
81
+ result
82
+ end
83
+
84
+ # Sets the token for brpm rest calls
85
+ #
86
+ # ==== Attributes
87
+ #
88
+ # * +token+ - rest token
89
+ #
90
+ def set_token(token)
91
+ @token = token
92
+ end
93
+
94
+ # Takes an array of version tag info and creates the version tags
95
+ #
96
+ # ==== Attributes
97
+ #
98
+ # * +tag_info+ - an array of hashes
99
+ # ex: [{ "application" => "app1", "component" => "database", "name" => "1.2.1", "artifact_url" => "file:///home/brady/stuff"}]
100
+ # * +options+ - a hash of options passed to the rest call
101
+ #
102
+ # ==== Returns
103
+ #
104
+ # * a hash of the command output
105
+ def create_version_tags(tag_info, options = {})
106
+ # Meant to be called after importing a spreadsheet of versions
107
+ results = {"status" => "ERROR", "message" => "", "data" => []}
108
+ message = "Processing tags: #{tag_info.size.to_s} to do\n"
109
+ version_tag = { "name" => "", "artifact_url" => "", "find_application" => "", "find_component" => "", "active" => true}
110
+ tag_info.each do |v_tag|
111
+ if v_tag.has_key?("name")
112
+ version_tag["find_application"] = v_tag["application"]
113
+ version_tag["find_component"] = v_tag["component"]
114
+ version_tag["name"] = v_tag["name"]
115
+ version_tag["artifact_url"] = v_tag["artifact_url"]
116
+ message += "adding #{v_tag["name"]} to #{v_tag["component"]}"
117
+ result = create("version_tags", {"version_tag" => version_tag}, options)
118
+ message += ", Status: #{result["status"]}\n"
119
+ results["data"] << result["data"]
120
+ results["status"] = result["status"]
121
+ else
122
+ message += "bad record: #{v_tag.inspect}\n"
123
+ end
124
+ end
125
+ results["message"] = message
126
+ results
127
+ end
128
+
129
+ # Queries RPM for a version by name
130
+ #
131
+ # ==== Attributes
132
+ #
133
+ # * +name+ - a version name
134
+ #
135
+ # ==== Returns
136
+ #
137
+ # * an array of matching version objects or "ERROR" if not found
138
+ #
139
+ def version_tag_query(name)
140
+ result = "ERROR"
141
+ result = get("version_tags",nil,{"filters" => "filters[name]=#{url_encode(name)}", "suppress_errors" => true})
142
+ if result["status"] == "success"
143
+ BrpmAuto.log "Tag Exists?: #{@base_url}\nResult: #{result["data"].inspect}"
144
+ result = result["data"]
145
+ else
146
+ BrpmAuto.log "No version tags found"
147
+ result = []
148
+ end
149
+ result
150
+ end
151
+
152
+ # Takes a version name and assigns it to the steps in a request
153
+ # === skips steps where the version does not exist
154
+ # ==== Attributes
155
+ #
156
+ # * +version+ - name of a version
157
+ # * +steps+ - an array of steps (returned from rest call to requests)
158
+ # * +options+ - hash of options passed to rest object e.g. {"verbose" => "yes"}
159
+ #
160
+ # ==== Returns
161
+ #
162
+ # * hash {"status" => success or ERROR, "rest_result" => [] array of rest responses
163
+ #
164
+ def assign_version_to_steps(version, steps, options = {})
165
+ result = {"status" => "ERROR - failed to update steps", "rest_result" => []}
166
+ components = steps.map{|l| l["component_name"]}.uniq
167
+ version_tags = version_tag_query(version)
168
+ return "ERROR no version tags for #{version}" if version_tags.is_a?(String) && version_tags.start_with?("ERROR")
169
+ components.reject{|l| l.nil? }.each do |component|
170
+ comp_steps = steps_with_matching_component(steps, component)
171
+ BrpmAuto.log "Comp: #{component}, steps: #{comp_steps.size == 0 ? "no steps" : comp_steps.map{|l| l["name"] }.join(",") }"
172
+ version_tag_id = "0"
173
+ version_tags.each{|k| version_tag_id = k["id"] if k["installed_component_id"] == comp_steps[0]["installed_component_id"] }
174
+ if version_tag_id == "0"
175
+ BrpmAuto.log "No version_tag for component: #{component}"
176
+ else
177
+ BrpmAuto.log "Tag exists for component"
178
+ comp_steps.each do |step|
179
+ step_data = {"version_tag_id" => version_tag_id, "component_version" => version}
180
+ rest_result = update("steps", step["id"], step_data, options)
181
+ if rest_result["status"] == "success"
182
+ BrpmAuto.log "Updating step: #{step["id"]}\nResult: #{rest_result["data"].inspect}"
183
+ result["status"] = "success"
184
+ end
185
+ result["rest_result"] << rest_result.inspect
186
+ end
187
+ end
188
+ end
189
+ result
190
+ end
191
+
192
+ # Takes an array of step objects and a component and returns the steps that match
193
+ #
194
+ # ==== Attributes
195
+ #
196
+ # * +steps+ - an array of steps (returned from rest call to requests)
197
+ # * +comp+ - a component name
198
+ #
199
+ # ==== Returns
200
+ #
201
+ # * array of the steps that match
202
+ def steps_with_matching_component(steps, comp)
203
+ result = []
204
+ steps.each do |step|
205
+ result << step if !step["installed_component_id"].nil? && comp == step["component_name"]
206
+ end
207
+ result
208
+ end
209
+
210
+ # Takes a request_id and monitors status until a condition is met
211
+ #
212
+ # ==== Attributes
213
+ #
214
+ # * +request_id+ - id of the calling request
215
+ # * +target_state+ - state to watch request or step for (default = complete)
216
+ # * +options+ - a hash of options, includes:
217
+ # +monitor_step_name+ - this monitor whether a specific step has reached the target state
218
+ # +max_time+ - maximum time in minutes to wait (default = 15)
219
+ # +interval+ - interval in seconds between checks (default = 15)
220
+ # +verbose+ - passed to rest call for verbose output (true/false)
221
+ #
222
+ # ==== Returns
223
+ #
224
+ # * array of the steps that match
225
+ def monitor_request(request_id, target_state = "complete", options = {})
226
+ states = ["created","planned","started","problem","hold","complete"]
227
+ max_time = get_option(options, "max_time", 15).to_i
228
+ max_time = max_time * 60 # seconds = 15 minutes
229
+ monitor_step_name = get_option(options, "monitor_step_name", "none")
230
+ seed_interval = get_option(options, "interval", 15) #seconds
231
+ verbose = get_option(options, "verbose")
232
+ verbose = "no" unless verbose == "yes"
233
+ raise "Command_Failed: bad request_id" if !(request_id.to_i > 0)
234
+ raise "Command_Failed: state not allowed, choose from [#{states.join(",")}]" if !states.include?(target_state)
235
+ BrpmAuto.message_box("Montoring Request: #{request_id}","sep")
236
+ req_status = "none"
237
+ start_time = Time.now
238
+ elapsed = 0
239
+ until (elapsed > max_time || req_status == target_state)
240
+ rest_result = get("requests", request_id, {"verbose" => verbose})
241
+ raise "Command_Failed: Request not found" if rest_result["status"] == "ERROR"
242
+ if monitor_step_name == "none"
243
+ req_status = rest_result["data"]["aasm_state"]
244
+ else
245
+ found = false
246
+ i_pos = rest_result["data"]["steps"].map{|l| l["name"]}.index(monitor_step_name)
247
+ raise "Command_Failed: Step name [#{monitor_step_name}] not found" if i_pos.nil?
248
+ req_status = rest_result["data"]["steps"][i_pos]["aasm_state"]
249
+ end
250
+ if req_status == target_state
251
+ break
252
+ else
253
+ BrpmAuto.log "\tWaiting(#{elapsed.floor.to_s}) - Current status: #{req_status}"
254
+ sleep(checking_interval)
255
+ elapsed = Time.now - start_time
256
+ end
257
+ end
258
+ if req_status == target_state
259
+ req_status = "Success test, looking for #{target_state}: Success!"
260
+ else
261
+ if elapsed > max_time
262
+ req_status = "Command_Failed: Max time: #{max_time}(secs) reached. Status is: #{req_status}, looking for: #{target_state}"
263
+ else
264
+ req_status = "REST call generated bad data, Status is: #{req_status}, looking for: #{target_state}"
265
+ end
266
+ end
267
+ req_status
268
+ end
269
+
270
+ def checking_interval(interval, total_time)
271
+ if (total_time/interval).to_i > 50
272
+ interval = interval * 30
273
+ elsif (total_time/interval).to_i > 20
274
+ interval = interval * 10
275
+ elsif (total_time/interval).to_i > 15
276
+ interval = interval * 6
277
+ elsif (total_time/interval).to_i > 10
278
+ interval = interval * 4
279
+ elsif (total_time/interval).to_i > 5
280
+ interval = interval * 2
281
+ end
282
+ interval
283
+ end
284
+
285
+
286
+ # Sends an email based on step recipients
287
+ #
288
+ # ==== Attributes
289
+ #
290
+ # * +subject+ - text of email subject
291
+ # * +body+ - text of email body
292
+ #
293
+ # ==== Returns
294
+ #
295
+ # * empty string
296
+ def notify(step_id, body, subject = "Mail from automation")
297
+ url = "#{@base_url}/v1/steps/#{step_id}/notify?token=#{@token}"
298
+ data = {"filters"=>{"notify"=>{"body"=> body, "subject"=> subject}}}
299
+ result = Rest.rest_call(url, "get", {"data" => data})
300
+ end
301
+
302
+ private
303
+
304
+ def rest_url(model_name, id = nil, filters = nil)
305
+ url = "#{@base_url}/v1/#{model_name}#{id == nil ? "" : "/#{id}" }"
306
+ url += "?#{filters}&token=#{@token}" if filters
307
+ url += "?token=#{@token}" unless filters
308
+ url
309
+ end
310
+
311
+ end
312
+