[Kimchi-devel] [PATCHv7 4/8] storage server: update controller.py

lvroyce0210 at gmail.com lvroyce0210 at gmail.com
Tue Jan 14 15:47:59 UTC 2014


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

Add storage server collection and resource to report
used storage server.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/API.json                 | 10 ++++++++++
 src/kimchi/control/storageserver.py | 38 +++++++++++++++++++++++++++++++++++++
 src/kimchi/root.py                  |  2 ++
 3 files changed, 50 insertions(+)
 create mode 100644 src/kimchi/control/storageserver.py

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 19b1c51..d951696 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -214,6 +214,16 @@
             },
             "additionalProperties": false
         },
+        "storageservers_get_list": {
+            "type": "object",
+            "properties": {
+                "target_type": {
+                    "description": "List storage servers of given type",
+                    "type": "string",
+                    "pattern": "^netfs$"
+                }
+            }
+        },
         "template_update": {
             "type": "object",
             "properties": {
diff --git a/src/kimchi/control/storageserver.py b/src/kimchi/control/storageserver.py
new file mode 100644
index 0000000..0d4cb05
--- /dev/null
+++ b/src/kimchi/control/storageserver.py
@@ -0,0 +1,38 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# Authors:
+#  Royce Lv <lvroyce 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
+
+
+class StorageServers(Collection):
+    def __init__(self, model):
+        super(StorageServers, self).__init__(model)
+        self.resource = StorageServer
+
+
+class StorageServer(Resource):
+    def __init__(self, model, ident):
+        super(StorageServer, self).__init__(model, ident)
+
+    @property
+    def data(self):
+        return self.info
diff --git a/src/kimchi/root.py b/src/kimchi/root.py
index 3cc6321..ec531c0 100644
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
@@ -36,6 +36,7 @@ from kimchi.control.interfaces import Interfaces
 from kimchi.control.networks import Networks
 from kimchi.control.plugins import Plugins
 from kimchi.control.storagepools import StoragePools
+from kimchi.control.storageserver import StorageServers
 from kimchi.control.tasks import Tasks
 from kimchi.control.templates import Templates
 from kimchi.control.utils import parse_request
@@ -60,6 +61,7 @@ class Root(Resource):
         self.vms = VMs(model)
         self.templates = Templates(model)
         self.storagepools = StoragePools(model)
+        self.storageservers = StorageServers(model)
         self.interfaces = Interfaces(model)
         self.networks = Networks(model)
         self.tasks = Tasks(model)
-- 
1.8.1.2




More information about the Kimchi-devel mailing list