Jiří Moskovčák has uploaded a new change for review.

Change subject: set the storage backend according to the config file
......................................................................

set the storage backend according to the config file

Change-Id: I5cf19510ae52157e21e08215bc88953f1c1f937c
Signed-off-by: Jiri Moskovcak <[email protected]>
---
M ovirt_hosted_engine_ha/agent/hosted_engine.py
M ovirt_hosted_engine_ha/broker/storage_broker.py
M ovirt_hosted_engine_ha/client/client.py
M ovirt_hosted_engine_ha/env/config.py
M ovirt_hosted_engine_ha/lib/storage_backends.py
5 files changed, 48 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha 
refs/changes/71/28271/1

diff --git a/ovirt_hosted_engine_ha/agent/hosted_engine.py 
b/ovirt_hosted_engine_ha/agent/hosted_engine.py
index ff9a17e..064b345 100644
--- a/ovirt_hosted_engine_ha/agent/hosted_engine.py
+++ b/ovirt_hosted_engine_ha/agent/hosted_engine.py
@@ -38,6 +38,7 @@
 from ..lib import metadata
 from ..lib import util
 from ..lib import vds_client as vdsc
+from ..lib.storage_backends import StorageBackendTypes
 from .state_machine import EngineStateMachine
 
 
@@ -391,9 +392,29 @@
         sd_uuid = self._config.get(config.ENGINE, config.SD_UUID)
         dom_type = self._config.get(config.ENGINE, config.DOMAIN_TYPE)
 
+        # use vdsm type as the default
+        storage_backend_type = StorageBackendTypes.VdsmBackend
+        try:
+            metadata_volume_uuid = self._config.get(config.ENGINE,
+                                                    
config.METADATA_VOLUME_UUID)
+            metadata_image_uuid = self._config.get(config.ENGINE,
+                                                   config.METADATA_IMAGE_UUID)
+            lockspace_volume_uuid = self._config.get(config.ENGINE,
+                                                     
config.LOCKSPACE_VOLUME_UUID)
+            lockspace_image_uuid = self._config.get(config.ENGINE,
+                                                    
config.LOCKSPACE_IMAGE_UUID)
+            if '' in (metadata_volume_uuid, metadata_image_uuid,
+                      lockspace_image_uuid, lockspace_volume_uuid):
+                storage_backend_type = StorageBackendTypes.FilesystemBackend
+        except Exception as _ex:
+            self._log.warn("Can't read volume uuids from config "
+                           "-> assuming fs based storage: '{0}'"
+                           .format(str(_ex)))
+            storage_backend_type = StorageBackendTypes.FilesystemBackend
+
         for attempt in range(0, constants.WAIT_FOR_STORAGE_RETRY):
             try:
-                self._broker.set_storage_domain("fs",
+                self._broker.set_storage_domain(storage_backend_type,
                                                 sd_uuid=sd_uuid,
                                                 dom_type=dom_type)
                 break
diff --git a/ovirt_hosted_engine_ha/broker/storage_broker.py 
b/ovirt_hosted_engine_ha/broker/storage_broker.py
index 5ee8660..ef48d9c 100644
--- a/ovirt_hosted_engine_ha/broker/storage_broker.py
+++ b/ovirt_hosted_engine_ha/broker/storage_broker.py
@@ -22,18 +22,21 @@
 import logging
 import os
 import threading
+from collections import namedtuple
 
 from ..env import constants
 from ..lib import monotonic
 from ..lib.exceptions import RequestError
-from ..lib.storage_backends import FilesystemBackend, BlockBackend
+from ..lib.storage_backends import FilesystemBackend, BlockBackend, VdsmBackend
+from ..lib.storage_backends import StorageBackendTypes
 
 
 class StorageBroker(object):
 
     DOMAINTYPES = {
-        "fs": FilesystemBackend,
-        "block": BlockBackend
+        StorageBackendTypes.FilesystemBackend: FilesystemBackend,
+        StorageBackendTypes.BlockBackend: BlockBackend,
+        StorageBackendTypes.VdsmBackend: VdsmBackend,
     }
 
     def __init__(self):
@@ -54,7 +57,7 @@
         to the broker. The client value is provided by the broker logic.
 
         :param sd_type: The type of backend the clients want to use
-        :type sd_type: Currently the only supported values are "fs" and "block"
+        :type sd_type: Values from StorageBackendTypes tuple
         """
         if client in self._backends:
             self._backends[client].disconnect()
diff --git a/ovirt_hosted_engine_ha/client/client.py 
b/ovirt_hosted_engine_ha/client/client.py
index 5d8eb41..8fce979 100644
--- a/ovirt_hosted_engine_ha/client/client.py
+++ b/ovirt_hosted_engine_ha/client/client.py
@@ -26,6 +26,7 @@
 from ..lib import metadata
 from ..lib import util
 from ..lib.exceptions import MetadataError
+from ..lib.storage_backends import StorageBackendTypes
 
 
 class HAClient(object):
@@ -111,7 +112,7 @@
         from ..broker import storage_broker
 
         sb = storage_broker.StorageBroker()
-        sb.set_storage_domain("client", "fs",
+        sb.set_storage_domain("client", StorageBackendTypes.FilesystemBackend,
                               sd_uuid=sd_uuid, dom_type=dom_type)
         stats = sb.get_raw_stats_for_service_type("client", service_type)
 
@@ -169,7 +170,7 @@
             self._config = config.Config()
         sd_uuid = self._config.get(config.ENGINE, config.SD_UUID)
         dom_type = self._config.get(config.ENGINE, config.DOMAIN_TYPE)
-        broker.set_storage_domain("fs",
+        broker.set_storage_domain(StorageBackendTypes.FilesystemBackend,
                                   sd_uuid=sd_uuid,
                                   dom_type=dom_type)
 
diff --git a/ovirt_hosted_engine_ha/env/config.py 
b/ovirt_hosted_engine_ha/env/config.py
index ef7c708..7e6d8b7 100644
--- a/ovirt_hosted_engine_ha/env/config.py
+++ b/ovirt_hosted_engine_ha/env/config.py
@@ -30,6 +30,11 @@
 SD_UUID = 'sdUUID'
 VDSM_SSL = 'vdsm_use_ssl'
 BRIDGE_NAME = 'bridge'
+METADATA_VOLUME_UUID = 'metadata_volume_UUID'
+METADATA_IMAGE_UUID = 'metadata_image_UUID'
+LOCKSPACE_VOLUME_UUID = 'lockspace_volume_UUID'
+LOCKSPACE_IMAGE_UUID = 'lockspace_image_UUID'
+
 
 # constants for vm.conf options
 VM = 'vm'
diff --git a/ovirt_hosted_engine_ha/lib/storage_backends.py 
b/ovirt_hosted_engine_ha/lib/storage_backends.py
index e4a3966..ff7449d 100644
--- a/ovirt_hosted_engine_ha/lib/storage_backends.py
+++ b/ovirt_hosted_engine_ha/lib/storage_backends.py
@@ -18,6 +18,17 @@
 
 logger = logging.getLogger(__name__)
 
+_StorageBackendTypesTuple = namedtuple(
+    'StorageBackendTypes',
+    ['FilesystemBackend', 'BlockBackend', 'VdsmBackend']
+)
+
+StorageBackendTypes = _StorageBackendTypesTuple(
+    FilesystemBackend='FilesystemBackend',
+    BlockBackend='BlockBackend',
+    VdsmBackend='VdsmBackend'
+)
+
 
 class BlockBackendCorruptedException(Exception):
     """


-- 
To view, visit http://gerrit.ovirt.org/28271
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5cf19510ae52157e21e08215bc88953f1c1f937c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-ha
Gerrit-Branch: master
Gerrit-Owner: Jiří Moskovčák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to