# coding:utf-8

'''
Created on Feb 2, 2015

@author: raul
'''

class Pool(object):
    def __init__(self):
        super(Pool, self).__init__()
        self.id = ''
        self.name = ''
        self.size = ''
        self.prestarted_vms = ''
        self.max_user_vms = ''

    def __str__(self):
        return 'id=' + self.id + ' name=' + self.name + ' size=' + self.size + ' prestarted_vms=' + self.prestarted_vms + ' max_user_vms='+ self.max_user_vms
    
class PoolDict(dict):
    _instance = None
    
    def __init__(self):
        super(PoolDict, self).__init__()
        
    def clear(self):
        super(PoolDict, self).clear()
    
    def refresh(self):
        from common.NetUtil import NetUtil
        net = NetUtil()
        net.queryVmPools()
    
    def reload(self):
        self.clear()
        self.refresh()
        
    def getPools(self):
        return self.values()
    
    @staticmethod 
    def instance():
        if PoolDict._instance is None:
            PoolDict._instance = PoolDict()
            
        return PoolDict._instance
