[Kimchi-devel] [PATCH 10/15] Move all resources related to interfaces to control/interfaces.py
Daniel H Barboza
danielhb at linux.vnet.ibm.com
Mon Dec 30 17:04:09 UTC 2013
Reviewed-by: Daniel Barboza <danielhb at linux.vnet.ibm.com>
On 12/26/2013 07:48 PM, Aline Manera wrote:
> From: Aline Manera <alinefm at br.ibm.com>
>
> Interfaces(Collection) and Interface(Resource) were moved to a new -
> control/interfaces.py
> That way we can easily know where interface resource is implemented.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
> src/kimchi/control/interfaces.py | 45 ++++++++++++++++++++++++++++++++++++++
> src/kimchi/controller.py | 20 -----------------
> src/kimchi/root.py | 3 ++-
> 3 files changed, 47 insertions(+), 21 deletions(-)
> create mode 100644 src/kimchi/control/interfaces.py
>
> diff --git a/src/kimchi/control/interfaces.py b/src/kimchi/control/interfaces.py
> new file mode 100644
> index 0000000..28be26e
> --- /dev/null
> +++ b/src/kimchi/control/interfaces.py
> @@ -0,0 +1,45 @@
> +#
> +# 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
> +
> +from kimchi.control.base import Collection, Resource
> +
> +
> +class Interfaces(Collection):
> + def __init__(self, model):
> + super(Interfaces, self).__init__(model)
> + self.resource = Interface
> +
> +
> +class Interface(Resource):
> + def __init__(self, model, ident):
> + super(Interface, self).__init__(model, ident)
> + self.uri_fmt = "/interfaces/%s"
> +
> + @property
> + def data(self):
> + return {'name': self.ident,
> + 'type': self.info['type'],
> + 'ipaddr': self.info['ipaddr'],
> + 'netmask': self.info['netmask'],
> + 'status': self.info['status']}
> diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
> index b691842..2a888a4 100644
> --- a/src/kimchi/controller.py
> +++ b/src/kimchi/controller.py
> @@ -35,26 +35,6 @@ from kimchi.exception import NotFoundError, OperationFailed
> from kimchi.model import ISO_POOL_NAME
>
>
> -class Interfaces(Collection):
> - def __init__(self, model):
> - super(Interfaces, self).__init__(model)
> - self.resource = Interface
> -
> -
> -class Interface(Resource):
> - def __init__(self, model, ident):
> - super(Interface, self).__init__(model, ident)
> - self.uri_fmt = "/interfaces/%s"
> -
> - @property
> - def data(self):
> - return {'name': self.ident,
> - 'type': self.info['type'],
> - 'ipaddr': self.info['ipaddr'],
> - 'netmask': self.info['netmask'],
> - 'status': self.info['status']}
> -
> -
> class Networks(Collection):
> def __init__(self, model):
> super(Networks, self).__init__(model)
> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
> index 6e41190..982c7ea 100644
> --- a/src/kimchi/root.py
> +++ b/src/kimchi/root.py
> @@ -32,6 +32,7 @@ from kimchi.config import get_api_schema_file
> from kimchi.control.utils import parse_request
> from kimchi.control.base import Resource
> from kimchi.control.debugreports import DebugReports
> +from kimchi.control.interfaces import Interfaces
> from kimchi.control.storagepools import StoragePools
> from kimchi.control.templates import Templates
> from kimchi.control.vms import VMs
> @@ -55,7 +56,7 @@ class Root(Resource):
> self.vms = VMs(model)
> self.templates = Templates(model)
> self.storagepools = StoragePools(model)
> - self.interfaces = controller.Interfaces(model)
> + self.interfaces = Interfaces(model)
> self.networks = controller.Networks(model)
> self.tasks = controller.Tasks(model)
> self.config = controller.Config(model)
More information about the Kimchi-devel
mailing list