[Kimchi-devel] [PATCH 4/8] Add model function to wait for task

Aline Manera alinefm at linux.vnet.ibm.com
Wed Nov 5 11:32:23 UTC 2014


On 11/04/2014 11:10 AM, Crístian Viana wrote:
>
> On 03-11-2014 14:12, Aline Manera wrote:
>> If you will use the new TaskModel.wait() function in all wait_task 
>> occurrences you should also remove the wait_task implementation from 
>> utils.py
>
> They have different implementations. The function implemented on 
> TaskModel is supposed to be used by the model (e.g. some_task.wait()), 
> which is needed now to wait for "StorageVolumes.create". The one 
> implemented in tests/utils.py is meant to be used for tests, 
> especially for the REST tests (i.e. running "GET /tasks/1" and parsing 
> its JSON result). The tests cannot use the model implementation 
> because they don't use the model directly and the model cannot use the 
> test implementation because it doesn't handle REST commands.
>
> Actually, the function in tests/utils.py receives a function as a 
> parameter so it can handle different lookup approaches (i.e. by model 
> / by REST). But IMO, when using the model directly, "wait" is not a 
> "util" function and it should be defined in the model itself.
>
> So I think we have two options here:
>
> 1) Implement one "wait" function for the model and another one for the 
> tests;
> 2) Implement one generic "wait" function and another one with the 
> partial "lookup" implementation to handle the REST commands;
>
> More than one function will have to be implemented anyway. And I 
> prefer option (1) because (2) looks like a workaround.
>
> What should I do?

I thought about one more option. In both cases, we use the AsynTask() 
object. So isn't there a way to implement the wait_task() there and 
reuse it in all cases?
I haven't checked the code yet - it is just an idea.




More information about the Kimchi-devel mailing list