Class: BrpmAuto
- Inherits:
-
Object
- Object
- BrpmAuto
- Defined in:
- lib/brpm_auto.rb
Class Attribute Summary collapse
-
.all_params ⇒ Object
readonly
Returns the value of attribute all_params.
-
.brpm_version ⇒ Object
readonly
Returns the value of attribute brpm_version.
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.framework_root_path ⇒ Object
readonly
Returns the value of attribute framework_root_path.
-
.global_params ⇒ Object
readonly
Returns the value of attribute global_params.
-
.integration_settings ⇒ Object
readonly
Returns the value of attribute integration_settings.
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
-
.params ⇒ Object
readonly
Returns the value of attribute params.
-
.request_params ⇒ Object
readonly
Returns the value of attribute request_params.
-
.version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
- .brpm_installed? ⇒ Boolean
- .get_global_params ⇒ Object
- .get_request_params_for_request(automation_results_dir, application, request_id) ⇒ Object
- .init ⇒ Object
- .initialize_integration_settings(dns, username, password, details) ⇒ Object
- .initialize_logger(log_file, also_log_to_console = false) ⇒ Object
- .initialize_request_params(path) ⇒ Object
- .load_customer_include_file ⇒ Object
- .log(message) ⇒ Object
- .log_error(message) ⇒ Object
- .message_box(message, m_type = "sep") ⇒ Object
- .pack_response(argument_name, response) ⇒ Object
- .require_module(module_name) ⇒ Object
- .run_from_brpm ⇒ Object
- .setup(params = {}) ⇒ Object
Class Attribute Details
.all_params ⇒ Object (readonly)
Returns the value of attribute all_params.
26 27 28 |
# File 'lib/brpm_auto.rb', line 26 def all_params @all_params end |
.brpm_version ⇒ Object (readonly)
Returns the value of attribute brpm_version.
22 23 24 |
# File 'lib/brpm_auto.rb', line 22 def brpm_version @brpm_version end |
.config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/brpm_auto.rb', line 20 def config @config end |
.framework_root_path ⇒ Object (readonly)
Returns the value of attribute framework_root_path.
30 31 32 |
# File 'lib/brpm_auto.rb', line 30 def framework_root_path @framework_root_path end |
.global_params ⇒ Object (readonly)
Returns the value of attribute global_params.
28 29 30 |
# File 'lib/brpm_auto.rb', line 28 def global_params @global_params end |
.integration_settings ⇒ Object (readonly)
Returns the value of attribute integration_settings.
27 28 29 |
# File 'lib/brpm_auto.rb', line 27 def integration_settings @integration_settings end |
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
23 24 25 |
# File 'lib/brpm_auto.rb', line 23 def logger @logger end |
.params ⇒ Object (readonly)
Returns the value of attribute params.
24 25 26 |
# File 'lib/brpm_auto.rb', line 24 def params @params end |
.request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
25 26 27 |
# File 'lib/brpm_auto.rb', line 25 def request_params @request_params end |
.version ⇒ Object (readonly)
Returns the value of attribute version.
21 22 23 |
# File 'lib/brpm_auto.rb', line 21 def version @version end |
Class Method Details
.brpm_installed? ⇒ Boolean
151 152 153 |
# File 'lib/brpm_auto.rb', line 151 def brpm_installed? ENV["BRPM_HOME"] and ! ENV["BRPM_HOME"].empty? end |
.get_global_params ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/brpm_auto.rb', line 82 def get_global_params server_config_file_path = "#{self.params.config_dir}/server.yml" if File.exists?(server_config_file_path) YAML.load_file(server_config_file_path) || {} else {} end end |
.get_request_params_for_request(automation_results_dir, application, request_id) ⇒ Object
143 144 145 |
# File 'lib/brpm_auto.rb', line 143 def get_request_params_for_request(automation_results_dir, application, request_id) RequestParams.new_for_request(automation_results_dir, application, request_id) end |
.init ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/brpm_auto.rb', line 32 def init @framework_root_path = File.("#{File.dirname(__FILE__)}/..") self.extend Utilities @config = get_config @version = @config["version"] @brpm_version = get_brpm_version if self.brpm_installed? end |
.initialize_integration_settings(dns, username, password, details) ⇒ Object
147 148 149 |
# File 'lib/brpm_auto.rb', line 147 def initialize_integration_settings(dns, username, password, details) @integration_settings = IntegrationSettings.new(dns, username, password, details) end |
.initialize_logger(log_file, also_log_to_console = false) ⇒ Object
104 105 106 |
# File 'lib/brpm_auto.rb', line 104 def initialize_logger(log_file, also_log_to_console = false) @logger = SimpleLogger.new(log_file, also_log_to_console) end |
.initialize_request_params(path) ⇒ Object
139 140 141 |
# File 'lib/brpm_auto.rb', line 139 def initialize_request_params(path) @request_params = RequestParams.new(path) end |
.load_customer_include_file ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/brpm_auto.rb', line 91 def load_customer_include_file customer_include_file_path = "#{self.params.config_dir}/customer_include.rb" params = {} if File.exists?(customer_include_file_path) load customer_include_file_path # use load instead of require to avoid having to restart BRPM after modifying the customer include file in a resource automation scenario if defined?(get_customer_include_params) params = get_customer_include_params || {} end end params end |
.log(message) ⇒ Object
112 113 114 |
# File 'lib/brpm_auto.rb', line 112 def log() @logger.log() end |
.log_error(message) ⇒ Object
116 117 118 |
# File 'lib/brpm_auto.rb', line 116 def log_error() @logger.log_error() end |
.message_box(message, m_type = "sep") ⇒ Object
120 121 122 |
# File 'lib/brpm_auto.rb', line 120 def (, m_type = "sep") @logger.(, m_type) end |
.pack_response(argument_name, response) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/brpm_auto.rb', line 124 def pack_response(argument_name, response) flag = "#------ Block to Set Pack Response ---------------#\n" unless argument_name.nil? if response.is_a?(Hash) # Used for out-table output parameter flag += "$$SS_Pack_Response{#{argument_name}@@#{response.to_json}}$$" else flag += "$$SS_Pack_Response{#{argument_name}=>#{response}}$$" end end flag += "\n#------- End Set Pack Response Block ---------------#\n" @logger.log(flag, false) flag end |
.require_module(module_name) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/brpm_auto.rb', line 155 def require_module(module_name) module_spec = Gem::Specification.find_by_name(module_name) # will raise an error when the module is not installed module_path = module_spec.gem_dir module_config_file_path = "#{module_path}/config.yml" if File.exist?(module_config_file_path) module_config = YAML.load_file(module_config_file_path) if module_config["dependencies"] BrpmAuto.log "Loading the dependent modules..." module_config["dependencies"].each do |dependency| if dependency.is_a?(Hash) dep_module_name = dependency.keys[0] else dep_module_name = dependency end BrpmAuto.log "Loading module #{dep_module_name}..." require_module(dep_module_name) end end else BrpmAuto.log "No config file found." end BrpmAuto.log "Loading the libraries of module #{module_name}..." require_libs(module_path) module_path end |
.run_from_brpm ⇒ Object
108 109 110 |
# File 'lib/brpm_auto.rb', line 108 def run_from_brpm @params.run_from_brpm end |
.setup(params = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/brpm_auto.rb', line 43 def setup(params = {}) @params = Params.new(params) @global_params = get_global_params @global_params.merge!(load_customer_include_file) if @params.run_from_brpm @logger = BrpmLogger.new @request_params = RequestParams.new_for_request(@params.automation_results_dir, @params.application, @params.request_id) else initialize_logger(@params.log_file, @params.also_log_to_console) initialize_request_params(@params.output_dir) end @all_params = AllParams.new(@params, @request_params) if @params["SS_integration_dns"] @integration_settings = IntegrationSettings.new( @params["SS_integration_dns"], @params["SS_integration_username"], @params["SS_integration_password"], @params["SS_integration_details"], @params["SS_project_server"], @params["SS_project_server_id"] ) elsif defined?(SS_integration_dns) @integration_settings = IntegrationSettings.new( SS_integration_dns, SS_integration_username, SS_integration_password, SS_integration_details, SS_project_server, SS_project_server_id ) end @params end |