Sandro Bonazzola has uploaded a new change for review.

Change subject: WIP: add UUIDs for lockspace initialization
......................................................................

WIP: add UUIDs for lockspace initialization

Change-Id: If439089f4f8efeb02416e041135563415f46a502
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/core/conf.py
M src/plugins/ovirt-hosted-engine-setup/sanlock/lockspace.py
M templates/hosted-engine.conf.in
4 files changed, 95 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/38/28238/1

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 7f345ac..18b7c6e 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -502,6 +502,30 @@
 
     ISCSI_PASSWORD = 'OVEHOSTED_STORAGE/iSCSIPortalPassword'
 
+    @ohostedattrs(
+        answerfile=True,
+    )
+    def METADATA_VOLUME_UUID(self):
+        return 'OVEHOSTED_STORAGE/metadataVolumeUUID'
+
+    @ohostedattrs(
+        answerfile=True,
+    )
+    def METADATA_IMAGE_UUID(self):
+        return 'OVEHOSTED_STORAGE/metadataImageUUID'
+
+    @ohostedattrs(
+        answerfile=True,
+    )
+    def LOCKSPACE_VOLUME_UUID(self):
+        return 'OVEHOSTED_STORAGE/lockspaceVolumeUUID'
+
+    @ohostedattrs(
+        answerfile=True,
+    )
+    def LOCKSPACE_IMAGE_UUID(self):
+        return 'OVEHOSTED_STORAGE/lockspaceImageUUID'
+
 
 @util.export
 @util.codegen
diff --git a/src/plugins/ovirt-hosted-engine-setup/core/conf.py 
b/src/plugins/ovirt-hosted-engine-setup/core/conf.py
index fd09dbf..0fc86c2 100644
--- a/src/plugins/ovirt-hosted-engine-setup/core/conf.py
+++ b/src/plugins/ovirt-hosted-engine-setup/core/conf.py
@@ -93,11 +93,24 @@
             '@BRIDGE@': self.environment[
                 ohostedcons.NetworkEnv.BRIDGE_NAME
             ],
+            '@METADATA_VOLUME_UUID@': self.environment[
+                ohostedcons.StorageEnv.METADATA_VOLUME_UUID
+            ],
+            '@METADATA_IMAGE_UUID@': self.environment[
+                ohostedcons.StorageEnv.METADATA_IMAGE_UUID
+            ],
+            '@LOCKSPACE_VOLUME_UUID@': self.environment[
+                ohostedcons.StorageEnv.LOCKSPACE_VOLUME_UUID
+            ],
+            '@LOCKSPACE_IMAGE_UUID@': self.environment[
+                ohostedcons.StorageEnv.LOCKSPACE_IMAGE_UUID
+            ],
             '@IQN@': '',
             '@PORTAL@': '',
             '@USER@': '',
             '@PASSWORD@': '',
             '@PORT@': '',
+
         }
         if self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
             ohostedcons.DomainTypes.ISCSI,
diff --git a/src/plugins/ovirt-hosted-engine-setup/sanlock/lockspace.py 
b/src/plugins/ovirt-hosted-engine-setup/sanlock/lockspace.py
index 28d38e6..d49c08a 100644
--- a/src/plugins/ovirt-hosted-engine-setup/sanlock/lockspace.py
+++ b/src/plugins/ovirt-hosted-engine-setup/sanlock/lockspace.py
@@ -26,6 +26,8 @@
 import sanlock
 import stat
 import os
+import uuid
+
 
 from otopi import util
 from otopi import plugin
@@ -33,7 +35,7 @@
 
 from ovirt_hosted_engine_setup import constants as ohostedcons
 from ovirt_hosted_engine_setup import util as ohostedutil
-from ovirt_hosted_engine_ha.lib.storage_backends import FilesystemBackend
+from ovirt_hosted_engine_ha.lib import storage_backends
 
 _ = lambda m: gettext.dgettext(message=m, domain='ovirt-hosted-engine-setup')
 
@@ -59,6 +61,22 @@
             ohostedcons.SanlockEnv.LOCKSPACE_NAME,
             ohostedcons.Defaults.DEFAULT_LOCKSPACE_NAME
         )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.METADATA_VOLUME_UUID,
+            str(uuid.uuid4())
+        )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.METADATA_IMAGE_UUID,
+            str(uuid.uuid4())
+        )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.LOCKSPACE_VOLUME_UUID,
+            str(uuid.uuid4())
+        )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.LOCKSPACE_IMAGE_UUID,
+            str(uuid.uuid4())
+        )
 
     @plugin.event(
         stage=plugin.Stages.STAGE_MISC,
@@ -71,6 +89,11 @@
         ),
     )
     def _misc(self):
+        """
+        Here the storage pool is connected and activated.
+        Pass needed configuration to HA FilesystemBackend for initializing
+        the metadata and lockspace volumes.
+        """
         self.logger.info(_('Verifying sanlock lockspace initialization'))
         self.services.state(
             name=self.environment[
@@ -79,21 +102,26 @@
             state=True,
         )
 
-        uuid = self.environment[ohostedcons.StorageEnv.SD_UUID]
         dom_type = self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE]
 
         # Prepare the Backend interface
         # - this supports nfs, iSCSI and Gluster automatically
-        backend = FilesystemBackend(sd_uuid=uuid,
-                                    dom_type=dom_type)
+        backend = storage_backends.FilesystemBackend(
+            sd_uuid=self.environment[ohostedcons.StorageEnv.SD_UUID],
+            sp_uuid=self.environment[ohostedcons.StorageEnv.SP_UUID],
+            dom_type=dom_type
+        )
 
         lockspace = self.environment[ohostedcons.SanlockEnv.LOCKSPACE_NAME]
         host_id = self.environment[ohostedcons.StorageEnv.HOST_ID]
 
         # Compute the size needed to store metadata for all hosts
         # and for the global cluster state
-        md_size = (ohostedcons.Const.METADATA_CHUNK_SIZE
-                   * (ohostedcons.Const.MAX_HOST_ID + 1))
+        md_size = (
+            ohostedcons.Const.METADATA_CHUNK_SIZE * (
+                ohostedcons.Const.MAX_HOST_ID + 1
+            )
+        )
 
         backendUserContext = ohostedutil.getStorageUserContext(
             self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE],
@@ -102,14 +130,31 @@
             umask=stat.S_IRWXO,
         )
         with backendUserContext:
-            # Create storage for he metadata and sanlock lockspace
+            # Create storage for HE metadata and sanlock lockspace
             # 1MB is good for 2000 clients when the block size is 512B
             # if it's a block device like iscsi it needs root privileges
             # to create volume using lvcreate and that's why we have
             # the backendUserContext magic up there
             created = backend.create({
-                lockspace + '.lockspace': 1024*1024*backend.blocksize/512,
-                lockspace + '.metadata': md_size
+                # TODO: refactor on Martin version of the HA patch
+                lockspace + '.lockspace': storage_backends.BlockDevice(
+                    imgUUID=self.environment[
+                        ohostedcons.StorageEnv.LOCKSPACE_IMAGE_UUID
+                    ],
+                    volUUID=self.environment[
+                        ohostedcons.StorageEnv.LOCKSPACE_VOLUME_UUID
+                    ],
+                    size=1024*1024*backend.blocksize/512,
+                ),
+                lockspace + '.metadata': storage_backends.BlockDevice(
+                    imgUUID=self.environment[
+                        ohostedcons.StorageEnv.METADATA_IMAGE_UUID
+                    ],
+                    volUUID=self.environment[
+                        ohostedcons.StorageEnv.METADATA_VOLUME_UUID
+                    ],
+                    size=md_size,
+                ),
             })
 
             # for lv_based storage (like iscsi) creates symlinks in /rhev/..
diff --git a/templates/hosted-engine.conf.in b/templates/hosted-engine.conf.in
index f587ba2..23d30a2 100644
--- a/templates/hosted-engine.conf.in
+++ b/templates/hosted-engine.conf.in
@@ -15,6 +15,10 @@
 vdsm_use_ssl=@VDSM_USE_SSL@
 gateway=@GATEWAY@
 bridge=@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@
 
 # The following are used only for iSCSI storage
 iqn=@IQN@


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If439089f4f8efeb02416e041135563415f46a502
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to