Adam Litke has uploaded a new change for review.

Change subject: sdm: add create_volume_container API stub
......................................................................

sdm: add create_volume_container API stub

Change-Id: I1ff2656f2dd427812e557e6587429759a9c0a845
Signed-off-by: Adam Litke <ali...@redhat.com>
---
M client/vdsClient.py
M lib/api/vdsmapi-schema.json
M vdsm/API.py
M vdsm/rpc/bindingxmlrpc.py
M vdsm/storage/hsm.py
5 files changed, 110 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/50220/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index ce8236c..7056038 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1059,6 +1059,10 @@
             print("\t%s = %s" % (element, info['dominfo'][element]))
         return 0, ''
 
+    def _get_initial_size(self, size):
+        size_gb = int(size)
+        return str(size_gb * constants.GIB)
+
     def createVolume(self, args):
         sdUUID = args[0]
         spUUID = args[1]
@@ -1081,15 +1085,32 @@
         params = [sdUUID, spUUID, imgUUID, size, volFormat, preallocate,
                   diskType, newVol, descr, srcImgUUID, srcVolUUID]
         if len(args) > 11:
-            initialSizeGIB = int(args[11])
-            initialSize = str(initialSizeGIB * constants.GIB)
-            params.append(initialSize)
+            params.append(self._get_initial_size(args[11]))
 
         image = self.s.createVolume(*params)
 
         if image['status']['code']:
             return image['status']['code'], image['status']['message']
         return 0, image['uuid']
+
+    def createVolumeContainer(self, args):
+        (job_id, sd_id, img_id, vol_id,
+         size, vol_format, disk_type, desc) = args[:8]
+
+        parent_img_id = args[8] if len(args) > 8 else BLANK_UUID
+        parent_vol_id = args[9] if len(args) > 9 else BLANK_UUID
+
+        initial_size = (self._get_initial_size(args[10])
+                        if len(args) > 10 else 0)
+
+        res = self.s.create_volume_container(
+            job_id, sd_id, img_id, vol_id, size, vol_format, disk_type, desc,
+            parent_img_id, parent_vol_id, initial_size)
+
+        if res['status']['code']:
+            return res['status']['code'], res['status']['message']
+
+        return 0, ''
 
     def getVolumeInfo(self, args):
         sdUUID = args[0]
@@ -2481,6 +2502,11 @@
                           '<srcImgUUID> <srcVolUUID> <initialSize>',
                           'Creates new volume or snapshot'
                           )),
+        'createVolumeContainer': (serv.createVolumeContainer, (
+            '<sdUUID> <imgUUID> <size> <volFormat> <diskType> <volUUID> '
+            '<desc> [<srcImgUUID>] [<srcVolUUID>]',
+            'Create a new volume or snapshot container'
+        )),
         'extendVolumeSize': (serv.extendVolumeSize, (
             '<spUUID> <sdUUID> <imgUUID> <volUUID> <newSize>',
             'Extend the volume size (virtual disk size seen by the guest).',
diff --git a/lib/api/vdsmapi-schema.json b/lib/api/vdsmapi-schema.json
index d926661..484ab58 100644
--- a/lib/api/vdsmapi-schema.json
+++ b/lib/api/vdsmapi-schema.json
@@ -8683,3 +8683,51 @@
 ##
 {'command': {'class': 'VM', 'name': 'updateVmPolicy'},
  'data': {'vmID': 'UUID', 'params': 'UpdateVmPolicyParams'}}
+
+## Category: @SDM ############################################################
+##
+# @SDM:
+#
+# This namespace is for SDM (storage domain manager) functions.
+#
+# Since: 4.16.0
+##
+{'class': 'SDM'}
+
+##
+# @SDM.create_volume_container:
+#
+# Create a new container to hold a volume.
+#
+# @job_id:         A UUID to be used for tracking the job progress
+#
+# @sd_id:          The Storage Domain associated with the Volume
+#
+# @image_id:       The Image associated with the Volume
+#
+# @volume_id:      The UUID of the Volume
+#
+# @size:           The Volume size in sectors
+#
+# @vol_format:     The data format to use for the destination Volume
+#
+# @disk_type:      An advisory disk usage type
+#
+# @desc:           The Volume description
+#
+# @parent_img_id:  #optional If specified, create a snapshot from this Image
+#
+# @parent_vol_id:  #optional If specified, create a snapshot from this Volume
+#
+# @initial_size:   #optional If specified, initial size of volume in bytes
+#                  (as string). Allowed only when creating thin provisioned
+#                  volume on block storage.
+#
+# Since: 4.18.0
+##
+{'command': {'class': 'SDM', 'name': 'create_volume_container'},
+ 'data': {'job_id': 'UUID', 'sd_id': 'UUID', 'image_id': 'UUID',
+          'volume_id': 'UUID', 'size': 'int', 'vol_format':'VolumeFormat',
+          'disk_type': 'DiskType', 'desc': 'str',
+          '*parent_img_id': 'UUID', '*parent_vol_id': 'UUID',
+          'initial_size': '*str'}}
diff --git a/vdsm/API.py b/vdsm/API.py
index 9936d1e..7120500 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1744,3 +1744,19 @@
                 logging.warn("options %s is deprecated. Use %s instead" %
                              (k, _translationMap[k]))
                 options[_translationMap[k]] = options.pop(k)
+
+
+class SDM(APIBase):
+    ctorArgs = []
+
+    def __init__(self):
+        APIBase.__init__(self)
+
+    def create_volume_container(self, job_id, sd_id, img_id, vol_id, size,
+                                vol_format, disk_type, desc,
+                                parent_img_id=Image.BLANK_UUID,
+                                parent_vol_id=Volume.BLANK_UUID,
+                                initial_size=None):
+        return self._irs.create_volume_container(
+            job_id, sd_id, img_id, vol_id, size, vol_format, disk_type, desc,
+            parent_img_id, parent_vol_id, initial_size)
diff --git a/vdsm/rpc/bindingxmlrpc.py b/vdsm/rpc/bindingxmlrpc.py
index dd82bca..22cce53 100644
--- a/vdsm/rpc/bindingxmlrpc.py
+++ b/vdsm/rpc/bindingxmlrpc.py
@@ -1023,6 +1023,15 @@
     def storageServerConnectionRefsStatuses(self):
         return API.ConnectionRefs().statuses()
 
+    def sdm_create_volume_container(self, job_id, sd_id, img_id, vol_id, size,
+                                    vol_format, disk_type, desc, parent_img_id,
+                                    parent_vol_id, initial_size):
+        sdm = API.SDM()
+        return sdm.create_volume_container(job_id, sd_id, img_id, vol_id, size,
+                                           vol_format, disk_type, desc,
+                                           parent_img_id, parent_vol_id,
+                                           initial_size)
+
     def getGlobalMethods(self):
         return ((self.vmDestroy, 'destroy'),
                 (self.vmCreate, 'create'),
@@ -1179,7 +1188,8 @@
                 (self.storageServerConnectionRefsRelease,
                  'storageServer_ConnectionRefs_release'),
                 (self.storageServerConnectionRefsStatuses,
-                 'storageServer_ConnectionRefs_statuses'),)
+                 'storageServer_ConnectionRefs_statuses'),
+                (self.sdm_create_volume_container, 'create_volume_container'))
 
 
 def wrapApiMethod(f):
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 33be84b..823ae11 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3684,3 +3684,9 @@
                             their meaning.
         """
         return {'domains': self.domainMonitor.getHostStatus(domains)}
+
+    @public
+    def create_volume_container(self, job_id, sd_id, img_id, vol_id, size,
+                                vol_format, disk_type, desc,
+                                parent_img_id, parent_vol_id, initial_size):
+        raise NotImplementedError()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ff2656f2dd427812e557e6587429759a9c0a845
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <ali...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to