diff --git a/tendrl/node_agent/node_sync/__init__.py b/tendrl/node_agent/node_sync/__init__.py index 15d652f5..fe10e9ba 100644 --- a/tendrl/node_agent/node_sync/__init__.py +++ b/tendrl/node_agent/node_sync/__init__.py @@ -96,7 +96,17 @@ def _run(self): index_key = "/indexes/machine_id/%s" % NS.node_context.machine_id NS.etcd_orm.client.write(index_key, NS.node_context.node_id) - Event( + except etcd.EtcdKeyNotFound: + pass + + if NS.tendrl_context.integration_id: + try: + NS.etcd_orm.client.read( + "/clusters/%s" % ( + NS.tendrl_context.integration_id + ) + ) + Event( Message( priority=priority, publisher=NS.publisher_id, @@ -107,26 +117,7 @@ def _run(self): } ) ) - except etcd.EtcdKeyNotFound: - Event( - Message( - priority=priority, - publisher=NS.publisher_id, - payload={"message": "Node %s is not part of any " - "sds cluster" % - NS.node_context.node_id - } - ) - ) - pass - if NS.tendrl_context.integration_id: - try: - NS.etcd_orm.client.read( - "/clusters/%s" % ( - NS.tendrl_context.integration_id - ) - ) except etcd.EtcdKeyNotFound: Event( Message( @@ -138,17 +129,7 @@ def _run(self): } ) ) - else: - Event( - Message( - priority=priority, - publisher=NS.publisher_id, - payload={"message": "node_sync, updating " - "tendrl context" - } - ) - ) - + else: Event( Message( priority=priority, diff --git a/tendrl/node_agent/objects/cluster_message/__init__.py b/tendrl/node_agent/objects/cluster_message/__init__.py index 8bcb4ee2..577bbc02 100644 --- a/tendrl/node_agent/objects/cluster_message/__init__.py +++ b/tendrl/node_agent/objects/cluster_message/__init__.py @@ -13,6 +13,9 @@ def __init__(self, **cluster_message): self.value = 'clusters/%s/messages/%s' self._etcd_cls = _ClusterMessageEtcd + def save(self): + super(ClusterMessage, self).save(update=False) + class _ClusterMessageEtcd(etcdobj.EtcdObj): """Cluster message object, lazily updated diff --git a/tendrl/node_agent/objects/message/__init__.py b/tendrl/node_agent/objects/message/__init__.py index 9a68d308..1f5d5792 100644 --- a/tendrl/node_agent/objects/message/__init__.py +++ b/tendrl/node_agent/objects/message/__init__.py @@ -11,7 +11,10 @@ def __init__(self, **message_arg): objects.BaseObject.__init__(self) self.value = 'messages/events/%s' self._etcd_cls = _MessageEtcd - + + def save(self): + super(Message, self).save(update=False) + class _MessageEtcd(etcdobj.EtcdObj): """Message object, lazily updated diff --git a/tendrl/node_agent/objects/node_message/__init__.py b/tendrl/node_agent/objects/node_message/__init__.py index fdc98958..0c2e99de 100644 --- a/tendrl/node_agent/objects/node_message/__init__.py +++ b/tendrl/node_agent/objects/node_message/__init__.py @@ -13,6 +13,9 @@ def __init__(self, **node_message): self.value = 'nodes/%s/messages/%s' self._etcd_cls = _NodeMessageEtcd + def save(self): + super(NodeMessage, self).save(update=False) + class _NodeMessageEtcd(etcdobj.EtcdObj): """Node message object, lazily updated