Skip to content

Commit d39c229

Browse files
Christian Gonzálezrsmontero
Christian González
authored andcommitted
B #5814: OneFlow server creates clients as needed
Oneflow do not caches OpenNebulaClient objects and generate a new one whenever an user operation needs to be made. * onflow-server sends the @username down to the flow components, so it can create serveradmin tokens when needed in callbacks. Athentication is performed in the flow-server * Direct (non-cb) actions receive a fresh client each time to execute the operation (cherry picked from commit 8980e1b)
1 parent 74bc751 commit d39c229

File tree

6 files changed

+539
-594
lines changed

6 files changed

+539
-594
lines changed

src/flow/lib/EventManager.rb

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def initialize(options)
101101
# @param [Service] service the service
102102
# @param [Role] the role which contains the VMs
103103
# @param [Node] nodes the list of nodes (VMs) to wait for
104-
def wait_deploy_action(client, service_id, role_name, nodes, report)
104+
def wait_deploy_action(external_user, service_id, role_name, nodes, report)
105105
if report
106106
Log.info LOG_COMP, "Waiting #{nodes} to report ready"
107107
rc = wait_report_ready(nodes)
@@ -113,25 +113,25 @@ def wait_deploy_action(client, service_id, role_name, nodes, report)
113113
if rc[0]
114114
@lcm.trigger_action(:deploy_cb,
115115
service_id,
116-
client,
116+
external_user,
117117
service_id,
118118
role_name,
119119
rc[1])
120120
else
121121
@lcm.trigger_action(:deploy_failure_cb,
122122
service_id,
123-
client,
123+
external_user,
124124
service_id,
125125
role_name)
126126
end
127127
end
128128

129129
# Wait for networks to e ready
130130
#
131-
# @param client [OpenNebula::Client] Client to perform requests
132-
# @param service_id [Integer] Service ID
133-
# @param networks [Array] Network IDs to wait until ready
134-
def wait_deploy_nets_action(client, service_id, networks)
131+
# @param external_user [String] External user to impersonate for performing the action
132+
# @param service_id [Integer] Service ID
133+
# @param networks [Array] Network IDs to wait until ready
134+
def wait_deploy_nets_action(external_user, service_id, networks)
135135
Log.info LOG_COMP, "Waiting networks #{networks} to be (READY)"
136136
rc = wait_nets(networks, 'READY')
137137

@@ -141,15 +141,15 @@ def wait_deploy_nets_action(client, service_id, networks)
141141
action = :deploy_nets_failure_cb
142142
end
143143

144-
@lcm.trigger_action(action, service_id, client, service_id)
144+
@lcm.trigger_action(action, service_id, external_user, service_id)
145145
end
146146

147147
# Wait for networks to e ready
148148
#
149-
# @param client [OpenNebula::Client] Client to perform requests
149+
# @param external_user [String] External user to impersonate for performing the action
150150
# @param service_id [Integer] Service ID
151151
# @param networks [Array] Network IDs to wait until ready
152-
def wait_undeploy_nets_action(client, service_id, networks)
152+
def wait_undeploy_nets_action(external_user, service_id, networks)
153153
Log.info LOG_COMP, "Waiting networks #{networks} to be (DONE)"
154154
rc = wait_nets(networks, 'DONE')
155155

@@ -159,28 +159,29 @@ def wait_undeploy_nets_action(client, service_id, networks)
159159
action = :undeploy_nets_failure_cb
160160
end
161161

162-
@lcm.trigger_action(action, service_id, client, service_id)
162+
@lcm.trigger_action(action, service_id, external_user, service_id)
163163
end
164164

165165
# Wait for nodes to be in DONE
166+
# @param [String] External user to impersonate for performing the action
166167
# @param [service_id] the service id
167168
# @param [role_name] the role name of the role which contains the VMs
168169
# @param [nodes] the list of nodes (VMs) to wait for
169-
def wait_undeploy_action(client, service_id, role_name, nodes)
170+
def wait_undeploy_action(external_user, service_id, role_name, nodes)
170171
Log.info LOG_COMP, "Waiting #{nodes} to be (DONE, LCM_INIT)"
171172
rc = wait(nodes, 'DONE', 'LCM_INIT')
172173

173174
if rc[0]
174175
@lcm.trigger_action(:undeploy_cb,
175176
service_id,
176-
client,
177+
external_user,
177178
service_id,
178179
role_name,
179180
rc[1])
180181
else
181182
@lcm.trigger_action(:undeploy_failure_cb,
182183
service_id,
183-
client,
184+
external_user,
184185
service_id,
185186
role_name,
186187
rc[1])
@@ -189,11 +190,12 @@ def wait_undeploy_action(client, service_id, role_name, nodes)
189190

190191
# Wait for nodes to be in RUNNING if OneGate check required it will trigger
191192
# another action after VMs are RUNNING
193+
# @param [String] External user to impersonate for performing the action
192194
# @param [Service] service the service
193195
# @param [Role] the role which contains the VMs
194196
# @param [Node] nodes the list of nodes (VMs) to wait for
195197
# @param [Bool] up true if scalling up false otherwise
196-
def wait_scaleup_action(client, service_id, role_name, nodes, report)
198+
def wait_scaleup_action(external_user, service_id, role_name, nodes, report)
197199
if report
198200
Log.info LOG_COMP, "Waiting #{nodes} to report ready"
199201
rc = wait_report_ready(nodes)
@@ -205,42 +207,42 @@ def wait_scaleup_action(client, service_id, role_name, nodes, report)
205207
if rc[0]
206208
@lcm.trigger_action(:scaleup_cb,
207209
service_id,
208-
client,
210+
external_user,
209211
service_id,
210212
role_name,
211213
rc[1])
212214
else
213215
@lcm.trigger_action(:scaleup_failure_cb,
214216
service_id,
215-
client,
217+
external_user,
216218
service_id,
217219
role_name)
218220
end
219221
end
220222

221-
def wait_scaledown_action(client, service_id, role_name, nodes)
223+
def wait_scaledown_action(external_user, service_id, role_name, nodes)
222224
Log.info LOG_COMP, "Waiting #{nodes} to be (DONE, LCM_INIT)"
223225

224226
rc = wait(nodes, 'DONE', 'LCM_INIT')
225227

226228
if rc[0]
227229
@lcm.trigger_action(:scaledown_cb,
228230
service_id,
229-
client,
231+
external_user,
230232
service_id,
231233
role_name,
232234
rc[1])
233235
else
234236
@lcm.trigger_action(:scaledown_failure_cb,
235237
service_id,
236-
client,
238+
external_user,
237239
service_id,
238240
role_name,
239241
rc[1])
240242
end
241243
end
242244

243-
def wait_add_action(client, service_id, role_name, nodes, report)
245+
def wait_add_action(external_user, service_id, role_name, nodes, report)
244246
if report
245247
Log.info LOG_COMP, "Waiting #{nodes} to report ready"
246248
rc = wait_report_ready(nodes)
@@ -252,82 +254,86 @@ def wait_add_action(client, service_id, role_name, nodes, report)
252254
if rc[0]
253255
@lcm.trigger_action(:add_cb,
254256
service_id,
255-
client,
257+
external_user,
256258
service_id,
257259
role_name,
258260
rc[1])
259261
else
260262
@lcm.trigger_action(:add_failure_cb,
261263
service_id,
262-
client,
264+
external_user,
263265
service_id,
264266
role_name)
265267
end
266268
end
267269

268270
# Wait for nodes to be in DONE
271+
# @param [String] External user to impersonate for performing the action
269272
# @param [service_id] the service id
270273
# @param [role_name] the role name of the role which contains the VMs
271274
# @param [nodes] the list of nodes (VMs) to wait for
272-
def wait_remove_action(client, service_id, role_name, nodes)
275+
def wait_remove_action(external_user, service_id, role_name, nodes)
273276
Log.info LOG_COMP, "Waiting #{nodes} to be (DONE, LCM_INIT)"
274277
rc = wait(nodes, 'DONE', 'LCM_INIT')
275278

276279
if rc[0]
277280
@lcm.trigger_action(:remove_cb,
278281
service_id,
279-
client,
282+
external_user,
280283
service_id,
281284
role_name,
282285
rc[1])
283286
else
284287
@lcm.trigger_action(:remove_failure_cb,
285288
service_id,
286-
client,
289+
external_user,
287290
service_id,
288291
role_name,
289292
rc[1])
290293
end
291294
end
292295

293296
# Wait for nodes to be in DONE
297+
# @param [String] External user to impersonate for performing the action
294298
# @param [service_id] the service id
295299
# @param [role_name] the role name of the role which contains the VMs
296300
# @param [nodes] the list of nodes (VMs) to wait for
297-
def wait_cooldown_action(client, service_id, role_name, cooldown_time)
301+
def wait_cooldown_action(external_user, service_id, role_name, cooldown_time)
298302
Log.info LOG_COMP, "Waiting #{cooldown_time}s for cooldown for " \
299303
"service #{service_id} and role #{role_name}."
300304

301305
sleep cooldown_time.to_i
302306

303307
@lcm.trigger_action(:cooldown_cb,
304308
service_id,
305-
client,
309+
external_user,
306310
service_id,
307311
role_name)
308312
end
309313

310314
# Wait for nodes to be in HOLD
315+
# @param [String] External user to impersonate for performing the action
311316
# @param [service_id] the service id
312317
# @param [role_name] the role name of the role which contains the VMs
313318
# @param [nodes] the list of nodes (VMs) to wait for
314-
def wait_hold_action(client, service_id, role_name, nodes)
319+
def wait_hold_action(external_user, service_id, role_name, nodes)
315320
Log.info LOG_COMP, "Waiting #{nodes} to be (HOLD, LCM_INIT)"
316321
wait(nodes, 'HOLD', 'LCM_INIT')
317322

318323
@lcm.trigger_action(:hold_cb,
319324
service_id,
320-
client,
325+
external_user,
321326
service_id,
322327
role_name)
323328
end
324329

325330
# Wait for nodes to be in RUNNING if OneGate check required it will trigger
326331
# another action after VMs are RUNNING
332+
# @param [String] External user to impersonate for performing the action
327333
# @param [Service] service the service
328334
# @param [Role] the role which contains the VMs
329335
# @param [Node] nodes the list of nodes (VMs) to wait for
330-
def wait_release_action(client, service_id, role_name, nodes, report)
336+
def wait_release_action(external_user, service_id, role_name, nodes, report)
331337
if report
332338
Log.info LOG_COMP, "Waiting #{nodes} to report ready"
333339
rc = wait_report_ready(nodes)
@@ -339,14 +345,14 @@ def wait_release_action(client, service_id, role_name, nodes, report)
339345
if rc[0]
340346
@lcm.trigger_action(:release_cb,
341347
service_id,
342-
client,
348+
external_user,
343349
service_id,
344350
role_name,
345351
rc[1])
346352
else
347353
@lcm.trigger_action(:deploy_failure_cb,
348354
service_id,
349-
client,
355+
external_user,
350356
service_id,
351357
role_name)
352358
end

0 commit comments

Comments
 (0)