summaryrefslogtreecommitdiff
path: root/iotronic/conductor/endpoints.py
diff options
context:
space:
mode:
Diffstat (limited to 'iotronic/conductor/endpoints.py')
-rw-r--r--iotronic/conductor/endpoints.py104
1 files changed, 44 insertions, 60 deletions
diff --git a/iotronic/conductor/endpoints.py b/iotronic/conductor/endpoints.py
index 5e10c49..14a4518 100644
--- a/iotronic/conductor/endpoints.py
+++ b/iotronic/conductor/endpoints.py
@@ -305,12 +305,12 @@ class ConductorEndpoint(object):
305 return serializer.serialize_entity(ctx, service) 305 return serializer.serialize_entity(ctx, service)
306 306
307 def action_service(self, ctx, service_uuid, board_uuid, action): 307 def action_service(self, ctx, service_uuid, board_uuid, action):
308 LOG.info('Enable service with id %s into the board %s',
309 service_uuid, board_uuid)
310 service = objects.Service.get(ctx, service_uuid) 308 service = objects.Service.get(ctx, service_uuid)
311 objects.service.is_valid_action(action) 309 objects.service.is_valid_action(action)
312 310
313 if action == "ServiceEnable": 311 if action == "ServiceEnable":
312 LOG.info('Enabling service with id %s into the board %s',
313 service_uuid, board_uuid)
314 try: 314 try:
315 objects.ExposedService.get(ctx, 315 objects.ExposedService.get(ctx,
316 board_uuid, 316 board_uuid,
@@ -348,6 +348,8 @@ class ConductorEndpoint(object):
348 return res.message 348 return res.message
349 349
350 elif action == "ServiceDisable": 350 elif action == "ServiceDisable":
351 LOG.info('Disabling service with id %s into the board %s',
352 service_uuid, board_uuid)
351 exposed = objects.ExposedService.get(ctx, 353 exposed = objects.ExposedService.get(ctx,
352 board_uuid, 354 board_uuid,
353 service_uuid) 355 service_uuid)
@@ -361,12 +363,11 @@ class ConductorEndpoint(object):
361 return result 363 return result
362 364
363 elif action == "ServiceRestore": 365 elif action == "ServiceRestore":
364 366 LOG.info('Restoring service with id %s into the board %s',
367 service_uuid, board_uuid)
365 exposed = objects.ExposedService.get(ctx, board_uuid, 368 exposed = objects.ExposedService.get(ctx, board_uuid,
366 service_uuid) 369 service_uuid)
367 370
368 print(exposed)
369
370 res = self.execute_on_board(ctx, board_uuid, action, 371 res = self.execute_on_board(ctx, board_uuid, action,
371 (service.name, exposed.public_port, 372 (service.name, exposed.public_port,
372 service.port, exposed.pid)) 373 service.port, exposed.pid))
@@ -396,58 +397,41 @@ class ConductorEndpoint(object):
396 LOG.debug(res.message) 397 LOG.debug(res.message)
397 return res.message 398 return res.message
398 399
399 # try: 400 def restore_services_on_board(self, ctx, board_uuid):
400 # 401 LOG.info('Restoring the services into the board %s',
401 # 402 board_uuid)
402 # return exception.ServiceAlreadyExposed(uuid=service_uuid) 403
403 # except: 404 exposed_list = objects.ExposedService.get_by_board_uuid(ctx,
404 # name=service.name 405 board_uuid)
405 # public_port=random_public_port() 406
406 # port=service.port 407 # response = []
407 # 408 for exposed in exposed_list:
408 # res = self.execute_on_board(ctx, board_uuid, action, 409 service = objects.Service.get_by_uuid(ctx, exposed.service_uuid)
409 # (name, public_port, port)) 410 res = self.execute_on_board(ctx, board_uuid, "ServiceRestore",
410 # 411 (service.name, exposed.public_port,
411 # if res.result == wm.SUCCESS: 412 service.port, exposed.pid))
412 # pid = res.message[0] 413
413 # 414 if res.result == wm.SUCCESS:
414 # exp_data = { 415 pid = res.message[0]
415 # 'board_uuid': board_uuid, 416
416 # 'service_uuid': service_uuid, 417 exp_data = {
417 # 'public_port': public_port, 418 'id': exposed.id,
418 # 'pid': pid, 419 'board_uuid': exposed.board_uuid,
419 # } 420 'service_uuid': exposed.service_uuid,
420 # exposed = objects.ExposedService(ctx, **exp_data) 421 'public_port': exposed.public_port,
421 # exposed.create() 422 'pid': pid,
422 # 423 }
423 # res.message = res.message[1] 424
424 # elif res.result == wm.ERROR: 425 exposed = objects.ExposedService(ctx, **exp_data)
425 # LOG.error('Error in the execution of %s on %s: %s', 426 exposed.save()
426 # action, 427
427 # board_uuid, res.message) 428 # response.append(exposed)
428 # raise exception.ErrorExecutionOnBoard(call=action, 429 elif res.result == wm.ERROR:
429 # board=board_uuid, 430 LOG.error('Error in restoring %s on %s: %s',
430 # error=res.message) 431 service.name,
431 # LOG.debug(res.message) 432 board_uuid, res.message)
432 # return res.message 433 raise exception.ErrorExecutionOnBoard(call="ServiceRestore",
433 # 434 board=board_uuid,
434 # 435 error=res.message)
435 # 436
436 # 437 return 0
437 #
438 #
439 #
440 #
441 #
442 #
443 #
444 # exposed = objects.ExposedService.get(ctx, board_uuid,
445 # service_uuid)
446 #
447 # res = self.execute_on_board(ctx, board_uuid, action,
448 # (service.name, exposed.pid))
449 #
450 # result=manage_result(res,action,board_uuid)
451 # LOG.debug(res.message)
452 # exposed.destroy()
453 # return result