brpm_content 0.1.19 → 0.1.20
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
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmNhMDI1MGFjY2JjNzZjYThjZTc3NjFlYjI5Y2ZiNGJkYTVkMDEyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWY5OGI2NDA4N2Q0YTZmOWU2YjNhNjUwOTA1YzhhZmM5ZGZjNmQxZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWRjOTYwMDI0MDkzNWY1NmJmYTY5OTdmMTQ2ZTQ5ZWJiMDg5ZjAxODNlZDQ4
|
10
|
+
ZDYyZmI2YjJjMjZjYWVhZTE1ODBmMTAxZTA2ZmIxMWM3ODk4YTEzN2UzYWQy
|
11
|
+
ZTI2ODYwNzAzNDlmOGQ3OTk0YmFhNjc3YWE2ZDRjYmVlM2IzN2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzAyNjliOThkZTM0YzRiM2UxNzJjMDFiZmVmNzc1NzgzMDExOWQ0OGM0ZWQ5
|
14
|
+
MWMyYTBiZGVkOGY0NWE3ODE1NDA4ZjIzZDBhYzUwZDAxODY5MTI5OGY0OWM3
|
15
|
+
OTJhNDQ5N2U4YTBiYjA2M2NlMTA2ZTZhMTk3M2ExN2Y3M2Y2MTI=
|
@@ -19,5 +19,5 @@ end
|
|
19
19
|
module_name = ARGV[0]
|
20
20
|
module_version = ARGV[1] # optional
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
module_installer = ModuleInstaller.new
|
23
|
+
module_installer.install_module(module_name, module_version)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class ModuleInstaller
|
2
2
|
def install_module(module_name, module_version)
|
3
3
|
BrpmAuto.log "Installing module #{module_name} #{module_version.nil? ? "" : module_version}..."
|
4
4
|
|
@@ -80,6 +80,8 @@ class BrpmInstaller
|
|
80
80
|
|
81
81
|
def install_auto_script_wrappers(module_path, module_name)
|
82
82
|
brpm_file = File.expand_path("~/.brpm")
|
83
|
+
|
84
|
+
config = nil
|
83
85
|
if File.exists?(brpm_file)
|
84
86
|
config = YAML.load_file(brpm_file)
|
85
87
|
end
|
@@ -110,11 +112,18 @@ class BrpmInstaller
|
|
110
112
|
resource_automation_dir = "#{module_path}/resource_automations"
|
111
113
|
resource_automation_script_paths = Dir.glob("#{resource_automation_dir}/*.rb")
|
112
114
|
|
115
|
+
failed_scripts = []
|
113
116
|
if resource_automation_script_paths.size > 0
|
114
117
|
BrpmAuto.log "Installing the wrapper scripts for the resource automations..."
|
115
118
|
|
116
119
|
resource_automation_script_paths.each do |auto_script_path|
|
117
|
-
|
120
|
+
begin
|
121
|
+
install_auto_script_wrapper(auto_script_path, "ResourceAutomation", module_name, integration_servers, brpm_rest_client)
|
122
|
+
rescue Exception => e
|
123
|
+
failed_scripts << auto_script_path
|
124
|
+
BrpmAuto.log_error(e)
|
125
|
+
BrpmAuto.log e.backtrace.join("\n\t")
|
126
|
+
end
|
118
127
|
end
|
119
128
|
end
|
120
129
|
|
@@ -126,9 +135,24 @@ class BrpmInstaller
|
|
126
135
|
BrpmAuto.log "Installing the wrapper scripts for the automations..."
|
127
136
|
|
128
137
|
automation_script_paths.each do |auto_script_path|
|
129
|
-
|
138
|
+
begin
|
139
|
+
install_auto_script_wrapper(auto_script_path, "Automation", module_name, integration_servers, brpm_rest_client)
|
140
|
+
rescue Exception => e
|
141
|
+
failed_scripts << auto_script_path
|
142
|
+
BrpmAuto.log_error(e)
|
143
|
+
BrpmAuto.log e.backtrace.join("\n\t")
|
144
|
+
end
|
130
145
|
end
|
131
146
|
end
|
147
|
+
|
148
|
+
if failed_scripts.size > 0
|
149
|
+
BrpmAuto.log "The following wrapper scripts generated errors during the installation:"
|
150
|
+
failed_scripts.each do |failed_script|
|
151
|
+
BrpmAuto.log " - #{failed_script}"
|
152
|
+
end
|
153
|
+
else
|
154
|
+
BrpmAuto.log "All wrapper scripts were installed successfully."
|
155
|
+
end
|
132
156
|
end
|
133
157
|
|
134
158
|
def install_auto_script_wrapper(auto_script_path, automation_type, module_name, integration_servers, brpm_rest_client)
|
@@ -139,19 +163,14 @@ class BrpmInstaller
|
|
139
163
|
|
140
164
|
auto_script_config_content = File.exists?(auto_script_config_path) ? File.read(auto_script_config_path) : ""
|
141
165
|
match = auto_script_config_content.match(/###\n(.*)\n###/m)
|
142
|
-
input_params_content = match ? match[1] : ""
|
166
|
+
input_params_content = match ? "#{match[1]}\n" : ""
|
143
167
|
|
144
|
-
input_params_content
|
168
|
+
matches = input_params_content.scan(/^# {0,1}(.*)/) || []
|
169
|
+
input_params_yaml = YAML.load(matches.join("\n")) || {}
|
145
170
|
|
146
|
-
|
147
|
-
# name: Framework version
|
148
|
-
# required: no
|
149
|
-
# module_version:
|
150
|
-
# name: Module version
|
151
|
-
# required: no
|
152
|
-
EOR
|
171
|
+
input_params_content += get_input_params_template(input_params_yaml)
|
153
172
|
|
154
|
-
wrapper_script_content = "###\n#{input_params_content}
|
173
|
+
wrapper_script_content = "###\n#{input_params_content}###\n"
|
155
174
|
|
156
175
|
auto_script_config = YAML.load(auto_script_config_content) || {}
|
157
176
|
|
@@ -162,17 +181,8 @@ EOR
|
|
162
181
|
integration_server = integration_servers.find { |integration_server| integration_server["server_name_id"] == server_type_id } #TODO: support multiple integration servers of same type (user should pick one)
|
163
182
|
|
164
183
|
if integration_server
|
165
|
-
wrapper_script_content +=
|
166
|
-
|
167
|
-
#=== #{auto_script_config["integration_server_type"]} Integration Server: #{integration_server["name"]} ===#
|
168
|
-
# [integration_id=#{integration_server["id"]}]
|
169
|
-
#=== End ===#
|
170
|
-
|
171
|
-
params["SS_integration_dns"] = SS_integration_dns
|
172
|
-
params["SS_integration_username"] = SS_integration_username
|
173
|
-
params["SS_integration_password_enc"] = SS_integration_password_enc
|
174
|
-
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
175
|
-
EOR
|
184
|
+
wrapper_script_content += "\n"
|
185
|
+
wrapper_script_content += get_integration_server_template(integration_server["id"], integration_server["name"], auto_script_config["integration_server_type"])
|
176
186
|
else
|
177
187
|
BrpmAuto.log "WARNING - An integration server of type #{auto_script_config["integration_server_type"]} doesn't exist so not setting the integration server in the wrapper script."
|
178
188
|
end
|
@@ -181,32 +191,8 @@ EOR
|
|
181
191
|
end
|
182
192
|
end
|
183
193
|
|
184
|
-
wrapper_script_content +=
|
185
|
-
|
186
|
-
params["direct_execute"] = "true"
|
187
|
-
|
188
|
-
params["framework_version"] = nil if params["framework_version"].empty?
|
189
|
-
params["module_version"] = nil if params["module_version"].empty?
|
190
|
-
|
191
|
-
require "\#{ENV["BRPM_CONTENT_HOME"] || "\#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-\#{params["framework_version"] || "latest"}/modules/framework/brpm_script_executor.rb"
|
192
|
-
EOR
|
193
|
-
|
194
|
-
if automation_type == "Automation"
|
195
|
-
|
196
|
-
wrapper_script_content += <<EOR
|
197
|
-
|
198
|
-
BrpmScriptExecutor.execute_automation_script_from_gem("#{module_name}", "#{auto_script_name}", params)
|
199
|
-
EOR
|
200
|
-
|
201
|
-
elsif automation_type == "ResourceAutomation"
|
202
|
-
|
203
|
-
wrapper_script_content += <<EOR
|
204
|
-
|
205
|
-
def execute(script_params, parent_id, offset, max_records)
|
206
|
-
BrpmScriptExecutor.execute_resource_automation_script_from_gem("#{module_name}", "#{auto_script_name}", script_params, parent_id, offset, max_records)
|
207
|
-
end
|
208
|
-
EOR
|
209
|
-
end
|
194
|
+
wrapper_script_content += "\n"
|
195
|
+
wrapper_script_content += get_script_executor_template(automation_type, module_name, auto_script_name)
|
210
196
|
|
211
197
|
auto_script_friendly_name = auto_script_config["friendly_name"] || "#{module_name.sub("brpm_module_", "").capitalize} - #{auto_script_name.gsub("_", " ").capitalize}"
|
212
198
|
automation_category = auto_script_config["automation_category"] || "#{module_name.sub("brpm_module_", "").capitalize}"
|
@@ -219,8 +205,8 @@ EOR
|
|
219
205
|
script["content"] = wrapper_script_content
|
220
206
|
script["integration_id"] = integration_server["id"] if auto_script_config["integration_server_type"] and integration_server
|
221
207
|
if automation_type == "ResourceAutomation"
|
222
|
-
script["resource_id"] = auto_script_config["resource_id"]
|
223
|
-
script["render_as"] = auto_script_config["render_as"]
|
208
|
+
script["resource_id"] = auto_script_config["resource_id"] || auto_script_name
|
209
|
+
script["render_as"] = auto_script_config["render_as"] || "List"
|
224
210
|
end
|
225
211
|
|
226
212
|
script = brpm_rest_client.create_or_update_script(script)
|
@@ -241,4 +227,76 @@ EOR
|
|
241
227
|
script = brpm_rest_client.update_script_from_hash(script_to_update)
|
242
228
|
end
|
243
229
|
end
|
230
|
+
|
231
|
+
def get_input_params_template(input_params_yaml)
|
232
|
+
include_position_attribute = false
|
233
|
+
if input_params_yaml.find {|_, param| param.has_key?("position")}
|
234
|
+
include_position_attribute = true
|
235
|
+
end
|
236
|
+
|
237
|
+
template = <<EOR
|
238
|
+
# framework_version:
|
239
|
+
# name: Framework version
|
240
|
+
# required: no
|
241
|
+
EOR
|
242
|
+
|
243
|
+
if include_position_attribute
|
244
|
+
template += "# position: A#{input_params_yaml.size + 1}:D#{input_params_yaml.size + 1}\n"
|
245
|
+
end
|
246
|
+
|
247
|
+
template += <<EOR
|
248
|
+
# module_version:
|
249
|
+
# name: Module version
|
250
|
+
# required: no
|
251
|
+
EOR
|
252
|
+
|
253
|
+
if include_position_attribute
|
254
|
+
template += "# position: A#{input_params_yaml.size + 2}:D#{input_params_yaml.size + 2}\n"
|
255
|
+
end
|
256
|
+
|
257
|
+
template
|
258
|
+
end
|
259
|
+
|
260
|
+
def get_integration_server_template(integration_server_id, integration_server_name, integration_server_type)
|
261
|
+
<<EOR
|
262
|
+
#=== #{integration_server_type} Integration Server: #{integration_server_name} ===#
|
263
|
+
# [integration_id=#{integration_server_id}]
|
264
|
+
#=== End ===#
|
265
|
+
|
266
|
+
params["SS_integration_dns"] = SS_integration_dns
|
267
|
+
params["SS_integration_username"] = SS_integration_username
|
268
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
269
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
270
|
+
EOR
|
271
|
+
end
|
272
|
+
|
273
|
+
def get_script_executor_template(automation_type, module_name, auto_script_name)
|
274
|
+
template = <<EOR
|
275
|
+
params["direct_execute"] = "true"
|
276
|
+
|
277
|
+
params["framework_version"] = nil if params["framework_version"].empty?
|
278
|
+
params["module_version"] = nil if params["module_version"].empty?
|
279
|
+
|
280
|
+
require "\#{ENV["BRPM_CONTENT_HOME"] || "\#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content-\#{params["framework_version"] || "latest"}/modules/framework/brpm_script_executor.rb"
|
281
|
+
EOR
|
282
|
+
|
283
|
+
if automation_type == "Automation"
|
284
|
+
|
285
|
+
template += <<EOR
|
286
|
+
|
287
|
+
BrpmScriptExecutor.execute_automation_script_from_gem("#{module_name}", "#{auto_script_name}", params)
|
288
|
+
EOR
|
289
|
+
|
290
|
+
elsif automation_type == "ResourceAutomation"
|
291
|
+
|
292
|
+
template += <<EOR
|
293
|
+
|
294
|
+
def execute(script_params, parent_id, offset, max_records)
|
295
|
+
BrpmScriptExecutor.execute_resource_automation_script_from_gem("#{module_name}", "#{auto_script_name}", script_params, parent_id, offset, max_records)
|
296
|
+
end
|
297
|
+
EOR
|
298
|
+
end
|
299
|
+
|
300
|
+
template
|
301
|
+
end
|
244
302
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brpm_content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niek Bartholomeus
|
@@ -291,10 +291,10 @@ files:
|
|
291
291
|
- modules/framework/config/customer_include.rb
|
292
292
|
- modules/framework/config/server.yml
|
293
293
|
- modules/framework/customer_include_default.rb
|
294
|
-
- modules/framework/lib/brpm_installer.rb
|
295
294
|
- modules/framework/lib/logging/brpm_logger.rb
|
296
295
|
- modules/framework/lib/logging/logger_base.rb
|
297
296
|
- modules/framework/lib/logging/simple_logger.rb
|
297
|
+
- modules/framework/lib/module_installer.rb
|
298
298
|
- modules/framework/lib/params/all_params.rb
|
299
299
|
- modules/framework/lib/params/integration_settings.rb
|
300
300
|
- modules/framework/lib/params/params.rb
|