[Kimchi-devel] [PATCH 2/5] cdrom: update controller

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Mon Jan 6 09:32:12 UTC 2014


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

Update controller and API.json for cdrom.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/API.json       | 16 ++++++++++++++++
 src/kimchi/control/vms.py | 22 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 3a3c48f..feb0c82 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -103,6 +103,22 @@
                 }
             }
         },
+        "cdroms_create": {
+            "type": "object",
+            "properties": {
+                "name": {
+                    "description": "The name of the new VM",
+                    "type": "string",
+                    "pattern": "^hd[b-z]$",
+                    "required": true
+                },
+               "path": {
+                    "description": "Path of image file inserted to the CDROM",
+                    "type": "string",
+                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*([.]iso)$"
+                }
+            }
+        },
         "networks_create": {
             "type": "object",
             "properties": {
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index d722920..51a18c1 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -37,6 +37,7 @@ class VM(Resource):
         super(VM, self).__init__(model, ident)
         self.update_params = ["name"]
         self.screenshot = VMScreenShot(model, ident)
+        self.cdroms = CDROMs(model, ident)
         self.uri_fmt = '/vms/%s'
         self.start = self.generate_action_handler('start')
         self.stop = self.generate_action_handler('stop')
@@ -63,3 +64,24 @@ class VMScreenShot(Resource):
     def get(self):
         self.lookup()
         raise internal_redirect(self.info)
+
+
+class CDROMs(Collection):
+    def __init__(self, model, vm):
+        super(CDROMs, self).__init__(model)
+        self.resource = CDROM
+        self.vm = vm
+        self.resource_args = [self.vm, ]
+        self.model_args = [self.vm, ]
+
+
+class CDROM(Resource):
+    def __init__(self, model, vm, ident):
+        super(CDROM, self).__init__(model, ident)
+        self.vm = vm
+        self.model_args = [self.vm, self.ident]
+        self.uri_fmt = '/vms/%s/cdroms/%s'
+
+    @property
+    def data(self):
+        return self.info
-- 
1.8.1.2




More information about the Kimchi-devel mailing list