def __init__(self, target, **kwargs): FSAction.__init__(self, target, **kwargs) # e2fsck send its progression on stderr self.stderr = True # As stderr msgtree is disabled, we have to track output ourselves. self._output = [] # Logging self.logger = logging.getLogger(__name__) # To track message rate self._last_progress = 0
def ev_error(self, worker): FSAction.ev_error(self, worker) try: line = worker.current_errmsg passid, current, total, dummy = line.split(' ', 3) result = FsckProgress(passid, current, total) # Limit message rate to one message per second max. if result.progress == 100 or self._last_progress + 1 < time.time(): self._last_progress = time.time() self.comp.action_event(self, 'progress', result=result) except ValueError: # Other error messages could be important self._output.append(worker.current_errmsg)
def ev_close(self, worker): """ Check process termination status and generate appropriate events. Note that if fsck has correctly fixed some errors, actions will be considered as successful. """ if worker.did_timeout(): return FSAction.ev_close(self, worker) # We want to skip FSAction.ev_close(), just call the upper layer. Action.ev_close(self, worker) self.comp.lustre_check() # fsck returns 0=NOERROR, 1=OK_BUT_CORRECTION, 2=OK_BUT_REBOOT. # see man fsck. if worker.retcode() in (0, 1, 2, 4): # action succeeded result = Result(duration=self.duration, retcode=worker.retcode()) if worker.retcode() in (1, 2): result.message = "Errors corrected" if worker.retcode() == 4: # -n result.message = "Errors found but NOT corrected" self.comp.action_event(self, 'done', result) self.set_status(ACT_OK) else: # action failed msg = "\n".join(self._output) result = ErrorResult(msg, self.duration, worker.retcode()) self.comp.action_event(self, 'failed', result) self.set_status(ACT_ERROR)
def __init__(self, target, **kwargs): FSAction.__init__(self, target, **kwargs) # Hack to work aroung cross-dependency with Target self.comp_is_mgs = (self.comp.TYPE == Shine.Lustre.Target.MGT.TYPE) self.comp_is_mdt = (self.comp.TYPE == Shine.Lustre.Target.MDT.TYPE) self.comp_is_ost = (self.comp.TYPE == Shine.Lustre.Target.OST.TYPE) self.stripecount = kwargs.get('stripecount') self.stripesize = kwargs.get('stripesize') self.format_params = kwargs.get('format_params') # Quota if kwargs.get('quota', False): self.quota_type = kwargs['quota_type'] else: self.quota_type = None
def _vars_substitute(self, txt, suppl_vars=None): """ Replace symbolic variable from the provided text. This function extends FSAction._var_substitute. It adds: $index $dev: Replaced by the basename of the device. $jdev: Same as 'dev' for the journal device. """ var_map = { 'index' : str(self.comp.index), 'dev' : os.path.basename(self.comp.dev), } if self.comp.journal: var_map['jdev'] = os.path.basename(self.comp.journal.dev) if suppl_vars: var_map.update(suppl_vars) return FSAction._vars_substitute(self, txt, var_map)
def __init__(self, target, **kwargs): FSAction.__init__(self, target, **kwargs) self.mount_options = kwargs.get('mount_options') self.mount_paths = kwargs.get('mount_paths')
def _shell(self): """Call superclass _shell() method and add logging.""" FSAction._shell(self) self.logger.info("%-16s %s" % (self.comp.label, "Starting fsck"))