diff options
author | Ramesh Nachimuthu <rnachimu@redhat.com> | 2014-05-26 12:15:13 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-05-28 22:58:45 -0700 |
commit | ce3518471c4853d1a51cff5a913de479b1b496ea (patch) | |
tree | 255e509f70696a0e41e738fe1666c8bf91d19820 /plugins/discovery.py | |
parent | 1306b9ec4e9fc098cf34a269727245c1e1499f20 (diff) |
autoConfig:Support for force syncing specific fields in service config
Currently Auto-config won't update any service configurations
in nagios. It always adds or deletes services configurations but
no update. With the following bugs we have the need to update few
values in service configuration. Hence adding the support to update
specific fields in service config.
All the fields in the list config_generator.SERVICE_FIELDS_TO_FORCE_SYNC
will be force updated during auto configuration. With this patch only
'_VOL_NAME' and 'notes' field will be updated.
Change-Id: I6003ade375d2f0d6e7dee97ef05f7a9af4ce6ffd
Bug-Url: https://bugzilla.redhat.com/1099093
Bug-Url: https://bugzilla.redhat.com/1099328
Signed-off-by: Ramesh Nachimuthu <rnachimu@redhat.com>
Reviewed-on: http://review.gluster.org/7868
Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins/discovery.py')
-rwxr-xr-x | plugins/discovery.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/discovery.py b/plugins/discovery.py index 5f29225..514dc22 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -34,6 +34,7 @@ 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 +from config_generator import SERVICE_FIELDS_TO_FORCE_SYNC #Discovers volumes info one by one. @@ -175,6 +176,22 @@ def findDeletedServices(host): return deletedService +#Looks for changes in the interesting service config fields. These fields +#will be force synced without preserving user changes. All these fields +#are list as part of config_generator.SERVICE_FIELDS_TO_FORCE_SYNC +def findChangeInService(newService, oldService): + changes = {} + for field in SERVICE_FIELDS_TO_FORCE_SYNC: + if newService.get(field) != oldService.get(field): + if not changes: + changes['service_description'] = \ + newService['service_description'] + changes['host_name'] = newService['host_name'] + changes['changeMode'] = CHANGE_MODE_UPDATE + changes[field] = newService.get(field) + return changes + + #Check if auto config is changed. IP address in the check command will change #when user runs the auto config using different host. def findChangeInAutoConfig(newService, oldService): @@ -192,7 +209,7 @@ def findChangeInAutoConfig(newService, oldService): return None -#Find all Added/Deleted services in the given host. +#Find all Added/Updated/Deleted services in the given host. #Note: 'Cluster Auto Config' is a special service. When user runs the #auto-config using different host instead what is used previously then we #have to update the host ip in existing auto-config service. @@ -208,6 +225,10 @@ def findServiceDelta(host): changes = findChangeInAutoConfig(service, serviceConfig) if changes: serviceDelta.append(changes) + else: + changes = findChangeInService(service, serviceConfig) + if changes: + serviceDelta.append(changes) serviceDelta.extend(findDeletedServices(host)) return serviceDelta |