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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTgwYTk4ZDViMjZjOTQyY2JiNDczNjNhYTgyOWYwOTc2NDE2MzI2ZA==
4
+ MWJmZWY0ZWYzZjdiYWQzNjBmMTM5M2ZjNGNlYmU0OGRlNDBjMWU0Mw==
5
5
  data.tar.gz: !binary |-
6
- MjkzNGEwMjhiMWQ5YzQxZmQwMjQ3YzU4MTQyMzRkZjFlZGJhNGI2NQ==
6
+ M2RiNzU0N2E1NGZjM2M5OWM5NDg2MmYyNGY3YjQ3Yjc0NDY5NjdkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDA1MTA4ZmM5MjA0MGU2OGNiMTNjZTQ1ZGVhMzE4MGFiNWRkN2RhMmVkZjJk
10
- ZGZhZjA3ZDIwNGQ3ZTg1MjY1YzBlYTEzZTA4OGRjNWEwZmIyNWUxZDE1YTcz
11
- ZDdmYjJhNGE1NmZjNjhlNjQ0YjQ5OTZlMzVjMDdjODQ4YjRjN2U=
9
+ NDA5Y2JlN2Y0ZDc5OTJiYmM5MzEwMmVmNTIyZTMxNjZlMGEwMTUwMjhhYWM1
10
+ MzFjNzQ5ZjFkMTE3NmY2ZTBkYmZlYjRiM2FmYjQ2MmQyMGZmNWNiNTk0Mjgy
11
+ MDNjMzY5YmQ1MDgyNDQzYjFiNjE1OTU4OTM4MzVhMWY4ZGNkMTE=
12
12
  data.tar.gz: !binary |-
13
- ZTI4MDk1YjJiZjIxMDE1YjUwYjhmYWI5Yzk2ODVlZGVmYTZlYzBkODNmMGM0
14
- ZjM0MjBlNjFkYTRhZmQxMzRjZjllODAwMjE5OThlZGM0NjM3ZWFjMjU0NTk2
15
- MWI1NzFjN2M3NTgwYTA2YWVhMzY1YjlhNDk1MjBlYjcwOTAzODI=
13
+ YWQ4YmM0MmIwMDEwZDhkOWIzZTEyOGM0MWRmNWJiY2NkYjYxYTc4YTc5NTIy
14
+ MmVlYTBlYTYxYmE1NjVjYjliNWI0MTQ3ZWQ0NDE5MGRkMWMyNmQ4MDdkNTQ4
15
+ NjA3MjRjNWY0ODkxNTRkOTVkODY0MTdlYjViNjAyNzExZTEzOTA=
data/config.yml CHANGED
@@ -1,4 +1,4 @@
1
- version: 0.2.29
1
+ version: 0.2.30
2
2
 
3
3
  author: Niek Bartholomeus
4
4
  email: niek.bartholomeus@gmail.com
@@ -1,3 +1,4 @@
1
1
  # This file should be located in BRPM_HOME/config
2
2
  # See the README for more information on how to use this file
3
+ execute_automation_scripts_in_docker: "if_docker_image_exists" #possible values: never, if_docker_image_exists, always
3
4
  my_parameter: "abc"
@@ -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
- env_vars = {}
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
- gemfile_path = "#{module_path}/Gemfile"
43
- if File.exists?(gemfile_path)
44
- BrpmAuto.log "Using Gemfile #{gemfile_path}."
45
- env_vars["BUNDLE_GEMFILE"] = gemfile_path
46
- require_bundler = "require 'bundler/setup';"
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
- BrpmAuto.log("This module doesn't have a Gemfile.")
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 = "#{working_path}/params_#{params["SS_run_key"] || params["run_key"] || "000"}.yml"
43
+ params_file = "params_#{params["SS_run_key"] || params["run_key"] || "000"}.yml"
44
+ params_path = "#{working_path}/#{params_file}"
54
45
 
55
- BrpmAuto.log "Temporarily storing the params to #{params_file}..."
56
- File.open(params_file, "w") do |file|
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
- BrpmAuto.log "Executing the script in a separate process..."
61
- 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_file}\", \"#{automation_type}\", \"#{parent_id}\", \"#{offset}\", \"#{max_records}\")")
62
- FileUtils.rm(params_file) if File.exists?(params_file)
63
- if return_value.nil?
64
- message = "The process that executed the automation script returned with 'Command execution failed'."
65
- BrpmAuto.log_error message
66
- raise message
67
- elsif return_value == false
68
- message = "The process that executed the automation script returned with non-zero exit code: #{$?.exitstatus}"
69
- BrpmAuto.log_error message
70
- raise message
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brpm_content_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.29
4
+ version: 0.2.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niek Bartholomeus