brpm_module_bladelogic 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDM2YTBiNGMwOTViNzE0ZTQzOTQ2ZTA4NjhjOGZkYzc2ZGEyN2M0Yw==
5
+ data.tar.gz: !binary |-
6
+ YjNlZWFmZmQ4N2Q1YWY4NzYzMzVhOWRlY2U1NzZkZDNlNDA3NjdjMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MDEzYWJlOTRmNjUyN2QwNTYzYTg5ZWNlZGJkMmYyNjk4NTgzZjljYjNkY2I1
10
+ MzM2YjQzMTIwMGYwNmEyYjMxOGQ2NDYyYTc5ZmE3ZjlkZjk0MjZhZWY0MDg3
11
+ MDI0NzQ4N2ZkOTIzNjdmMWE4MjVlN2VhYmYzZWI3NzgxOTUyOGU=
12
+ data.tar.gz: !binary |-
13
+ Y2VhNWZkODAyMjBmMzI1ZWYzZTVhZTdjNzUzMGIwZmZlMjM5NTM3NWMyMzEx
14
+ NDdlOTkxNDk1MmI3ZWFlZDdlZDI3MTBjOGZjOGY4NDZjNjdhMGQ5M2E5ODc3
15
+ MmFiYWYwNzg2N2JmNzBhNmYxMTYzZGMxMTI5MDhjNDY4MTMyOGI=
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ Gemfile.lock
30
+ .ruby-gemset
31
+
32
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
33
+ .rvmrc
34
+
35
+ .DS_Store
36
+
37
+ .idea
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p392
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+
3
+ before_install:
4
+ - gem update --system 2.1.9
5
+
6
+ bundler_args: '' #remove the --deployment flag that causes the gems to be installed in .../1.9.1/...
7
+
8
+ script:
9
+ - rspec tests --format documentation --color
10
+
11
+ notifications:
12
+ email:
13
+ - niek.bartholomeus@gmail.com
14
+
15
+ branches:
16
+ except:
17
+ - /^v[0-9.]*/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 BMC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # BRPM module for Bladelogic
2
+
3
+ [![Build Status](https://travis-ci.org/BMC-RLM/brpm_module_bladelogic.svg?branch=master)](https://travis-ci.org/BMC-RLM/brpm_module_bladelogic)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/brpm_module_bladelogic.png)](http://badge.fury.io/rb/brpm_module_bladelogic)
6
+
7
+ This repository represents an external module for Bladelogic, to be used on top of the [BRPM content repository](https://github.com/BMC-RLM/brpm_content)
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # Copied from https://github.com/mitchellh/vagrant-aws/blob/master/Rakefile
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'rspec/core/rake_task'
5
+
6
+ # Immediately sync all stdout so that tools like buildbot can
7
+ # immediately load in the output.
8
+ $stdout.sync = true
9
+ $stderr.sync = true
10
+
11
+ # Change to the directory of this file.
12
+ Dir.chdir(File.expand_path("../", __FILE__))
13
+
14
+ # This installs the tasks that help with gem creation and
15
+ # publishing.
16
+ Bundler::GemHelper.install_tasks
17
+
18
+ # Install the `spec` task so that we can run tests.
19
+ RSpec::Core::RakeTask.new do |task|
20
+ task.pattern = "tests/**/*_spec.rb"
21
+ end
22
+
23
+ # Default task is to run the unit tests
24
+ task :default => "spec"
@@ -0,0 +1,29 @@
1
+ params = BrpmAuto.params
2
+
3
+ bl_build_component_name = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["bl_build_component_name"]), "#{params["component"]} - build")
4
+ depot_group_path = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["depot_group_path"]), "/Applications/#{params["application"]}/#{params["component"]}")
5
+ package_name = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["bl_package_name"]), params["component_version"])
6
+
7
+ BrpmAuto.log("Retrieving the key of the bl component of the build server #{bl_build_component_name}...")
8
+ bsa_rest_client = BsaRestClient.new
9
+ bl_build_component = bsa_rest_client.get_component_by_name(bl_build_component_name)
10
+
11
+ BrpmAuto.log("Logging on to Bladelogic...")
12
+ bsa_soap_client = BsaSoapClient.new
13
+
14
+ BrpmAuto.log("Retrieving the id of the bl depot group of the package #{depot_group_path}...")
15
+ depot_group_id = bsa_soap_client.depot_group.group_name_to_id({:group_name => depot_group_path})
16
+ depot_group_id = depot_group_id.to_i #is this necessary?
17
+
18
+ BrpmAuto.log("Creating blpackage #{depot_group_path}/#{package_name}...")
19
+ bsa_soap_client.blpackage.create_package_from_component({:package_name => package_name, :depot_group_id => depot_group_id, :component_key => bl_build_component["dbKey"]})
20
+
21
+ brpm_rest_client = BrpmRestClient.new
22
+
23
+ BrpmAuto.log "Getting all environments of application #{params["application"]} ..."
24
+ environments = brpm_rest_client.get_environments_of_application(params["application"])
25
+
26
+ environments.each do |environment|
27
+ BrpmAuto.log "Creating the version tag for version #{params["component_version"]} of application #{params["application"]} and component #{params["component"]} in environment #{environment["name"]} ..."
28
+ environment = brpm_rest_client.create_version_tag(params["application"], params["component"], environment["name"], params["component_version"])
29
+ end
@@ -0,0 +1,26 @@
1
+ ###
2
+ # bl_build_component_name:
3
+ # name: Bladelogic build component name
4
+ # position: A1:C1
5
+ # depot_group_path:
6
+ # name: Depot group path
7
+ # position: A2:D2
8
+ # bl_package_name:
9
+ # name: Bladelogic package name
10
+ # position: A3:C3
11
+ ###
12
+
13
+ #=== BMC Application Automation Integration Server: BladeLogic on aws ===#
14
+ # [integration_id=6]
15
+ #=== End ===#
16
+
17
+ require "#{ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-#{ENV["BRPM_CONTENT_VERSION"] || "latest"}/modules/framework/brpm_script_executor.rb"
18
+
19
+ params["direct_execute"] = true
20
+
21
+ params["SS_integration_dns"] = SS_integration_dns
22
+ params["SS_integration_username"] = SS_integration_username
23
+ params["SS_integration_password_enc"] = SS_integration_password_enc
24
+ params["SS_integration_details"] = YAML.load(SS_integration_details)
25
+
26
+ BrpmScriptExecutor.execute_automation_script_from_gem("brpm_module_bladelogic", "create_package", params)
@@ -0,0 +1,137 @@
1
+ params = BrpmAuto.params
2
+ brpm_rest_client = BrpmRestClient.new
3
+
4
+ environment = params.request_environment
5
+ unless params["server_group"] # can already be populated by the automated tests
6
+ BrpmAuto.log("Getting the server group from the step...")
7
+ params["server_group"] = brpm_rest_client.get_server_group_from_step_id(params["step_id"])
8
+ end
9
+ server_group = params["server_group"]
10
+
11
+ target_type = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["target_type"]), "Server group")
12
+ target_path = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["target_path"]), "/Applications/#{params["application"]}/#{params["request_environment"]}/#{server_group}")
13
+
14
+ deploy_job_name = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["deploy_job_name"]), "Deploy #{params["component"]} #{params["component_version"]} in #{environment} - #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}")
15
+ deploy_job_group_path = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["deploy_job_group_path"]), "/Applications/#{params["application"]}")
16
+
17
+ depot_group_path = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["depot_group_path"]), "/Applications/#{params["application"]}/#{params["component"]}")
18
+ package_name = BrpmAuto.first_defined(BrpmAuto.substitute_tokens(params["bl_package_name"]), params["component_version"])
19
+
20
+ BrpmAuto.log("Logging on to Bladelogic...")
21
+ bsa_soap_client = BsaSoapClient.new
22
+
23
+ BrpmAuto.log("Retrieving the db key of blpackage #{depot_group_path}/#{package_name}...")
24
+ package_db_key = bsa_soap_client.blpackage.get_dbkey_by_group_and_name({:parent_group => depot_group_path, :depot_group_path => package_name })
25
+
26
+ BrpmAuto.log("Retrieving the id of job group #{deploy_job_group_path}...")
27
+ deploy_job_group_id = bsa_soap_client.job_group.group_name_to_id({:group_name => deploy_job_group_path })
28
+
29
+ BrpmAuto.log("Creating Deploy job #{deploy_job_group_path}/#{deploy_job_name}...")
30
+ job_db_key = bsa_soap_client.deploy_job.create_deploy_job({:job_name => deploy_job_name, :group_id => deploy_job_group_id, :package_db_key => package_db_key, :server_name => "localhost" })
31
+
32
+ BrpmAuto.log("Cleaning the servers from the Deploy job...")
33
+ job_db_key = bsa_soap_client.job.clear_target_servers({:job_key => job_db_key})
34
+
35
+ if target_type == "Server group"
36
+ BrpmAuto.log("Adding server group #{target_path} to the Deploy job...")
37
+ job_db_key = bsa_soap_client.job.add_target_group({:job_key => job_db_key, :group_name => target_path})
38
+ elsif target_type == "Component group"
39
+ BrpmAuto.log("Adding component group #{target_path} to the Deploy job...")
40
+ job_db_key = bsa_soap_client.job.add_target_component_group({:job_key => job_db_key, :group_name => target_path})
41
+ end
42
+
43
+ BrpmAuto.log("Executing the Deploy job...")
44
+ job_run_key = bsa_soap_client.job.execute_job_and_wait({:job_key => job_db_key})
45
+ BrpmAuto.log("Job run key is #{job_run_key}.")
46
+
47
+ BrpmAuto.log("Checking if the job finished successfully...")
48
+ had_errors = bsa_soap_client.job_run.get_job_run_had_errors({:job_run_key => job_run_key})
49
+
50
+ had_errors ? BrpmAuto.log("WARNING: The job had errors!") : BrpmAuto.log("The job had no errors.")
51
+ pack_response "job_status", had_errors ? "The job had errors" : "The job ran successfully"
52
+
53
+ BrpmAuto.log("Retrieving the job run id from the job run key...")
54
+ job_run_id = bsa_soap_client.job_run.job_run_key_to_job_run_id({:job_run_key => job_run_key})
55
+
56
+ results_full_path = "#{params.output_dir}/#{deploy_job_name}_result.csv"
57
+
58
+ BrpmAuto.log("Retrieving the results from the job run id...")
59
+ return_data = bsa_soap_client.utility.export_deploy_script_run({
60
+ :job_group_name => deploy_job_group_path,
61
+ :job_name => deploy_job_name,
62
+ :run_id => job_run_id,
63
+ :export_file_name => results_full_path})
64
+ results_content = Base64.decode64(return_data)
65
+
66
+ File.open(results_full_path, "w") do |f|
67
+ f.puts(results_content)
68
+ end
69
+
70
+ BrpmAuto.log("Parsing the results...")
71
+ # As this export contains "embedded" double quotes it is not possible to parse it with the CSV library
72
+ log_lines = results_content.split("\n")[6..-1]
73
+ log_lines.select! { |log| !log.start_with?("run level log,") }
74
+
75
+ logs = log_lines.map do |log_line|
76
+ log_items = log_line.split(",",7)
77
+
78
+ # 0: server
79
+ # 1: phase
80
+ # 2: attempt
81
+ # 3: date part 1
82
+ # 4: date part 2
83
+ # 5: Info - Warning - Error
84
+ # 6: message
85
+
86
+ if log_items.count < 7 # Some lines are broken in two because of end-of-lines appearing in the message field...
87
+ nil
88
+ else
89
+ log_items[6] = log_items[6].tr(",,","")
90
+ log_items[3] = DateTime.parse("#{log_items[3]},#{log_items[4]}")
91
+
92
+ log_items
93
+ end
94
+ end
95
+
96
+ logs = logs.compact # removing the possible nils from the array
97
+
98
+ logs = logs.sort_by { |log| [log[0], log[1], log[3]] }
99
+
100
+ servers_with_logs = logs.group_by { |log| log[0] }
101
+
102
+ failed_servers_with_logs = servers_with_logs.select { |key, value| value.select{|log| log[5] == "Error" }.count > 0}
103
+
104
+ pack_response "results_summary", "#{servers_with_logs.count - failed_servers_with_logs.count}/#{servers_with_logs.count} servers were successful"
105
+
106
+ table_data = [[' ', 'Server', 'Simulate', 'Stage', 'Commit']]
107
+ counter = 0
108
+ servers_with_logs.each do |key, logs|
109
+ server = key
110
+
111
+ phase_with_logs = logs.group_by { |log| log[1] }
112
+
113
+ if phase_with_logs.has_key?("Simulate")
114
+ simulate = phase_with_logs["Simulate"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
115
+ else
116
+ simulate = ""
117
+ end
118
+ if phase_with_logs.has_key?("Stage")
119
+ stage = phase_with_logs["Stage"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
120
+ else
121
+ stage = ""
122
+ end
123
+ if phase_with_logs.has_key?("Commit")
124
+ commit = phase_with_logs["Commit"].any? { |log| log[5] == "Error" } ? "Error" : "Succeeded"
125
+ else
126
+ commit = ""
127
+ end
128
+
129
+ counter += 1
130
+ table_data << [counter, server, simulate, stage, commit]
131
+ end
132
+
133
+ pack_response "results", { :perPage => 10, :totalItems => table_data.count - 1, :data => table_data }
134
+
135
+ pack_response "results_link", results_full_path
136
+
137
+ raise "The Deploy job had errors!" if had_errors
@@ -0,0 +1,53 @@
1
+ ###
2
+ # depot_group_path:
3
+ # name: Depot group path
4
+ # position: A1:F1
5
+ # bl_package_name:
6
+ # name: Bladelogic package name
7
+ # position: A2:D2
8
+ # deploy_job_group_path:
9
+ # name: Deploy job group path
10
+ # position: A3:F3
11
+ # deploy_job_name:
12
+ # name: Deploy job name
13
+ # position: A4:D4
14
+ # target_type:
15
+ # name: Target type
16
+ # type: in-list-single
17
+ # list_pairs: 0,Server group|1,Component group
18
+ # position: A5:C5
19
+ # target_path:
20
+ # name: Target path
21
+ # position: A6:F6
22
+ # job_status:
23
+ # name: Job Status
24
+ # type: out-text
25
+ # position: A1:C1
26
+ # results_summary:
27
+ # name: Summary
28
+ # type: out-text
29
+ # position: A2:E2
30
+ # results:
31
+ # name: Installs
32
+ # type: out-table
33
+ # position: A3:E3
34
+ # results_link:
35
+ # name: Link
36
+ # type: out-file
37
+ # position: A4:E4
38
+ ###
39
+
40
+ #=== BMC Application Automation Integration Server: BladeLogic on aws ===#
41
+ # [integration_id=6]
42
+ #=== End ===#
43
+
44
+ require "#{ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-#{ENV["BRPM_CONTENT_VERSION"] || "latest"}/modules/framework/brpm_script_executor.rb"
45
+
46
+ params["direct_execute"] = true
47
+
48
+ params["SS_integration_dns"] = SS_integration_dns
49
+ params["SS_integration_username"] = SS_integration_username
50
+ params["SS_integration_password_enc"] = SS_integration_password_enc
51
+ params["SS_integration_details"] = YAML.load(SS_integration_details)
52
+
53
+ BrpmScriptExecutor.execute_automation_script_from_gem("brpm_module_bladelogic", "deploy_package", params)
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require "brpm_script_executor"
3
+
4
+ params = {}
5
+ params["application"] = ENV["APPLICATION"]
6
+ params["component"] = ENV["COMPONENT"]
7
+ params["component_version"] = ENV["COMPONENT_VERSION"]
8
+
9
+ params["brpm_url"] = "http://#{ENV["BRPM_HOST"]}:#{ENV["BRPM_PORT"]}/brpm"
10
+ params["brpm_api_token"] = ENV["BRPM_TOKEN"]
11
+
12
+ params["SS_integration_dns"] = ENV["SS_INTEGRATION_DNS"]
13
+ params["SS_integration_username"] = ENV["SS_INTEGRATION_USERNAME"]
14
+ params["SS_integration_password"] = ENV["SS_INTEGRATION_PASSWORD"]
15
+ params["SS_integration_details"] = {}
16
+ params["SS_integration_details"]["role"] = ENV["SS_INTEGRATION_DETAILS_ROLE"]
17
+
18
+ params["log_file"] = ENV["LOG_FILE"]
19
+ params["also_log_to_console"] = "true"
20
+
21
+ BrpmScriptExecutor.execute_automation_script_from_gem("brpm_module_bladelogic", "create_package", params)
22
+
@@ -0,0 +1,39 @@
1
+ require "yaml"
2
+
3
+ config = YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = File.basename(File.expand_path(File.dirname(__FILE__)))
7
+ spec.version = config["version"]
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.license = "GNU General Public License v2.0"
10
+ spec.authors = [config["author"]]
11
+ spec.email = config["email"]
12
+ spec.homepage = config["homepage"]
13
+ spec.summary = config["summary"]
14
+ spec.description = config["description"]
15
+
16
+ spec.add_runtime_dependency "brpm_content", ">=0.1.11"
17
+
18
+ if config["dependencies"]
19
+ config["dependencies"].each do |dependency|
20
+ if dependency.is_a?(Hash)
21
+ modul = dependency.keys[0]
22
+ options = dependency.values[0]
23
+ else
24
+ modul = dependency
25
+ options = {}
26
+ end
27
+ spec.add_runtime_dependency modul, options["version"] unless ["brpm", "bladelogic", "jira"].include?(modul)
28
+ end
29
+ end
30
+
31
+ spec.add_development_dependency "rake"
32
+ spec.add_development_dependency "rspec"
33
+
34
+ spec.files = `git ls-files`.split("\n")
35
+ spec.require_path = 'lib'
36
+
37
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
38
+ spec.bindir = "bin"
39
+ end