Esempio n. 1
0
 def __check_mirror_status(self, eventid, mirrorid, dextid):
     # this method called with event_record locked
     try:
         status = get_mirror_status(mirrorid)
         if not status or not status.has_key(dextid): # mirror or dext gone ?
             self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['ERROR'], errno.ENOENT)
         elif status[dextid] == 'in_sync': # done
             self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['DONE'], 0)
         # else: rebuild progress, status not change
     except Exception:
         logger.error(traceback.format_exc())
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['ERROR'], 500)
Esempio n. 2
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