[Kimchi-devel] [PATCH 2/2] MockModel refactor: Create MockModel based on Model("test:///default")

Aline Manera alinefm at linux.vnet.ibm.com
Fri Nov 14 17:15:34 UTC 2014


On 11/14/2014 02:48 PM, Crístian Viana wrote:
> On 14-11-2014 13:51, Aline Manera wrote:
>> +        for res, items in params.iteritems():
>> +            resources = getattr(self, '%s_get_list' % res)()
>> +            for i in resources:
>> +                if i in items:
>> +                    continue
>
> What's the purpose of the loops above? AFAIU, the inner loop is useless.

The reset() function is to clean up all the mockup resources as it is 
running for the first time.

The whole code is:

         params = {'vms': [u'test'], 'templates': [],
                   'networks': [u'default'], 'storagepools': 
[u'default-pool']}

         for res, items in params.iteritems():
             resources = getattr(self, '%s_get_list' % res)()
             for i in resources:
                 if i in items:
continue

try:
                     getattr(self, '%s_deactivate' % res[:-1])(i)
except:
pass

                 getattr(self, '%s_delete' % res[:-1])(i)


"params" hold the first time configuration - so one only VM named "test" 
must persist on 'test:///default' URI and the same for storagepools and 
networks.

The first loop (for res, items in params.iteritems()) is to go by the 
"params" list.
Then I collect all the resources for the API (resources = getattr(self, 
'%s_get_list' % res)()).
The seconds loop is to identify the resources that need to be removed, 
ie, will not be in the first run time. So I compared the item against 
the "params" values.

Does that make sense?

>
>> +    def _probe_image(self, path):
>> +        return ('unkown', 'unkown')
>>
>
> Shouldn't it be "unknown"?

ACK.

>
> Also, "make check-local" reported one i18n issue.

ACK.




More information about the Kimchi-devel mailing list