Change in vdsm[master]: storage: add get_volume_artifacts_class to the domain manifest

alitke at redhat.com alitke at redhat.com
Fri Dec 11 16:34:18 UTC 2015


Adam Litke has uploaded a new change for review.

Change subject: storage: add get_volume_artifacts_class to the domain manifest
......................................................................

storage: add get_volume_artifacts_class to the domain manifest

When working with a domain manifest code needs to know the type of
VolumeArtifact class to use.  Add helper methods to
BlockStorageDomainManifest and FileStorageDomainManifest to return the
proper type.

This patch expands the scope of volume_artifact_test in order to add the
BlockVolumeArtifactsTests class.  The added code will all be necessary
once more block domain support is added.

Change-Id: Iade716f7487f502243aaf280a7a8c147f501307d
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M tests/volume_artifacts_test.py
M vdsm/storage/blockSD.py
M vdsm/storage/fileSD.py
3 files changed, 37 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/50339/1

diff --git a/tests/volume_artifacts_test.py b/tests/volume_artifacts_test.py
index d9edf62..62fae31 100644
--- a/tests/volume_artifacts_test.py
+++ b/tests/volume_artifacts_test.py
@@ -23,9 +23,11 @@
 from contextlib import contextmanager
 
 from testlib import VdsmTestCase, namedTemporaryDir
-from storagetestlib import make_filesd_manifest
+from monkeypatch import MonkeyPatchScope
+from storagetestlib import make_filesd_manifest, make_blocksd
+from storagefakelib import FakeLVM
 
-from storage import fileSD, fileVolume, image, sd, volume
+from storage import blockSD, fileSD, fileVolume, image, sd, volume
 from storage.sdm import volume_artifacts
 
 
@@ -35,6 +37,14 @@
 
 class ExpectedFailure(Exception):
     pass
+
+
+ at contextmanager
+def fake_block_env(cls=None):
+    with namedTemporaryDir() as tmpdir:
+        lvm = FakeLVM(tmpdir)
+        with MonkeyPatchScope([(blockSD, 'lvm', lvm)]):
+            yield make_blocksd(tmpdir, lvm)
 
 
 @contextmanager
@@ -60,6 +70,11 @@
 
     def failure(*args):
         raise ExpectedFailure()
+
+    def test_get_volume_artifacts_class(self):
+        with self.fake_env() as manifest:
+            self.assertEqual(self.artifacts_class,
+                             manifest.get_volume_artifacts_class())
 
     def test_nonexist(self):
         with self.fake_env() as manifest:
@@ -188,6 +203,18 @@
                               artifacts.create, *base_raw_params())
 
 
+class BlockVolumeArtifactsTests(VdsmTestCase):
+    # TODO: Inherit from VolumeArtifactsTestsMixin once support is added
+
+    artifacts_class = volume_artifacts.BlockVolumeArtifacts
+    fake_env = fake_block_env
+
+    def test_get_volume_artifacts_class(self):
+        with self.fake_env() as manifest:
+            self.assertEqual(self.artifacts_class,
+                             manifest.get_volume_artifacts_class())
+
+
 class FileVolumeArtifactVisibilityTests(VdsmTestCase):
 
     def test_getallimages(self):
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 5453a8a..9d5e605 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -40,6 +40,7 @@
 import misc
 import fileUtils
 import sd
+import sdm
 import lvm
 import clusterlock
 import blockVolume
@@ -585,6 +586,9 @@
         """
         return blockVolume.BlockVolumeMetadata
 
+    def get_volume_artifacts_class(self):
+        return sdm.volume_artifacts.BlockVolumeArtifacts
+
     def _getImgExclusiveVols(self, imgUUID, volsImgs):
         """Filter vols belonging to imgUUID only."""
         exclusives = dict((vName, v) for vName, v in volsImgs.iteritems()
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 9248c11..00405d7 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -27,6 +27,7 @@
 import re
 
 import sd
+import sdm
 import storage_exception as se
 import fileUtils
 import fileVolume
@@ -201,6 +202,9 @@
         """
         return fileVolume.FileVolumeMetadata
 
+    def get_volume_artifacts_class(self):
+        return sdm.volume_artifacts.FileVolumeArtifacts
+
     def _getDeletedImagePath(self, imgUUID):
         currImgDir = self.getImagePath(imgUUID)
         dirName, baseName = os.path.split(currImgDir)


-- 
To view, visit https://gerrit.ovirt.org/50339
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iade716f7487f502243aaf280a7a8c147f501307d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>


More information about the vdsm-patches mailing list