Simone Tiraboschi has uploaded a new change for review. Change subject: loading broker.conf from the shared storage ......................................................................
loading broker.conf from the shared storage broker.conf is now on the shared storage and not on the localfilesystem. Reading from there abd refreshing when needed. Change-Id: Ia6a1a6213834f9c8b97834ebd95456fac2ca224d Signed-off-by: Simone Tiraboschi <stira...@redhat.com> --- M ovirt_hosted_engine_ha/broker/constants.py.in M ovirt_hosted_engine_ha/broker/notifications.py M ovirt_hosted_engine_ha/env/config.py 3 files changed, 40 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha refs/changes/09/42209/1 diff --git a/ovirt_hosted_engine_ha/broker/constants.py.in b/ovirt_hosted_engine_ha/broker/constants.py.in index 235ea74..bd41a9f 100644 --- a/ovirt_hosted_engine_ha/broker/constants.py.in +++ b/ovirt_hosted_engine_ha/broker/constants.py.in @@ -30,7 +30,8 @@ LOG_FILE = '@ENGINE_HA_LOGDIR@/broker.log' PID_FILE = '@ENGINE_HA_RUNDIR@/broker.pid' -NOTIFY_CONF_FILE = '@ENGINE_HA_CONFDIR@/broker.conf' +ENGINE_SETUP_CONF_FILE = '/etc/ovirt-hosted-engine/hosted-engine.conf' +NOTIFY_CONF_FILE = 'broker.conf' NOTIFY_TEMPLATES = '@ENGINE_HA_CONFDIR@/notifications' VDSM_USER = '@VDSM_USER@' diff --git a/ovirt_hosted_engine_ha/broker/notifications.py b/ovirt_hosted_engine_ha/broker/notifications.py index 6e7717c..77b3e89 100644 --- a/ovirt_hosted_engine_ha/broker/notifications.py +++ b/ovirt_hosted_engine_ha/broker/notifications.py @@ -5,13 +5,44 @@ import re import os import logging +from io import StringIO from . import constants +from ..env import config + +from ovirt_hosted_engine_setup import heconflib +from ovirt_hosted_engine_setup import util as ohostedutil __author__ = 'msivak' # regular expression used to split the email addresses EMAIL_SPLIT_RE = re.compile(' *, *') + +notify_conf = '' + + +def _reload_conf(logger): + global notify_conf + heconf = config.Config() + + sd_uuid = heconf.get(config.ENGINE, config.SD_UUID) + dom_type = heconf.get(config.ENGINE, config.DOMAIN_TYPE) + conf_volume = heconf.get(config.ENGINE, config.CONF_VOLUME_UUID) + conf_image = heconf.get(config.ENGINE, config.CONF_IMAGE_UUID) + + source = ohostedutil.get_volume_path( + dom_type, + sd_uuid, + conf_image, + conf_volume, + ) + + if heconflib.validateConfImage(logger, source): + notify_conf = heconflib.extractConfFile( + logger, + source, + constants.NOTIFY_CONF_FILE, + ) def send_email(cfg, message): @@ -37,14 +68,16 @@ The configuration is refreshed with every call of this method. """ - logging.getLogger("%s.Notifications" % __name__)\ - .debug("nofity: %s" % (repr(kwargs),)) + logger = logging.getLogger("%s.Notifications" % __name__) + logger.debug("nofity: %s" % (repr(kwargs),)) assert "type" in kwargs type = kwargs["type"] + _reload_conf(logger=logger) cfg = ConfigParser.SafeConfigParser() - cfg.read(constants.NOTIFY_CONF_FILE) + buf = StringIO(unicode(notify_conf)) + cfg.readfp(buf) detail = kwargs.get("detail", "") diff --git a/ovirt_hosted_engine_ha/env/config.py b/ovirt_hosted_engine_ha/env/config.py index 29cea7e..fc3bc4a 100644 --- a/ovirt_hosted_engine_ha/env/config.py +++ b/ovirt_hosted_engine_ha/env/config.py @@ -35,6 +35,8 @@ METADATA_IMAGE_UUID = 'metadata_image_UUID' LOCKSPACE_VOLUME_UUID = 'lockspace_volume_UUID' LOCKSPACE_IMAGE_UUID = 'lockspace_image_UUID' +CONF_VOLUME_UUID = 'conf_volume_UUID' +CONF_IMAGE_UUID = 'conf_image_UUID' # constants for vm.conf options -- To view, visit https://gerrit.ovirt.org/42209 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia6a1a6213834f9c8b97834ebd95456fac2ca224d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-ha Gerrit-Branch: master Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches