def getEventStatus(self, data): eventid = mand_keys(data, 'eventid') try: return get_event_status(self.event_record, eventid) except Exception: logger.error(traceback.format_exc()) raise xmlrpclib.Fault(500, 'Internal Server Error')
def registerShredRequest(self, data): def vbtomb(vb): mb = vbtos(vb) / (1024 * 1024 / 512) tvb, todd = stovb(mb * (1024 * 1024 / 512)) if tvb != vb or todd != 0: logger.info("vb %s != %s (%s)" % \ (stovb(mb * (1024 * 1024 / 512)), vb, mb)) raise xmlrpclib.Fault(errno.EINVAL, 'EINVAL') return mb self.event_record.lock() try: eventid, dextid, pdskid, offset, capacity = \ mand_keys(data, 'eventid', 'dextid', 'pdskid', 'offset', \ 'capacity') if self.event_record.event_exist(eventid): self.event_record.unlock() return 0 local_path = '%s/%08x' % (VAS_PDSK_DIR, pdskid) # XXX wait for ssvr_reporter creating symlinks. execute_retry_not_path_exist("false", local_path, 16) self.__start_shredder(eventid, local_path, vbtomb(offset), \ vbtomb(capacity), dextid, pdskid) self.event_record.add_event(eventid, EVENT_STATUS['PROGRESS']) self.event_record.unlock() except xmlrpclib.Fault: self.event_record.unlock() raise except Exception: self.event_record.unlock() logger.error(traceback.format_exc()) raise xmlrpclib.Fault(500, 'Internal Server Error') return 0
def attachLogicalVolume(self, data): eventid, lvolstruct = mand_keys(data, 'eventid', 'lvolstruct') self.event_record.lock() if self.event_record.event_exist(eventid): self.event_record.unlock() return 0 start_worker(self.__attach_worker, eventid, lvolstruct) self.event_record.add_event(eventid, EVENT_STATUS['PROGRESS']) self.event_record.unlock() return 0
def replaceMirrorDisk(self, data): eventid, mirrorid, add_lvolstruct, remove_lvolstruct = \ mand_keys(data, 'eventid', 'mirrorid', 'add', 'remove') self.event_record.lock() if self.event_record.event_exist(eventid): self.event_record.unlock() return 0 dextid = add_lvolstruct['lvolid'] status = get_mirror_status(mirrorid) if not status: # mirror not exist self.event_record.unlock() raise xmlrpclib.Fault(errno.ENOENT, 'ENOENT') if not status.has_key(dextid) or status[dextid] == "faulty": # start rebuild start_worker(self.__mirror_worker, eventid, mirrorid, add_lvolstruct, remove_lvolstruct) self.event_record.add_event(eventid, EVENT_STATUS['PROGRESS'], 0, \ self.__check_mirror_status, (mirrorid, add_lvolstruct['lvolid'])) elif status[dextid] == "in_sync": # rebuild done already self.event_record.add_event(eventid, EVENT_STATUS['DONE'], 0) elif status[dextid] == "spare": # rebuild started already self.event_record.add_event(eventid, EVENT_STATUS['PROGRESS'], 0, \ self.__check_mirror_status, (mirrorid, add_lvolstruct['lvolid'])) # else: that's all self.event_record.unlock() return 0
def getEventStatus(self, data): eventid = mand_keys(data, 'eventid') try: return get_event_status(self.event_record, eventid) except Exception: raise xmlrpclib.Fault(500, 'Internal Server Error')