[Kimchi-devel] [PATCH 15/16] Move all resources related to tasks to control/tasks.py
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Dec 26 18:38:47 UTC 2013
On 12/26/2013 12:00 AM, Shu Ming wrote:
> 2013/12/24 18:43, Sheldon:
>> On 12/24/2013 02:41 AM, 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.
>>>
>>> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> When I post the first patch of task series, there was such a file. But
> Adam.L required to remove it in the code review and place the code into
> controller.py. Can I know why we should split this again?
>
controller.py tends to increase to infinite as more resources are added
to kimchi.
Small modules are easier to maintain and most of them are already
stable, ie, don't need to be changed with high frequency as
controller.py was
>>> ---
>>> Makefile.am | 1 +
>>> src/kimchi/control/tasks.py | 41
>>> +++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 42 insertions(+)
>>> create mode 100644 src/kimchi/control/tasks.py
>>>
>>> diff --git a/Makefile.am b/Makefile.am
>>> index 7278a9b..d9daa63 100644
>>> --- a/Makefile.am
>>> +++ b/Makefile.am
>>> @@ -54,6 +54,7 @@ PEP8_WHITELIST = \
>>> src/kimchi/control/plugins.py \
>>> src/kimchi/control/storagepools.py \
>>> src/kimchi/control/storagevolumes.py \
>>> + src/kimchi/control/tasks.py \
>>> src/kimchi/control/templates.py \
>>> src/kimchi/control/utils.py \
>>> src/kimchi/control/vms.py \
>>> diff --git a/src/kimchi/control/tasks.py b/src/kimchi/control/tasks.py
>>> new file mode 100644
>>> index 0000000..43f232e
>>> --- /dev/null
>>> +++ b/src/kimchi/control/tasks.py
>>> @@ -0,0 +1,41 @@
>>> +#
>>> +# Project Kimchi
>>> +#
>>> +# Copyright IBM, Corp. 2013
>>> +#
>>> +# Authors:
>> $ git show 0968b5c9
>> the author is:
>> Shu Ming <shuming at linux.vnet.ibm.com>
>> Not
>> Adam Litke <agl at linux.vnet.ibm.com>
> Yes. That is me to do the initial work.
>
>>> +# Adam Litke <agl at linux.vnet.ibm.com>
>>> +# Aline Manera <alinefm 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']}
>>
More information about the Kimchi-devel
mailing list