def status_update_all(self, extra_status = None, replace_status = None): if not self.require("real_id"): return errors.throw(errors.BACKEND_INVALID_INPUT) # if stopped, don't continue status = self.status() if status != errors.VPS_STATUS_RUNNING: return status # ssh master start self.executer = executer_vps(self) self.executer.ssh_master_start() self.executer.thread_safe = True # replace status completely if replace_status != None: threads = replace_status # setup status threads else: threads = [ generic_thread(self.load_averages), generic_thread(self.uptime), generic_thread(self.usage_bandwidth), generic_thread(self.usage_cpu), generic_thread(self.usage_disk), generic_thread(self.usage_mem), generic_thread(self.users) ] # add extra status fields defined by any drivers for status in extra_status: threads.append(generic_thread(status)) # execute status threads for thread in threads: thread.start() # wait for threads for thread in threads: thread.join() # get first error error_first = None for thread in threads: if thread.ret != errors.ERR_SUCCESS: error_first = thread.ret break # ssh master stop self.executer.ssh_master_stop() self.executer = None # return error if error_first: return error_first # return status of VPS return self.status()
def status_update_all(self): # get xentop info self.__get_xentop_info() # if we didn't find it, it's not started if self.xentop_info == -1: return errors.throw(errors.VPS_STATUS_STOPPED) # Xen specific threads threads = [ generic_thread(self.uptime), generic_thread(self.usage_bandwidth), generic_thread(self.usage_disk), generic_thread(self.__usage_cpu), generic_thread(self.__usage_mem), ] # call super ret = super(xen_core, self).status_update_all(replace_status=threads) if ret: return ret return errors.throw(errors.XEN_ERR_UNKNOWN)