From 175653d8aa6327c12b1d4622ceec1de04e28f222 Mon Sep 17 00:00:00 2001 From: Fabio Verboso Date: Tue, 5 Feb 2019 11:03:22 +0100 Subject: [PATCH] Wamp registration rpc returns the configuration. if the board is already registered the wamp rpc returns the board config instead of rejects the request, Change-Id: Id23f558d7598d44d69effc929d07bdc25ae90e45 --- iotronic/conductor/endpoints.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iotronic/conductor/endpoints.py b/iotronic/conductor/endpoints.py index b30258d..01bf11c 100644 --- a/iotronic/conductor/endpoints.py +++ b/iotronic/conductor/endpoints.py @@ -130,12 +130,6 @@ class ConductorEndpoint(object): LOG.error(msg) return wm.WampError(msg).serialize() - if not board.status == states.REGISTERED: - msg = "board with code %(board)s cannot " \ - "be registered again." % {'board': code} - LOG.error(msg) - return wm.WampError(msg).serialize() - try: old_ses = objects.SessionWP(ctx) old_ses = old_ses.get_session_by_board_uuid(ctx, board.uuid, @@ -152,6 +146,16 @@ class ConductorEndpoint(object): session = objects.SessionWP(ctx, **session_data) session.create() + if not board.status == states.REGISTERED: + msg = "board with code %(board)s " \ + "already registered" % {'board': code} + LOG.warning((msg)) + board.status = states.OFFLINE + board.save() + LOG.debug('sending this conf %s', board.config) + wmessage = wm.WampSuccess(board.config) + return wmessage.serialize() + board.agent = get_best_agent(ctx) agent = objects.WampAgent.get_by_hostname(ctx, board.agent)