brpm_content_framework 0.2.29 → 0.2.30
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 +8 -8
- data/config.yml +1 -1
- data/infrastructure/config/server.yml +1 -0
- data/lib/brpm_script_executor.rb +60 -32
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWJmZWY0ZWYzZjdiYWQzNjBmMTM5M2ZjNGNlYmU0OGRlNDBjMWU0Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2RiNzU0N2E1NGZjM2M5OWM5NDg2MmYyNGY3YjQ3Yjc0NDY5NjdkYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDA5Y2JlN2Y0ZDc5OTJiYmM5MzEwMmVmNTIyZTMxNjZlMGEwMTUwMjhhYWM1
|
10
|
+
MzFjNzQ5ZjFkMTE3NmY2ZTBkYmZlYjRiM2FmYjQ2MmQyMGZmNWNiNTk0Mjgy
|
11
|
+
MDNjMzY5YmQ1MDgyNDQzYjFiNjE1OTU4OTM4MzVhMWY4ZGNkMTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWQ4YmM0MmIwMDEwZDhkOWIzZTEyOGM0MWRmNWJiY2NkYjYxYTc4YTc5NTIy
|
14
|
+
MmVlYTBlYTYxYmE1NjVjYjliNWI0MTQ3ZWQ0NDE5MGRkMWMyNmQ4MDdkNTQ4
|
15
|
+
NjA3MjRjNWY0ODkxNTRkOTVkODY0MTdlYjViNjAyNzExZTEzOTA=
|
data/config.yml
CHANGED
data/lib/brpm_script_executor.rb
CHANGED
@@ -19,10 +19,7 @@ class BrpmScriptExecutor
|
|
19
19
|
BrpmAuto.log ""
|
20
20
|
BrpmAuto.log "Executing #{automation_type} '#{name}' from module '#{modul}' in a separate process..."
|
21
21
|
|
22
|
-
|
23
|
-
env_vars["GEM_HOME"] = ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"
|
24
|
-
|
25
|
-
BrpmAuto.log "Finding the module path..."
|
22
|
+
BrpmAuto.log "Finding the module's version..."
|
26
23
|
case automation_type
|
27
24
|
when "automation"
|
28
25
|
module_version = params["module_version"] || get_latest_installed_version(modul)
|
@@ -31,43 +28,74 @@ class BrpmScriptExecutor
|
|
31
28
|
else
|
32
29
|
raise "Automation type #{automation_type} is not supported."
|
33
30
|
end
|
34
|
-
module_path = get_module_gem_path(modul, module_version)
|
35
|
-
|
36
|
-
if File.exists?(module_path)
|
37
|
-
BrpmAuto.log "Found module #{modul} #{module_version || ""} in path #{module_path}."
|
38
|
-
else
|
39
|
-
raise Gem::GemNotFoundException, "Module #{modul} version #{module_version} is not installed. Expected it on path #{module_path}."
|
40
|
-
end
|
41
31
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
32
|
+
case params["execute_automation_scripts_in_docker"]
|
33
|
+
when "always"
|
34
|
+
use_docker = true
|
35
|
+
when "if_docker_image_exists"
|
36
|
+
output = exec("docker pull bmcrlm/#{modul}:#{module_version}")
|
37
|
+
use_docker = (output =~ /Image is up to date for/)
|
47
38
|
else
|
48
|
-
|
49
|
-
require_bundler = ""
|
39
|
+
use_docker = false
|
50
40
|
end
|
51
41
|
|
52
42
|
working_path = File.expand_path(params["SS_output_dir"] || params["output_dir"] || Dir.pwd)
|
53
|
-
params_file = "
|
43
|
+
params_file = "params_#{params["SS_run_key"] || params["run_key"] || "000"}.yml"
|
44
|
+
params_path = "#{working_path}/#{params_file}"
|
54
45
|
|
55
|
-
|
56
|
-
|
46
|
+
if use_docker
|
47
|
+
params["SS_output_dir"] = "/workdir" if params.has_key?("SS_output_dir")
|
48
|
+
params["output_dir"] = "/workdir" if params.has_key?("output_dir")
|
49
|
+
end
|
50
|
+
|
51
|
+
BrpmAuto.log "Temporarily storing the params to #{params_path}..."
|
52
|
+
File.open(params_path, "w") do |file|
|
57
53
|
file.puts(params.to_yaml)
|
58
54
|
end
|
59
55
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
56
|
+
if use_docker
|
57
|
+
BrpmAuto.log "Executing the script in a docker container..."
|
58
|
+
command = "docker run -v #{working_path}:/workdir --rm bmcrlm/#{modul}:#{module_version} /docker_execute_automation \"#{name}\" \"#{params_file}\" \"#{automation_type}\""
|
59
|
+
if automation_type == "resource_automation"
|
60
|
+
command += " \"#{parent_id}\"" if parent_id
|
61
|
+
command += " \"#{offset}\"" if offset
|
62
|
+
command += " \"#{max_records}\"" if max_records
|
63
|
+
end
|
64
|
+
exec(command)
|
65
|
+
else
|
66
|
+
env_vars = {}
|
67
|
+
env_vars["GEM_HOME"] = ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"
|
68
|
+
|
69
|
+
module_path = get_module_gem_path(modul, module_version)
|
70
|
+
|
71
|
+
if File.exists?(module_path)
|
72
|
+
BrpmAuto.log "Found module #{modul} #{module_version || ""} in path #{module_path}."
|
73
|
+
else
|
74
|
+
raise Gem::GemNotFoundException, "Module #{modul} version #{module_version} is not installed. Expected it on path #{module_path}."
|
75
|
+
end
|
76
|
+
|
77
|
+
gemfile_path = "#{module_path}/Gemfile"
|
78
|
+
if File.exists?(gemfile_path)
|
79
|
+
BrpmAuto.log "Using Gemfile #{gemfile_path}."
|
80
|
+
env_vars["BUNDLE_GEMFILE"] = gemfile_path
|
81
|
+
require_bundler = "require 'bundler/setup';"
|
82
|
+
else
|
83
|
+
BrpmAuto.log("This module doesn't have a Gemfile.")
|
84
|
+
require_bundler = ""
|
85
|
+
end
|
86
|
+
|
87
|
+
BrpmAuto.log "Executing the script in a separate process..."
|
88
|
+
return_value = Bundler.clean_system(env_vars, "ruby", "-e", "#{require_bundler}require 'brpm_script_executor'; BrpmScriptExecutor.execute_automation_script_from_other_process(\"#{modul}\", \"#{name}\", \"#{params_path}\", \"#{automation_type}\", \"#{parent_id}\", \"#{offset}\", \"#{max_records}\")")
|
89
|
+
FileUtils.rm(params_path) if File.exists?(params_path)
|
90
|
+
if return_value.nil?
|
91
|
+
message = "The process that executed the automation script returned with 'Command execution failed'."
|
92
|
+
BrpmAuto.log_error message
|
93
|
+
raise message
|
94
|
+
elsif return_value == false
|
95
|
+
message = "The process that executed the automation script returned with non-zero exit code: #{$?.exitstatus}"
|
96
|
+
BrpmAuto.log_error message
|
97
|
+
raise message
|
98
|
+
end
|
71
99
|
end
|
72
100
|
|
73
101
|
if automation_type == "resource_automation"
|