From 39e3336a0ea6f785763f44238871e149258a31f3 Mon Sep 17 00:00:00 2001 From: Rohan Kanade Date: Thu, 18 May 2017 13:53:27 +0530 Subject: [PATCH] Update __init__.py --- tendrl/node_agent/node_sync/__init__.py | 132 ++++++++++++------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/tendrl/node_agent/node_sync/__init__.py b/tendrl/node_agent/node_sync/__init__.py index d627280c..370af727 100644 --- a/tendrl/node_agent/node_sync/__init__.py +++ b/tendrl/node_agent/node_sync/__init__.py @@ -130,72 +130,6 @@ def _run(self): except etcd.EtcdAlreadyExist: pass - if NS.tendrl_context.integration_id: - try: - NS._int.client.read( - "/clusters/%s" % ( - NS.tendrl_context.integration_id - ) - ) - Event( - Message( - priority=priority, - publisher=NS.publisher_id, - payload={"message": "Node %s is part of sds " - "cluster %s" % ( - NS.node_context.node_id, - NS.tendrl_context.integration_id) - } - ) - ) - - except etcd.EtcdKeyNotFound: - Event( - Message( - priority="warning", - publisher=NS.publisher_id, - payload={"message": "Node %s is not part of " - "any sds cluster" % - NS.node_context.node_id - } - ) - ) - else: - Event( - Message( - priority=priority, - publisher=NS.publisher_id, - payload={"message": "node_sync, updating " - "cluster tendrl context" - } - ) - ) - - NS.tendrl.objects.ClusterTendrlContext( - integration_id=NS.tendrl_context.integration_id, - cluster_id=NS.tendrl_context.cluster_id, - cluster_name=NS.tendrl_context.cluster_name, - sds_name=NS.tendrl_context.sds_name, - sds_version=NS.tendrl_context.sds_version - ).save() - Event( - Message( - priority=priority, - publisher=NS.publisher_id, - payload={"message": "node_sync, Updating" - "cluster node context" - } - ) - ) - NS.tendrl.objects.ClusterNodeContext( - machine_id=NS.node_context.machine_id, - node_id=NS.node_context.node_id, - fqdn=NS.node_context.fqdn, - status=NS.node_context.status, - tags=NS.node_context.tags - ).save() - gevent.sleep(interval) - Event( Message( priority=priority, @@ -357,6 +291,72 @@ def _run(self): if interface["subnet"] is not "": NS.node_agent.objects.GlobalNetwork( **interface).save() + + if NS.tendrl_context.integration_id: + try: + NS._int.client.read( + "/clusters/%s" % ( + NS.tendrl_context.integration_id + ) + ) + Event( + Message( + priority=priority, + publisher=NS.publisher_id, + payload={"message": "Node %s is part of sds " + "cluster %s" % ( + NS.node_context.node_id, + NS.tendrl_context.integration_id) + } + ) + ) + + except etcd.EtcdKeyNotFound: + Event( + Message( + priority="warning", + publisher=NS.publisher_id, + payload={"message": "Node %s is not part of " + "any sds cluster" % + NS.node_context.node_id + } + ) + ) + else: + Event( + Message( + priority=priority, + publisher=NS.publisher_id, + payload={"message": "node_sync, updating " + "cluster tendrl context" + } + ) + ) + + NS.tendrl.objects.ClusterTendrlContext( + integration_id=NS.tendrl_context.integration_id, + cluster_id=NS.tendrl_context.cluster_id, + cluster_name=NS.tendrl_context.cluster_name, + sds_name=NS.tendrl_context.sds_name, + sds_version=NS.tendrl_context.sds_version + ).save() + Event( + Message( + priority=priority, + publisher=NS.publisher_id, + payload={"message": "node_sync, Updating" + "cluster node context" + } + ) + ) + NS.tendrl.objects.ClusterNodeContext( + machine_id=NS.node_context.machine_id, + node_id=NS.node_context.node_id, + fqdn=NS.node_context.fqdn, + status=NS.node_context.status, + tags=NS.node_context.tags + ).save() + gevent.sleep(interval) except Exception as ex: Event(