Jiří Moskovčák has uploaded a new change for review. Change subject: allow None as device uuid when creating new storage ......................................................................
allow None as device uuid when creating new storage Change-Id: Id3e0d4653011b57259d1062052253de3de191fb0 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1171452 Signed-off-by: Jiri Moskovcak <[email protected]> --- M ovirt_hosted_engine_ha/agent/hosted_engine.py M ovirt_hosted_engine_ha/env/config.py M ovirt_hosted_engine_ha/lib/storage_backends.py 3 files changed, 15 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha refs/changes/75/36275/1 diff --git a/ovirt_hosted_engine_ha/agent/hosted_engine.py b/ovirt_hosted_engine_ha/agent/hosted_engine.py index 2f717d1..70dcd89 100644 --- a/ovirt_hosted_engine_ha/agent/hosted_engine.py +++ b/ovirt_hosted_engine_ha/agent/hosted_engine.py @@ -410,16 +410,20 @@ constants.SERVICE_TYPE + constants.MD_EXTENSION: VdsmBackend.Device( self._config.get(config.ENGINE, - config.METADATA_IMAGE_UUID), + config.METADATA_IMAGE_UUID, + raise_on_none=True), self._config.get(config.ENGINE, - config.METADATA_VOLUME_UUID), + config.METADATA_VOLUME_UUID, + raise_on_none=True), ).dump(), constants.SERVICE_TYPE + constants.LOCKSPACE_EXTENSION: VdsmBackend.Device( self._config.get(config.ENGINE, - config.LOCKSPACE_IMAGE_UUID), + config.LOCKSPACE_IMAGE_UUID, + raise_on_none=True), self._config.get(config.ENGINE, - config.LOCKSPACE_VOLUME_UUID), + config.LOCKSPACE_VOLUME_UUID, + raise_on_none=True), ).dump() } # check if we have all the needed config params needed for vdsm api diff --git a/ovirt_hosted_engine_ha/env/config.py b/ovirt_hosted_engine_ha/env/config.py index b2bd1d2..29cea7e 100644 --- a/ovirt_hosted_engine_ha/env/config.py +++ b/ovirt_hosted_engine_ha/env/config.py @@ -73,12 +73,17 @@ conf[tokens[0]] = tokens[1].strip() self._config[type] = conf - def get(self, type, key): + def get(self, type, key, raise_on_none=False): if type in Config.dynamic_files.keys(): self._load(dict([(type, Config.dynamic_files[type])])) try: - return self._config[type][key] + val = self._config[type][key] + if raise_on_none and val in (None, "None", ""): + raise ValueError( + "'{0} can't be '{1}'".format(key, val) + ) + return val except KeyError: unknown = "unknown (type={0})".format(type) raise Exception("Configuration value not found: file={0}, key={1}" diff --git a/ovirt_hosted_engine_ha/lib/storage_backends.py b/ovirt_hosted_engine_ha/lib/storage_backends.py index be444f5..cf88d67 100644 --- a/ovirt_hosted_engine_ha/lib/storage_backends.py +++ b/ovirt_hosted_engine_ha/lib/storage_backends.py @@ -147,10 +147,6 @@ __slots__ = ["image_uuid", "volume_uuid", "path"] def __init__(self, image_uuid, volume_uuid, path=None): - if any(k in (None, "None", "") for k in (image_uuid, volume_uuid)): - raise ValueError( - "image_uuid or volume_uuid is missing or None" - ) self.image_uuid = image_uuid self.volume_uuid = volume_uuid self.path = path -- To view, visit http://gerrit.ovirt.org/36275 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id3e0d4653011b57259d1062052253de3de191fb0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-ha Gerrit-Branch: ovirt-hosted-engine-ha-1.2 Gerrit-Owner: Jiří Moskovčák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
