brpm_content 0.1.38 → 0.1.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/modules/framework/brpm_auto.rb +87 -2
- data/modules/framework/config.yml +1 -1
- data/modules/framework/lib/module_installer.rb +34 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGJiMjY3NDAzOWU5ZGY3YmQyNjM3ODM1MzdiYTA0MzdhZmQ3ZDA1Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzM4YzA0Mjc1Mzg4NWRkNGY5YjQwMWUwMTdlMWMzZGM0MWFiYmFhNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzZjMDkyZDU0NmNkYmZhOWI5ZjkzMDQ5NTQ4ZTNhMzRlMGJlYjI3MjFjM2Mz
|
10
|
+
ZTQ2Yjk3YWRkYTc5ZGMxYjY1YzI1MjdkYWQ2YjdjOTM4NWJjYzA0ZWQyZWEw
|
11
|
+
MGZmNmY1MWIzZmQ2NDY3MWU0MmQ3ZjgwOGExNmYwMjY5ZWI2NTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDI5MzdhYWJlYjU3YTdlNzZhMDU3MDA4ZDc4MmY0NmNlMDZiNjNkMTRmYjdm
|
14
|
+
YWU0ZjJiZDdhMzA4ZjI3MTkyYjFmYzhiNmZmMGIyYjQ2YjNhMTVhNmMxYWNm
|
15
|
+
YmVkM2FjNTg3YTE0ZTBlOTJkYWEwMzk1M2M2ZWYzNGIwMzIzNzQ=
|
@@ -122,8 +122,8 @@ class BrpmAuto
|
|
122
122
|
end
|
123
123
|
|
124
124
|
gemfile_lock_path = "#{module_gem_path}/Gemfile.lock"
|
125
|
-
if File.exists?(gemfile_lock_path)
|
126
|
-
BrpmAuto.log "Found a Gemfile.lock: #{gemfile_lock_path}
|
125
|
+
if File.exists?(gemfile_lock_path) # TODO: decide how to react when multiple gems are 'required', each with a gemfile.lock
|
126
|
+
BrpmAuto.log "Found a Gemfile.lock: #{gemfile_lock_path} so parsing the specified version numbers for later usage..."
|
127
127
|
Dir.chdir(File.dirname(gemfile_lock_path)) do
|
128
128
|
@gemfile_lock = Bundler::LockfileParser.new(Bundler.read_file(gemfile_lock_path))
|
129
129
|
end
|
@@ -232,6 +232,91 @@ class BrpmAuto
|
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
|
+
###############################################################################################################################
|
236
|
+
# Assure backward compatibility with the ssh_script_header methods when running the automation scripts in a separate process
|
237
|
+
def set_property_flag(prop, value = nil)
|
238
|
+
acceptable_fields = ["name", "value", "environment", "component", "global", "private"]
|
239
|
+
flag = "#------ Block to Set Property ---------------#\n"
|
240
|
+
if value.nil?
|
241
|
+
flag += set_build_flag_data("properties", prop, acceptable_fields)
|
242
|
+
else
|
243
|
+
flag += "$$SS_Set_property{#{prop}=>#{value}}$$"
|
244
|
+
end
|
245
|
+
flag += "\n#------- End Set Property ---------------#\n"
|
246
|
+
BrpmAuto.log flag
|
247
|
+
flag
|
248
|
+
end
|
249
|
+
|
250
|
+
def set_server_flag(servers)
|
251
|
+
# servers = "server_name, env\ncserver2_name, env2"
|
252
|
+
acceptable_fields = ["name", "environment", "group"]
|
253
|
+
flag = "#------ Block to Set Servers ---------------#\n"
|
254
|
+
flag += set_build_flag_data("servers", servers, acceptable_fields)
|
255
|
+
flag += "\n#------ End Set Servers ---------------#\n"
|
256
|
+
BrpmAuto.log flag
|
257
|
+
flag
|
258
|
+
end
|
259
|
+
|
260
|
+
def set_component_flag(components)
|
261
|
+
# comps = "comp_name, version\ncomp2_name, version2"
|
262
|
+
flag = "#------ Block to Set Components ---------------#\n"
|
263
|
+
acceptable_fields = ["name", "version", "environment", "application"]
|
264
|
+
flag += set_build_flag_data("components", components, acceptable_fields)
|
265
|
+
flag += "\n#------ End Set Components ---------------#\n"
|
266
|
+
BrpmAuto.log flag
|
267
|
+
flag
|
268
|
+
end
|
269
|
+
|
270
|
+
def set_titles_acceptable?(cur_titles, acceptable_titles)
|
271
|
+
cur_titles.each.reject{ |cur| acceptable_titles.include?(cur)}.count == 0
|
272
|
+
end
|
273
|
+
|
274
|
+
def set_build_flag_data(set_item, set_data, acceptable_titles)
|
275
|
+
flag = ""; msg = ""
|
276
|
+
lines = set_data.split("\n")
|
277
|
+
titles = lines[0].split(",").map{ |it| it.strip }
|
278
|
+
if set_titles_acceptable?(titles, acceptable_titles)
|
279
|
+
flag += "$$SS_Set_#{set_item}{\n"
|
280
|
+
flag += "#{titles.join(", ")}\n"
|
281
|
+
lines[1..-1].each do |line|
|
282
|
+
if line.split(",").count == titles.count
|
283
|
+
flag += "#{line}\n"
|
284
|
+
else
|
285
|
+
msg += "Skipped: #{line}"
|
286
|
+
end
|
287
|
+
end
|
288
|
+
flag += "}$$\n"
|
289
|
+
else
|
290
|
+
flag += "ERROR - Unable to set #{set_item} - improper format\n"
|
291
|
+
end
|
292
|
+
flag += msg
|
293
|
+
end
|
294
|
+
|
295
|
+
def set_application_version(prop, value)
|
296
|
+
# set_application_flag(app_name, version)
|
297
|
+
flag = "#------ Block to Set Application Version ---------------#\n"
|
298
|
+
flag += "$$SS_Set_application{#{prop}=>#{value}}$$"
|
299
|
+
flag += "\n#------ End Set Application ---------------#\n"
|
300
|
+
BrpmAuto.log(flag)
|
301
|
+
flag
|
302
|
+
end
|
303
|
+
|
304
|
+
def pack_response(argument_name, response)
|
305
|
+
flag = "#------ Block to Set Pack Response ---------------#\n"
|
306
|
+
unless argument_name.nil?
|
307
|
+
if response.is_a?(Hash)
|
308
|
+
# Used for out-table output parameter
|
309
|
+
flag += "$$SS_Pack_Response{#{argument_name}@@#{response.to_json}}$$"
|
310
|
+
else
|
311
|
+
flag += "$$SS_Pack_Response{#{argument_name}=>#{response}}$$"
|
312
|
+
end
|
313
|
+
end
|
314
|
+
flag += "\n#------- End Set Pack Response Block ---------------#\n"
|
315
|
+
BrpmAuto.log flag
|
316
|
+
flag
|
317
|
+
end
|
318
|
+
###############################################################################################################################
|
319
|
+
|
235
320
|
private
|
236
321
|
|
237
322
|
def require_module_internal(module_name, module_version)
|
@@ -2,10 +2,15 @@ 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
|
|
5
|
-
|
6
|
-
|
5
|
+
if true #TODO: support non-gem-install mode
|
6
|
+
specs = install_gem(module_name, module_version)
|
7
|
+
module_spec = specs.find { |spec| spec.name == module_name}
|
7
8
|
|
8
|
-
|
9
|
+
install_bundle_if_necessary(module_spec)
|
10
|
+
else
|
11
|
+
specs = [ Gem::Specification.find_by_name(module_name) ]
|
12
|
+
module_spec = specs.find { |spec| spec.name == module_name}
|
13
|
+
end
|
9
14
|
|
10
15
|
if brpm_installed_locally?
|
11
16
|
BrpmAuto.log "A BRPM instance is installed locally"
|
@@ -28,12 +33,12 @@ class ModuleInstaller
|
|
28
33
|
BrpmAuto.log "Creating an automation error for '******** ERROR ********' if one doesn't exist yet..."
|
29
34
|
create_automation_error_if_not_exists("******** ERROR ********")
|
30
35
|
|
31
|
-
module_friendly_name = get_module_friendly_name(
|
36
|
+
module_friendly_name = get_module_friendly_name(module_spec)
|
32
37
|
BrpmAuto.log "Creating an automation category for #{module_friendly_name} if one doesn't exist yet..."
|
33
38
|
create_automation_category_if_not_exists(module_friendly_name)
|
34
39
|
|
35
40
|
BrpmAuto.log "Installing the automation script wrappers in the local BRPM instance..."
|
36
|
-
install_auto_script_wrappers(module_spec.gem_dir, module_spec.name)
|
41
|
+
install_auto_script_wrappers(module_spec.gem_dir, module_spec.name, module_friendly_name)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -41,13 +46,13 @@ class ModuleInstaller
|
|
41
46
|
def prepare_brpm_connection
|
42
47
|
brpm_file = File.expand_path("~/.brpm")
|
43
48
|
|
44
|
-
|
49
|
+
brpm_config = nil
|
45
50
|
if File.exists?(brpm_file)
|
46
|
-
|
51
|
+
brpm_config = YAML.load_file(brpm_file)
|
47
52
|
end
|
48
53
|
|
49
|
-
if
|
50
|
-
unless
|
54
|
+
if brpm_config
|
55
|
+
unless brpm_config["brpm_url"] and brpm_config["brpm_api_token"]
|
51
56
|
BrpmAuto.log "WARNING - Properties brpm_url and/or brpm_api_token don't exist in file ~/.brpm so not installing the automation script wrappers in BRPM. If you want to install them the next time you should add brpm_url and brpm_api_token properties in yaml format in file ~/.brpm."
|
52
57
|
return false
|
53
58
|
end
|
@@ -64,7 +69,7 @@ class ModuleInstaller
|
|
64
69
|
return false
|
65
70
|
end
|
66
71
|
|
67
|
-
@brpm_rest_client = BrpmRestClient.new(
|
72
|
+
@brpm_rest_client = BrpmRestClient.new(brpm_config["brpm_url"], brpm_config["brpm_api_token"])
|
68
73
|
true
|
69
74
|
end
|
70
75
|
|
@@ -94,13 +99,13 @@ class ModuleInstaller
|
|
94
99
|
gemfile_lock = File.join(spec.gem_dir, "Gemfile.lock")
|
95
100
|
|
96
101
|
if File.exists?(gemfile) && File.exists?(gemfile_lock)
|
97
|
-
BrpmAuto.log "Found a Gemfile.lock so executing command 'bundle install --gemfile #{gemfile}'..."
|
98
|
-
# %x(bundle install --gemfile #{gemfile})
|
99
102
|
if BrpmAuto.run_from_brpm or BrpmAuto.params.unit_test
|
100
|
-
|
103
|
+
command = "cd #{spec.gem_dir}; export GEM_HOME=#{BrpmAuto.get_gems_root_path}; bundle install"
|
101
104
|
else
|
102
|
-
|
105
|
+
command = "cd #{spec.gem_dir}; bundle install"
|
103
106
|
end
|
107
|
+
BrpmAuto.log "Found a Gemfile.lock so executing command '#{command}'..."
|
108
|
+
result = BrpmAuto.execute_shell(command)
|
104
109
|
|
105
110
|
BrpmAuto.log result["stdout"] if result["stdout"] and !result["stdout"].empty?
|
106
111
|
unless result["status"] == 0
|
@@ -129,8 +134,10 @@ class ModuleInstaller
|
|
129
134
|
ENV["BRPM_HOME"] and !ENV["BRPM_HOME"].empty?
|
130
135
|
end
|
131
136
|
|
132
|
-
def get_module_friendly_name(
|
133
|
-
"#{
|
137
|
+
def get_module_friendly_name(module_spec)
|
138
|
+
module_config = YAML.load_file("#{module_spec.gem_dir}/config.yml")
|
139
|
+
|
140
|
+
module_config["name"] || "#{module_spec.name.sub("brpm_module_", "").capitalize}"
|
134
141
|
end
|
135
142
|
|
136
143
|
def create_automation_error_if_not_exists(automation_error)
|
@@ -158,7 +165,7 @@ class ModuleInstaller
|
|
158
165
|
end
|
159
166
|
end
|
160
167
|
|
161
|
-
def install_auto_script_wrappers(module_path, module_name)
|
168
|
+
def install_auto_script_wrappers(module_path, module_name, module_friendly_name)
|
162
169
|
BrpmAuto.log "Retrieving the integration servers..."
|
163
170
|
integration_servers = @brpm_rest_client.get_project_servers
|
164
171
|
|
@@ -172,7 +179,7 @@ class ModuleInstaller
|
|
172
179
|
|
173
180
|
resource_automation_script_paths.each do |auto_script_path|
|
174
181
|
begin
|
175
|
-
install_auto_script_wrapper(auto_script_path, "ResourceAutomation", module_name, integration_servers)
|
182
|
+
install_auto_script_wrapper(auto_script_path, "ResourceAutomation", module_name, module_friendly_name, integration_servers)
|
176
183
|
rescue Exception => e
|
177
184
|
failed_scripts << auto_script_path
|
178
185
|
BrpmAuto.log_error(e)
|
@@ -190,7 +197,7 @@ class ModuleInstaller
|
|
190
197
|
|
191
198
|
automation_script_paths.each do |auto_script_path|
|
192
199
|
begin
|
193
|
-
install_auto_script_wrapper(auto_script_path, "Automation", module_name, integration_servers)
|
200
|
+
install_auto_script_wrapper(auto_script_path, "Automation", module_name, module_friendly_name, integration_servers)
|
194
201
|
rescue Exception => e
|
195
202
|
failed_scripts << auto_script_path
|
196
203
|
BrpmAuto.log_error(e)
|
@@ -209,7 +216,7 @@ class ModuleInstaller
|
|
209
216
|
end
|
210
217
|
end
|
211
218
|
|
212
|
-
def install_auto_script_wrapper(auto_script_path, automation_type, module_name, integration_servers)
|
219
|
+
def install_auto_script_wrapper(auto_script_path, automation_type, module_name, module_friendly_name, integration_servers)
|
213
220
|
auto_script_name = File.basename(auto_script_path, ".rb")
|
214
221
|
BrpmAuto.log "Installing the wrapper script for resource automation #{auto_script_name}..."
|
215
222
|
|
@@ -251,7 +258,6 @@ class ModuleInstaller
|
|
251
258
|
wrapper_script_content += "\n"
|
252
259
|
wrapper_script_content += get_script_executor_template(automation_type, module_name, auto_script_name)
|
253
260
|
|
254
|
-
module_friendly_name = get_module_friendly_name(module_name)
|
255
261
|
if auto_script_config["automation_category"]
|
256
262
|
automation_category = auto_script_config["automation_category"]
|
257
263
|
create_automation_category_if_not_exists(automation_category)
|
@@ -298,16 +304,21 @@ class ModuleInstaller
|
|
298
304
|
include_position_attribute = true
|
299
305
|
end
|
300
306
|
|
307
|
+
input_params = auto_script_params.select do |_, param|
|
308
|
+
type = param["type"] || "in"
|
309
|
+
! type.start_with?("out")
|
310
|
+
end
|
311
|
+
|
301
312
|
module_version_param = {}
|
302
313
|
module_version_param["name"] = "module_version"
|
303
314
|
module_version_param["required"] = false
|
304
|
-
module_version_param["position"] = "A#{auto_script_params.size + 1}:C#{
|
315
|
+
module_version_param["position"] = "A#{auto_script_params.size + 1}:C#{input_params.size + 1}" if include_position_attribute
|
305
316
|
auto_script_params["module_version"] = module_version_param
|
306
317
|
|
307
318
|
framework_version_param = {}
|
308
319
|
framework_version_param["name"] = "framework_version"
|
309
320
|
framework_version_param["required"] = false
|
310
|
-
framework_version_param["position"] = "A#{auto_script_params.size + 1}:C#{
|
321
|
+
framework_version_param["position"] = "A#{auto_script_params.size + 1}:C#{input_params.size + 1}" if include_position_attribute
|
311
322
|
auto_script_params["framework_version"] = framework_version_param
|
312
323
|
end
|
313
324
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niek Bartholomeus
|
8
8
|
autorequire:
|
9
9
|
bindir: modules/framework/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|