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,30 @@
|
|
1
|
+
brpm_rest_client = BrpmRestClient.new
|
2
|
+
params = BrpmAuto.params
|
3
|
+
request_params = BrpmAuto.request_params
|
4
|
+
|
5
|
+
new_request_params = {}
|
6
|
+
new_request_params["calling_request"] = params["SS_request_number"]
|
7
|
+
new_request_params["jenkins_job"] = params["jenkins_job"]
|
8
|
+
|
9
|
+
BrpmAuto.log "Creating a new request from template 'Execute test run in Jenkins' for test run #{new_request_params["jenkins_job"]} and BRPM v#{request_params["application_version"]} ..."
|
10
|
+
new_request = brpm_rest_client.create_request_for_plan_from_template(
|
11
|
+
params["request_plan_id"].to_i,
|
12
|
+
params["new_request_stage"],
|
13
|
+
"Execute test run in Jenkins",
|
14
|
+
"Execute test run #{new_request_params["jenkins_job"]} in Jenkins for BRPM v#{request_params["application_version"]}",
|
15
|
+
params["new_request_environment"],
|
16
|
+
false, #execute_now
|
17
|
+
new_request_params
|
18
|
+
)
|
19
|
+
|
20
|
+
BrpmAuto.log "Setting the version number of the steps that are linked to component 'Application' to #{request_params["application_version"]} ... "
|
21
|
+
brpm_rest_client.set_version_tag_of_steps_for_component(new_request, "Application", request_params["application_version"])
|
22
|
+
|
23
|
+
BrpmAuto.log "Planning the request ... "
|
24
|
+
brpm_rest_client.plan_request(new_request["id"])
|
25
|
+
|
26
|
+
BrpmAuto.log "Starting the request ... "
|
27
|
+
brpm_rest_client.start_request(new_request["id"])
|
28
|
+
|
29
|
+
BrpmAuto.log "Waiting until the request has finished ..."
|
30
|
+
brpm_rest_client.monitor_request(new_request["id"], { :max_time => 20*60, :checking_interval => params["checking_interval"] })
|
@@ -0,0 +1,14 @@
|
|
1
|
+
###
|
2
|
+
# jenkins_job:
|
3
|
+
# name: jenkins_job
|
4
|
+
# required: yes
|
5
|
+
# new_request_stage:
|
6
|
+
# name: new_request_stage
|
7
|
+
# required: yes
|
8
|
+
# new_request_environment:
|
9
|
+
# name: new_request_environment
|
10
|
+
# required: yes
|
11
|
+
###
|
12
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
13
|
+
|
14
|
+
BrpmScriptExecutor.execute_automation_script("docker_brpm", "launch_test_run_request", params)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
###
|
2
|
+
# brpm_version:
|
3
|
+
# name: brpm_version
|
4
|
+
# required: no
|
5
|
+
###
|
6
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
7
|
+
|
8
|
+
BrpmScriptExecutor.execute_automation_script("docker_brpm", "release_brpm_input_params", params)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
if request_params.has_key?("application_version")
|
5
|
+
application_version = request_params["application_version"]
|
6
|
+
else
|
7
|
+
application_version = params["step_version"]
|
8
|
+
end
|
9
|
+
|
10
|
+
if request_params.has_key?("instance_name")
|
11
|
+
environment = request_params["instance_name"]
|
12
|
+
else
|
13
|
+
environment = params["SS_environment"]
|
14
|
+
end
|
15
|
+
|
16
|
+
if request_params.has_key?("port")
|
17
|
+
port = request_params["port"]
|
18
|
+
else
|
19
|
+
port = params["port"]
|
20
|
+
end
|
21
|
+
raise("No port specified.") if port.nil?
|
22
|
+
|
23
|
+
BrpmAuto.log "Stopping dependent docker containers if necessary ..."
|
24
|
+
stop_running_containers_if_necessary(["brpm_#{environment}"])
|
25
|
+
|
26
|
+
BrpmAuto.log "Running the application container ..."
|
27
|
+
run_docker_command("run -d --restart=always -p #{port}:8080 --link brpm_db_#{environment}:db --name brpm_#{environment} bmc_devops/brpm:v#{application_version}")
|
@@ -0,0 +1,14 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
if request_params.has_key?("instance_name")
|
5
|
+
environment = request_params["instance_name"]
|
6
|
+
else
|
7
|
+
environment = params["SS_environment"]
|
8
|
+
end
|
9
|
+
|
10
|
+
BrpmAuto.log "Stopping dependent docker containers if necessary ..."
|
11
|
+
stop_running_containers_if_necessary(["brpm_#{environment}", "brpm_db_#{environment}"])
|
12
|
+
|
13
|
+
BrpmAuto.log "Running the database container ..."
|
14
|
+
run_docker_command("run -d --restart=always -v /home/ubuntu/docker_data/brpm_db_#{environment}:/var/lib/pgsql/data --name brpm_db_#{environment} bmc_devops/brpm_db:v1.0.0")
|
@@ -0,0 +1,11 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
if request_params.has_key?("instance_name")
|
5
|
+
environment = request_params["instance_name"]
|
6
|
+
else
|
7
|
+
environment = params["SS_environment"]
|
8
|
+
end
|
9
|
+
|
10
|
+
BrpmAuto.log "Stopping application container ..."
|
11
|
+
stop_running_containers_if_necessary(["brpm_#{environment}"])
|
@@ -0,0 +1,11 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
if request_params.has_key?("instance_name")
|
5
|
+
environment = request_params["instance_name"]
|
6
|
+
else
|
7
|
+
environment = params["SS_environment"]
|
8
|
+
end
|
9
|
+
|
10
|
+
BrpmAuto.log "Stopping the database container ..."
|
11
|
+
stop_running_containers_if_necessary(["brpm_db_#{environment}"])
|
@@ -0,0 +1,18 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
ENV["DOCKER_HOST"] = get_docker_host_name
|
5
|
+
ENV["BRPM_PORT"] = params["port"]
|
6
|
+
ENV["BRPM_API_TOKEN"] = params["api_token"]
|
7
|
+
|
8
|
+
BrpmAuto.log "Running the tests ..."
|
9
|
+
BrpmAuto.execute_shell("#{params["local_debug"] == 'true' ? "" : "jruby -S"} rspec #{File.dirname(__FILE__)}/../spec --format html --out #{params["SS_output_dir"]}/rspec_results.html")
|
10
|
+
|
11
|
+
BrpmAuto.log "Storing the test results url ..."
|
12
|
+
output_dir = params["SS_output_dir"].slice(params["SS_output_dir"].index("automation_results")..-1)
|
13
|
+
|
14
|
+
test_results_url = "#{params["SS_base_url"]}/#{output_dir}/rspec_results.html"
|
15
|
+
|
16
|
+
request_params["test_results_url"] = test_results_url
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
params = BrpmAuto.params
|
2
|
+
request_params = BrpmAuto.request_params
|
3
|
+
|
4
|
+
if request_params.has_key?("application_version")
|
5
|
+
application_version = request_params["application_version"]
|
6
|
+
else
|
7
|
+
application_version = params["step_version"]
|
8
|
+
end
|
9
|
+
|
10
|
+
if request_params.has_key?("instance_name")
|
11
|
+
environment = request_params["instance_name"]
|
12
|
+
else
|
13
|
+
environment = params["SS_environment"]
|
14
|
+
end
|
15
|
+
|
16
|
+
BrpmAuto.log "Upgrading the database ..."
|
17
|
+
run_docker_command("run --rm --link brpm_db_#{environment}:db bmc_devops/brpm:v#{application_version} /source-files/upgradedatabase.sh")
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
###
|
2
|
+
# overwrite_existing_data:
|
3
|
+
# name: overwrite_existing_data
|
4
|
+
# required: no
|
5
|
+
###
|
6
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
7
|
+
|
8
|
+
BrpmScriptExecutor.execute_automation_script("docker_brpm", "upgrade_database", params)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
def get_docker_server_name
|
2
|
+
"Docker"
|
3
|
+
end
|
4
|
+
|
5
|
+
def get_docker_host_name
|
6
|
+
@docker_host_name ||= BrpmAuto.params.servers[get_docker_server_name]["dns"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def run_docker_command(command, ignore_error=false)
|
10
|
+
complete_command = "docker -H tcp://#{get_docker_host_name()}:4243 #{command} 2>&1"
|
11
|
+
|
12
|
+
BrpmAuto.log complete_command
|
13
|
+
output = `#{complete_command}`
|
14
|
+
BrpmAuto.log "\toutput: #{output}"
|
15
|
+
|
16
|
+
exit_status = $?.exitstatus
|
17
|
+
unless exit_status == 0
|
18
|
+
message = "The docker command exited with #{exit_status}."
|
19
|
+
if ignore_error
|
20
|
+
BrpmAuto.log "\t#{message}"
|
21
|
+
else
|
22
|
+
raise(message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
output
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_docker_command_and_ignore_error(command)
|
30
|
+
run_docker_command(command, true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stop_running_containers_if_necessary(container_names_to_be_stopped)
|
34
|
+
container_names_to_be_stopped.each do |container_name|
|
35
|
+
BrpmAuto.log "Stopping and removing container #{container_name} ..."
|
36
|
+
run_docker_command("stop #{container_name}", true)
|
37
|
+
run_docker_command("rm #{container_name}", true)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
def clone_git_repo(git_repo_name, output_dir)
|
2
|
+
BrpmAuto.log "Downloading the git repository for the application ..."
|
3
|
+
|
4
|
+
root_git_repo_dir = "#{output_dir}/git_repos"
|
5
|
+
|
6
|
+
FileUtils.rm_r(root_git_repo_dir) if Dir.exists?(root_git_repo_dir)
|
7
|
+
|
8
|
+
Dir.mkdir(root_git_repo_dir)
|
9
|
+
|
10
|
+
git_repo_dir = "#{root_git_repo_dir}/#{git_repo_name}"
|
11
|
+
Dir.mkdir(git_repo_dir)
|
12
|
+
|
13
|
+
BrpmAuto.exec_command("git clone https://github.com/brpm-dev/#{git_repo_name}.git #{git_repo_dir}")
|
14
|
+
|
15
|
+
git_repo_dir
|
16
|
+
end
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'mail'
|
2
|
+
|
3
|
+
brpm_rest_client = BrpmRestClient.new
|
4
|
+
params = BrpmAuto.params
|
5
|
+
request_params = BrpmAuto.request_params
|
6
|
+
|
7
|
+
smtp_server = params["SS_integration_dns"]
|
8
|
+
smtp_server_address = smtp_server.split(":")[0]
|
9
|
+
smtp_server_port = smtp_server.split(":")[1] || "25"
|
10
|
+
username = params["SS_integration_username"]
|
11
|
+
password = decrypt_string_with_prefix(params["SS_integration_password_enc"]) unless params["SS_integration_password_enc"].empty?
|
12
|
+
from_address = params["SS_integration_details"]["from"]
|
13
|
+
domain = params["SS_integration_details"]["domain"]
|
14
|
+
|
15
|
+
options = {}
|
16
|
+
options[:address] = smtp_server_address
|
17
|
+
options[:port] = smtp_server_port
|
18
|
+
options[:domain] = domain
|
19
|
+
options[:enable_starttls_auto] = false
|
20
|
+
unless password.empty?
|
21
|
+
options[:user_name] = username
|
22
|
+
options[:password] = password
|
23
|
+
options[:authentication] = 'plain'
|
24
|
+
options[:enable_starttls_auto] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
Mail.defaults do
|
28
|
+
delivery_method :smtp, options
|
29
|
+
end
|
30
|
+
|
31
|
+
recipient_first_name = params["recipient_name"].split(",").last.strip
|
32
|
+
recipient_last_name = params["recipient_name"].split(",").first.strip
|
33
|
+
user = brpm_rest_client.get_user_by_name(recipient_first_name, recipient_last_name)
|
34
|
+
recipient_email_address = user["email"]
|
35
|
+
|
36
|
+
all_params = params.merge(request_params)
|
37
|
+
subject = BrpmAuto.substitute_tokens(params["subject"], all_params)
|
38
|
+
body = BrpmAuto.substitute_tokens(params["body"].gsub('\n', "\n"), all_params)
|
39
|
+
|
40
|
+
BrpmAuto.log "Sending notification to #{user["first_name"]} #{user["last_name"]} '#{subject}' ..."
|
41
|
+
Mail.deliver do
|
42
|
+
to recipient_email_address
|
43
|
+
from from_address
|
44
|
+
subject subject
|
45
|
+
body body
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
###
|
2
|
+
# recipient_name:
|
3
|
+
# name: Recipient
|
4
|
+
# type: in-user-single-select
|
5
|
+
# position: A1:C1
|
6
|
+
# subject:
|
7
|
+
# name: Subject
|
8
|
+
# position: A2:D2
|
9
|
+
# body:
|
10
|
+
# name: Body
|
11
|
+
# position: A3:F3
|
12
|
+
###
|
13
|
+
|
14
|
+
#=== BMC Application Automation Integration Server: Smtp server ===#
|
15
|
+
# [integration_id=8]
|
16
|
+
#=== End ===#
|
17
|
+
|
18
|
+
params["direct_execute"] = "true"
|
19
|
+
|
20
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
21
|
+
|
22
|
+
params["SS_integration_dns"] = SS_integration_dns
|
23
|
+
params["SS_integration_username"] = SS_integration_username
|
24
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
25
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
26
|
+
|
27
|
+
BrpmScriptExecutor.execute_automation_script("email", "send_notification", params)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
@p = BrpmAuto.all_params
|
2
|
+
|
3
|
+
result = run_command(@p, @p.get("command"),"")
|
4
|
+
|
5
|
+
# Apply success or failure criteria
|
6
|
+
if result.include?(@p.get("success"))
|
7
|
+
BrpmAuto.log "Success - found term: #{@p.get("success")}\n"
|
8
|
+
else
|
9
|
+
BrpmAuto.log "Command_Failed - term not found: [#{@p.get("success")}]\n"
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
###
|
2
|
+
# command:
|
3
|
+
# name: command to run
|
4
|
+
# position: A1:F1
|
5
|
+
# type: in-text
|
6
|
+
# success:
|
7
|
+
# name: term to indicate success
|
8
|
+
# position: A2:D2
|
9
|
+
# type: in-text
|
10
|
+
###
|
11
|
+
|
12
|
+
require "#{ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-#{ENV["BRPM_CONTENT_VERSION"] || "latest"}/modules/framework/brpm_script_executor.rb"
|
13
|
+
|
14
|
+
params["direct_execute"] = "true"
|
15
|
+
|
16
|
+
BrpmScriptExecutor.execute_automation_script("framework", "direct_execute", params)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
BrpmAuto.params["name"]
|
2
|
+
BrpmAuto.params["version"]
|
3
|
+
|
4
|
+
version_flag = ""
|
5
|
+
if BrpmAuto.params["version"] and ! BrpmAuto.params["version"].empty?
|
6
|
+
version_flag = " -v #{BrpmAuto.params["version"]}"
|
7
|
+
end
|
8
|
+
|
9
|
+
result = BrpmAuto.execute_shell("export GEM_HOME=${BRPM_CONTENT_HOME:-$BRPM_HOME/modules} && gem install #{BrpmAuto.params["name"]} #{version_flag}")
|
10
|
+
BrpmAuto.log result["stdout"] if result["stdout"] and ! result["stdout"].empty?
|
11
|
+
unless result["status"] == 0
|
12
|
+
raise result["stderr"]
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
###
|
2
|
+
# name:
|
3
|
+
# name: name
|
4
|
+
# type: in-text
|
5
|
+
# required: yes
|
6
|
+
# version:
|
7
|
+
# name: version
|
8
|
+
# type: in-text
|
9
|
+
# required: no
|
10
|
+
###
|
11
|
+
|
12
|
+
require "#{ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-#{ENV["BRPM_CONTENT_VERSION"] || "latest"}/modules/framework/brpm_script_executor.rb"
|
13
|
+
|
14
|
+
params["direct_execute"] = "true"
|
15
|
+
|
16
|
+
BrpmScriptExecutor.execute_automation_script("framework", "install_module", params)
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require "bundler"
|
4
|
+
require "brpm_auto"
|
5
|
+
require "yaml"
|
6
|
+
|
7
|
+
def install_gem(module_name, module_version)
|
8
|
+
if module_version
|
9
|
+
BrpmAuto.log "Executing command 'gem install #{module_name} -v #{module_version}'..."
|
10
|
+
specs = Gem.install(module_name, module_version)
|
11
|
+
else
|
12
|
+
BrpmAuto.log "Executing command 'gem install #{module_name}'..."
|
13
|
+
specs = Gem.install(module_name)
|
14
|
+
end
|
15
|
+
BrpmAuto.log "Installed gems:"
|
16
|
+
BrpmAuto.log specs.inspect
|
17
|
+
specs
|
18
|
+
end
|
19
|
+
|
20
|
+
def install_bundle_if_necessary(spec)
|
21
|
+
gemfile = File.join(spec.gem_dir, "Gemfile")
|
22
|
+
gemfile_lock = File.join(spec.gem_dir, "Gemfile.lock")
|
23
|
+
|
24
|
+
if File.exists?(gemfile) && File.exists?(gemfile_lock)
|
25
|
+
BrpmAuto.log "Found a Gemfile.lock so executing command 'bundle install --gemfile #{gemfile}'..."
|
26
|
+
# %x(bundle install --gemfile #{gemfile})
|
27
|
+
result = BrpmAuto.execute_shell("bundle install --gemfile #{gemfile}")
|
28
|
+
BrpmAuto.log result["stdout"] if result["stdout"] and ! result["stdout"].empty?
|
29
|
+
unless result["status"] == 0
|
30
|
+
raise result["stderr"]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_symlink_to_brpm_content(brpm_content_spec)
|
36
|
+
if brpm_content_spec.version > Gem::Version.new(BrpmAuto.version)
|
37
|
+
new_version_path = brpm_content_spec.gem_dir
|
38
|
+
symlink_path = "#{ENV["GEM_HOME"]}/gems/brpm_content-latest"
|
39
|
+
|
40
|
+
BrpmAuto.log "A newer version of brpm_content was installed so updating symlink #{symlink_path} to #{new_version_path}..."
|
41
|
+
result = BrpmAuto.execute_shell("ln -sfn #{new_version_path} #{symlink_path}")
|
42
|
+
BrpmAuto.log result["stdout"] if result["stdout"] and ! result["stdout"].empty?
|
43
|
+
unless result["status"] == 0
|
44
|
+
raise result["stderr"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def install_auto_script_wrappers(spec, brpm_url, brpm_api_token)
|
50
|
+
brpm_rest_client = BrpmRestClient.new(brpm_url, brpm_api_token)
|
51
|
+
|
52
|
+
integration_servers = brpm_rest_client.get_integration_servers
|
53
|
+
|
54
|
+
Dir.glob("#{spec.gem_dir}/{automations, resource_automations}/*.rb").each do |auto_script|
|
55
|
+
#TODO: open txt file
|
56
|
+
#TODO: add wrapper code
|
57
|
+
#TODO: set integration server id if necessary
|
58
|
+
|
59
|
+
script = {}
|
60
|
+
brpm_rest_client.create_or_update_script(script)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
if ARGV.size < 1
|
67
|
+
BrpmAuto.log "Missing arguments."
|
68
|
+
BrpmAuto.log "Usage: brpm_install <module name> [<module version>]"
|
69
|
+
end
|
70
|
+
|
71
|
+
module_name = ARGV[0]
|
72
|
+
module_version = ARGV[1]
|
73
|
+
|
74
|
+
params = {}
|
75
|
+
params["log_file"] = "/tmp/brpm_install.log"
|
76
|
+
params["also_log_to_console"] = "true"
|
77
|
+
BrpmAuto.setup(params)
|
78
|
+
|
79
|
+
BrpmAuto.log "Installing module #{module_name} #{module_version.nil? ? "" : module_version}..."
|
80
|
+
|
81
|
+
specs = install_gem(module_name, module_version)
|
82
|
+
module_spec = specs.last
|
83
|
+
|
84
|
+
install_bundle_if_necessary(module_spec)
|
85
|
+
|
86
|
+
if ENV["BRPM_HOME"] and ! ENV["BRPM_HOME"].empty?
|
87
|
+
brpm_content_spec = specs.find { |spec| spec.name == "brpm_content" }
|
88
|
+
update_symlink_to_brpm_content(brpm_content_spec) if brpm_content_spec
|
89
|
+
|
90
|
+
if File.exists?("~/.brpm")
|
91
|
+
config = YAML.load_file("~/.brpm")
|
92
|
+
|
93
|
+
if config["brpm_url"] and config["brpm_api_token"]
|
94
|
+
install_auto_script_wrappers(spec, brpm_url, brpm_api_token)
|
95
|
+
else
|
96
|
+
BrpmAuto.log "Properties brpm_url and/or brpm_api_token don't exist in file ~/.brpm so not installing the automation script wrappers in BRPM. If you want to install them the next time you should add brpm_url and brpm_api_token properties in yaml format in file ~/.brpm."
|
97
|
+
end
|
98
|
+
else
|
99
|
+
BrpmAuto.log "File ~/.brpm doesn't exist so not installing the automation script wrappers in BRPM. If you want to install them the next time you should create this file and add brpm_url and brpm_api_token properties in yaml format."
|
100
|
+
end
|
101
|
+
|
102
|
+
if module_name == "brpm_content"
|
103
|
+
#TODO: cp $CONTENT_REPO_PATH/modules/framework/log.html $BRPM_HOME/automation_results
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|