From 7f05b72eb56f2f012c426c988ec426740c5d1e1a Mon Sep 17 00:00:00 2001 From: Ramesh Nachimuthu Date: Tue, 13 May 2014 13:59:37 +0530 Subject: autoconfig: delete only auto generated configs in auto-config Currently auto-config removes all the custom services and hosts defined by user. So with this issue, user can't add any extra services on top of services generated by auto-config. Adding a custom filed '__GENERATED_BY_AUTOCONFIG' as part of all the services added by auto-config. Only services with the above custom field will be deleted by auto-config when respective volume/brick/ is removed in gluster. Change-Id: I85d3d971d3b99f52ff603044f7f974746e247737 Signed-off-by: Ramesh Nachimuthu Reviewed-on: http://review.gluster.org/7750 Reviewed-by: Sahina Bose --- plugins/config_generator.py | 2 ++ plugins/discovery.py | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'plugins') diff --git a/plugins/config_generator.py b/plugins/config_generator.py index ed32912..8466c83 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -33,6 +33,7 @@ are added or removed to the entity. CHANGE_MODE_ADD = "ADD" CHANGE_MODE_REMOVE = "REMOVE" CHANGE_MODE_UPDATE = "UPDATE" +GENERATED_BY_AUTOCONFIG = "__GENERATED_BY_AUTOCONFIG" class GlusterNagiosConfManager: @@ -287,6 +288,7 @@ class GlusterNagiosConfManager: serviceModel = Model.Service() serviceModel = self.fillModel(serviceModel, service) serviceModel.set_filename(self.getCfgFileName(hostname)) + serviceModel[GENERATED_BY_AUTOCONFIG] = 1 serviceModel.save() elif service['changeMode'] == CHANGE_MODE_REMOVE: serviceModel = Model.Service.objects.filter( diff --git a/plugins/discovery.py b/plugins/discovery.py index 78f666e..5f29225 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -33,6 +33,7 @@ from constants import DEFAULT_AUTO_CONFIG_DIR from config_generator import CHANGE_MODE_ADD from config_generator import CHANGE_MODE_REMOVE from config_generator import CHANGE_MODE_UPDATE +from config_generator import GENERATED_BY_AUTOCONFIG #Discovers volumes info one by one. @@ -162,6 +163,9 @@ def findDeletedServices(host): deletedService = [] serviceConfigs = server_utils.getServiceConfigByHost(host['host_name']) for serviceConfig in serviceConfigs: + #Consider only the service generated by autoconfig + if not serviceConfig[GENERATED_BY_AUTOCONFIG]: + continue service = findServiceInList(host.get('host_services', []), serviceConfig['service_description']) if service is None: -- cgit