[Kimchi-devel] [PATCH 2/5 V3] Host's software update: Update REST API
Aline Manera
alinefm at linux.vnet.ibm.com
Wed Feb 12 12:23:36 UTC 2014
On 02/11/2014 03:28 PM, Paulo Vital wrote:
> 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>
> ---
> src/kimchi/control/host.py | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
> index 053c822..e9437c7 100644
> --- a/src/kimchi/control/host.py
> +++ b/src/kimchi/control/host.py
> @@ -36,6 +36,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 +62,19 @@ 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
> + self.update = self.model.packagesupdate_update
> +
The action function needs to catch the exception raised
(InvalidOperation, MissingParameter, etc) and raise
and cherrypy.HTTPError with the error code and message
As generate_action_handler() is only for Resource you need to expose
this function as follwing:
@cherrypy.expose
def update(self):
try:
self.mode.packagesupdate_update()
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
More information about the Kimchi-devel
mailing list