Skip to content

Commit

Permalink
Merge pull request #361 from Tendrl/develop
Browse files Browse the repository at this point in the history
Merge develop onto master
  • Loading branch information
r0h4n authored Mar 31, 2017
2 parents ec02279 + d976f57 commit 241a8b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 32 deletions.
43 changes: 12 additions & 31 deletions tendrl/node_agent/node_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions tendrl/node_agent/objects/cluster_message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tendrl/node_agent/objects/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tendrl/node_agent/objects/node_message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 241a8b6

Please sign in to comment.