[Kimchi-devel] [PATCH v4 2/6] CDROM Management: Update controller and API.json for guest storages

Daniel Barboza danielhb at linux.vnet.ibm.com
Thu Feb 13 18:47:44 UTC 2014


From: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>

This patch adds the control classes for guest storages

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>

Removing hard disk support from API.json
Changed API.json declarations to the new exception model

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 src/kimchi/API.json               | 37 +++++++++++++++++++++++++++++
 src/kimchi/control/vm/storages.py | 49 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 src/kimchi/control/vm/storages.py

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index ba1619f..a1bdf64 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -340,6 +340,43 @@
             "additionalProperties": false,
             "error": "KCHAPI0001E"
          },
+        "storages_create": {
+            "type": "object",
+            "properties": {
+                "dev": {
+                    "description": "The storage (cd-rom) device name",
+                    "type": "string",
+                    "pattern": "^hd[b-z]$",
+                    "error": "KCHCDROM0001E"
+                },
+                "type": {
+                    "description": "The storage type",
+                    "type": "string",
+                    "pattern": "^cdrom$",
+                    "required": true,
+                    "error": "KCHCDROM0002E"
+                },
+               "path": {
+                    "description": "Path of iso image file or disk mount point",
+                    "type": "string",
+                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
+                    "required": true,
+                    "error": "KCHCDROM0003E"
+                }
+            }
+        },
+        "storage_update": {
+            "type": "object",
+            "properties": {
+               "path": {
+                    "description": "Path of iso image file or disk mount point",
+                    "type": "string",
+                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
+                    "required": true,
+                    "error": "KCHCDROM0003E"
+                }
+            }
+        },
         "template_update": {
             "type": "object",
             "properties": {
diff --git a/src/kimchi/control/vm/storages.py b/src/kimchi/control/vm/storages.py
new file mode 100644
index 0000000..49f524c
--- /dev/null
+++ b/src/kimchi/control/vm/storages.py
@@ -0,0 +1,49 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# Authors:
+#  Rodrigo Trujilo <rodrigo.trujillo at linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+from kimchi.control.base import Collection, Resource
+from kimchi.control.utils import UrlSubNode
+
+
+ at UrlSubNode("storages")
+class Storages(Collection):
+    def __init__(self, model, vm):
+        super(Storages, self).__init__(model)
+        self.resource = Storage
+        self.vm = vm
+        self.resource_args = [self.vm, ]
+        self.model_args = [self.vm, ]
+
+
+class Storage(Resource):
+    def __init__(self, model, vm, ident):
+        super(Storage, self).__init__(model, ident)
+        self.vm = vm
+        self.ident = ident
+        self.info = {}
+        self.model_args = [self.vm, self.ident]
+        self.uri_fmt = '/vms/%s/storages/%s'
+        self.update_params = ['path']
+
+    @property
+    def data(self):
+        return self.info
-- 
1.8.3.1




More information about the Kimchi-devel mailing list