[Kimchi-devel] [kimchi-devel][PATCHv4 1/7] Update docs and json schema of storage volume upload

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Wed Apr 22 08:02:53 UTC 2015


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

Volume upload will use the same REST api as 'capacity' type when creating
storage volume. Following data transfer is implemented by several storage volume
update:
    POST /storagepools/<pool-name>/storagevolumes/
        {"capacity": 1000000, "format": "raw", "name": "volume-1"}
    PUT /storagepools/<pool-name>/storagevolumes/volume-1
        {"index": "0", "chunk_size": "1024", "chunk": form-data}
    PUT /storagepools/<pool-name>/storagevolumes/volume-1
        {"index": "1", "chunk_size": "1024", "chunk": form-data}
    ...
    PUT /storagepools/<pool-name>/storagevolumes/volume-1
        {"index": "1024", "chunk_size": "1024", "chunk": form-data}

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 docs/API.md         |  7 +++++--
 src/kimchi/API.json | 22 ++++++++++++++++++++++
 src/kimchi/i18n.py  |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/docs/API.md b/docs/API.md
index 3f7925f..2e71989 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -474,14 +474,13 @@ A interface represents available network interface on VM.
            in the defined Storage Pool
 * **POST**: Create a new Storage Volume in the Storage Pool
             The return resource is a task resource * See Resource: Task *
-            Only one of 'file', 'capacity', 'url' can be specified.
+            Only one of 'capacity', 'url' can be specified.
     * name: The name of the Storage Volume
     * capacity: The total space which can be used to store volumes
                 The unit is bytes
     * format: The format of the defined Storage Volume. Only used when creating
               a storage volume with 'capacity'.
     * file: File to be uploaded, passed through form data
-    * url: URL to be downloaded
 
 ### Resource: Storage Volume
 
@@ -508,6 +507,10 @@ A interface represents available network interface on VM.
 
 * **DELETE**: Remove the Storage Volume
 * **POST**: *See Storage Volume Actions*
+* **PUT**: Upload storage volume chunk
+    * index: Chunk index of the slice in file.
+    * chunk_size: Chunk size of the slice in Bytes.
+    * chunk: Actual data of uploaded file
 
 **Actions (POST):**
 
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 474661c..9df1dc0 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -222,6 +222,28 @@
                 }
             }
         },
+        "storagevolume_update": {
+            "type": "object",
+            "properties": {
+                "chunk": {
+                    "description": "Upload storage volume chunk",
+                    "required": true
+                },
+                "index": {
+                    "description": "Chunk index of uploaded storage volume",
+                    "type": "string",
+                    "error": "KCHVOL0024E",
+                    "required": true
+                },
+                "chunk_size": {
+                    "description": "Chunk size of uploaded storage volume",
+                    "type": "string",
+                    "error": "KCHVOL0024E",
+                    "required": true
+                }
+            },
+            "additionalProperties": false
+        },
         "vms_create": {
             "type": "object",
             "error": "KCHVM0016E",
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index c8986cf..c012a62 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -215,6 +215,7 @@ messages = {
     "KCHVOL0021E": _("Storage volume URL must be http://, https://, ftp:// or ftps://."),
     "KCHVOL0022E": _("Unable to access file %(url)s. Please, check it."),
     "KCHVOL0023E": _("Unable to clone storage volume '%(name)s' in pool '%(pool)s'. Details: %(err)s"),
+    "KCHVOL0024E": _("Upload volume chunk index, size and total size must be integer"),
 
     "KCHIFACE0001E": _("Interface %(name)s does not exist"),
 
-- 
2.1.0




More information about the Kimchi-devel mailing list