brpm_content 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +38 -0
- data/.travis.yml +14 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +308 -0
- data/Rakefile +24 -0
- data/TO_BE_MIGRATED.txt +8 -0
- data/architecture.png +0 -0
- data/brpm_content.gemspec +31 -0
- data/customers/demo/integrations/brpm/process_event_handler_event.rb +183 -0
- data/customers/demo/integrations/jenkins/spec/api/applications_spec.rb +89 -0
- data/customers/demo/integrations/jenkins/spec/api/plans_spec.rb +69 -0
- data/customers/demo/integrations/jenkins/spec/api/requests_spec.rb +57 -0
- data/customers/demo/integrations/jenkins/spec/spec_helper.rb +33 -0
- data/customers/demo/integrations/jira/process_webhook_event.rb +33 -0
- data/customers/demo/jira_mappings.rb +29 -0
- data/infrastructure/integrations/event_handler.rb +62 -0
- data/infrastructure/integrations/webhook_receiver.rb +49 -0
- data/infrastructure/shell_scripts/backup_database.sh +19 -0
- data/infrastructure/shell_scripts/create_bl_package.sh +34 -0
- data/infrastructure/shell_scripts/create_release_request.sh +34 -0
- data/infrastructure/shell_scripts/ddns.sh +10 -0
- data/infrastructure/shell_scripts/install_brpm.sh +63 -0
- data/infrastructure/shell_scripts/install_content_module.sh +66 -0
- data/infrastructure/shell_scripts/install_content_repo.sh +60 -0
- data/infrastructure/shell_scripts/install_module_from_gem.sh +80 -0
- data/infrastructure/shell_scripts/maintenance.sh +4 -0
- data/infrastructure/shell_scripts/patch_brpm.sh +90 -0
- data/infrastructure/shell_scripts/restore_database.sh +33 -0
- data/infrastructure/shell_scripts/run_event_handler.cmd +16 -0
- data/infrastructure/shell_scripts/run_event_handler.sh +20 -0
- data/infrastructure/shell_scripts/run_webhook_receiver.cmd +14 -0
- data/infrastructure/shell_scripts/run_webhook_receiver.sh +15 -0
- data/infrastructure/shell_scripts/update_content_repo.sh +21 -0
- data/infrastructure/silent_install_options_4.6.txt +93 -0
- data/infrastructure/silent_install_options_upgrade_4.6.txt +92 -0
- data/infrastructure/smtp_settings.rb +42 -0
- data/infrastructure/ssh_script_header_additions.rb +21 -0
- data/modules/ansible/automations/execute_role.rb +3 -0
- data/modules/ansible/automations/execute_role.txt +12 -0
- data/modules/ansible/config.yml +5 -0
- data/modules/ansible/lib/ansible.rb +41 -0
- data/modules/atrium_orchestrator/automations/execute_workflow.rb +12 -0
- data/modules/atrium_orchestrator/automations/execute_workflow.txt +25 -0
- data/modules/atrium_orchestrator/automations/reserve_ip_address.rb +22 -0
- data/modules/atrium_orchestrator/automations/reserve_ip_address.txt +21 -0
- data/modules/atrium_orchestrator/config.yml +7 -0
- data/modules/atrium_orchestrator/lib/ao_soap_client.rb +94 -0
- data/modules/bladelogic/automations/create_package.rb +29 -0
- data/modules/bladelogic/automations/create_package.txt +26 -0
- data/modules/bladelogic/automations/deploy_package.rb +137 -0
- data/modules/bladelogic/automations/deploy_package.txt +53 -0
- data/modules/bladelogic/config.yml +7 -0
- data/modules/bladelogic/lib/bl_rest/bsa_rest_client.rb +65 -0
- data/modules/bladelogic/lib/bl_soap/blpackage.rb +43 -0
- data/modules/bladelogic/lib/bl_soap/bsa_soap_base.rb +118 -0
- data/modules/bladelogic/lib/bl_soap/bsa_soap_client.rb +34 -0
- data/modules/bladelogic/lib/bl_soap/compliance_job.rb +155 -0
- data/modules/bladelogic/lib/bl_soap/deploy_job.rb +48 -0
- data/modules/bladelogic/lib/bl_soap/depot_group.rb +47 -0
- data/modules/bladelogic/lib/bl_soap/job.rb +376 -0
- data/modules/bladelogic/lib/bl_soap/job_group.rb +72 -0
- data/modules/bladelogic/lib/bl_soap/job_management.rb +22 -0
- data/modules/bladelogic/lib/bl_soap/job_result.rb +12 -0
- data/modules/bladelogic/lib/bl_soap/job_run.rb +271 -0
- data/modules/bladelogic/lib/bl_soap/login.rb +47 -0
- data/modules/bladelogic/lib/bl_soap/nsh_script_job.rb +14 -0
- data/modules/bladelogic/lib/bl_soap/patch_catalog.rb +178 -0
- data/modules/bladelogic/lib/bl_soap/patch_remediation_job.rb +137 -0
- data/modules/bladelogic/lib/bl_soap/patching_job.rb +250 -0
- data/modules/bladelogic/lib/bl_soap/server.rb +12 -0
- data/modules/bladelogic/lib/bl_soap/template.rb +13 -0
- data/modules/bladelogic/lib/bl_soap/utility.rb +99 -0
- data/modules/bladelogic/resource_automations/select_job.rb +33 -0
- data/modules/bladelogic/resource_automations/select_job.txt +15 -0
- data/modules/bladelogic/tests/create_package_spec.rb +28 -0
- data/modules/bladelogic/tests/deploy_package_spec.rb +23 -0
- data/modules/bladelogic/tests/spec_helper.rb +82 -0
- data/modules/brpm/automations/create_release_from_excel.rb +34 -0
- data/modules/brpm/automations/create_release_from_excel.txt +5 -0
- data/modules/brpm/automations/create_release_request.rb +100 -0
- data/modules/brpm/automations/create_release_request.txt +5 -0
- data/modules/brpm/automations/create_request.rb +73 -0
- data/modules/brpm/automations/create_request.txt +23 -0
- data/modules/brpm/automations/promote_request.rb +197 -0
- data/modules/brpm/automations/promote_request.txt +24 -0
- data/modules/brpm/automations/select_application_version.rb +22 -0
- data/modules/brpm/automations/select_application_version.txt +17 -0
- data/modules/brpm/automations/select_component_version.rb +12 -0
- data/modules/brpm/automations/select_component_version.txt +5 -0
- data/modules/brpm/automations/select_request_template.rb +6 -0
- data/modules/brpm/automations/select_request_template.txt +13 -0
- data/modules/brpm/automations/wait_for_step_in_other_request.rb +11 -0
- data/modules/brpm/automations/wait_for_step_in_other_request.txt +13 -0
- data/modules/brpm/automations/wait_till_promoted_request_is_completed.rb +9 -0
- data/modules/brpm/automations/wait_till_promoted_request_is_completed.txt +5 -0
- data/modules/brpm/config.yml +6 -0
- data/modules/brpm/lib/brpm_request.rb +207 -0
- data/modules/brpm/lib/brpm_rest.rb +312 -0
- data/modules/brpm/lib/brpm_rest_client.rb +1501 -0
- data/modules/brpm/resource_automations/select_application.rb +16 -0
- data/modules/brpm/resource_automations/select_application.txt +5 -0
- data/modules/brpm/resource_automations/select_environment.rb +14 -0
- data/modules/brpm/resource_automations/select_environment.txt +5 -0
- data/modules/brpm/resource_automations/select_request_template.rb +16 -0
- data/modules/brpm/resource_automations/select_request_template.txt +5 -0
- data/modules/brpm/resource_automations/select_step_in_request.rb +33 -0
- data/modules/brpm/resource_automations/select_step_in_request.txt +5 -0
- data/modules/brpm/sample_applications/e-finance.json +0 -0
- data/modules/brpm/tests/create_release_request_spec.rb +66 -0
- data/modules/brpm/tests/create_request_spec.rb +84 -0
- data/modules/brpm/tests/select_application_version_spec.rb +47 -0
- data/modules/brpm/tests/spec_helper.rb +63 -0
- data/modules/docker_brpm/automations/create_brpm_instance_input_params.rb +10 -0
- data/modules/docker_brpm/automations/create_brpm_instance_input_params.txt +17 -0
- data/modules/docker_brpm/automations/create_brpm_instance_one_shot.rb +60 -0
- data/modules/docker_brpm/automations/create_brpm_instance_one_shot.txt +14 -0
- data/modules/docker_brpm/automations/create_brpm_instance_show_results.rb +23 -0
- data/modules/docker_brpm/automations/create_brpm_instance_show_results.txt +13 -0
- data/modules/docker_brpm/automations/create_database.rb +24 -0
- data/modules/docker_brpm/automations/create_database.txt +3 -0
- data/modules/docker_brpm/automations/create_environment.rb +14 -0
- data/modules/docker_brpm/automations/create_environment.txt +3 -0
- data/modules/docker_brpm/automations/create_image_for_application.rb +23 -0
- data/modules/docker_brpm/automations/create_image_for_application.txt +6 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.rb +7 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.txt +8 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.rb +7 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.txt +8 -0
- data/modules/docker_brpm/automations/create_image_for_database_creator.rb +21 -0
- data/modules/docker_brpm/automations/create_image_for_database_creator.txt +6 -0
- data/modules/docker_brpm/automations/create_installed_component_for_application.rb +11 -0
- data/modules/docker_brpm/automations/create_installed_component_for_application.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database.rb +7 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database_creator.rb +8 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database_creator.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_utilities.rb +7 -0
- data/modules/docker_brpm/automations/create_installed_component_for_utilities.txt +3 -0
- data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.rb +13 -0
- data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.txt +6 -0
- data/modules/docker_brpm/automations/delete_brpm_instance.rb +38 -0
- data/modules/docker_brpm/automations/delete_brpm_instance.txt +8 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins.rb +43 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins.txt +13 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.rb +5 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.txt +9 -0
- data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.rb +27 -0
- data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.txt +3 -0
- data/modules/docker_brpm/automations/launch_test_run_request.rb +30 -0
- data/modules/docker_brpm/automations/launch_test_run_request.txt +14 -0
- data/modules/docker_brpm/automations/release_brpm_input_params.rb +7 -0
- data/modules/docker_brpm/automations/release_brpm_input_params.txt +8 -0
- data/modules/docker_brpm/automations/run_application_container.rb +27 -0
- data/modules/docker_brpm/automations/run_application_container.txt +3 -0
- data/modules/docker_brpm/automations/run_database_container.rb +14 -0
- data/modules/docker_brpm/automations/run_database_container.txt +3 -0
- data/modules/docker_brpm/automations/stop_application_container.rb +11 -0
- data/modules/docker_brpm/automations/stop_application_container.txt +3 -0
- data/modules/docker_brpm/automations/stop_database_container.rb +11 -0
- data/modules/docker_brpm/automations/stop_database_container.txt +3 -0
- data/modules/docker_brpm/automations/test_rest_api.rb +18 -0
- data/modules/docker_brpm/automations/test_rest_api.txt +3 -0
- data/modules/docker_brpm/automations/upgrade_database.rb +19 -0
- data/modules/docker_brpm/automations/upgrade_database.txt +8 -0
- data/modules/docker_brpm/config.yml +8 -0
- data/modules/docker_brpm/lib/docker.rb +39 -0
- data/modules/docker_brpm/lib/git.rb +16 -0
- data/modules/docker_brpm/sample_applications/dockerizedbrpm.json +0 -0
- data/modules/email/automations/send_notification.rb +48 -0
- data/modules/email/automations/send_notification.txt +27 -0
- data/modules/email/config.yml +6 -0
- data/modules/framework/automations/direct_execute.rb +10 -0
- data/modules/framework/automations/direct_execute.txt +16 -0
- data/modules/framework/automations/install_module.rb +13 -0
- data/modules/framework/automations/install_module.txt +16 -0
- data/modules/framework/bin/brpm_install +106 -0
- data/modules/framework/bin/event_handler +63 -0
- data/modules/framework/bin/webhook_receiver +49 -0
- data/modules/framework/brpm_auto.rb +307 -0
- data/modules/framework/brpm_framework.rb +88 -0
- data/modules/framework/brpm_script_executor.rb +146 -0
- data/modules/framework/config.yml +7 -0
- data/modules/framework/config/customer_include.rb +26 -0
- data/modules/framework/config/server.yml +3 -0
- data/modules/framework/customer_include_default.rb +25 -0
- data/modules/framework/lib/logging/brpm_logger.rb +39 -0
- data/modules/framework/lib/logging/logger_base.rb +36 -0
- data/modules/framework/lib/logging/simple_logger.rb +27 -0
- data/modules/framework/lib/params/all_params.rb +80 -0
- data/modules/framework/lib/params/integration_settings.rb +27 -0
- data/modules/framework/lib/params/params.rb +172 -0
- data/modules/framework/lib/params/params_base.rb +81 -0
- data/modules/framework/lib/params/request_params.rb +38 -0
- data/modules/framework/lib/resource_framework.rb +211 -0
- data/modules/framework/lib/rest_api.rb +155 -0
- data/modules/framework/lib/semaphore.rb +79 -0
- data/modules/framework/lib/utilities.rb +317 -0
- data/modules/framework/lib/version_control/git.rb +192 -0
- data/modules/framework/lib/version_control/svn.rb +221 -0
- data/modules/framework/log.html +39 -0
- data/modules/framework/tests/all_params_spec.rb +116 -0
- data/modules/framework/tests/brpm_auto_spec.rb +84 -0
- data/modules/framework/tests/customer_include/config/customer_include.rb +10 -0
- data/modules/framework/tests/customer_include/config/server.yml +3 -0
- data/modules/framework/tests/customer_include_spec.rb +29 -0
- data/modules/framework/tests/local_jirb.rb +15 -0
- data/modules/framework/tests/params_spec.rb +172 -0
- data/modules/framework/tests/request_params_spec.rb +86 -0
- data/modules/framework/tests/server_yaml_spec.rb +19 -0
- data/modules/framework/tests/spec_helper.rb +42 -0
- data/modules/framework/transport/dispatch_baa.rb +355 -0
- data/modules/framework/transport/dispatch_base.rb +345 -0
- data/modules/framework/transport/dispatch_nsh.rb +248 -0
- data/modules/framework/transport/dispatch_ssh.rb +154 -0
- data/modules/framework/transport/transport_baa.rb +1095 -0
- data/modules/framework/transport/transport_nsh.rb +359 -0
- data/modules/framework/transport/transport_ssh.rb +220 -0
- data/modules/framework/write_to.rb +1 -0
- data/modules/jenkins/automations/create_release.rb +4 -0
- data/modules/jenkins/automations/create_release.txt +23 -0
- data/modules/jenkins/automations/f2_downloadJenkinsArtifact.rb +126 -0
- data/modules/jenkins/config.yml +7 -0
- data/modules/jenkins/lib/jenkins.rb +300 -0
- data/modules/jenkins/resource_automations/f2_rsc_jenkinsJobs.rb +58 -0
- data/modules/jira/automations/add_comment.rb +4 -0
- data/modules/jira/automations/add_comment.txt +23 -0
- data/modules/jira/automations/create_release.rb +4 -0
- data/modules/jira/automations/create_release.txt +23 -0
- data/modules/jira/automations/delete_release.rb +4 -0
- data/modules/jira/automations/delete_release.txt +23 -0
- data/modules/jira/automations/transition_issue.rb +4 -0
- data/modules/jira/automations/transition_issue.txt +23 -0
- data/modules/jira/automations/transition_issues_for_request.rb +29 -0
- data/modules/jira/automations/transition_issues_for_request.txt +20 -0
- data/modules/jira/automations/transition_issues_for_run.rb +26 -0
- data/modules/jira/automations/transition_issues_for_run.txt +20 -0
- data/modules/jira/automations/update_release.rb +4 -0
- data/modules/jira/automations/update_release.txt +26 -0
- data/modules/jira/config.yml +7 -0
- data/modules/jira/lib/jira_rest_client.rb +185 -0
- data/modules/jira/tests/create_read_update_delete_release_spec.rb +39 -0
- data/modules/jira/tests/spec_helper.rb +39 -0
- data/modules/jira/tests/transition_issue_spec.rb +32 -0
- data/modules/patch_process_management/automations/execute_job/script.rb +105 -0
- data/modules/patch_process_management/automations/execute_job/wrapper.txt +39 -0
- data/modules/patch_process_management/automations/patch_analysis/script.rb +107 -0
- data/modules/patch_process_management/automations/patch_analysis/wrapper.txt +33 -0
- data/modules/patch_process_management/automations/patch_readiness/script.rb +89 -0
- data/modules/patch_process_management/automations/patch_readiness/wrapper.txt +33 -0
- data/modules/patch_process_management/automations/patch_remediation/script.rb +217 -0
- data/modules/patch_process_management/automations/patch_remediation/wrapper.txt +40 -0
- data/modules/patch_process_management/config.yml +10 -0
- data/modules/teamcity/automations/trigger_build.rb +4 -0
- data/modules/teamcity/automations/trigger_build.txt +14 -0
- data/modules/teamcity/config.yml +7 -0
- data/modules/teamcity/lib/teamcity_rest_client.rb +17 -0
- data/modules/teamcity/tests/spec_helper.rb +34 -0
- data/modules/teamcity/tests/trigger_build_spec.rb +27 -0
- data/modules/windows/automations/deploy_directory_over_windows_shares/script.rb +87 -0
- data/modules/windows/automations/deploy_directory_over_windows_shares/wrapper.txt +29 -0
- data/modules/windows/automations/deploy_file_over_windows_shares/script.rb +31 -0
- data/modules/windows/automations/deploy_file_over_windows_shares/wrapper.txt +24 -0
- data/modules/windows/config.yml +6 -0
- data/modules/windows/lib/samba.rb +29 -0
- metadata +397 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
###
|
2
|
+
# job_status:
|
3
|
+
# name: Job Status
|
4
|
+
# type: out-text
|
5
|
+
# position: A1:C1
|
6
|
+
# results_summary:
|
7
|
+
# name: Summary
|
8
|
+
# type: out-text
|
9
|
+
# position: A2:E2
|
10
|
+
# results:
|
11
|
+
# name: Checks
|
12
|
+
# type: out-table
|
13
|
+
# position: A3:E3
|
14
|
+
# results_link:
|
15
|
+
# name: Link
|
16
|
+
# type: out-file
|
17
|
+
# position: A4:E4
|
18
|
+
###
|
19
|
+
|
20
|
+
#=== BMC Application Automation Integration Server: BladeLogic on C4 ===#
|
21
|
+
# [integration_id=6]
|
22
|
+
#=== End ===#
|
23
|
+
|
24
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
25
|
+
|
26
|
+
params["direct_execute"] = true
|
27
|
+
|
28
|
+
params["SS_integration_dns"] = SS_integration_dns
|
29
|
+
params["SS_integration_username"] = SS_integration_username
|
30
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
31
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
32
|
+
|
33
|
+
BrpmScriptExecutor.execute_automation_script("patch_process_management", "patch_readiness", params)
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'uri'
|
3
|
+
require 'base64'
|
4
|
+
require 'csv'
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
def retrieve_results(job, results_full_path, session_id, params)
|
8
|
+
BrpmAuto.log("Removing trailing csv files in case this is a re-run...")
|
9
|
+
`rm -f #{params["SS_output_dir"]}/*_result.csv`
|
10
|
+
|
11
|
+
BrpmAuto.log("Retrieving the job run id from the job run key...")
|
12
|
+
job_run_id = JobRun.get_deploy_job_max_run_id(session_id, {:db_key_of_deploy_job => job["db_key"]})
|
13
|
+
|
14
|
+
BrpmAuto.log("Retrieving the results from the job run id...")
|
15
|
+
return_data = Utility.export_deploy_script_run(session_id, {
|
16
|
+
:job_group_name => job["group_name"],
|
17
|
+
:job_name => job["name"],
|
18
|
+
:run_id => job_run_id,
|
19
|
+
:export_file_name => results_full_path})
|
20
|
+
results_content = Base64.decode64(return_data)
|
21
|
+
|
22
|
+
File.open(results_full_path, "w") do |f|
|
23
|
+
f.puts(results_content)
|
24
|
+
end
|
25
|
+
|
26
|
+
BrpmAuto.log("Parsing the results...")
|
27
|
+
# As this export contains "embedded" double quotes it is not possible to parse it with the CSV library
|
28
|
+
log_lines = results_content.split("\n")[6..-1]
|
29
|
+
log_lines.select! { |log| !log.start_with?("run level log,") }
|
30
|
+
|
31
|
+
logs = log_lines.map do |log_line|
|
32
|
+
log_items = log_line.split(",",7)
|
33
|
+
|
34
|
+
# 0: server
|
35
|
+
# 1: phase
|
36
|
+
# 2: attempt
|
37
|
+
# 3: date part 1
|
38
|
+
# 4: date part 2
|
39
|
+
# 5: Info - Warning - Error
|
40
|
+
# 6: message
|
41
|
+
|
42
|
+
if log_items.count < 7 # Some lines are broken in two because of end-of-lines appearing in the message field...
|
43
|
+
nil
|
44
|
+
else
|
45
|
+
log_items[6] = log_items[6].tr(",,","")
|
46
|
+
log_items[3] = DateTime.parse("#{log_items[3]},#{log_items[4]}")
|
47
|
+
|
48
|
+
log_items
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
logs.compact # removing the possible nils from the array
|
53
|
+
end
|
54
|
+
|
55
|
+
brpm_rest_client = BrpmRestClient.new
|
56
|
+
params = BrpmAuto.params
|
57
|
+
request_params = BrpmAuto.request_params
|
58
|
+
|
59
|
+
raise "No job key found for a Patch Analysis job. A Patch Analysis job must be executed before a Patch Remediation job." if !request_params.has_key?("patch_analysis_job_run_key") or request_params["patch_analysis_job_run_key"].nil?
|
60
|
+
|
61
|
+
bsa_base_url = params["SS_integration_dns"]
|
62
|
+
bsa_username = params["SS_integration_username"]
|
63
|
+
bsa_password = decrypt_string_with_prefix(params["SS_integration_password_enc"])
|
64
|
+
bsa_role = params["SS_integration_details"]["role"]
|
65
|
+
|
66
|
+
phase = params["phase_list"].index(params["phase"].strip)
|
67
|
+
|
68
|
+
patch_remediation_depot_group = "/#{params["application"].downcase}/remediation"
|
69
|
+
|
70
|
+
patch_remediation_job_root_path = "/#{params["application"].downcase}/remediation"
|
71
|
+
patch_remediation_job_runs_path = "#{patch_remediation_job_root_path}/runs"
|
72
|
+
patch_remediation_job_group = "#{phase}-job-#{params["request_id"]}-#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
73
|
+
patch_remediation_job_name = "#{phase}-job"
|
74
|
+
patch_remediation_job_run_path = "#{patch_remediation_job_runs_path}/#{patch_remediation_job_group}"
|
75
|
+
|
76
|
+
patch_remediation_job_template_group = patch_remediation_job_root_path
|
77
|
+
patch_remediation_job_template_name = "#{phase}-job-template"
|
78
|
+
|
79
|
+
BrpmAuto.log("Logging on to Bladelogic instance #{BsaSoapClient.get_url} with user #{BsaSoapClient.get_username} and role #{BsaSoapClient.get_role}...")
|
80
|
+
session_id = BsaSoapClient.login
|
81
|
+
|
82
|
+
BrpmAuto.log("Retrieving the job key of the Patch Remediation #{phase} job template...")
|
83
|
+
job_template_db_key = DeployJob.get_dbkey_by_group_and_name(session_id, {:group_name => patch_remediation_job_template_group, :job_name => patch_remediation_job_template_name})
|
84
|
+
|
85
|
+
BrpmAuto.log("Creating a new folder for the Patch Remediation #{phase} job...")
|
86
|
+
JobGroup.create_group_with_parent_name(session_id, {:group_name => patch_remediation_job_group, :parent_group_name => patch_remediation_job_runs_path})
|
87
|
+
|
88
|
+
unless phase == "commit"
|
89
|
+
wait_time = 30
|
90
|
+
start_time = Time.now + wait_time
|
91
|
+
BrpmAuto.log("Scheduling the #{phase} phase of the Patch Remediation #{phase} job template to start in #{wait_time} seconds (at #{start_time.strftime("%Y-%m-%d %H:%M:%S")})...")
|
92
|
+
DeployJob.set_phase_schedule_by_dbkey(session_id, {
|
93
|
+
:job_run_key => job_template_db_key,
|
94
|
+
:simulate_type => "AtTime",
|
95
|
+
:simulate_date => start_time.strftime("%Y-%m-%d %H:%M:%S"),
|
96
|
+
:stage_type => "AfterPreviousPhase",
|
97
|
+
:stage_date => "",
|
98
|
+
:commit_type => phase == "commit" ? "AfterPreviousPhase" : "NotScheduled",
|
99
|
+
:commit_date => ""})
|
100
|
+
end
|
101
|
+
|
102
|
+
BrpmAuto.log("Creating the Patch Remediation job #{patch_remediation_job_runs_path}/#{patch_remediation_job_group}/#{patch_remediation_job_name} for Patch Analysis job run key #{request_params["patch_analysis_job_run_key"]}...")
|
103
|
+
job_db_key = PatchRemediationJob.create_remediation_job_with_deploy_opts(session_id, {
|
104
|
+
:remediation_name => patch_remediation_job_name,
|
105
|
+
:job_group_name => patch_remediation_job_run_path,
|
106
|
+
:pa_job_run_key => request_params["patch_analysis_job_run_key"],
|
107
|
+
:pck_prefix => patch_remediation_job_name,
|
108
|
+
:depot_group_name => patch_remediation_depot_group,
|
109
|
+
:dep_job_group_name => patch_remediation_job_run_path,
|
110
|
+
:deploy_job_key => job_template_db_key})
|
111
|
+
|
112
|
+
BrpmAuto.log("Executing the Patch Remediation job...")
|
113
|
+
job_run_key = PatchRemediationJob.execute_job_and_wait(session_id, {:job_key => job_db_key})
|
114
|
+
|
115
|
+
unless phase =="commit"
|
116
|
+
BrpmAuto.log("Polling the Patch Remediation job until it is finished...")
|
117
|
+
begin
|
118
|
+
sleep(wait_time)
|
119
|
+
is_still_running = JobRun.get_job_run_is_running_by_run_key(session_id, {:job_run_key => job_run_key})
|
120
|
+
end while is_still_running
|
121
|
+
BrpmAuto.log("The Patch Remediation job has finished.")
|
122
|
+
end
|
123
|
+
|
124
|
+
BrpmAuto.log("Checking if the Patch Remediation job finished successfully...")
|
125
|
+
had_errors = JobRun.get_job_run_had_errors(session_id, {:job_run_key => job_run_key})
|
126
|
+
|
127
|
+
had_errors ? BrpmAuto.log("WARNING: The Patch Remediation job had errors!") : BrpmAuto.log("The Patch Remediation job had no errors.")
|
128
|
+
pack_response "job_status", had_errors ? "The job had errors" : "The job ran successfully"
|
129
|
+
|
130
|
+
raise "The Patch Remediation job had errors!" if had_errors
|
131
|
+
|
132
|
+
BrpmAuto.log("Retrieving all the generated jobs from group #{patch_remediation_job_run_path}...")
|
133
|
+
jobs = Job.list_all_by_group(session_id, {:group_name => patch_remediation_job_run_path})
|
134
|
+
|
135
|
+
job_names = jobs.split("\n")
|
136
|
+
job_names = job_names.reject{|job| job == patch_remediation_job_name or job.include?(" batch deploy ")}.sort
|
137
|
+
|
138
|
+
BrpmAuto.log("Retrieving the job run keys of the generated jobs...")
|
139
|
+
jobs = {}
|
140
|
+
job_names.each do |job_name|
|
141
|
+
jobs[job_name] = {}
|
142
|
+
jobs[job_name]["name"] = job_name
|
143
|
+
jobs[job_name]["group_name"] = patch_remediation_job_run_path
|
144
|
+
|
145
|
+
BrpmAuto.log("Retrieving the job run key of job #{job_name}...")
|
146
|
+
jobs[job_name]["db_key"] = DeployJob.get_dbkey_by_group_and_name(session_id, {:group_name => patch_remediation_job_run_path, :job_name => job_name})
|
147
|
+
jobs[job_name]["run_key"] = JobRun.find_last_run_key_by_job_key(session_id, {:job_key => jobs[job_name]["db_key"]})
|
148
|
+
end
|
149
|
+
|
150
|
+
BrpmAuto.log("Polling the generated jobs until they are finished...")
|
151
|
+
running_jobs = jobs
|
152
|
+
begin
|
153
|
+
finished_jobs = {}
|
154
|
+
running_jobs.each do |key, job|
|
155
|
+
is_still_running = JobRun.get_job_run_is_running_by_run_key(session_id, {:job_run_key => job["run_key"]})
|
156
|
+
|
157
|
+
unless is_still_running
|
158
|
+
BrpmAuto.log("The job with run key #{job["run_key"]} has finished, retrieving its results...")
|
159
|
+
job["results"] = retrieve_results(job, "#{params["SS_output_dir"]}/#{job["name"]}_result.csv", session_id, params)
|
160
|
+
|
161
|
+
finished_jobs[key] = job
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
running_jobs = running_jobs.reject { |key, job| finished_jobs.has_key?(key) }
|
166
|
+
|
167
|
+
sleep(10) if running_jobs.count > 0
|
168
|
+
end while running_jobs.count > 0
|
169
|
+
|
170
|
+
BrpmAuto.log("Processing the job results into one view...")
|
171
|
+
logs = jobs.values.reduce([]){ |results,job| results + job["results"] }
|
172
|
+
|
173
|
+
logs = logs.sort_by { |log| [log[0], log[1], log[3]] }
|
174
|
+
|
175
|
+
servers_with_logs = logs.group_by { |log| log[0] }
|
176
|
+
|
177
|
+
failed_servers_with_logs = servers_with_logs.select { |key, value| value.select{|log| log[5] == "Error" }.count > 0}
|
178
|
+
|
179
|
+
pack_response "results_summary", "#{servers_with_logs.count - failed_servers_with_logs.count}/#{servers_with_logs.count} servers were successful"
|
180
|
+
|
181
|
+
table_data = [[' ', 'Server', 'Simulate', 'Stage', 'Commit']]
|
182
|
+
counter = 0
|
183
|
+
servers_with_logs.each do |key, logs|
|
184
|
+
server = key
|
185
|
+
|
186
|
+
phase_with_logs = logs.group_by { |log| log[1] }
|
187
|
+
|
188
|
+
if phase_with_logs.has_key?("Simulate")
|
189
|
+
simulate = phase_with_logs["Simulate"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
|
190
|
+
else
|
191
|
+
simulate = ""
|
192
|
+
end
|
193
|
+
if phase_with_logs.has_key?("Stage")
|
194
|
+
stage = phase_with_logs["Stage"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
|
195
|
+
else
|
196
|
+
stage = ""
|
197
|
+
end
|
198
|
+
if phase_with_logs.has_key?("Commit")
|
199
|
+
commit = phase_with_logs["Commit"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
|
200
|
+
else
|
201
|
+
commit = ""
|
202
|
+
end
|
203
|
+
|
204
|
+
counter += 1
|
205
|
+
table_data << [counter, server, simulate, stage, commit]
|
206
|
+
end
|
207
|
+
|
208
|
+
pack_response "results", { :perPage => 10, :totalItems => table_data.count - 1, :data => table_data }
|
209
|
+
|
210
|
+
BrpmAuto.log("Concatenating the result files into one file...")
|
211
|
+
results_full_path = "#{params["SS_output_dir"]}/all_jobs_result.csv"
|
212
|
+
|
213
|
+
`cat #{params["SS_output_dir"]}/*_result.csv >> #{results_full_path}`
|
214
|
+
|
215
|
+
pack_response "results_link", results_full_path
|
216
|
+
|
217
|
+
raise "The Patch Remediation job had errors!" if had_errors
|
@@ -0,0 +1,40 @@
|
|
1
|
+
###
|
2
|
+
# phase:
|
3
|
+
# name: Phase
|
4
|
+
# type: in-list-single
|
5
|
+
# list_pairs: stage,Stage|commit,Stage (if necessary) + Commit
|
6
|
+
# position: A1:C1
|
7
|
+
# job_status:
|
8
|
+
# name: Job Status
|
9
|
+
# type: out-text
|
10
|
+
# position: A1:C1
|
11
|
+
# results_summary:
|
12
|
+
# name: Summary
|
13
|
+
# type: out-text
|
14
|
+
# position: A2:E2
|
15
|
+
# results:
|
16
|
+
# name: Installs
|
17
|
+
# type: out-table
|
18
|
+
# position: A3:E3
|
19
|
+
# results_link:
|
20
|
+
# name: Link
|
21
|
+
# type: out-file
|
22
|
+
# position: A4:E4
|
23
|
+
###
|
24
|
+
|
25
|
+
#=== BMC Application Automation Integration Server: BladeLogic on C4 ===#
|
26
|
+
# [integration_id=6]
|
27
|
+
#=== End ===#
|
28
|
+
|
29
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
30
|
+
|
31
|
+
params["direct_execute"] = true
|
32
|
+
|
33
|
+
params["SS_integration_dns"] = SS_integration_dns
|
34
|
+
params["SS_integration_username"] = SS_integration_username
|
35
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
36
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
37
|
+
|
38
|
+
params["phase_list"] = { "stage" => "Stage", "commit" => "Stage (if necessary) + Commit" }
|
39
|
+
|
40
|
+
BrpmScriptExecutor.execute_automation_script("patch_process_management", "patch_remediation", params)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#=== BMC Application Automation Integration Server: TeamCity ===#
|
2
|
+
# [integration_id=xxxxxxxx]
|
3
|
+
#=== End ===#
|
4
|
+
|
5
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
6
|
+
|
7
|
+
params["direct_execute"] = "true"
|
8
|
+
|
9
|
+
params["SS_integration_dns"] = SS_integration_dns
|
10
|
+
params["SS_integration_username"] = SS_integration_username
|
11
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
12
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
13
|
+
|
14
|
+
BrpmScriptExecutor.execute_automation_script("teamcity", "trigger_build", params)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class TeamcityRestClient
|
5
|
+
def initialize(integration_settings = BrpmAuto.integration_settings)
|
6
|
+
@url = integration_settings.dns
|
7
|
+
@username = integration_settings.username
|
8
|
+
@password = integration_settings.password
|
9
|
+
|
10
|
+
@api_url = "#{@url}/rest/api"
|
11
|
+
end
|
12
|
+
|
13
|
+
def trigger_build(application, component)
|
14
|
+
data = {:application => application, :component => component}
|
15
|
+
Rest.post("#{@api_url}/build", data)["response"]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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( { "output_dir" => "/tmp/brpm_content" }.merge!(get_integration_params_for_jira) )
|
8
|
+
|
9
|
+
BrpmAuto.require_module "brpm"
|
10
|
+
BrpmAuto.require_module "teamcity"
|
11
|
+
|
12
|
+
@teamcity_rest_client = TeamcityRestClient.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_default_params
|
16
|
+
params = {}
|
17
|
+
params['also_log_to_console'] = 'true'
|
18
|
+
|
19
|
+
params['brpm_url'] = 'http://brpm-content.pulsar-it.be:8088/brpm'
|
20
|
+
params['brpm_api_token'] = ENV["BRPM_API_TOKEN"]
|
21
|
+
|
22
|
+
params['output_dir'] = "/tmp/brpm_content"
|
23
|
+
|
24
|
+
params
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_integration_params_for_teamcity
|
28
|
+
params = {}
|
29
|
+
params["SS_integration_dns"] = 'http://brpm.pulsar-it.be:6060'
|
30
|
+
params["SS_integration_username"] = 'brpm'
|
31
|
+
params["SS_integration_password"] = ENV["TEAMCITY_PASSWORD"]
|
32
|
+
|
33
|
+
params
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe 'trigger build' do
|
4
|
+
before(:all) do
|
5
|
+
setup_brpm_auto
|
6
|
+
end
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
#cleanup_release('TeamCity tests - release 1')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '' do
|
13
|
+
it 'should trigger a build in TeamCity' do
|
14
|
+
params = get_default_params
|
15
|
+
params = params.merge(get_integration_params_for_teamcity)
|
16
|
+
|
17
|
+
params["application"] = 'E-Finance'
|
18
|
+
params["application"] = 'EF - java calculation engine'
|
19
|
+
BrpmScriptExecutor.execute_automation_script("teamcity", "trigger_build", params)
|
20
|
+
|
21
|
+
#verify the tests: check if the build was triggered succesfully
|
22
|
+
#build = @teamcity_rest_client.get_build(...)
|
23
|
+
#expect(build).not_to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "windows/lib/samba"
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
params = BrpmAuto.params
|
5
|
+
|
6
|
+
raise "Repo directory is not provided" if params["repo_directory"].empty?
|
7
|
+
repo_directory = BrpmAuto.substitute_tokens(params["repo_directory"])
|
8
|
+
|
9
|
+
raise "Repo directory is not provided" if params["repo_directory"].empty?
|
10
|
+
target_server_directory = BrpmAuto.substitute_tokens(params["target_server_directory"])
|
11
|
+
|
12
|
+
temp_directory = "#{params["SS_output_dir"]}/package"
|
13
|
+
|
14
|
+
FileUtils.rm_rf(temp_directory) if File.exists?(temp_directory)
|
15
|
+
Dir.mkdir(temp_directory)
|
16
|
+
|
17
|
+
if params["SS_integration_dns"].nil?
|
18
|
+
repo_server_name = params["repo_server_name"]
|
19
|
+
repo_server_share = params["repo_server_share"]
|
20
|
+
repo_server_username = params["repo_server_username"]
|
21
|
+
repo_server_password = params["repo_server_password"]
|
22
|
+
else
|
23
|
+
repo_server_name = params["SS_integration_dns"]
|
24
|
+
repo_server_share = params["SS_integration_details"]["share"]
|
25
|
+
repo_server_username = params["SS_integration_username"]
|
26
|
+
repo_server_password = decrypt_string_with_prefix(params["SS_integration_password_enc"]) unless params["SS_integration_password_enc"].empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
BrpmAuto.log("Getting directory #{repo_directory} from the repo...")
|
30
|
+
smbclient_get_directory(
|
31
|
+
repo_server_name,
|
32
|
+
repo_server_share,
|
33
|
+
repo_server_username,
|
34
|
+
repo_server_password,
|
35
|
+
repo_directory,
|
36
|
+
temp_directory
|
37
|
+
)
|
38
|
+
|
39
|
+
unless params["param_substitution_file_list"].empty?
|
40
|
+
BrpmAuto.log("Substituting params in the indicated files...")
|
41
|
+
file_paths = params["param_substitution_file_list"].split(";")
|
42
|
+
file_paths.each do|file_path|
|
43
|
+
file_absolute_path = "#{temp_directory}/#{file_path}"
|
44
|
+
unless File.exists?(file_absolute_path)
|
45
|
+
BrpmAuto.log("File #{file_absolute_path} doesn't exist, continuing...")
|
46
|
+
next
|
47
|
+
end
|
48
|
+
|
49
|
+
BrpmAuto.log("Substituting params in file #{file_path}...")
|
50
|
+
file_content = File.read(file_absolute_path)
|
51
|
+
substituted_file_content = BrpmAuto.substitute_tokens(file_content)
|
52
|
+
File.open(file_absolute_path, "w") {|file| file.puts substituted_file_content}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
unless params["exclude_file_list"].empty?
|
57
|
+
BrpmAuto.log("Excluding the indicated files...")
|
58
|
+
file_paths = params["exclude_file_list"].split(";")
|
59
|
+
file_paths.each do|file_path|
|
60
|
+
file_absolute_path = "#{temp_directory}/#{file_path}"
|
61
|
+
if File.exists?(file_absolute_path)
|
62
|
+
BrpmAuto.log("Deleting file #{file_path}...")
|
63
|
+
file_content = File.delete(file_absolute_path)
|
64
|
+
else
|
65
|
+
BrpmAuto.log("File #{file_absolute_path} doesn't exist, continuing...")
|
66
|
+
next
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
BrpmAuto.log("Getting the list of target servers...")
|
72
|
+
BrpmAuto.log("Found #{BrpmAuto.params.servers.count} servers.")
|
73
|
+
|
74
|
+
BrpmAuto.params.servers.each do |server|
|
75
|
+
BrpmAuto.log("Putting directory #{repo_directory} onto server #{server[0]} (//#{server[1]["ip_address"]}/#{server[1]["deploy_share_name"]})...")
|
76
|
+
smbclient_put_directory(
|
77
|
+
server[1]["ip_address"],
|
78
|
+
server[1]["deploy_share_name"],
|
79
|
+
server[1]["deploy_share_username"],
|
80
|
+
server[1]["deploy_share_password"],
|
81
|
+
target_server_directory,
|
82
|
+
temp_directory
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
BrpmAuto.log("Cleaning up the directory locally...")
|
87
|
+
FileUtils.rm_rf(temp_directory)
|