[Kimchi-devel] [PATCH 3/5] clone template: update controller

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Tue Feb 11 13:58:12 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

Add clone action in controller
also update API.json

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/API.json             | 80 +++++++++++++++++++++++++++++++++++++++++
 src/kimchi/control/templates.py |  1 +
 2 files changed, 81 insertions(+)

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 10741a4..aca72a7 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -280,6 +280,86 @@
             },
             "additionalProperties": false
         },
+        "template_clone": {
+            "type": "object",
+            "properties": {
+                "name": {
+                    "description": "The name of the new template",
+                    "type": "string",
+                    "pattern": "^[^ ]+( +[^ ]+)*$",
+                    "minLength": 1
+                },
+                "icon": {
+                    "description": "The template icon path",
+                    "type": "string",
+                    "pattern": "^images/"
+                },
+                "os_distro": {
+                    "description": "Distribution name of the Operating System",
+                    "type": "string",
+                    "minLength": 1
+                },
+                "os_version": {
+                    "description": "Version of the Operating System",
+                    "type": "string",
+                    "minLength": 1
+                },
+                "cpus": {
+                    "description": "Number of CPUs for the template",
+                    "type": "integer",
+                    "minimum": 1
+                },
+                "memory": {
+                    "description": "Memory (MB) for the template",
+                    "type": "integer",
+                    "minimum": 512
+                },
+                "cdrom": {
+                    "description": "Path for cdrom",
+                    "type": "string",
+                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*([.]iso)$"
+                },
+                "disks": {
+                    "description": "List of disks",
+                    "type": "array",
+                    "items": {
+                        "type": "object",
+                        "properties": {
+                            "index": {
+                                "description": "Index of the disk",
+                                "type": "integer",
+                                "minimum": 0
+                            },
+                            "size": {
+                                "description": "Size (GB) of the disk",
+                                "type": "number",
+                                "minimum": 1
+                            }
+                        }
+                    },
+                    "minItems": 1,
+                    "uniqueItems": true
+                },
+                "storagepool": {
+                    "description": "Location of the storage pool",
+                    "type": "string",
+                    "pattern": "^/storagepools/[^/]+/?$"
+                },
+                "networks": {
+                    "description": "list of which networks will be assigned to the new VM.",
+                    "type": "array",
+                    "items": { "type": "string" },
+                    "uniqueItems": true
+                },
+                "folder": {
+                    "description": "Folder",
+                    "type": "array",
+                    "items": { "type": "string" }
+                },
+                "graphics": { "$ref": "#/kimchitype/graphics" }
+            },
+            "additionalProperties": false
+        },
         "template_update": {
             "type": "object",
             "properties": {
diff --git a/src/kimchi/control/templates.py b/src/kimchi/control/templates.py
index ce1dda4..58dafcc 100644
--- a/src/kimchi/control/templates.py
+++ b/src/kimchi/control/templates.py
@@ -40,6 +40,7 @@ class Template(Resource):
                               "memory", "cdrom", "disks", "networks",
                               "graphics"]
         self.uri_fmt = "/templates/%s"
+        self.clone = self.generate_action_handler('clone')
 
     @property
     def data(self):
-- 
1.8.4.2




More information about the Kimchi-devel mailing list