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,33 @@
1
+ def execute_script(params, parent_id, offset, max_records)
2
+ root_group_name = "/#{params["application"].downcase}/public"
3
+
4
+ BrpmAuto.log("Logging on to Bladelogic instance #{BsaSoapClient.get_url} with user #{BsaSoapClient.get_username} and role #{BsaSoapClient.get_role}...")
5
+ session_id = BsaSoapClient.login
6
+
7
+ if parent_id.blank?
8
+ BrpmAuto.log("Retrieving all the groups from group #{root_group_name}...")
9
+ groups = JobGroup.find_all_groups_by_parent_group_name(session_id, {:job_group => root_group_name})
10
+
11
+ groups = groups.to_s.split(' ').sort()
12
+
13
+ results = []
14
+ groups.each do |group|
15
+ results << { :title => group, :key => group, :isFolder => true, :hasChild => true, :hideCheckbox => true }
16
+ end
17
+ else
18
+ job_type = parent_id
19
+ group_name = "#{root_group_name}/#{job_type}"
20
+
21
+ BrpmAuto.log("Retrieving all the objects from group #{group_name}...")
22
+ jobs = Job.list_all_by_group(session_id, {:group_name => group_name})
23
+
24
+ jobs = jobs.to_s.split(' ').sort
25
+
26
+ results = []
27
+ jobs.each do |job|
28
+ results << { :title => job, :key => "#{job_type}|#{job}", :isFolder => false }
29
+ end
30
+ end
31
+
32
+ results
33
+ end
@@ -0,0 +1,15 @@
1
+
2
+ #=== BMC Application Automation Integration Server: BladeLogic on C4 ===#
3
+ # [integration_id=6]
4
+ #=== End ===#
5
+
6
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
7
+
8
+ def execute(script_params, parent_id, offset, max_records)
9
+ script_params["SS_integration_dns"] = SS_integration_dns
10
+ script_params["SS_integration_username"] = SS_integration_username
11
+ script_params["SS_integration_password_enc"] = SS_integration_password_enc
12
+ script_params["SS_integration_details"] = YAML.load(SS_integration_details)
13
+
14
+ BrpmScriptExecutor.execute_resource_automation_script("bladelogic", "select_job", script_params, parent_id, offset, max_records)
15
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe 'create package' do
4
+ before(:all) do
5
+ setup_brpm_auto
6
+ end
7
+
8
+ before(:each) do
9
+ cleanup_package "/Applications/E-Finance/EF - Java calculation engine", "1.0.0"
10
+ end
11
+
12
+ describe '' do
13
+ it 'should create a package in BladeLogic' do # need to add logic to delete the bl package in Bladelogic
14
+ params = get_default_params
15
+ params = params.merge(get_integration_params_for_bladelogic)
16
+
17
+ params["application"] = 'E-Finance'
18
+ params["component"] = 'EF - Java calculation engine'
19
+ params["component_version"] = '1.0.0'
20
+
21
+ BrpmScriptExecutor.execute_automation_script("bladelogic", "create_package", params)
22
+
23
+ version_tag = @brpm_rest_client.get_version_tag("E-Finance","EF - Java calculation engine", "development", "1.0.0")
24
+ expect(version_tag).not_to be_nil
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,23 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe 'deploy package' do
4
+ before(:all) do
5
+ setup_brpm_auto
6
+ end
7
+
8
+ describe '' do
9
+ it 'should deploy a package in BladeLogic' do
10
+ params = get_default_params
11
+ params = params.merge(get_integration_params_for_bladelogic)
12
+
13
+ params["application"] = 'E-Finance'
14
+ params["component"] = 'EF - Java calculation engine'
15
+ params["component_version"] = '2.0.0'
16
+ params["request_environment"] = "development"
17
+ params["server_group"] = "EF - java app servers - development"
18
+
19
+ BrpmScriptExecutor.execute_automation_script("bladelogic", "deploy_package", params)
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,82 @@
1
+ require 'fileutils'
2
+ require_relative "../../framework/brpm_script_executor"
3
+
4
+ def setup_brpm_auto
5
+ FileUtils.mkdir_p "/tmp/brpm_content"
6
+
7
+ BrpmAuto.setup( get_default_params.merge!(get_integration_params_for_bladelogic) )
8
+
9
+ BrpmAuto.require_module "brpm"
10
+ BrpmAuto.require_module "bladelogic"
11
+
12
+ @brpm_rest_client = BrpmRestClient.new('http://brpm-content.pulsar-it.be:8088/brpm', ENV["BRPM_API_TOKEN"])
13
+ @bsa_soap_client = BsaSoapClient.new
14
+ end
15
+
16
+ def get_default_params
17
+ params = {}
18
+ params['also_log_to_console'] = 'true'
19
+
20
+ params['brpm_url'] = 'http://brpm-content.pulsar-it.be:8088/brpm'
21
+ params['brpm_api_token'] = ENV["BRPM_API_TOKEN"]
22
+
23
+ params['output_dir'] = "/tmp/brpm_content"
24
+
25
+ params
26
+ end
27
+
28
+ def get_integration_params_for_bladelogic
29
+ params = {}
30
+ params["SS_integration_dns"] = "https://bladelogic.pulsar-it.be:9843"
31
+ params["SS_integration_username"] = "BLAdmin"
32
+ params["SS_integration_password"] = ENV["BLADELOGIC_PASSWORD"]
33
+ params["SS_integration_details"] = {}
34
+ params["SS_integration_details"]["role"] = "BLAdmins"
35
+
36
+ params
37
+ end
38
+
39
+ def cleanup_requests_and_plans_for_app(app_name)
40
+ app = @brpm_rest_client.get_app_by_name(app_name)
41
+
42
+ requests = @brpm_rest_client.get_requests_by({ "app_id" => app["id"]})
43
+
44
+ requests.each do |request|
45
+ @brpm_rest_client.delete_request(request["id"]) unless request.has_key?("request_template")
46
+ end
47
+
48
+ plan_template = @brpm_rest_client.get_plan_template_by_name("#{app_name} Release Plan")
49
+
50
+ plans = @brpm_rest_client.get_plans_by({ "plan_template_id" => plan_template["id"]})
51
+ plans.each do |plan|
52
+ @brpm_rest_client.cancel_plan(plan["id"])
53
+ @brpm_rest_client.delete_plan(plan["id"])
54
+ end
55
+ end
56
+
57
+ def cleanup_version_tags_for_app(app_name)
58
+ app = @brpm_rest_client.get_app_by_name(app_name)
59
+
60
+ version_tags = @brpm_rest_client.get_version_tags_by({ "app_id" => app["id"]})
61
+
62
+ version_tags.each do |version_tag|
63
+ @brpm_rest_client.delete_version_tag(version_tag["id"])
64
+ end
65
+ end
66
+
67
+ def cleanup_package path, name
68
+ BrpmAuto.log("Deleting blpackage #{path}/#{name}...")
69
+ begin
70
+ @bsa_soap_client.blpackage.delete_blpackage_by_group_and_name({ :parent_group => path, :package_name => name })
71
+ rescue Exception => ex
72
+ if ex.message =~ /Cannot find depot object by name/
73
+ BrpmAuto.log "assuming that the package didn't exist so all is fine."
74
+ else
75
+ raise ex
76
+ end
77
+ end
78
+ end
79
+
80
+ def pack_response key, value
81
+ BrpmAuto.log "pack_response: #{key}: #{value}"
82
+ end
@@ -0,0 +1,34 @@
1
+ require 'simple_xlsx_reader'
2
+
3
+ brpm_rest_client = BrpmRestClient.new
4
+ params = BrpmAuto.params
5
+
6
+ doc = SimpleXlsxReader.open(params["step_attachment_0"])
7
+ BrpmAuto.log doc.sheets.first.rows.inspect
8
+
9
+ plan = nil
10
+ env_name = nil
11
+ stage_name = nil
12
+ sub_stage_name = nil
13
+ app_name = nil
14
+ request = nil
15
+
16
+ doc.sheets.first.rows.each do |row|
17
+ if !row[0].nil?
18
+ BrpmAuto.log "Creating a new plan from template 'My Release Plan' for release #{row[0]} ..."
19
+ plan = brpm_rest_client.create_plan("My Release Plan", row[0], Time.now)
20
+ elsif !row[1].nil?
21
+ env_name = row[1].downcase
22
+ stage_name = row[1]
23
+ elsif !row[2].nil?
24
+ sub_stage_name = row[2]
25
+ elsif !row[3].nil?
26
+ app_name = row[3]
27
+ elsif !row[4].nil?
28
+ BrpmAuto.log "Creating a new request '#{row[4]}' for plan '#{plan["name"]}', stage '#{stage_name} - #{sub_stage_name}' and app '#{app_name}' ..."
29
+ request = brpm_rest_client.create_request_for_plan(plan["id"], "#{stage_name} - #{sub_stage_name}", row[4], 1, app_name, env_name, false)
30
+ elsif !row[5].nil?
31
+ BrpmAuto.log "Creating a new step '#{row[5]}' for request '#{request["name"]}' ..."
32
+ brpm_rest_client.create_step(request["id"], row[5], "User", 1)
33
+ end
34
+ end
@@ -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", "create_release_from_excel", params)
@@ -0,0 +1,100 @@
1
+ # TODO workaround bug fix where the request params are not transferred to the updated application's directory
2
+ require 'fileutils'
3
+
4
+ brpm_rest_client = BrpmRestClient.new
5
+
6
+ BrpmAuto.log "Retrieving the application..."
7
+ application = brpm_rest_client.get_app_by_name(BrpmAuto.params["application_name"])
8
+ application_version = BrpmAuto.params["application_version"]
9
+
10
+ release_request_template_name = BrpmAuto.params["release_request_template_name"] || "Release application"
11
+ release_plan_template_name = BrpmAuto.params["release_plan_template_name"]
12
+ release_plan_name = BrpmAuto.params["release_plan_name"]
13
+
14
+ request_name = "Release #{application["name"]} #{application_version}"
15
+
16
+ request_params = {}
17
+ request_params["auto_created"] = true
18
+ request_params["application_version"] = application_version
19
+ request_params["component_versions"] = {}
20
+ request_params["component_versions"]["EF - .NET web front end"] = BrpmAuto.params["ef_net_version"]
21
+ request_params["component_versions"]["EF - Java calculation engine"] = BrpmAuto.params["ef_java_version"]
22
+
23
+ if release_plan_template_name or release_plan_name
24
+ if release_plan_template_name
25
+ BrpmAuto.log "Creating a new plan from template '#{release_plan_template_name}' for #{application["name"]} v#{application_version} ..."
26
+ plan = brpm_rest_client.create_plan(release_plan_template_name, "Release #{BrpmAuto.params["application_name"]} v#{application_version}", Time.now)
27
+
28
+ BrpmAuto.log "Planning the plan ..."
29
+ brpm_rest_client.plan_plan(plan["id"])
30
+
31
+ BrpmAuto.log "Starting the plan ..."
32
+ brpm_rest_client.start_plan(plan["id"])
33
+ elsif release_plan_name
34
+ plan = brpm_rest_client.get_plan_by_name(release_plan_name)
35
+ raise "Release plan '#{release_plan_name}' doesn't exist." unless plan
36
+ end
37
+
38
+ BrpmAuto.log "Creating a new request '#{request_name}' from template '#{release_request_template_name}' for application '#{application["name"]}' and plan #{plan["name"]}..."
39
+ target_request = brpm_rest_client.create_request_for_plan_from_template(
40
+ plan["id"],
41
+ "Release",
42
+ release_request_template_name,
43
+ request_name,
44
+ "release",
45
+ false, # execute_now
46
+ request_params
47
+ )
48
+
49
+ else
50
+ BrpmAuto.log "Creating a new request '#{request_name}' from template '#{release_request_template_name}' for application '#{application["name"]}'..."
51
+ target_request = brpm_rest_client.create_request(
52
+ release_request_template_name,
53
+ request_name,
54
+ "release",
55
+ false, # execute_now
56
+ request_params
57
+ )
58
+ end
59
+
60
+ unless target_request["apps"].first["id"] == application["id"]
61
+ BrpmAuto.log "The application from the template is different than the application we want to use so updating the request with the correct application..."
62
+ request = {}
63
+ request["id"] = target_request["id"]
64
+ request["app_ids"] = [application["id"]]
65
+ target_request = brpm_rest_client.update_request_from_hash(request)
66
+
67
+ # TODO workaround bug fix where the request params are not transferred to the updated application's directory
68
+ Dir.mkdir "#{BrpmAuto.params.automation_results_dir}/request/#{application["name"]}/#{1000 + target_request["id"].to_i}"
69
+ json = FileUtils.mv("#{BrpmAuto.params.automation_results_dir}/request/#{target_request["apps"].first["name"]}/#{1000 + target_request["id"].to_i}/request_data.json", "#{BrpmAuto.params.automation_results_dir}/request/#{application["name"]}/#{1000 + target_request["id"].to_i}/request_data.json")
70
+
71
+ BrpmAuto.log "Setting the owner of the manual steps to the groups that belong to application '#{application["name"]}'..."
72
+ target_request["steps"].select{ |step| step["manual"] }.each do |step|
73
+ BrpmAuto.log "Retrieving the details of step #{step["id"]} '#{step["name"]}'..."
74
+ step_details = brpm_rest_client.get_step_by_id(step["id"])
75
+
76
+ next if step_details["procedure"]
77
+
78
+ group_name = "#{step_details["owner"]["name"]} - #{application["name"]}"
79
+
80
+ BrpmAuto.log "Retrieving group #{group_name}..."
81
+ group = brpm_rest_client.get_group_by_name(group_name)
82
+ raise "Group '#{group_name}' doesn't exist" if group.nil?
83
+
84
+ step_to_update = {}
85
+ step_to_update["id"] = step["id"]
86
+ step_to_update["owner_id"] = group["id"]
87
+ step_to_update["owner_type"] = "Group"
88
+ brpm_rest_client.update_step_from_hash step_to_update
89
+ end
90
+ end
91
+
92
+ BrpmAuto.log "Planning the request ... "
93
+ brpm_rest_client.plan_request(target_request["id"])
94
+
95
+ BrpmAuto.log "Starting the request ... "
96
+ brpm_rest_client.start_request(target_request["id"])
97
+
98
+ BrpmAuto.params["result"] = {}
99
+ BrpmAuto.params["result"]["request_id"] = target_request["id"]
100
+
@@ -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", "create_release_request", params)
@@ -0,0 +1,73 @@
1
+ brpm_rest_client = BrpmRestClient.new
2
+ params = BrpmAuto.params
3
+ request_params = BrpmAuto.request_params
4
+
5
+ BrpmAuto.log "Retrieving the application..."
6
+ application = brpm_rest_client.get_app_by_name(params["application"])
7
+ application_version = request_params["application_version"] || ""
8
+
9
+ BrpmAuto.log "Retrieving the environment..."
10
+ target_environment = brpm_rest_client.get_environment_by_id(params["target_environment_id"])
11
+
12
+ if request_params.has_key? "request_template_id"
13
+ request_template_id = request_params["request_template_id"]
14
+ request_template_name = nil
15
+ else
16
+ request_template_id = nil
17
+ request_template_name = "Deploy #{application["name"]}"
18
+ end
19
+
20
+ BrpmAuto.log "Creating request 'Deploy #{application["name"]} #{application_version}' from template '#{request_template_id || request_template_name}' for application '#{application["name"]}' and environment '#{target_environment["name"]}'..."
21
+ request = {}
22
+ request["request_template_id"] = request_template_id
23
+ request["template_name"] = request_template_name
24
+ request["name"] = "Deploy #{application["name"]} #{application_version}"
25
+ request["environment"] = target_environment["name"]
26
+ request["execute_now"] = false
27
+ request["app_ids"] = [ application["id"] ]
28
+
29
+ if params.request_plan_id and ! params.request_plan_id.empty? and params["target_stage"] and ! params["target_stage"].empty?
30
+ plan_stage_id = brpm_rest_client.get_plan_stage_id(params.request_plan_id, params["target_stage"])
31
+ request["plan_member_attributes"] = { "plan_id" => params.request_plan_id, "plan_stage_id" => plan_stage_id }
32
+ end
33
+
34
+ target_request = brpm_rest_client.create_request_from_hash(request)
35
+
36
+ unless target_request["apps"].first["id"] == application["id"]
37
+ BrpmAuto.log "The application from the template is different than the application we want to use so updating the request with the correct application..."
38
+ request = {}
39
+ request["id"] = target_request["id"]
40
+ request["app_ids"] = [application["id"]]
41
+ target_request = brpm_rest_client.update_request_from_hash(request)
42
+ end
43
+
44
+ if request_params.has_key?"component_versions"
45
+ BrpmAuto.log "Component versions found in the request params so setting the version number of the components... "
46
+ request_params["component_versions"].each do |component_name, component_version|
47
+ BrpmAuto.log "Setting the version of component '#{component_name}' to '#{component_version}'... "
48
+ brpm_rest_client.set_version_tag_of_steps_for_component(target_request, component_name, component_version)
49
+ end
50
+ elsif ! application_version.empty?
51
+ BrpmAuto.log "Application version found so setting the version number of all components to #{application_version}... "
52
+ application["components"].each do |component|
53
+ brpm_rest_client.set_version_tag_of_steps_for_component(target_request, component["name"], application_version)
54
+ end
55
+ end
56
+
57
+ if params["execute_target_request"].downcase.include?("execute")
58
+ BrpmAuto.log "Planning the request ... "
59
+ brpm_rest_client.plan_request(target_request["id"])
60
+
61
+ BrpmAuto.log "Starting the request ... "
62
+ brpm_rest_client.start_request(target_request["id"])
63
+ end
64
+
65
+ if params["execute_target_request"].downcase.include?("monitor")
66
+ BrpmAuto.log "Waiting until the request has finished ..."
67
+ brpm_rest_client.monitor_request(target_request["id"])
68
+ end
69
+
70
+ BrpmAuto.log "Adding the created request' id to the request_params ..."
71
+ request_params["target_request_id"] = target_request["id"]
72
+
73
+
@@ -0,0 +1,23 @@
1
+ ###
2
+ # target_environment_id:
3
+ # name: Target environment
4
+ # required: yes
5
+ # position: A1:C1
6
+ # type: in-external-single-select
7
+ # external_resource: select_environment
8
+ # target_stage:
9
+ # name: Target stage
10
+ # required: no
11
+ # position: A2:C2
12
+ # execute_target_request:
13
+ # name: execute_target_request
14
+ # required: yes
15
+ # type: in-list-single
16
+ # list_pairs: 1,No|2,Execute|3,Execute and monitor
17
+ # position: A3:C3
18
+ ###
19
+ params["direct_execute"] = "true"
20
+
21
+ require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
22
+
23
+ BrpmScriptExecutor.execute_automation_script("brpm", "create_request", params)
@@ -0,0 +1,197 @@
1
+ def get_source_requests(params)
2
+ brpm_rest_client = BrpmRestClient.new
3
+
4
+ source_request_ids = brpm_rest_client.get_requests_by_plan_id_and_stage_name_and_app_name(params["request_plan_id"], params["source_stage"], params["application"])
5
+
6
+ raise "No requests found for application '#{params["application"]}' in stage '#{params["source_stage"]}' of this plan" if source_request_ids.count == 0
7
+
8
+ source_requests = source_request_ids.map { |source_request_id| brpm_rest_client.get_request_by_id(source_request_id) }
9
+ .sort_by { |request| request["created_at"] }
10
+
11
+ source_requests
12
+ end
13
+
14
+ def step_has_incremental_deployment(correction_source_step, source_steps_with_same_name)
15
+ brpm_rest_client = BrpmRestClient.new
16
+
17
+ incremental_deployment = false
18
+ if source_steps_with_same_name.count > 1
19
+ BrpmAuto.log "Already multiple steps with the same name, this means that it is a step that has a component with incremental deploy."
20
+ incremental_deployment = true
21
+ else
22
+ if !source_steps_with_same_name.first["component"].nil? and !correction_source_step["component"].nil?
23
+ if source_steps_with_same_name.first["component"]["id"] == correction_source_step["component"]["id"]
24
+ if !source_steps_with_same_name.first["version_tag"].nil? and !correction_source_step["version_tag"].nil?
25
+ BrpmAuto.log "Verifying if the associated component '#{correction_source_step["component"]["name"]}' uses incremental deployment ..."
26
+ component = brpm_rest_client.get_component_by_id(correction_source_step["component"]["id"])
27
+ incremental_deployment = (component.has_key?("properties") and component["properties"].any? { |property| property["name"] == "incremental_deployment" })
28
+
29
+ if incremental_deployment and source_steps_with_same_name.first["version_tag"]["name"] == correction_source_step["version_tag"]["name"]
30
+ raise "This component has incremental deployment and there already exists a step with the same component and version number."
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ incremental_deployment
38
+ end
39
+
40
+ def merge_source_request_steps(source_requests)
41
+ brpm_rest_client = BrpmRestClient.new
42
+
43
+ BrpmAuto.log "Getting the step details of the initial request ..."
44
+ source_steps = source_requests.first["steps"].map { |source_step_summary| brpm_rest_client.get_step_by_id(source_step_summary["id"]) }
45
+ .sort_by { |step| step["number"].to_f }
46
+
47
+ #TODO: use work tasks to find the first post-deploy step
48
+ post_deploy_step = source_steps.find { |step| step["name"] == "Post-deploy" }
49
+
50
+ BrpmAuto.log "Merging the correction requests with the original request ..."
51
+ source_requests[1..source_requests.count].each do |source_request|
52
+ BrpmAuto.log "Merging the steps from correction request #{source_request["id"]} - #{source_request["name"] || "<no name>"} (#{source_request["steps"].count} steps)"
53
+ source_request["steps"].sort_by { |step| step["number"].to_f }.each do |correction_source_step_summary|
54
+ correction_source_step = brpm_rest_client.get_step_by_id(correction_source_step_summary["id"])
55
+ BrpmAuto.log "Merging step '#{correction_source_step["name"]}' ..."
56
+
57
+ source_steps_with_same_name = source_steps.find_all { |source_step| source_step["name"] == correction_source_step["name"] }
58
+
59
+ if source_steps_with_same_name.count == 0
60
+ BrpmAuto.log "No steps yet with the same name, so adding this step to the list ..."
61
+ index = source_steps.index(post_deploy_step)
62
+ source_steps.insert(index, correction_source_step)
63
+ next
64
+ end
65
+
66
+ BrpmAuto.log "Verifying if the step has a component with incremental deployment ..."
67
+ incremental_deployment = step_has_incremental_deployment(correction_source_step, source_steps_with_same_name)
68
+
69
+ if incremental_deployment
70
+ BrpmAuto.log "This step has a component with incremental deployment so adding it to the list ..."
71
+ index = source_steps.index(source_steps_with_same_name.last)
72
+ source_steps.insert(index + 1, correction_source_step)
73
+ else
74
+ BrpmAuto.log "Replacing the original step with this one in the list ..."
75
+ index = source_steps.index(source_steps_with_same_name.first)
76
+ source_steps[index] = correction_source_step
77
+ end
78
+ end
79
+ end
80
+
81
+ source_steps
82
+ end
83
+
84
+ def create_target_request(initial_source_request, source_steps, params)
85
+ brpm_rest_client = BrpmRestClient.new
86
+
87
+ target_request = {}
88
+ target_request["name"] = params["request_name"].sub("Release", "Deploy")
89
+ target_request["description"] = initial_source_request["description"]
90
+ target_request["estimate"] = initial_source_request["estimate"]
91
+ target_request["owner_id"] = initial_source_request["owner"]["id"]
92
+ target_request["requestor_id"] = initial_source_request["requestor"]["id"]
93
+ target_request["deployment_coordinator_id"] = initial_source_request["deployment_coordinator"]["id"]
94
+ target_request["app_ids"] = initial_source_request["apps"][0]["id"]
95
+
96
+ plan_stage_id = brpm_rest_client.get_plan_stage_id(params["request_plan_id"], params["target_stage"])
97
+ target_request["plan_member_attributes"] = { "plan_id" => params["request_plan_id"], "plan_stage_id" => plan_stage_id }
98
+ target_request["environment"] = params["target_env"]
99
+ target_request["execute_now"] = (params["execute_target_request"] == 'Yes') #TODO: doesn't work - maybe try starting it explicitly after creation
100
+
101
+ BrpmAuto.log "Creating the target request ..."
102
+ target_request = brpm_rest_client.create_request_from_hash(target_request)
103
+
104
+ BrpmAuto.log "Creating the target steps ..."
105
+ procedure_mapping = {}
106
+ source_steps.each do |source_step|
107
+ BrpmAuto.log "Creating target step for step #{source_step["name"]} ..."
108
+
109
+ target_step = {}
110
+ if source_step["procedure"]
111
+ #TODO doesnt work yet
112
+ target_step["parent_id"] = procedure_mapping[source_step["parent_id"]]
113
+ end
114
+ target_step["request_id"] = target_request["id"]
115
+ target_step["name"] = source_step["name"]
116
+ target_step["description"] = source_step["description"]
117
+ target_step["owner_type"] = source_step["owner_type"]
118
+ target_step["owner_id"] = source_step["owner"]["id"] unless source_step["owner"].nil?
119
+ target_step["manual"] = source_step["manual"]
120
+ target_step["script_id"] = source_step["script"]["id"] unless source_step["script"].nil?
121
+ target_step["script_type"] = source_step["script_type"]
122
+ target_step["procedure"] = source_step["procedure"]
123
+
124
+ unless source_step["installed_component"].nil?
125
+ installed_components = brpm_rest_client.get_installed_components_by({ "app_name" => source_step["installed_component"]["app"]["name"],
126
+ "component_name" => source_step["installed_component"]["component"]["name"],
127
+ "environment_name" => params["target_env"] })
128
+
129
+ raise "No installed component found for app '#{source_step["installed_component"]["app"]["name"]}', component '#{source_step["installed_component"]["component"]["name"]}' and environment '#{source_step["installed_component"]["environment"]["name"]}'" if installed_components.count == 0
130
+
131
+ target_step["installed_component_id"] = installed_components[0]["id"]
132
+
133
+ unless source_step["version_tag"].nil?
134
+ version_tags = brpm_rest_client.get_version_tags_by({ "name" => source_step["version_tag"]["name"],
135
+ "app_name" => source_step["installed_component"]["app"]["name"],
136
+ "component_name" => source_step["installed_component"]["component"]["name"],
137
+ "environment_name" => params["target_env"] })
138
+
139
+ raise "No version tag found for app '#{source_step["installed_component"]["app"]["name"]}', component '#{source_step["installed_component"]["component"]["name"]}', environment '#{params["target_env"]}' and version '#{source_step["version_tag"]["name"]}'" if version_tags.count == 0
140
+
141
+ target_step["version_tag_id"] = version_tags[0]["id"]
142
+ end
143
+ end
144
+
145
+ target_step["component_id"] = source_step["component"]["id"] unless source_step["component"].nil?
146
+
147
+ target_step["own_version"] = source_step["own_version"]
148
+ target_step["component_version"] = source_step["component_version"]
149
+ target_step["custom_ticket_id"] = source_step["custom_ticket_id"]
150
+ target_step["release_content_item_id"] = source_step["release_content_item_id"]
151
+ target_step["on_plan"] = source_step["on_plan"]
152
+ target_step["should_execute"] = source_step["should_execute"]
153
+ target_step["execute_anytime"] = source_step["execute_anytime"]
154
+ target_step["start_by"] = source_step["start_by"]
155
+ target_step["location_detail"] = source_step["location_detail"]
156
+ target_step["estimate"] = source_step["estimate"]
157
+ target_step["different_level_from_previous"] = source_step["different_level_from_previous"]
158
+ target_step["phase_id"] = source_step["phase"]["id"] unless source_step["phase"].nil?
159
+ target_step["runtime_phase_id"] = source_step["runtime_phase"]["id"] unless source_step["runtime_phase"].nil?
160
+
161
+ target_step = brpm_rest_client.create_step_from_hash(target_step)
162
+
163
+ BrpmAuto.log "Created target step for step #{source_step["name"]} (#{target_step["position"]})."
164
+
165
+ procedure_mapping[source_step["id"]] = target_step["id"] if source_step["procedure"]
166
+ end
167
+
168
+ target_request
169
+ end
170
+
171
+ brpm_rest_client = BrpmRestClient.new
172
+ params = BrpmAuto.params
173
+
174
+ BrpmAuto.log "Getting the source requests ..."
175
+ source_requests = brpm_rest_client.get_source_requests(params)
176
+
177
+ if params["request_template"].nil? || params["request_template"].empty?
178
+ initial_source_request = source_requests.first
179
+ BrpmAuto.log "Found initial source request #{initial_source_request["id"]} - #{initial_source_request["name"] || "<no name>"}"
180
+
181
+ BrpmAuto.log "Merging the source request steps ..."
182
+ source_steps = merge_source_request_steps(source_requests)
183
+
184
+ BrpmAuto.log "Creating the target request ..."
185
+ target_request = create_target_request(initial_source_request, source_steps, params)
186
+ else
187
+ target_request = brpm_rest_client.create_request_for_plan_from_template(params["request_plan_id"], params["target_stage"], params["request_template"], params["request_name"].sub("Release", "Deploy"), params["target_env"], (params["execute_target_request"] == 'Yes'))
188
+ end
189
+
190
+ BrpmAuto.log "Moving the source requests to the stage '#{params["source_stage"]} - Archived' ..."
191
+ source_requests.each do |source_request|
192
+ brpm_rest_client.move_request_to_plan_and_stage(source_request["id"], params["request_plan_id"], "#{params["source_stage"]} - Archived")
193
+ end
194
+
195
+ BrpmAuto.log "Adding the promoted request' id to the request_params ..."
196
+ BrpmAuto.request_params["promoted_request_id"] = target_request["id"]
197
+