brpm_content 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/modules/framework/config.yml +1 -1
- data/modules/framework/lib/module_installer.rb +66 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGZjMzAyNjYxMzE1YWVkNzU1ZGE2MTFmODM2ZmMyOWY2ZTI0MGU2Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmI4ZDA4ZjZlZWM1ZjBmMzI4Zjk5NWMxNmJmZWVlNGNjMDY3NTllMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjBlMGM5YWRlMzlhNTFlY2I1MDE1YzM0YjhhMTQ1YmQ5ZDc3ZWYyOTdiMDM2
|
10
|
+
MDQ5NzNlNzk2NGI4YTEwMGRjM2Y4N2NlYjlhYzI5NTQ5ZDAzYWQwNDNiOWEy
|
11
|
+
YTM5YzMxMzMwYzgzN2JlNThkYjBiOTU2ZGU5ZDdlNmI4YWQ0YmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTBiMTcwYzY1MzQzYTU0OTY4YzVkYTRlMGNjYTFlYmUwYjYxM2I4NGVhNWZk
|
14
|
+
MjUxNTIwMzMzNzZhYzA0MzFhYjM1NzgxNWZlOTQwMjVhMjE1ZTdjMDExNjIw
|
15
|
+
Njg2NGNhODE2OTVkODQwMWZmNDEzOGRhOWNjZDAwYzhhYmNmNTQ=
|
@@ -21,9 +21,45 @@ class ModuleInstaller
|
|
21
21
|
FileUtils.cp("#{brpm_content_spec.gem_dir}/modules/framework/log.html", "#{ENV["BRPM_HOME"]}/automation_results")
|
22
22
|
end
|
23
23
|
|
24
|
-
BrpmAuto.log "
|
25
|
-
|
24
|
+
BrpmAuto.log "Preparing the connectivity to BRPM..."
|
25
|
+
if prepare_brpm_connection
|
26
|
+
module_friendly_name = get_module_friendly_name(module_name)
|
27
|
+
BrpmAuto.log "Creating an automation category for #{module_friendly_name} if one doesn't exist yet..."
|
28
|
+
create_automation_category_if_not_exists(module_friendly_name)
|
29
|
+
|
30
|
+
BrpmAuto.log "Installing the automation script wrappers in the local BRPM instance..."
|
31
|
+
install_auto_script_wrappers(module_spec.gem_dir, module_spec.name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def prepare_brpm_connection
|
37
|
+
brpm_file = File.expand_path("~/.brpm")
|
38
|
+
|
39
|
+
config = nil
|
40
|
+
if File.exists?(brpm_file)
|
41
|
+
config = YAML.load_file(brpm_file)
|
26
42
|
end
|
43
|
+
|
44
|
+
if config
|
45
|
+
unless config["brpm_url"] and config["brpm_api_token"]
|
46
|
+
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."
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
else
|
50
|
+
BrpmAuto.log "WARNING - File ~/.brpm doesn't exist so not installing the automation script wrappers in BRPM. If you want to install them the next time you should create this file and add brpm_url and brpm_api_token properties in yaml format."
|
51
|
+
return false
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
BrpmAuto.require_module_from_gem "brpm_module_brpm"
|
56
|
+
rescue Gem::GemNotFoundException
|
57
|
+
BrpmAuto.log "WARNING - Module brpm_module_brpm is not installed so not installing the automation script wrappers in BRPM."
|
58
|
+
return false
|
59
|
+
end
|
60
|
+
|
61
|
+
@brpm_rest_client = BrpmRestClient.new(config["brpm_url"], config["brpm_api_token"])
|
62
|
+
true
|
27
63
|
end
|
28
64
|
|
29
65
|
def install_gem(module_name, module_version)
|
@@ -78,35 +114,25 @@ class ModuleInstaller
|
|
78
114
|
ENV["BRPM_HOME"] and !ENV["BRPM_HOME"].empty?
|
79
115
|
end
|
80
116
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
config = nil
|
85
|
-
if File.exists?(brpm_file)
|
86
|
-
config = YAML.load_file(brpm_file)
|
87
|
-
end
|
117
|
+
def get_module_friendly_name(module_name)
|
118
|
+
"#{module_name.sub("brpm_module_", "").capitalize}"
|
119
|
+
end
|
88
120
|
|
89
|
-
|
90
|
-
|
91
|
-
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."
|
92
|
-
return false
|
93
|
-
end
|
94
|
-
else
|
95
|
-
BrpmAuto.log "WARNING - File ~/.brpm doesn't exist so not installing the automation script wrappers in BRPM. If you want to install them the next time you should create this file and add brpm_url and brpm_api_token properties in yaml format."
|
96
|
-
return false
|
97
|
-
end
|
121
|
+
def create_automation_category_if_not_exists(module_friendly_name)
|
122
|
+
list_item = @brpm_rest_client.get_list_item_by_name(module_friendly_name)
|
98
123
|
|
99
|
-
|
100
|
-
BrpmAuto.
|
101
|
-
|
102
|
-
|
103
|
-
|
124
|
+
unless list_item
|
125
|
+
BrpmAuto.log "Automation category #{module_friendly_name} doesn't exist yet, so creating it now..."
|
126
|
+
list_item = {}
|
127
|
+
list_item["list_id"] = 24 # AutomationCategory TODO: find the id by the name of the list
|
128
|
+
list_item["value_text"] = module_friendly_name
|
129
|
+
@brpm_rest_client.create_list_item_by_hash(list_item)
|
104
130
|
end
|
131
|
+
end
|
105
132
|
|
106
|
-
|
107
|
-
|
133
|
+
def install_auto_script_wrappers(module_path, module_name)
|
108
134
|
BrpmAuto.log "Retrieving the integration servers..."
|
109
|
-
integration_servers = brpm_rest_client.get_project_servers
|
135
|
+
integration_servers = @brpm_rest_client.get_project_servers
|
110
136
|
|
111
137
|
# For resource automations
|
112
138
|
resource_automation_dir = "#{module_path}/resource_automations"
|
@@ -118,7 +144,7 @@ class ModuleInstaller
|
|
118
144
|
|
119
145
|
resource_automation_script_paths.each do |auto_script_path|
|
120
146
|
begin
|
121
|
-
install_auto_script_wrapper(auto_script_path, "ResourceAutomation", module_name, integration_servers
|
147
|
+
install_auto_script_wrapper(auto_script_path, "ResourceAutomation", module_name, integration_servers)
|
122
148
|
rescue Exception => e
|
123
149
|
failed_scripts << auto_script_path
|
124
150
|
BrpmAuto.log_error(e)
|
@@ -136,7 +162,7 @@ class ModuleInstaller
|
|
136
162
|
|
137
163
|
automation_script_paths.each do |auto_script_path|
|
138
164
|
begin
|
139
|
-
install_auto_script_wrapper(auto_script_path, "Automation", module_name, integration_servers
|
165
|
+
install_auto_script_wrapper(auto_script_path, "Automation", module_name, integration_servers)
|
140
166
|
rescue Exception => e
|
141
167
|
failed_scripts << auto_script_path
|
142
168
|
BrpmAuto.log_error(e)
|
@@ -155,7 +181,7 @@ class ModuleInstaller
|
|
155
181
|
end
|
156
182
|
end
|
157
183
|
|
158
|
-
def install_auto_script_wrapper(auto_script_path, automation_type, module_name, integration_servers
|
184
|
+
def install_auto_script_wrapper(auto_script_path, automation_type, module_name, integration_servers)
|
159
185
|
auto_script_name = File.basename(auto_script_path, ".rb")
|
160
186
|
BrpmAuto.log "Installing the wrapper script for resource automation #{auto_script_name}..."
|
161
187
|
|
@@ -181,7 +207,7 @@ class ModuleInstaller
|
|
181
207
|
|
182
208
|
integration_server = nil
|
183
209
|
if auto_script_config["integration_server_type"]
|
184
|
-
server_type_id = brpm_rest_client.get_id_for_project_server_type(auto_script_config["integration_server_type"])
|
210
|
+
server_type_id = @brpm_rest_client.get_id_for_project_server_type(auto_script_config["integration_server_type"])
|
185
211
|
if server_type_id
|
186
212
|
integration_server = integration_servers.find { |integration_server| integration_server["server_name_id"] == server_type_id } #TODO: support multiple integration servers of same type (user should pick one)
|
187
213
|
|
@@ -199,14 +225,18 @@ class ModuleInstaller
|
|
199
225
|
wrapper_script_content += "\n"
|
200
226
|
wrapper_script_content += get_script_executor_template(automation_type, module_name, auto_script_name)
|
201
227
|
|
202
|
-
|
203
|
-
|
228
|
+
module_friendly_name = get_module_friendly_name(module_name)
|
229
|
+
auto_script_friendly_name = auto_script_config["friendly_name"] || "#{module_friendly_name} - #{auto_script_name.gsub("_", " ").capitalize}"
|
230
|
+
if auto_script_config["automation_category"]
|
231
|
+
automation_category = auto_script_config["automation_category"]
|
232
|
+
create_automation_category_if_not_exists(automation_category)
|
233
|
+
end
|
204
234
|
|
205
235
|
script = {}
|
206
236
|
script["name"] = auto_script_friendly_name
|
207
237
|
script["description"] = auto_script_friendly_name
|
208
238
|
script["automation_type"] = automation_type
|
209
|
-
script["automation_category"] =
|
239
|
+
script["automation_category"] = module_friendly_name
|
210
240
|
script["content"] = wrapper_script_content
|
211
241
|
script["integration_id"] = integration_server["id"] if auto_script_config["integration_server_type"] and integration_server
|
212
242
|
if automation_type == "ResourceAutomation"
|
@@ -214,14 +244,14 @@ class ModuleInstaller
|
|
214
244
|
script["render_as"] = auto_script_config["render_as"] || "List"
|
215
245
|
end
|
216
246
|
|
217
|
-
script = brpm_rest_client.create_or_update_script(script)
|
247
|
+
script = @brpm_rest_client.create_or_update_script(script)
|
218
248
|
|
219
249
|
if script["aasm_state"] == "draft"
|
220
250
|
BrpmAuto.log "Updating the aasm_state of the script to 'pending'..."
|
221
251
|
script_to_update = {}
|
222
252
|
script_to_update["id"] = script["id"]
|
223
253
|
script_to_update["aasm_state"] = "pending"
|
224
|
-
script = brpm_rest_client.update_script_from_hash(script_to_update)
|
254
|
+
script = @brpm_rest_client.update_script_from_hash(script_to_update)
|
225
255
|
end
|
226
256
|
|
227
257
|
if script["aasm_state"] == "pending"
|
@@ -229,7 +259,7 @@ class ModuleInstaller
|
|
229
259
|
script_to_update = {}
|
230
260
|
script_to_update["id"] = script["id"]
|
231
261
|
script_to_update["aasm_state"] = "released"
|
232
|
-
script = brpm_rest_client.update_script_from_hash(script_to_update)
|
262
|
+
script = @brpm_rest_client.update_script_from_hash(script_to_update)
|
233
263
|
end
|
234
264
|
end
|
235
265
|
|