
On 03/04/2014 10:56 PM, Royce Lv wrote:
On 2014年03月05日 02:48, Aline Manera wrote:
On 03/04/2014 07:14 AM, lvroyce@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
When using get_list function of vms model,
I could not find an occurrence when we use VMsModel.get_list() outside its class. Aline,
I used this when counting volume reference--query all vm disks and see if there is path match between volume and vmstorage. And for functionality like restart host, host.py:
def _get_vms_list_by_state(self, state): conn = self.conn.get() names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]
ret_list = [] for name in names: dom = conn.lookupByName(name.encode("utf-8")) info = dom.info() if (DOM_STATE_MAP[info[0]]) == state: ret_list.append(name) return ret_list
This is duplicate code for vms.get_list().
I mean, in future extension we may also introduce vms.get_list() and we don't want multiple background task running right? So based on this making vms model singleton make sense to me. And also, for me there is no need to have multiple instance of every model because in run time we just need one. What do you think?
I am OK with it. I was just trying to understand if it is a bug fix patch or a preventive one. As you commented you will need it on future patches.
Background Task will run multiple times because of started in vm init function. Fix this by making vms model singleton.
Royce Lv (2): Make vm model to be a singleton Hack test_model to support vm model singleton
src/kimchi/model/vms.py | 3 +++ tests/test_model.py | 2 ++ 2 files changed, 5 insertions(+)