def __init__ (self, _id): self.vps_id = _id self.name = "vps%s" % (str(_id).zfill (2)) # to be compatible with current practice standard self.config_path = os.path.join (conf.XEN_CONFIG_DIR, self.name) self.auto_config_path = os.path.join (conf.XEN_AUTO_DIR, self.name) self.xen_bridge = conf.XEN_BRIDGE self.has_all_attr = False self.xen_inf = xen.get_xen_inf () self.data_disks = {} self.trash_disks = {} self.vifs = {}
def __init__(self, _id): self.vps_id = _id self.name = "vps%s" % ( str(_id).zfill(2) ) # to be compatible with current practice standard self.config_path = os.path.join(conf.XEN_CONFIG_DIR, self.name) self.auto_config_path = os.path.join(conf.XEN_AUTO_DIR, self.name) self.xen_bridge = conf.XEN_BRIDGE self.has_all_attr = False self.xen_inf = xen.get_xen_inf() self.data_disks = {} self.trash_disks = {} self.vifs = {}
def refresh_host_space (self): if not conf.USE_LVM: return try: extra = 0 if "LVM_VG_MIN_SPACE" in dir(conf) and conf.LVM_VG_MIN_SPACE: extra = int(conf.LVM_VG_MIN_SPACE) disk_remain = vps_common.vg_free_space (conf.VPS_LVM_VGNAME) # in g disk_remain -= extra if disk_remain < 0: disk_remain = 0 xen_inf = get_xen_inf () mem_remain = xen_inf.mem_free () # in m trans, client = self.get_client () trans.open () try: client.host_refresh (self.host_id, disk_remain, mem_remain) finally: trans.close () self.logger.info ("send host remain disk:%dG, mem:%dM" % (disk_remain, mem_remain)) except Exception, e: self.logger_err.exception (e)
def refresh_host_space(self): if not conf.USE_LVM: return try: extra = 0 if "LVM_VG_MIN_SPACE" in dir(conf) and conf.LVM_VG_MIN_SPACE: extra = int(conf.LVM_VG_MIN_SPACE) disk_remain = vps_common.vg_free_space(conf.VPS_LVM_VGNAME) # in g disk_remain -= extra if disk_remain < 0: disk_remain = 0 xen_inf = get_xen_inf() mem_remain = xen_inf.mem_free() # in m trans, client = self.get_client() trans.open() try: client.host_refresh(self.host_id, disk_remain, mem_remain) finally: trans.close() self.logger.info("send host remain disk:%dG, mem:%dM" % (disk_remain, mem_remain)) except Exception, e: self.logger_err.exception(e)