Ejemplo n.º 1
0
    def enter_exec_mode(self, session):
        session.prompt = re.sub(r"\\Z$", r"\(enable\)\s?\Z", session.prompt)
        self.logger.debug("prompt changed to %r", session.prompt)

        session.connection.sendline("enable")
        index = session.connection.expect(
            [r"[Pp]assword: ?\Z", pexpect.TIMEOUT, session.prompt])
        if index == 0:
            if not session.exec_password:
                raise canner.error("Exec password not specified")
            session.connection.sendline(session.exec_password)
            index = session.connection.expect(
                [r"[Pp]assword: ?\Z", pexpect.TIMEOUT, session.prompt])
            if index == 0:
                raise canner.error("Exec password not accepted")
            if index == 1:
                raise canner.error("Problem sending exec password")
        elif index == 1:
            raise canner.error("Problem entering exec mode")
Ejemplo n.º 2
0
    def setup(self, session):
        session.connection.sendline("enable")
        index = session.connection.expect(
            [r"[Pp]assword: ?\Z", pexpect.TIMEOUT, session.prompt])
        if index == 0:
            if not session.exec_password:
                raise canner.error("Exec password not specified")
            session.connection.sendline(session.exec_password)
            index = session.connection.expect(
                [r"[Pp]assword: ?\Z", pexpect.TIMEOUT, session.prompt])
            if index == 0:
                raise canner.error("Exec password not accepted")
            if index == 1:
                raise canner.error("Problem sending exec password")
        elif index == 1:
            raise canner.error("Problem entering exec mode")

        session.perform_command("terminal length 0")
        session.perform_command("terminal width 0")
Ejemplo n.º 3
0
    def setup(self, session):
        session.connection.sendline("enable")
        index = session.connection.expect([r"[Pp]assword: ?\Z",
                                           pexpect.TIMEOUT,
                                           session.prompt])
        if index == 0:
            if not session.exec_password:
                raise canner.error("Exec password not specified")
            session.connection.sendline(session.exec_password)
            index = session.connection.expect([r"[Pp]assword: ?\Z",
                                               pexpect.TIMEOUT,
                                               session.prompt])
            if index == 0:
                raise canner.error("Exec password not accepted")
            if index == 1:
                raise canner.error("Problem sending exec password")
        elif index == 1:
            raise canner.error("Problem entering exec mode")

        session.perform_command("terminal length 0")
        session.perform_command("terminal width 0")
Ejemplo n.º 4
0
    def enter_exec_mode(self, session):
        session.prompt = re.sub(r"\\Z$", r"\(enable\)\s?\Z", session.prompt)
        self.logger.debug("prompt changed to %r", session.prompt)

        session.connection.sendline("enable")
        index = session.connection.expect([r"[Pp]assword: ?\Z",
                                           pexpect.TIMEOUT,
                                           session.prompt])
        if index == 0:
            if not session.exec_password:
                raise canner.error("Exec password not specified")
            session.connection.sendline(session.exec_password)
            index = session.connection.expect([r"[Pp]assword: ?\Z",
                                               pexpect.TIMEOUT,
                                               session.prompt])
            if index == 0:
                raise canner.error("Exec password not accepted")
            if index == 1:
                raise canner.error("Problem sending exec password")
        elif index == 1:
            raise canner.error("Problem entering exec mode")