def executeRecover(self, _file, destdir, dir=True): # recover -s wspbackup.messe-muenchen.de -c wspbackup.messe-muenchen.de -a -d /mnt/backup/recover /tmp/metadata/vg_gfstest-lv_gfstest_filesystem.xml if dir: _dir = _file _selection = "*" else: _dir = os.path.dirname(_file) _selection = os.path.basename(_file) _cmd = "%s %s -c %s -s %s -d %s %s" % ( LegatoNetworker.LEGATO_CMD_RECOVER, " ".join( self.recover_options), self.client, self.server, destdir, _dir) if ComSystem.askExecModeCmd(_cmd): # Ignore timeouts _shell = pexpect.spawn(_cmd, [], None) if self.log.getEffectiveLevel() == DEBUG: _shell.logfile = file( str("/tmp/%s.log" % (os.path.basename( LegatoNetworker.LEGATO_CMD_RECOVER))), "w") _shell.cmdlogfile = file( str("/tmp/%s-cmd.log" % (os.path.basename( LegatoNetworker.LEGATO_CMD_RECOVER))), "w") _shell.expect(self.LEGATO_RECOVER_SHELL) _shell.sendline("add -q %s" % _selection) _shell.expect(self.LEGATO_RECOVER_SHELL) _shell.sendline("recover") _shell.expect(self.LEGATO_RECOVER_SHELL, None) _shell.close()
def executeRecover(self, _file, destdir, dir=True): # recover -s wspbackup.messe-muenchen.de -c wspbackup.messe-muenchen.de -a -d /mnt/backup/recover /tmp/metadata/vg_gfstest-lv_gfstest_filesystem.xml if dir: _dir=_file _selection="*" else: _dir=os.path.dirname(_file) _selection=os.path.basename(_file) _cmd="%s %s -c %s -s %s -d %s %s" %(LegatoNetworker.LEGATO_CMD_RECOVER, " ".join(self.recover_options), self.client, self.server, destdir, _dir) if ComSystem.askExecModeCmd(_cmd): # Ignore timeouts _shell=pexpect.spawn(_cmd, [], None) if self.log.getEffectiveLevel() == DEBUG: _shell.logfile=file(str("/tmp/%s.log" %(os.path.basename(LegatoNetworker.LEGATO_CMD_RECOVER))), "w") _shell.cmdlogfile=file(str("/tmp/%s-cmd.log" %(os.path.basename(LegatoNetworker.LEGATO_CMD_RECOVER))), "w") _shell.expect(self.LEGATO_RECOVER_SHELL) _shell.sendline("add -q %s" %_selection) _shell.expect(self.LEGATO_RECOVER_SHELL) _shell.sendline("recover") _shell.expect(self.LEGATO_RECOVER_SHELL, None) _shell.close()
def cmd(self, cmd, params=None, match=None): self.last_cmd = cmd if not match: match = HP_EVA_SSSU.MATCH_COMMANDSTATUS self.last_cmd = cmd + HP_EVA_SSSU.DELIM + self.toParams(params) mylogger.log(CMD_LOG_LEVEL, self.last_cmd) if not ComSystem.askExecModeCmd(self.last_cmd): return 0 self.sssu_shell.sendline(self.last_cmd) self.sssu_shell.expect(match) self.last_output = self.sssu_shell.before self.xml_output = None if self.sssu_shell.match == pexpect.EOF: return 0 else: if isinstance(self.sssu_shell.match, pexpect.ExceptionPexpect): raise CommandError(1, self.last_cmd, self.sssu_shell.before) else: thematch = self.sssu_shell.match #mylogger.debug("self.sssu_shell.match.group(1): %s" %(thematch.group(1))) self.last_error_code = int(thematch.group(1)) if self.last_error_code == 0: self.xml_output = self.LastOutput2XML() return self.last_error_code else: # Check for the special case when system is managed by another agent to get the right back _match = self.MATCH_MANAGED_ERROR.search(self.last_output) if _match and self.managed_overwrite: mylogger.warn( "SSSU Warning: System is managed by another agent (%s, %s). Overwriting." % (_match.group(1), _match.group(2))) self.setSystem(self.system, "manage") self.cmd(cmd, params, match) return 0 raise CommandError(self.last_error_code, self.last_cmd, self.last_output)
def cmd(self, cmd, params=None, match=None): self.last_cmd=cmd if not match: match=HP_EVA_SSSU.MATCH_COMMANDSTATUS self.last_cmd=cmd+HP_EVA_SSSU.DELIM+self.toParams(params) mylogger.log(CMD_LOG_LEVEL, self.last_cmd) if not ComSystem.askExecModeCmd(self.last_cmd): return 0 self.sssu_shell.sendline(self.last_cmd) self.sssu_shell.expect(match) self.last_output=self.sssu_shell.before self.xml_output=None if self.sssu_shell.match==pexpect.EOF: return 0 else: if isinstance(self.sssu_shell.match,pexpect.ExceptionPexpect): raise CommandError(1, self.last_cmd, self.sssu_shell.before) else: thematch=self.sssu_shell.match #mylogger.debug("self.sssu_shell.match.group(1): %s" %(thematch.group(1))) self.last_error_code=int(thematch.group(1)) if self.last_error_code == 0: self.xml_output=self.LastOutput2XML() return self.last_error_code else: # Check for the special case when system is managed by another agent to get the right back _match=self.MATCH_MANAGED_ERROR.search(self.last_output) if _match and self.managed_overwrite: mylogger.warn("SSSU Warning: System is managed by another agent (%s, %s). Overwriting." %(_match.group(1), _match.group(2))) self.setSystem(self.system, "manage") self.cmd(cmd, params, match) return 0 raise CommandError(self.last_error_code, self.last_cmd, self.last_output)