[Kimchi-devel] [PATCH 2/7] Host's software update: Update REST API
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Feb 13 14:07:28 UTC 2014
From: Paulo Vital <pvital at linux.vnet.ibm.com>
Define PackageUpdate resource features according to API.md
Activate auth support to new resource
Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
src/kimchi/control/host.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
index 053c822..b4dd544 100644
--- a/src/kimchi/control/host.py
+++ b/src/kimchi/control/host.py
@@ -23,8 +23,12 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import cherrypy
+
from kimchi.control.base import Collection, Resource
from kimchi.control.utils import UrlSubNode
+from kimchi.exception import OperationFailed
+from kimchi.template import render
@UrlSubNode("host", True)
@@ -36,6 +40,7 @@ class Host(Resource):
self.shutdown = self.generate_action_handler('shutdown')
self.stats = HostStats(self.model)
self.partitions = Partitions(self.model)
+ self.packagesupdate = PackagesUpdate(self.model)
@property
def data(self):
@@ -61,3 +66,27 @@ class Partition(Resource):
@property
def data(self):
return self.info
+
+
+class PackagesUpdate(Collection):
+ def __init__(self, model):
+ super(PackagesUpdate, self).__init__(model)
+ self.resource = PackageUpdate
+
+ @cherrypy.expose
+ def update(self):
+ try:
+ task = self.model.packagesupdate_update()
+ cherrypy.response.status = 202
+ return render("Task", task)
+ except OperationFailed, e:
+ raise cherrypy.HTTPError(500, e.message)
+
+
+class PackageUpdate(Resource):
+ def __init__(self, model, id=None):
+ super(PackageUpdate, self).__init__(model, id)
+
+ @property
+ def data(self):
+ return self.info
--
1.7.10.4
More information about the Kimchi-devel
mailing list