brpm_content_framework 0.2.31 → 0.2.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/config.yml +1 -1
- data/infrastructure/docker/docker_execute_automation +0 -0
- data/infrastructure/scripts/publish_module_version.sh +34 -0
- data/lib/brpm_script_executor.rb +18 -15
- data/lib/logging/simple_logger.rb +0 -1
- data/tests/brpm_script_executor_spec.rb +20 -0
- data/tests/customer_include/config/server.yml +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzQxZGE2NGI0ZGQ4YzgxZGY1YzQyYjBiZGIzOTE2YzQ2Y2RhZTdhYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDkxOWQ3ZTk0OTQ0ZDkyMTZlOWYxMTgzZWRjYjY2ZDQyMTJmZTMyMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODEzYWRlZjg4YWQ3ZDkwZTk3ODJjNjIwOGY0YzAwOGFmOWZmYjdhYTdjOTg2
|
10
|
+
OWZjMzdkZjMyZDcyZWQ5MzI0M2RiYmFmZDM0YzFhMjVhNTNmNTU3YzE2NzM5
|
11
|
+
ZjBiNGM2YzM1OTUyNjA2Y2RkOGI5YTY0NTJmM2FmZGViODhjYWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTI2MWQ0N2U4NDgwMzM2OThhMGE2NGE0MDQ2ODRlMzdiZmI0NzJhMWEwYTFi
|
14
|
+
MzQxYjkzZDMyOTUwM2U5OGUxMmZjN2JjNTJjOTA1NWRjMTRkMjgzM2NlNzhk
|
15
|
+
YjEzZmExMTUzZGM4ZGZhY2VkMGRhYWZhZDRkODAzOGUzNjk2YmY=
|
data/config.yml
CHANGED
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
USAGE="publish_module_version.sh <module name>"
|
3
|
+
|
4
|
+
MODULE_NAME=$1
|
5
|
+
MODULE_VERSION=$2
|
6
|
+
|
7
|
+
if [ -z "$MODULE_NAME" ]; then
|
8
|
+
echo "Module name is not specified. Aborting."
|
9
|
+
echo "Usage: $USAGE"
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
cd $(dirname $0)/../../../$MODULE_NAME
|
14
|
+
|
15
|
+
echo ">>> Publishing the module as a gem to rubygems.org..."
|
16
|
+
rake release
|
17
|
+
if [ -f "Dockerfile" ]; then
|
18
|
+
MODULE_VERSION=$(eval "sed -n \"s=version: \(.*\)=\1=p\" config.yml")
|
19
|
+
|
20
|
+
OLD_MODULE_VERSION=$(eval "sed -n \"s=ENV VERSION \(.*\)=\1=p\" Dockerfile")
|
21
|
+
sed -i "" s/$OLD_MODULE_VERSION/$MODULE_VERSION/ Dockerfile
|
22
|
+
|
23
|
+
echo ">>> Building the docker image..."
|
24
|
+
docker build -t bmcrlm/$MODULE_NAME:$MODULE_VERSION .
|
25
|
+
|
26
|
+
echo ">>> Publishing the docker image to the docker hub..."
|
27
|
+
docker push bmcrlm/$MODULE_NAME:$MODULE_VERSION
|
28
|
+
|
29
|
+
echo ">>> Tagging the module version as 'latest'..."
|
30
|
+
docker tag -f bmcrlm/$MODULE_NAME:$MODULE_VERSION bmcrlm/$MODULE_NAME:latest
|
31
|
+
docker push bmcrlm/$MODULE_NAME:latest
|
32
|
+
|
33
|
+
sed -i "" s/$MODULE_VERSION/$OLD_MODULE_VERSION/ Dockerfile
|
34
|
+
fi
|
data/lib/brpm_script_executor.rb
CHANGED
@@ -45,6 +45,7 @@ class BrpmScriptExecutor
|
|
45
45
|
else
|
46
46
|
use_docker = false
|
47
47
|
end
|
48
|
+
BrpmAuto.log "The automation script will be executed in a docker container." if use_docker
|
48
49
|
|
49
50
|
working_path = File.expand_path(BrpmAuto.params.output_dir)
|
50
51
|
params_file = "params_#{params["SS_run_key"] || params["run_key"] || "000"}.yml"
|
@@ -53,9 +54,10 @@ class BrpmScriptExecutor
|
|
53
54
|
|
54
55
|
if use_docker
|
55
56
|
params["SS_output_dir"] = "/workdir"
|
56
|
-
params["SS_output_file"].sub!(working_path, "/workdir")
|
57
|
-
|
57
|
+
params["SS_output_file"].sub!(working_path, "/workdir") if params["SS_output_file"]
|
58
58
|
params["SS_automation_results_dir"] = "/automation_results"
|
59
|
+
|
60
|
+
params["log_file"].sub!(working_path, "/workdir") if params["log_file"]
|
59
61
|
end
|
60
62
|
|
61
63
|
BrpmAuto.log "Temporarily storing the params to #{params_path}..."
|
@@ -72,7 +74,7 @@ class BrpmScriptExecutor
|
|
72
74
|
command += " \"#{max_records}\"" if max_records
|
73
75
|
end
|
74
76
|
BrpmAuto.log command
|
75
|
-
|
77
|
+
return_value = system(command)
|
76
78
|
else
|
77
79
|
env_vars = {}
|
78
80
|
env_vars["GEM_HOME"] = ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"
|
@@ -97,20 +99,21 @@ class BrpmScriptExecutor
|
|
97
99
|
|
98
100
|
BrpmAuto.log "Executing the script in a separate process..."
|
99
101
|
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}\")")
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
102
|
+
end
|
103
|
+
|
104
|
+
FileUtils.rm(params_path) if File.exists?(params_path)
|
105
|
+
if return_value.nil?
|
106
|
+
message = "The process that executed the automation script returned with 'Command execution failed'."
|
107
|
+
BrpmAuto.log_error message
|
108
|
+
raise message
|
109
|
+
elsif return_value == false
|
110
|
+
message = "The process that executed the automation script returned with non-zero exit code: #{$?.exitstatus}"
|
111
|
+
BrpmAuto.log_error message
|
112
|
+
raise message
|
110
113
|
end
|
111
114
|
|
112
115
|
if automation_type == "resource_automation"
|
113
|
-
result_file =
|
116
|
+
result_file = params_file.sub!("params", "result")
|
114
117
|
BrpmAuto.log "Loading the result from #{result_file} and cleaning it up..."
|
115
118
|
result = YAML.load_file(result_file)
|
116
119
|
FileUtils.rm result_file
|
@@ -139,7 +142,7 @@ class BrpmScriptExecutor
|
|
139
142
|
|
140
143
|
result = execute_automation_script_internal(modul, name, params, automation_type, parent_id, offset, max_records)
|
141
144
|
if automation_type == "resource_automation"
|
142
|
-
result_file =
|
145
|
+
result_file = params_file.sub!("params", "result")
|
143
146
|
BrpmAuto.log " Temporarily storing the result to #{result_file}..."
|
144
147
|
FileUtils.rm(result_file) if File.exists?(result_file)
|
145
148
|
File.open(result_file, "w") do |file|
|
@@ -11,7 +11,6 @@ class SimpleLogger < LoggerBase
|
|
11
11
|
def log(message)
|
12
12
|
message = message.to_s # in case booleans or whatever are passed
|
13
13
|
timestamp = "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
|
14
|
-
log_message = ""
|
15
14
|
|
16
15
|
prefix = "#{timestamp}|"
|
17
16
|
message = message.gsub("\n", "\n" + (" " * prefix.length))
|
@@ -52,6 +52,16 @@ describe 'BRPM Script Executor' do
|
|
52
52
|
expect(result).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should execute an automation script in a docker container" do
|
56
|
+
params = get_default_params
|
57
|
+
params['output_dir'] = File.expand_path("~/tmp/brpm_content") # docker volume mappong only works from the current user's home directory on Mac OSX
|
58
|
+
params["execute_automation_scripts_in_docker"] = "always"
|
59
|
+
|
60
|
+
result = BrpmScriptExecutor.execute_automation_script_in_separate_process("brpm_module_test", "test_ruby", params)
|
61
|
+
|
62
|
+
expect(result).to be_truthy
|
63
|
+
end
|
64
|
+
|
55
65
|
it "should return false when executing an non-existing automation script in a separate process" do
|
56
66
|
expect{BrpmScriptExecutor.execute_automation_script_in_separate_process(@module_name, "xxx", get_default_params)}.to raise_exception
|
57
67
|
end
|
@@ -65,4 +75,14 @@ describe 'BRPM Script Executor' do
|
|
65
75
|
|
66
76
|
expect(result.count).to eql(3)
|
67
77
|
end
|
78
|
+
|
79
|
+
it "should execute a resource automation script in a docker container" do
|
80
|
+
params = get_default_params
|
81
|
+
params['output_dir'] = File.expand_path("~/tmp/brpm_content") # docker volume mappong only works from the current user's home directory on Mac OSX
|
82
|
+
params["execute_automation_scripts_in_docker"] = "always"
|
83
|
+
|
84
|
+
result = BrpmScriptExecutor.execute_resource_automation_script_in_separate_process(@module_name, "test_resource", params, nil, 0, 10)
|
85
|
+
|
86
|
+
expect(result.count).to eql(3)
|
87
|
+
end
|
68
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brpm_content_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niek Bartholomeus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- infrastructure/scripts/install_brpm.sh
|
206
206
|
- infrastructure/scripts/maintenance.sh
|
207
207
|
- infrastructure/scripts/patch_brpm.sh
|
208
|
+
- infrastructure/scripts/publish_module_version.sh
|
208
209
|
- infrastructure/scripts/restore_database.sh
|
209
210
|
- infrastructure/scripts/run_event_handler.cmd
|
210
211
|
- infrastructure/scripts/run_event_handler.sh
|