[Kimchi-devel] [PATCH 15/15] Move all resources related to tasks to control/tasks.py

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Dec 30 17:43:11 UTC 2013


Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>

On 12/26/2013 07:49 PM, Aline Manera wrote:
> From: Aline Manera <alinefm at br.ibm.com>
>
> Tasks(Collection) and Task(Resource) were moved to a new - control/tasks.py
> That way we can easily know where task resource is implemented.
> Also remove former controller.py
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/Makefile.am      |    1 -
>   src/kimchi/control/tasks.py |   41 ++++++++++++++++++++++++++++++++++
>   src/kimchi/controller.py    |   52 -------------------------------------------
>   src/kimchi/root.py          |    4 ++--
>   4 files changed, 43 insertions(+), 55 deletions(-)
>   create mode 100644 src/kimchi/control/tasks.py
>   delete mode 100644 src/kimchi/controller.py
>
> diff --git a/src/kimchi/Makefile.am b/src/kimchi/Makefile.am
> index 78af50f..955e63c 100644
> --- a/src/kimchi/Makefile.am
> +++ b/src/kimchi/Makefile.am
> @@ -25,7 +25,6 @@ SUBDIRS = control
>   kimchi_PYTHON = \
>   	asynctask.py      \
>   	auth.py           \
> -	controller.py     \
>   	disks.py          \
>   	distroloader.py   \
>   	exception.py      \
> diff --git a/src/kimchi/control/tasks.py b/src/kimchi/control/tasks.py
> new file mode 100644
> index 0000000..b799422
> --- /dev/null
> +++ b/src/kimchi/control/tasks.py
> @@ -0,0 +1,41 @@
> +#
> +# Project Kimchi
> +#
> +# Copyright IBM, Corp. 2013
> +#
> +# Authors:
> +#  Aline Manera <alinefm at linux.vnet.ibm.com>
> +#  Shu Ming <shuming 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 Tasks(Collection):
> +    def __init__(self, model):
> +        super(Tasks, self).__init__(model)
> +        self.resource = Task
> +
> +
> +class Task(Resource):
> +    def __init__(self, model, id):
> +        super(Task, self).__init__(model, id)
> +
> +    @property
> +    def data(self):
> +        return {'id': self.ident,
> +                'status': self.info['status'],
> +                'message': self.info['message']}
> diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
> deleted file mode 100644
> index 4684e11..0000000
> --- a/src/kimchi/controller.py
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -#
> -# Project Kimchi
> -#
> -# Copyright IBM, Corp. 2013
> -#
> -# Authors:
> -#  Adam Litke <agl 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
> -
> -import cherrypy
> -import urllib2
> -
> -
> -from functools import wraps
> -
> -
> -import kimchi.template
> -from kimchi.control.utils import get_class_name, internal_redirect, model_fn
> -from kimchi.control.utils import parse_request, validate_method, validate_params
> -from kimchi.exception import InvalidOperation, InvalidParameter, MissingParameter
> -from kimchi.exception import NotFoundError,  OperationFailed
> -from kimchi.model import ISO_POOL_NAME
> -
> -
> -class Task(Resource):
> -    def __init__(self, model, id):
> -        super(Task, self).__init__(model, id)
> -
> -    @property
> -    def data(self):
> -        return {'id': self.ident,
> -                'status': self.info['status'],
> -                'message': self.info['message']}
> -
> -
> -class Tasks(Collection):
> -    def __init__(self, model):
> -        super(Tasks, self).__init__(model)
> -        self.resource = Task
> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
> index 8ea15d8..1750014 100644
> --- a/src/kimchi/root.py
> +++ b/src/kimchi/root.py
> @@ -26,7 +26,6 @@ import json
>
>
>   from kimchi import auth
> -from kimchi import controller
>   from kimchi import template
>   from kimchi.config import get_api_schema_file
>   from kimchi.control.utils import parse_request
> @@ -38,6 +37,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.tasks import Tasks
>   from kimchi.control.templates import Templates
>   from kimchi.control.vms import VMs
>   from kimchi.exception import OperationFailed
> @@ -62,7 +62,7 @@ class Root(Resource):
>           self.storagepools = StoragePools(model)
>           self.interfaces = Interfaces(model)
>           self.networks = Networks(model)
> -        self.tasks = controller.Tasks(model)
> +        self.tasks = Tasks(model)
>           self.config = Config(model)
>           self.host = Host(model)
>           self.debugreports = DebugReports(model)




More information about the Kimchi-devel mailing list