From dcb4290fb8ad4956eb37ba14a52efe28f1d6b015 Mon Sep 17 00:00:00 2001 From: Shubhendu Date: Thu, 31 Aug 2017 23:20:19 +0530 Subject: [PATCH] Added logic to invoke update dashboard flow from monitoring integration tendrl-bug-id: Tendrl/gluster-integration#385 Signed-off-by: Shubhendu --- .../gluster_integration/sds_sync/__init__.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tendrl/gluster_integration/sds_sync/__init__.py b/tendrl/gluster_integration/sds_sync/__init__.py index ed9bd81..2b63a43 100644 --- a/tendrl/gluster_integration/sds_sync/__init__.py +++ b/tendrl/gluster_integration/sds_sync/__init__.py @@ -12,6 +12,7 @@ from tendrl.commons import sds_sync from tendrl.commons.utils import cmd_utils from tendrl.commons.utils import etcd_utils +from tendrl.commons.utils import monitoring_utils from tendrl.commons.utils.time_utils import now as tendrl_now from tendrl.gluster_integration import ini2json from tendrl.gluster_integration.sds_sync import brick_device_details @@ -26,6 +27,10 @@ gevent.hub.Hub.NOT_ERROR=(Exception,) +RESOURCE_TYPE_BRICK = "brick" +RESOURCE_TYPE_PEER = "host" +RESOURCE_TYPE_VOLUME = "volume" + class GlusterIntegrationSdsSyncStateThread(sds_sync.SdsSyncThread): @@ -151,6 +156,13 @@ def _run(self): ], state=peers['peer%s.state' % index] ) + if not peer.exists(): + monitoring_utils.update_dashboard( + peer.hostname, + RESOURCE_TYPE_PEER, + NS.tendrl_context.integration_id, + "add" + ) peer.save(ttl=SYNC_TTL) index += 1 except KeyError: @@ -346,6 +358,13 @@ def sync_volumes(volumes, index, vol_options): snapd_status=volumes['volume%s.snapd_svc.online_status' % index], snapd_inited=volumes['volume%s.snapd_svc.inited' % index], ) + if not volume.exists(): + monitoring_utils.update_dashboard( + volume.name, + RESOURCE_TYPE_VOLUME, + NS.tendrl_context.integration_id, + "add" + ) volume.save(ttl=SYNC_TTL) # Save the default values of volume options @@ -514,6 +533,13 @@ def sync_volumes(volumes, index, vol_options): 'volume%s.brick%s.is_arbiter' % (index, b_index) ), ) + if not brick.exists(): + monitoring_utils.update_dashboard( + brick.brick_name, + RESOURCE_TYPE_BRICK, + NS.tendrl_context.integration_id, + "add" + ) brick.save(ttl=SYNC_TTL) # sync brick device details brick_device_details.\