Change in vdsm[master]: Support initial_size parameter
alitke at redhat.com
alitke at redhat.com
Tue Apr 26 13:39:41 UTC 2016
Adam Litke has uploaded a new change for review.
Change subject: Support initial_size parameter
......................................................................
Support initial_size parameter
The non-SDM volume creation API supports an initial_size parameter which
allows you to indicate the initial size of a thinly-provisioned block
volume. We need to support this functionality in the sdm create volume
flow as well.
Change-Id: I795d5c8e187252c95764ede998447c6524b37f91
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M tests/storage_volume_artifacts_test.py
M vdsm/storage/sdm/api/create_volume.py
M vdsm/storage/sdm/volume_artifacts.py
3 files changed, 37 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/56628/1
diff --git a/tests/storage_volume_artifacts_test.py b/tests/storage_volume_artifacts_test.py
index c0b7b35..aa27210 100644
--- a/tests/storage_volume_artifacts_test.py
+++ b/tests/storage_volume_artifacts_test.py
@@ -21,7 +21,7 @@
import os
import uuid
-from testlib import VdsmTestCase
+from testlib import VdsmTestCase, permutations, expandPermutations
from testValidation import brokentest
from storagetestlib import fake_block_env, fake_file_env
@@ -153,6 +153,7 @@
self.assertIn(self.vol_id, env.sd_manifest.getAllVolumes())
+ at expandPermutations
class FileVolumeArtifactsTests(VolumeArtifactsTestsMixin, VdsmTestCase):
def fake_env(self):
@@ -244,6 +245,15 @@
artifacts.commit()
self.assertRaises(OSError, artifacts.commit)
+ @permutations([[0], [MB]])
+ def test_initial_size(self, initial_size):
+ with self.fake_env() as env:
+ artifacts = env.sd_manifest.get_volume_artifacts(
+ self.img_id, self.vol_id)
+ self.assertRaises(se.InvalidParameterException,
+ artifacts.create, *BASE_RAW_PARAMS,
+ initial_size=initial_size)
+
def validate_new_image_path(self, artifacts, has_md=False,
has_lease=False, has_volume=False):
path = artifacts.artifacts_dir
@@ -295,6 +305,7 @@
self.assertEqual({self.img_id}, env.sd_manifest.getAllImages())
+ at expandPermutations
class BlockVolumeArtifactsTests(VolumeArtifactsTestsMixin, VdsmTestCase):
def fake_env(self):
@@ -310,6 +321,16 @@
vol = env.sd_manifest.produceVolume(self.img_id, self.vol_id)
self.assertEqual(volume.PREALLOCATED_VOL, vol.getType())
+ @permutations([[0], [volume.BLOCK_SIZE]])
+ def test_raw_volume_initial_size(self, initial_size):
+ # TODO: Write a test for COW volumes when support is added
+ with self.fake_env() as env:
+ artifacts = env.sd_manifest.get_volume_artifacts(
+ self.img_id, self.vol_id)
+ self.assertRaises(se.InvalidParameterException,
+ artifacts.create, *BASE_RAW_PARAMS,
+ initial_size=initial_size)
+
def test_size_rounded_up(self):
# If the underlying device is larger the size will be updated
initial_size = (9 * MB) + 1024
diff --git a/vdsm/storage/sdm/api/create_volume.py b/vdsm/storage/sdm/api/create_volume.py
index 21acf51..add597f 100644
--- a/vdsm/storage/sdm/api/create_volume.py
+++ b/vdsm/storage/sdm/api/create_volume.py
@@ -51,7 +51,7 @@
artifacts.create(
self.vol_info.virtual_size, vol_format,
self.vol_info.disk_type, self.vol_info.description,
- self.vol_info.parent)
+ self.vol_info.parent, self.vol_info.initial_size)
artifacts.commit()
diff --git a/vdsm/storage/sdm/volume_artifacts.py b/vdsm/storage/sdm/volume_artifacts.py
index 72c11de..2ae0380 100644
--- a/vdsm/storage/sdm/volume_artifacts.py
+++ b/vdsm/storage/sdm/volume_artifacts.py
@@ -77,7 +77,8 @@
self.img_id = img_id
self.vol_id = vol_id
- def create(self, size, vol_format, disk_type, desc, parent=None):
+ def create(self, size, vol_format, disk_type, desc, parent=None,
+ initial_size=None):
"""
Create a new image and volume artifacts or a new volume inside an
existing image. The result is considered as garbage until you invoke
@@ -207,12 +208,17 @@
def volume_path(self):
return os.path.join(self.artifacts_dir, self.vol_id)
- def create(self, size, vol_format, disk_type, desc, parent=None):
+ def create(self, size, vol_format, disk_type, desc, parent=None,
+ initial_size=None):
"""
Create metadata file artifact, lease file, and volume file on storage.
"""
prealloc = self._get_volume_preallocation(vol_format)
self._validate_create_params(vol_format, parent, prealloc)
+
+ if initial_size is not None:
+ self.log.debug("initial_size is not supported for file volumes")
+ raise se.InvalidParameterException("initial_size", initial_size)
if not self.is_image():
self._create_image_artifact()
@@ -347,11 +353,15 @@
def volume_path(self):
return lvm.lvPath(self.sd_manifest.sdUUID, self.vol_id)
- def create(self, size, vol_format, disk_type, desc, parent=None):
- # TODO: Support initialsize
+ def create(self, size, vol_format, disk_type, desc, parent=None,
+ initial_size=None):
prealloc = self.get_volume_preallocation(vol_format)
self._validate_create_params(vol_format, parent, prealloc)
+ if initial_size is not None and vol_format != volume.COW_FORMAT:
+ self.log.debug("initial_size is supported only for COW volumes")
+ raise se.InvalidParameterException("initial_size", initial_size)
+
lv_size = self.vol_class.calculate_volume_alloc_size(
prealloc, size / volume.BLOCK_SIZE, None)
parent_vol_id = parent.vol_id if parent else volume.BLANK_UUID
--
To view, visit https://gerrit.ovirt.org/56628
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I795d5c8e187252c95764ede998447c6524b37f91
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