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

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Dec 30 17:42:53 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>
>
> Host(Resource), HostStats(Resource), Partitions(Collection) and Partition(Resource)
> were moved to a new - control/host.py
> That way we can easily know where host resource is implemented.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/control/host.py |   63 ++++++++++++++++++++++++++++++++++++++++++++
>   src/kimchi/controller.py   |   34 ------------------------
>   src/kimchi/root.py         |    3 ++-
>   3 files changed, 65 insertions(+), 35 deletions(-)
>   create mode 100644 src/kimchi/control/host.py
>
> diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
> new file mode 100644
> index 0000000..9b19577
> --- /dev/null
> +++ b/src/kimchi/control/host.py
> @@ -0,0 +1,63 @@
> +#
> +# Project Kimchi
> +#
> +# Copyright IBM, Corp. 2013
> +#
> +# Authors:
> +#  Adam Litke <agl at linux.vnet.ibm.com>
> +#  Aline Manera <alinefm at linux.vnet.ibm.com>
> +#  Daniel Henrique Barboza <danielhb 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
> +
> +from kimchi.control.base import Collection, Resource
> +
> +
> +class Host(Resource):
> +    def __init__(self, model, id=None):
> +        super(Host, self).__init__(model, id)
> +        self.uri_fmt = '/host/%s'
> +        self.reboot = self.generate_action_handler('reboot')
> +        self.shutdown = self.generate_action_handler('shutdown')
> +        self.stats = HostStats(self.model)
> +        self.stats.exposed = True
> +        self.partitions = Partitions(self.model)
> +        self.partitions.exposed = True
> +
> +    @property
> +    def data(self):
> +        return self.info
> +
> +
> +class HostStats(Resource):
> +    @property
> +    def data(self):
> +        return self.info
> +
> +
> +class Partitions(Collection):
> +    def __init__(self, model):
> +        super(Partitions, self).__init__(model)
> +        self.resource = Partition
> +
> +
> +class Partition(Resource):
> +    def __init__(self, model, id):
> +        super(Partition, self).__init__(model, id)
> +
> +    @property
> +    def data(self):
> +        return self.info
> diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
> index 0ec0c6f..aca54f2 100644
> --- a/src/kimchi/controller.py
> +++ b/src/kimchi/controller.py
> @@ -52,40 +52,6 @@ class Tasks(Collection):
>           self.resource = Task
>
>
> -class Host(Resource):
> -    def __init__(self, model, id=None):
> -        super(Host, self).__init__(model, id)
> -        self.stats = HostStats(self.model)
> -        self.stats.exposed = True
> -        self.uri_fmt = '/host/%s'
> -        self.reboot = self.generate_action_handler('reboot')
> -        self.shutdown = self.generate_action_handler('shutdown')
> -        self.partitions = Partitions(self.model)
> -        self.partitions.exposed = True
> -
> -    @property
> -    def data(self):
> -        return self.info
> -
> -class HostStats(Resource):
> -    @property
> -    def data(self):
> -        return self.info
> -
> -class Partitions(Collection):
> -    def __init__(self, model):
> -        super(Partitions, self).__init__(model)
> -        self.resource = Partition
> -
> -
> -class Partition(Resource):
> -    def __init__(self, model,id):
> -        super(Partition, self).__init__(model,id)
> -
> -    @property
> -    def data(self):
> -        return self.info
> -
>   class Plugins(Collection):
>       def __init__(self, model):
>           super(Plugins, self).__init__(model)
> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
> index c4f795b..6e5f282 100644
> --- a/src/kimchi/root.py
> +++ b/src/kimchi/root.py
> @@ -33,6 +33,7 @@ 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.host import Host
>   from kimchi.control.interfaces import Interfaces
>   from kimchi.control.networks import Networks
>   from kimchi.control.storagepools import StoragePools
> @@ -62,7 +63,7 @@ class Root(Resource):
>           self.networks = Networks(model)
>           self.tasks = controller.Tasks(model)
>           self.config = Config(model)
> -        self.host = controller.Host(model)
> +        self.host = Host(model)
>           self.debugreports = DebugReports(model)
>           self.plugins = controller.Plugins(model)
>           self.api_schema = json.load(open(get_api_schema_file()))




More information about the Kimchi-devel mailing list