Change in vdsm[master]: sdm: add the allocateVolume command

alitke at redhat.com alitke at redhat.com
Mon Feb 9 21:38:23 UTC 2015


Adam Litke has uploaded a new change for review.

Change subject: sdm: add the allocateVolume command
......................................................................

sdm: add the allocateVolume command

Change-Id: Id3db76e9e27f8f5bed5ebcb1d217ab94ec782070
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/storage/hsm.py
M vdsm/storage/sdm/__init__.py
5 files changed, 43 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/37627/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index a347b48..089c2e1 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1081,6 +1081,13 @@
 
         return 0, image['uuid']
 
+    def allocateVolume(self, args):
+        sdUUID, imgUUID, volUUID = args
+        image = self.s.allocateVolume(sdUUID, imgUUID, volUUID)
+        if image['status']['code']:
+            return image['status']['code'], image['status']['message']
+        return 0, image['uuid']
+
     def getVolumeInfo(self, args):
         sdUUID = args[0]
         spUUID = args[1]
@@ -2458,6 +2465,10 @@
             '<description> <srcImgUUID> <srcVolUUID>',
             'Creates new volume or snapshot'
         )),
+        'allocateVolume': (serv.allocateVolume, (
+            '<sdUUID> <imgUUID> <volUUID> ',
+            'Preallocates a volume or snapshot'
+        )),
         'extendVolumeSize': (serv.extendVolumeSize, (
             '<spUUID> <sdUUID> <imgUUID> <volUUID> <newSize>',
             'Extend the volume size (virtual disk size seen by the guest).',
diff --git a/vdsm/API.py b/vdsm/API.py
index 013e821..9e9010b 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -798,6 +798,10 @@
                                         self._UUID, size, volFormat,
                                         description, srcImgUUID, srcVolUUID)
 
+    def allocate(self):
+        return self._irs.allocateVolume(self._sdUUID, self._imgUUID,
+                                        self._UUID)
+
     def delete(self, postZero, force):
         return self._irs.deleteVolume(self._sdUUID, self._spUUID,
                                       self._imgUUID, [self._UUID], postZero,
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 21535ad..a78a6d5 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -863,6 +863,10 @@
         return volume.createV2(size, volFormat, description, srcImgUUID,
                                srcVolUUID)
 
+    def volumeAllocate(self, sdUUID, imgUUID, volUUID):
+        volume = API.Volume(volUUID, None, sdUUID, imgUUID)
+        return volume.allocate()
+
     def volumeExtendSize(self, spUUID, sdUUID, imgUUID, volUUID, newSize):
         volume = API.Volume(volUUID, spUUID, sdUUID, imgUUID)
         return volume.extendSize(newSize)
@@ -1133,7 +1137,8 @@
                  'storageServer_ConnectionRefs_release'),
                 (self.storageServerConnectionRefsStatuses,
                  'storageServer_ConnectionRefs_statuses'),
-                (self.volumeCreateV2, 'createVolumeV2'),)
+                (self.volumeCreateV2, 'createVolumeV2'),
+                (self.volumeAllocate, 'allocateVolume'),)
 
 
 def wrapApiMethod(f):
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 3fabf2e..d3da4d5 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3666,6 +3666,9 @@
                                       rm.LockType.exclusive):
             self.domainMonitor.stopMonitoring([sdUUID])
 
+    def _sdmSchedule(self, name, func, *args):
+        self.taskMng.scheduleJob("sdm", None, vars.task, name, func, *args)
+
     @public
     def getHostLeaseStatus(self, domains):
         """
@@ -3688,3 +3691,8 @@
         domain.validateCreateVolumeParams(volFormat, srcVolUUID)
         return sdm.createVolume(domain, imgUUID, volUUID, size, volFormat,
                                 description, srcImgUUID, srcVolUUID)
+
+    @public
+    def allocateVolume(self, sdUUID, imgUUID, volUUID):
+        self._sdmSchedule('allocateVolume', sdm.allocateVolume, sdUUID,
+                          imgUUID, volUUID)
diff --git a/vdsm/storage/sdm/__init__.py b/vdsm/storage/sdm/__init__.py
index 11f7ed0..976a007 100644
--- a/vdsm/storage/sdm/__init__.py
+++ b/vdsm/storage/sdm/__init__.py
@@ -43,3 +43,17 @@
     return __getStoreModule(domain).createVolume(
         domain, imgUUID, volUUID, size, volFormat, desc, srcImgUUID,
         srcVolUUID)
+
+
+def allocateVolume(sdUUID, imgUUID, volUUID, wipeData):
+    if wipeData is not True:
+        raise NotImplementedError("Keeping old data is not supported")
+
+    domain = sdCache.produce(sdUUID)
+
+    # TODO: pass the sanlock lease to the allocating process
+    sanlock.acquire(sdUUID, volUUID, [(leasePath, leaseOffset)])
+    try:
+        pass
+    finally:
+        sanlock.release(sdUUID, volUUID, [(leasePath, leaseOffset)])


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3db76e9e27f8f5bed5ebcb1d217ab94ec782070
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