This patch adds the control classes for guest storages
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/kimchi/API.json | 33 ++++++++++++++++++++++++++
src/kimchi/control/vm/storages.py | 49 +++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
create mode 100644 src/kimchi/control/vm/storages.py
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 842fb11..861c96e 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -290,6 +290,39 @@
},
"additionalProperties": false
},
+ "storage_create": {
+ "type": "object",
+ "properties": {
+ "dev": {
+ "description": "The storage device name",
+ "type": "string",
+ "pattern": "^hd[b-z]$",
+ "required": true
+ },
+ "type": {
+ "description": "The storage type",
+ "type": "string",
+ "pattern": "^[cdrom|disk]$",
+ "required": true
+ },
+ "path": {
+ "description": "Path of iso image file or disk mount
point",
+ "type": "string",
+ "pattern":
"^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$"
+ }
+ }
+ },
+ "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
+ }
+ }
+ },
"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..8878d6e
--- /dev/null
+++ b/src/kimchi/control/vm/storages.py
@@ -0,0 +1,49 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+# ShaoHe Feng <shaohef(a)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
+
+
+@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.5.3