brpm_content_framework 0.1.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +38 -0
  3. data/.travis.yml +17 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +21 -0
  6. data/README.md +308 -0
  7. data/Rakefile +23 -0
  8. data/TO_BE_MIGRATED.txt +9 -0
  9. data/architecture.png +0 -0
  10. data/automations/direct_execute.meta +10 -0
  11. data/automations/direct_execute.rb +10 -0
  12. data/automations/install_module.meta +10 -0
  13. data/automations/install_module.rb +13 -0
  14. data/bin/brpm_install +30 -0
  15. data/bin/brpm_uninstall +30 -0
  16. data/bin/event_handler +63 -0
  17. data/bin/webhook_receiver +49 -0
  18. data/brpm_content.gemspec +31 -0
  19. data/config.yml +8 -0
  20. data/infrastructure/.bashrc +6 -0
  21. data/infrastructure/.brpm +2 -0
  22. data/infrastructure/config/customer_include.rb +26 -0
  23. data/infrastructure/config/server.yml +3 -0
  24. data/infrastructure/log.html +39 -0
  25. data/infrastructure/scripts/backup_database.sh +19 -0
  26. data/infrastructure/scripts/ddns.sh +10 -0
  27. data/infrastructure/scripts/install_brpm.sh +63 -0
  28. data/infrastructure/scripts/maintenance.sh +4 -0
  29. data/infrastructure/scripts/patch_brpm.sh +90 -0
  30. data/infrastructure/scripts/restore_database.sh +33 -0
  31. data/infrastructure/scripts/run_event_handler.cmd +19 -0
  32. data/infrastructure/scripts/run_event_handler.sh +20 -0
  33. data/infrastructure/scripts/run_webhook_receiver.cmd +15 -0
  34. data/infrastructure/scripts/run_webhook_receiver.sh +15 -0
  35. data/infrastructure/silent_install_options_4.6.txt +93 -0
  36. data/infrastructure/silent_install_options_upgrade_4.6.txt +92 -0
  37. data/infrastructure/smtp_settings.rb +42 -0
  38. data/lib/brpm_auto.rb +358 -0
  39. data/lib/brpm_script_executor.rb +80 -0
  40. data/lib/logging/brpm_logger.rb +39 -0
  41. data/lib/logging/logger_base.rb +36 -0
  42. data/lib/logging/simple_logger.rb +27 -0
  43. data/lib/module_installer.rb +483 -0
  44. data/lib/params/all_params.rb +80 -0
  45. data/lib/params/integration_settings.rb +27 -0
  46. data/lib/params/params.rb +174 -0
  47. data/lib/params/params_base.rb +81 -0
  48. data/lib/params/request_params.rb +38 -0
  49. data/lib/rest_api.rb +155 -0
  50. data/lib/semaphore.rb +79 -0
  51. data/lib/utilities.rb +317 -0
  52. data/lib/version_control/git.rb +192 -0
  53. data/lib/version_control/svn.rb +221 -0
  54. data/lib/write_to.rb +1 -0
  55. data/tests/all_params_spec.rb +116 -0
  56. data/tests/brpm_auto_spec.rb +84 -0
  57. data/tests/customer_include/config/customer_include.rb +10 -0
  58. data/tests/customer_include/config/server.yml +3 -0
  59. data/tests/customer_include_spec.rb +29 -0
  60. data/tests/gemspec_spec.rb +11 -0
  61. data/tests/module_installer_spec.rb +46 -0
  62. data/tests/params_spec.rb +172 -0
  63. data/tests/request_params_spec.rb +86 -0
  64. data/tests/server_yaml_spec.rb +19 -0
  65. data/tests/spec_helper.rb +64 -0
  66. data/to_be_migrated/brpm_framework.rb +88 -0
  67. data/to_be_migrated/customer_include_default.rb +25 -0
  68. data/to_be_migrated/local_jirb.rb +15 -0
  69. data/to_be_migrated/resource_framework.rb +211 -0
  70. data/transport/dispatch_baa.rb +355 -0
  71. data/transport/dispatch_base.rb +345 -0
  72. data/transport/dispatch_nsh.rb +248 -0
  73. data/transport/dispatch_ssh.rb +154 -0
  74. data/transport/transport_baa.rb +1095 -0
  75. data/transport/transport_nsh.rb +359 -0
  76. data/transport/transport_ssh.rb +220 -0
  77. metadata +204 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGU4YWFmZTY1ODZhOTgzOTc3MWRiMWI4MTRlMjIyZTY5NWFiMGE0MQ==
5
+ data.tar.gz: !binary |-
6
+ MDhhODJhZDIxZmMzNDM3MjQwNTJhMDkwYzE0ZjdkN2VkMjkxMDlkOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NmFiMWRjYjdjNDQ2NTE3ZDI1MTA4MDBlM2ExNTU3ZTNlY2VlYjU2OWI3ZThm
10
+ ZGI3YTU4MGFmZjMzZjZlZjhkNjdlY2UyZWI5MjhjMTliNWNlODY4YzBlYzk2
11
+ YjNiZTc4M2Q3MTU4ZTI1NmUwMmI2OGE2Yjg3YjZiZTE0NDgyMzY=
12
+ data.tar.gz: !binary |-
13
+ YTVmODI1MjE4OWY5NzQ1MjQ0MjcxMWI1NmJhYjg3OWExNzZjZDcwOWQ3MjE5
14
+ NTFlYjIwMjQxNTQ2MDliMzRlMjc0N2VkNTY0ZWY5Y2QwZTBjNzlmMDliZGYx
15
+ N2Y5MDViOTUwOTY5YWViMWRmYWU0NWYxYWVlZWY4ZDZmNmJkMjg=
data/.gitignore ADDED
@@ -0,0 +1,38 @@
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-version
31
+ .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ .DS_Store
37
+
38
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+
5
+ before_install:
6
+ - gem update --system 2.1.9
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,308 @@
1
+ # BRPM Content framework
2
+
3
+ [![Build Status](https://travis-ci.org/BMC-RLM/brpm_content.svg?branch=master)](https://travis-ci.org/BMC-RLM/brpm_content)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/brpm_content.png)](http://badge.fury.io/rb/brpm_content)
6
+
7
+ The BRPM Content framework is intended to make the creation and usage of content (for the moment limited to automation scripts) on top of BRPM as easy as possible.
8
+
9
+ It is designed around a number of core concepts like modularity, re-usability, testability that are further explained below.
10
+
11
+ ## Getting started
12
+
13
+ ### Installation
14
+
15
+ First of all, make sure that the environment variable BRPM_HOME is set to the location where BRPM is installed, e.g.:
16
+ ```shell
17
+ export BRPM_HOME=/opt/bmc/RLM
18
+ ```
19
+
20
+ Then copy the [BRPM Content framework's installation script](https://raw.githubusercontent.com/BMC-RLM/brpm_content/master/infrastructure/shell_scripts/install_content_repo.sh) to the instance on which BRPM is installed and execute it.
21
+
22
+ See here the commands to get you started:
23
+ ```shell
24
+ wget https://raw.githubusercontent.com/BMC-RLM/brpm_content/master/infrastructure/shell_scripts/install_content_repo.sh
25
+ chmod +x install_content_repo.sh
26
+ ./install_content_repo.sh
27
+ ```
28
+
29
+ The script will ask for the location of a zip file that contains the files. If the BRPM instance has access to the internet you can leave it empty in which case it will directly grab the files from this github.com repo.
30
+ If you need the zip file of this repo you can find it on [https://github.com/BMC-RLM/brpm_content/archive/master.zip](https://github.com/BMC-RLM/brpm_content/archive/master.zip)
31
+
32
+ Alternatively, if the BRPM instance has internet access and wget is installed the framework can be installed by simply executing the following command on the BRPM instance as root:
33
+ ```shell
34
+ wget -qO- https://raw.githubusercontent.com/BMC-RLM/brpm_content/master/infrastructure/shell_scripts/install_content_repo.sh | INSTALL=ONLINE sh
35
+ ```
36
+
37
+ ### Configuration
38
+
39
+ At this early stage it is still necessary to manually configure the automation scripts that come with this content repository in BRPM before you can start using them in the request steps.
40
+
41
+ This can be done as following:
42
+ - go to Environment > Automation and create an automation script
43
+ - choose the type and category of the automation script
44
+ - paste the content of the automation script's wrapper file (the file with the same name as the automation script but with the .txt extension) into the script body
45
+
46
+ The above remark applies to both automation scripts as well as resource automation scripts
47
+
48
+ Finally, make sure that the following item is added to Metadata > Lists > AutomationErrors:
49
+ ```
50
+ ******** ERROR ********
51
+ ```
52
+ This will allow non caught exceptions from the automation scripts to cause the step to go in problem mode.
53
+
54
+ ## Architecture
55
+
56
+ The BRPM Content framework is an automation platform that is built on top of BRPM. It allows to create, install and run what are called modules that contain automation logic that naturally belongs together. The framework itself provides a number of general purpose features like an automation script executor, dependency management, parameter handling, logging, etc.
57
+
58
+ ![alt text](https://github.com/BMC-RLM/brpm_content/blob/master/architecture.png "architecture")
59
+
60
+ The BRPM Content framework was built with the following design principles in mind, all further explained in the remainder of this document:
61
+ - **modularity**
62
+ - **re-usability**
63
+ - **testability**
64
+ - **developer-friendliness**.
65
+
66
+ ## Modularity
67
+
68
+ ### Using existing modules
69
+
70
+ One of the core design principles of the framework is its modularity. The framework itself is deliberately chosen to be very lightweight. The purpose is that all custom automation logic is added by means of modules. Modules will typically group multiple automation scripts, resource automation scripts and libraries of one specific domain.
71
+
72
+ Modules can be installed by executing the [module installation](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/shell_scripts/install_content_module.sh) script on the BRPM instance:
73
+ ```shell
74
+ ~/shell_scripts/install_content_module.sh
75
+ ```
76
+
77
+ The script will ask for the location of a zip file or the url of a github.com repository that contains the module's files. For the Selenium module this url would be [https://github.com/BMC-RLM/brpm_module_selenium](https://github.com/BMC-RLM/brpm_module_selenium).
78
+
79
+ Note that the BRPM Content framework contains a number of core [modules](https://github.com/BMC-RLM/brpm_content/tree/master/modules) that will be installed by default. The purpose is to gradually move these built-in modules into their own dedicated github repositories.
80
+
81
+ ### Creating your own modules
82
+
83
+ It is very simple to create your own module.
84
+
85
+ Just make sure to stick with the following file structure:
86
+ ```
87
+ +-- automations
88
+ | +-- my_automation_script.rb
89
+ | +-- my_automation_script.txt
90
+ +-- resource_automations
91
+ | +-- my_resource_automation_script.rb
92
+ | +-- my_resource_automation_script.txt
93
+ +-- lib
94
+ | +-- my_library.rb
95
+ +-- tests
96
+ | +-- my_automation_script_spec.rb
97
+ | +-- spec_helper.rb
98
+ +-- config.yml
99
+ ```
100
+
101
+ The config.yml file contains the integration server and all other modules it depends on. Both settings are optional. In the future it will also be possible to version modules.
102
+
103
+ If you use a github.com repository to host the source code of the module you can directly install it from there. Otherwise you can create a zip file of the module and install it as such.
104
+
105
+ It is also possible to execute (and debug if your ruby IDE supports it, e.g. RubyMine) the scripts on your development machine. See further the section on Testability.
106
+
107
+ For an example see the [Selenium](https://github.com/BMC-RLM/brpm_module_selenium) module.
108
+
109
+ ## Re-usability
110
+
111
+ ### Automation scripts
112
+
113
+ Although the initial purpose of the BRPM Content framework is to exist on top of BRPM, it is perfectly possible to use it outside of BRPM. Let's say that you initially developed an automation script for usage within BRPM but now you need to run it from Jenkins, a shell script, or even a unit test? As the framework is highly decoupled from BRPM nothing prevents you from doing this.
114
+
115
+ As an example, see here how the create_package automation script from the bladelogic module can be executed in stand-alone mode:
116
+
117
+ ```ruby
118
+ # Load the BRPM Content framework's script executor
119
+ require "modules/framework/brpm_script_executor"
120
+
121
+ # Supply the input parameters for the automation script, if any
122
+ params = {}
123
+ params["application"] = "E-Finance"
124
+ params["component"] = "EF - Java calculation engine"
125
+ params["component_version"] = "1.2.3"
126
+
127
+ params["SS_integration_dns"] = "bladelogic"
128
+ params["SS_integration_username"] = "brpm"
129
+ params["SS_integration_password"] = "password"
130
+
131
+ # Execute the automation script
132
+ BrpmScriptExecutor.execute_automation_script("bladelogic", "create_package", params)
133
+ ```
134
+ [source](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/shell_scripts/create_bl_package.sh)
135
+
136
+ ### Libraries
137
+
138
+ It is also possible to re-use the module's libraries in stand-alone mode:
139
+
140
+ ```ruby
141
+ # Load the BRPM Content framework
142
+ require "framework/brpm_auto"
143
+
144
+ # Set up the framework and load the brpm module
145
+ BrpmAuto.setup()
146
+ BrpmAuto.require_module "brpm"
147
+
148
+ # Create a BRPM REST client and find all requests for application E-Finance
149
+ @brpm_rest_client = BrpmRestClient.new("http://my-brpm-server/brpm', "<api token>")
150
+
151
+ app = @brpm_rest_client.get_app_by_name("E-Finance")
152
+ requests = @brpm_rest_client.get_requests_by({ "app_id" => app["id"]})
153
+ ```
154
+
155
+ ## Testability
156
+
157
+ Thanks to the decoupling between the BRPM Content framework and BRPM itself, it is very easy to write automated tests for the automation logic that runs on top of the framework.
158
+
159
+ As an example, see here a unit test written in RSpec that will create a plan and a request in that plan:
160
+
161
+ ```ruby
162
+ describe 'create release request' do
163
+ ...
164
+ describe 'in new plan' do
165
+ it 'should create a plan from template and a request from template in that plan' do
166
+ # Supply the input parameters for the automation script, if any
167
+ params = {}
168
+ params["application_name"] = 'E-Finance'
169
+ params["application_version"] = '1.2.3'
170
+ params["release_request_template_name"] = 'Release E-Finance'
171
+ params["release_plan_template_name"] = 'E-Finance Release Plan'
172
+
173
+ # Execute the automation script
174
+ BrpmScriptExecutor.execute_automation_script("brpm", "create_release_request", params)
175
+
176
+ # Verify that the request was created and linked to the plan
177
+ @brpm_rest_client = BrpmRestClient.new("http://my-brpm-server/brpm', "<api token>")
178
+ request = @brpm_rest_client.get_request_by_id(BrpmAuto.params["result"]["request_id"])
179
+
180
+ expect(request["aasm_state"]).to eq("started")
181
+ expect(request).to have_key("plan_member")
182
+ expect(request["plan_member"]["plan"]["id"]).not_to be_nil
183
+ end
184
+ end
185
+ ...
186
+ end
187
+ ```
188
+ [source](https://github.com/BMC-RLM/brpm_content/blob/master/modules/brpm/tests/create_release_request_spec.rb)
189
+
190
+ The framework itself comes with a set of RSpec tests that are executed automatically by [Travis CI](https://travis-ci.org/) after each commit. The status can be consulted on top of this page.
191
+
192
+ When setting up an automated testing platform for your modules, make sure that the framework is installed before executing the tests.
193
+
194
+ ### Mac OS X
195
+
196
+ Clone this repository to a location that is side by side with your module's location. Then 'require' the brpm_script_executor in your spec_helper.rb:
197
+ ```ruby
198
+ require_relative "../../../brpm_content/modules/framework/brpm_script_executor"
199
+ ```
200
+
201
+ Make sure that you are running on ruby 1.9.3 and that all gem dependencies as specified in the Gemfile are installed.
202
+
203
+ ### Travis CI
204
+
205
+ See the [.travis.yml](https://github.com/BMC-RLM/brpm_module_selenium/blob/master/.travis.yml) file in the Selenium module for more information on how to do this.
206
+
207
+ ## Framework
208
+ ### Dependency management
209
+
210
+ If you want to use a library or automation script from a different module you can indicate a dependency to that module in your own module's config.yml file. This will automatically make all libraries and automation modules available to all of the scripts in your own module. No need to add 'require' statements yourself.
211
+
212
+ ### Parameters
213
+
214
+ The framework parses the input parameters it receives from the caller and stores them into an easy to use structure for usage by the automation scripts.
215
+
216
+ #### input params
217
+
218
+ Input params are the regular parameters that are received from the caller.
219
+
220
+ They can be used as following:
221
+ ```ruby
222
+ application = BrpmAuto.params.application
223
+
224
+ my_custom_param = BrpmAuto.params["my_custom_param"]
225
+ ```
226
+
227
+ Check out the [automated tests](https://github.com/BMC-RLM/brpm_content/blob/master/modules/framework/tests/params_spec.rb) for more complex use cases.
228
+
229
+ #### request params
230
+
231
+ Request params are special in the sense that they are kept over the whole life cycle of the request in which they exist. When one step needs information from a previous step this information can be stored as a request param.
232
+
233
+ They can be used as following:
234
+ - In step 1:
235
+ ```ruby
236
+ BrpmAuto.request_params["created_issue_id"] = 123
237
+ ```
238
+ - In step 2:
239
+ ```ruby
240
+ BrpmAuto.log "The id of the issue that was created by step 1 is #{BrpmAuto.request_params["created_issue_id"]}"
241
+ ```
242
+
243
+ Check out the [automated tests](https://github.com/BMC-RLM/brpm_content/blob/master/modules/framework/tests/request_params_spec.rb) for more complex use cases.
244
+
245
+ #### integration settings
246
+
247
+ The integration settings are the connection parameters that are needed to connect with the integration server that was defined for the automation script in BRPM. They are stored as part of the input params.
248
+
249
+ ### Logging
250
+
251
+ You can use the built-in logging feature for any logging needs. The logs will be visible on the 'Notes' tab of the associated BRPM step after the automation is finished. You can also consult the logs in real-time by navigating to my_brpm_server/brpm/automation_results/log.html?request=request id
252
+
253
+ Example:
254
+ ```ruby
255
+ BrpmAuto.log "Hello World"
256
+ ```
257
+
258
+ ### Error handling
259
+
260
+ Any ruby exception that is not trapped inside the automation scripts will cause the associated BRPM step to transition into problem state. This is also the only way to force the step into a problem state. If no exception is thrown the step will always be considered successful and the request will continue.
261
+
262
+ ### Extensions
263
+
264
+ #### server yaml file
265
+
266
+ The framework allows you to define your own parameters that will automatically be made available to all automation scripts. You can do this by creating a file server.yml in $BRPM_HOME/config and adding your parameters into it, in YAML format. See [here](https://github.com/BMC-RLM/brpm_content/blob/master/modules/framework/config/server.yml) for an example.
267
+
268
+ #### customer include file
269
+
270
+ The framework allows you to create your own ruby methods that you will automatically be able to use in all automation scripts. You can do this by creating a file customer_include.rb in $BRPM_HOME/config and adding your custom methods into it. See [here](https://github.com/BMC-RLM/brpm_content/blob/master/modules/framework/config/customer_include.rb) for an example.
271
+
272
+ Note
273
+ If a get_customer_include_params method exists, the framework will automatically execute it and add the resulting hash into the parameters hash.
274
+
275
+ This feature is deprecated. Consider creating a server.yml file for storing customer-specific parameters or creating a module for re-using customer-specific logic.
276
+
277
+ ### Other framework features
278
+ #### Execute command
279
+ #### Semaphores
280
+
281
+ ## Integrations
282
+
283
+ The BRPM Content framework makes it easy to integrate with other tools using web hook and messaging technology. In both cases it is possible to execute an automation script (or use a library) whenever a notification is received.
284
+
285
+ ### Web hook receivers
286
+
287
+ The framework contains a generic [web hook receiver script](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/integrations/webhook_receiver.rb) with an associated [bash wrapper script](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/shell_scripts/run_webhook_receiver.sh) that can be run as a daemon. You can pass it a custom script that can take care of processing the received events. Typically this event processing script will then execute the appropriate automation scripts.
288
+
289
+ A web hook receiver solution can be used for synchronizing data that is owned by another system (assuming it supports web hooks) with BRPM.
290
+
291
+ For an example of how to synchronize JIRA issues with BRPM tickets see the [event handler script](https://github.com/BMC-RLM/brpm_content/blob/master/customers/demo/integrations/jira/process_webhook_event.rb) that could be used for this purpose. As soon as the script is run in daemon mode (and JIRA is configured to send event notifications to a web hook) it will start receiving events when issues are created or updated.
292
+
293
+ ### Messaging engine
294
+
295
+ BRPM comes with a messaging engine that can send a notification for many events like the creation or update or requests, plans etc. The framework contains an [event handler script](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/integrations/event_handler.rb) with an associated [bash wrapper script](https://github.com/BMC-RLM/brpm_content/blob/master/infrastructure/shell_scripts/run_event_handler.sh) that can be set up to listen to these incoming events. You can pass it a custom script that can take care of processing the received events. Typically this event processing script will then execute the appropriate automation scripts.
296
+
297
+ A messaging solution can be used for extending the out-of-the-box BRPM feature set or for synchronizing BRPM owned data with other systems.
298
+
299
+ For an example of how to update the status of the associated JIRA tickets after a deployment request finished successfully see the [event handler script](https://github.com/BMC-RLM/brpm_content/blob/master/customers/demo/integrations/brpm/process_event_handler_event.rb) (search for update_tickets_in_jira_by_request) that could be used for this purpose. As soon as the script is run in daemon mode it will start receiving events when requests change status.
300
+
301
+ ## Modules
302
+ ### BRPM
303
+ ### BladeLogic
304
+ ### JIRA
305
+ ### Jenkins
306
+
307
+ ### [Selenium](https://github.com/BMC-RLM/brpm_module_selenium) (in progress)
308
+
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new do |task|
19
+ task.pattern = "modules/framework/tests/**/*_spec.rb"
20
+ end
21
+
22
+ # Default task is to run the unit tests
23
+ task :default => "spec"
@@ -0,0 +1,9 @@
1
+ Following code is deprecated and any missing logic should be migrated to other places:
2
+
3
+ lib/to_be_migrated/brpm_framework.rb
4
+ lib/to_be_migrated/customer_include_default.rb
5
+ lib/to_be_migrated/resource_framework.rb
6
+ lib/to_be_migrated/local_jirb.rb - contains env specific logic
7
+ transport/* - decide where these functionalities should end up (preferrably in BRPM itself)
8
+
9
+ [brpm_module_brpm]/lib/brpm_rest_client.rb and [brpm_module_brpm]/lib/brpm_rest.rb - should be merged
data/architecture.png ADDED
Binary file
@@ -0,0 +1,10 @@
1
+ params:
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
+
@@ -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,10 @@
1
+ params:
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
+
@@ -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
data/bin/brpm_install ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ if ARGV.size < 1
3
+ puts "Missing arguments."
4
+ puts "Usage: \n brpm_install <module name> [<module version>]\n brpm_install <path to module>"
5
+ exit
6
+ end
7
+
8
+ require "yaml"
9
+ require "brpm_auto"
10
+
11
+ params = {}
12
+ params["log_file"] = "/tmp/brpm_install.log"
13
+ params["also_log_to_console"] = "true"
14
+
15
+ begin
16
+ BrpmAuto.setup(params)
17
+
18
+ module_name_or_path = ARGV[0]
19
+ module_version = ARGV[1] # optional
20
+
21
+ BrpmAuto.log "Installing module #{module_name_or_path}#{module_version.nil? ? "" : " " + module_version}..."
22
+ module_installer = ModuleInstaller.new
23
+ module_installer.install_module(module_name_or_path, module_version)
24
+
25
+ rescue Exception => e
26
+ BrpmAuto.log_error "#{e}"
27
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
28
+
29
+ raise e
30
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ if ARGV.size < 2
3
+ puts "Missing arguments."
4
+ puts "Usage: \n brpm_uninstall <module name> <module version>"
5
+ exit
6
+ end
7
+
8
+ require "yaml"
9
+ require "brpm_auto"
10
+
11
+ params = {}
12
+ params["log_file"] = "/tmp/brpm_install.log"
13
+ params["also_log_to_console"] = "true"
14
+
15
+ begin
16
+ BrpmAuto.setup(params)
17
+
18
+ module_name = ARGV[0]
19
+ module_version = ARGV[1] # optional
20
+
21
+ BrpmAuto.log "Uninstalling module #{module_name} #{module_version}..."
22
+ module_installer = ModuleInstaller.new
23
+ module_installer.uninstall_module(module_name, module_version)
24
+
25
+ rescue Exception => e
26
+ BrpmAuto.log_error "#{e}"
27
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
28
+
29
+ raise e
30
+ end
data/bin/event_handler ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'torquebox'
4
+ require 'torquebox-messaging'
5
+ require 'xmlsimple'
6
+ require "brpm_script_executor"
7
+
8
+ BrpmAuto.initialize_logger(ENV["EVENT_HANDLER_LOG_FILE"])
9
+
10
+ host = ENV["EVENT_HANDLER_BRPM_HOST"]
11
+ port = ENV["EVENT_HANDLER_MESSAGING_PORT"]
12
+ username = ENV["EVENT_HANDLER_MESSAGING_USERNAME"]
13
+ password = ENV["EVENT_HANDLER_MESSAGING_PASSWORD"]
14
+ process_event_script = ENV["EVENT_HANDLER_PROCESS_EVENT_SCRIPT"]
15
+
16
+ require process_event_script
17
+
18
+ class MessagingProcessor < TorqueBox::Messaging::MessageProcessor
19
+
20
+ MESSAGING_PATH = '/topics/messaging/brpm_event_queue'
21
+
22
+ def initialize(host, port, username, password)
23
+ BrpmAuto.log "Initializing the message processor..."
24
+ @destination = TorqueBox::Messaging::Topic.new(
25
+ MESSAGING_PATH,
26
+ :host => host,
27
+ :port => port,
28
+ :username => username,
29
+ :password => password
30
+ )
31
+ end
32
+
33
+ def run
34
+ begin
35
+ xml = "<root>#{@destination.receive}</root>"
36
+
37
+ BrpmAuto.log "Processing new event..."
38
+ BrpmAuto.log xml if ENV["EVENT_HANDLER_LOG_EVENT"]=="1"
39
+
40
+ event = XmlSimple.xml_in(xml)
41
+
42
+ process_event(event)
43
+
44
+ rescue Exception => e
45
+ BrpmAuto.log_error(e)
46
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
47
+ end
48
+ end
49
+ end
50
+
51
+ begin
52
+ consumer = MessagingProcessor.new(host, port, username, password)
53
+ BrpmAuto.log "Starting to listen for events ..."
54
+ loop do
55
+ consumer.run
56
+ end
57
+
58
+ rescue Exception => e
59
+ BrpmAuto.log_error(e)
60
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
61
+
62
+ raise e
63
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'json'
4
+ require 'rest-client'
5
+ require 'webrick'
6
+ require "brpm_script_executor"
7
+
8
+ BrpmAuto.initialize_logger(ENV["WEBHOOK_RECEIVER_LOG_FILE"])
9
+
10
+ port = ENV["WEBHOOK_RECEIVER_PORT"]
11
+ mount_point = "/#{ENV["WEBHOOK_RECEIVER_MOUNT_POINT"]}"
12
+ process_event_script = ENV["WEBHOOK_RECEIVER_PROCESS_EVENT_SCRIPT"]
13
+
14
+ require process_event_script
15
+
16
+ class EventProcessor < WEBrick::HTTPServlet::AbstractServlet
17
+ def do_POST(request, response)
18
+ begin
19
+ event = JSON.parse(request.body)
20
+
21
+ BrpmAuto.log "Processing new event..."
22
+ process_event(event)
23
+
24
+ response.status = 200
25
+ response['Content-Type'] = "text/plain"
26
+ response.body = "OK"
27
+ rescue Exception => e
28
+ BrpmAuto.log_error(e)
29
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
30
+ end
31
+ end
32
+ end
33
+
34
+ begin
35
+ server = WEBrick::HTTPServer.new(:Port => port)
36
+ server.mount mount_point, EventProcessor
37
+
38
+ trap("INT") {
39
+ server.shutdown
40
+ }
41
+
42
+ BrpmAuto.log "Starting the server..."
43
+ server.start
44
+ rescue Exception => e
45
+ BrpmAuto.log_error(e)
46
+ BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
47
+
48
+ raise e
49
+ end