Example #1
0
 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 connect(self):
        """
        Connects to the HP EVA MA. With the parameters given to the constructor.
        """
        mylogger.debug("spawning shell %s" %(self.sssu_cmd))
        self.sssu_shell=pexpect.spawn(self.sssu_cmd, [], self.timeout)
        self.sssu_shell.logfile=self.logfile
        self.sssu_shell.cmdlogfile=self.cmdlog
        if not self.sssu_shell.isalive():
            raise CouldNotConnectToManager("Could not connect to manager %s" %(self.manager))
        mylogger.debug("connecting to manager shell %s" %(self.manager))
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_MANAGER) >= 0:
            self.sssu_shell.sendline(self.manager)
        else:
            mylogger.debug(self.sssu_shell.buffer)
            raise CouldNotParseSSSU("Manager not found")
        mylogger.debug("username %s" %(self.username))
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_USERNAME)>=0:
            self.sssu_shell.sendline(self.username)
        else:
            raise CouldNotParseSSSU("Username not found")
        mylogger.debug("password: ***")
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_PASSWORD)>=0:
            self.sssu_shell.sendline(self.password)
        else:
            raise CouldNotParseSSSU("Password not found")

        if self.sssu_shell.expect([HP_EVA_SSSU.MATCH_NOSYSTEMSELECTED, pexpect.TIMEOUT, pexpect.EOF], 10)>0:
            raise CouldNotConnectToManager, "Either manager, username or password or all are wrong.\nCould not estabilsh connection to %s/%s/*****\n" %(self.manager, self.username)

        mylogger.debug("Switching to xmlstatus")
        self.setOptions(HP_EVA_SSSU.DISPLAY_XMLSTATUS)
        self.selectSystem(self.system)
        mylogger.debug("manage system")
        self.setSystem(self.system, "manage")
 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 connect(self):
        """
        Connects to the HP EVA MA. With the parameters given to the constructor.
        """
        mylogger.debug("spawning shell %s" % (self.sssu_cmd))
        self.sssu_shell = pexpect.spawn(self.sssu_cmd, [], self.timeout)
        self.sssu_shell.logfile = self.logfile
        self.sssu_shell.cmdlogfile = self.cmdlog
        if not self.sssu_shell.isalive():
            raise CouldNotConnectToManager("Could not connect to manager %s" %
                                           (self.manager))
        mylogger.debug("connecting to manager shell %s" % (self.manager))
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_MANAGER) >= 0:
            self.sssu_shell.sendline(self.manager)
        else:
            mylogger.debug(self.sssu_shell.buffer)
            raise CouldNotParseSSSU("Manager not found")
        mylogger.debug("username %s" % (self.username))
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_USERNAME) >= 0:
            self.sssu_shell.sendline(self.username)
        else:
            raise CouldNotParseSSSU("Username not found")
        mylogger.debug("password: ***")
        if self.sssu_shell.expect(HP_EVA_SSSU.MATCH_PASSWORD) >= 0:
            self.sssu_shell.sendline(self.password)
        else:
            raise CouldNotParseSSSU("Password not found")

        if self.sssu_shell.expect(
            [HP_EVA_SSSU.MATCH_NOSYSTEMSELECTED, pexpect.TIMEOUT, pexpect.EOF],
                10) > 0:
            raise CouldNotConnectToManager, "Either manager, username or password or all are wrong.\nCould not estabilsh connection to %s/%s/*****\n" % (
                self.manager, self.username)

        mylogger.debug("Switching to xmlstatus")
        self.setOptions(HP_EVA_SSSU.DISPLAY_XMLSTATUS)
        self.selectSystem(self.system)
        mylogger.debug("manage system")
        self.setSystem(self.system, "manage")