Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
r0h4n authored May 18, 2017
1 parent d682a76 commit 39e3336
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions tendrl/node_agent/node_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 39e3336

Please sign in to comment.