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

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Dec 30 17:42:46 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>
>
> Config(Resource), Capabilities(Resource), Distros(Collection) and Distro(Resource)
> were moved to a new - control/config.py
> That way we can easily know where config resource is implemented.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/control/config.py |   69 ++++++++++++++++++++++++++++++++++++++++++
>   src/kimchi/controller.py     |   41 -------------------------
>   src/kimchi/root.py           |    3 +-
>   3 files changed, 71 insertions(+), 42 deletions(-)
>   create mode 100644 src/kimchi/control/config.py
>
> diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py
> new file mode 100644
> index 0000000..3630172
> --- /dev/null
> +++ b/src/kimchi/control/config.py
> @@ -0,0 +1,69 @@
> +#
> +# Project Kimchi
> +#
> +# Copyright IBM, Corp. 2013
> +#
> +# Authors:
> +#  Adam Litke <agl at linux.vnet.ibm.com>
> +#  Aline Manera <alinefm at linux.vnet.ibm.com>
> +#  ShaoHe Feng <shaohef 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
> +
> +
> +from kimchi.control.base import Collection, Resource
> +
> +
> +class Config(Resource):
> +    def __init__(self, model, id=None):
> +        super(Config, self).__init__(model, id)
> +        self.capabilities = Capabilities(self.model)
> +        self.capabilities.exposed = True
> +        self.distros = Distros(model)
> +        self.distros.exposed = True
> +
> +    @property
> +    def data(self):
> +        return {'http_port': cherrypy.server.socket_port}
> +
> +
> +class Capabilities(Resource):
> +    def __init__(self, model, id=None):
> +        super(Capabilities, self).__init__(model, id)
> +
> +    @property
> +    def data(self):
> +        caps = ['libvirt_stream_protocols', 'qemu_stream',
> +                'screenshot', 'system_report_tool']
> +        ret = dict([(x, None) for x in caps])
> +        ret.update(self.model.get_capabilities())
> +        return ret
> +
> +
> +class Distros(Collection):
> +    def __init__(self, model):
> +        super(Distros, self).__init__(model)
> +        self.resource = Distro
> +
> +
> +class Distro(Resource):
> +    def __init__(self, model, ident):
> +        super(Distro, self).__init__(model, ident)
> +
> +    @property
> +    def data(self):
> +        return self.info
> diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
> index 8f21bfd..0ec0c6f 100644
> --- a/src/kimchi/controller.py
> +++ b/src/kimchi/controller.py
> @@ -52,47 +52,6 @@ class Tasks(Collection):
>           self.resource = Task
>
>
> -class Config(Resource):
> -    def __init__(self, model, id=None):
> -        super(Config, self).__init__(model, id)
> -        self.capabilities = Capabilities(self.model)
> -        self.capabilities.exposed = True
> -        self.distros = Distros(model)
> -        self.distros.exposed = True
> -
> -    @property
> -    def data(self):
> -        return {'http_port': cherrypy.server.socket_port}
> -
> -class Capabilities(Resource):
> -    def __init__(self, model, id=None):
> -        super(Capabilities, self).__init__(model, id)
> -        self.model = model
> -
> -    @property
> -    def data(self):
> -        caps = ['libvirt_stream_protocols', 'qemu_stream',
> -                'screenshot', 'system_report_tool']
> -        ret = dict([(x, None) for x in caps])
> -        ret.update(self.model.get_capabilities())
> -        return ret
> -
> -
> -class Distro(Resource):
> -    def __init__(self, model, ident):
> -        super(Distro, self).__init__(model, ident)
> -
> -    @property
> -    def data(self):
> -        return self.info
> -
> -
> -class Distros(Collection):
> -    def __init__(self, model):
> -        super(Distros, self).__init__(model)
> -        self.resource = Distro
> -
> -
>   class Host(Resource):
>       def __init__(self, model, id=None):
>           super(Host, self).__init__(model, id)
> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
> index ebcd062..c4f795b 100644
> --- a/src/kimchi/root.py
> +++ b/src/kimchi/root.py
> @@ -31,6 +31,7 @@ from kimchi import template
>   from kimchi.config import get_api_schema_file
>   from kimchi.control.utils import parse_request
>   from kimchi.control.base import Resource
> +from kimchi.control.config import Config
>   from kimchi.control.debugreports import DebugReports
>   from kimchi.control.interfaces import Interfaces
>   from kimchi.control.networks import Networks
> @@ -60,7 +61,7 @@ class Root(Resource):
>           self.interfaces = Interfaces(model)
>           self.networks = Networks(model)
>           self.tasks = controller.Tasks(model)
> -        self.config = controller.Config(model)
> +        self.config = Config(model)
>           self.host = controller.Host(model)
>           self.debugreports = DebugReports(model)
>           self.plugins = controller.Plugins(model)




More information about the Kimchi-devel mailing list