예제 #1
0
def sendbrk_handler(spawn, break_count):
    ''' Send break while rebooting device
        Args:
            spawn ('obj'): Spawn connection object
            break_count ('int'): Number of sending break times
        Returns:
            None
    '''

    count = 1
    xr_patterns = IOSXRPatterns()
    while count <= break_count:
        spawn.send("\035")
        spawn.expect([xr_patterns.telnet_prompt])
        spawn.send("send brk\r\r")
        time.sleep(1)
        count += 1
pat = IOSXRSwitchoverPatterns()

prompt_switchover_stmt = Statement(pattern=pat.prompt_switchover,
                                   action='sendline()',
                                   args=None,
                                   loop_continue=True,
                                   continue_timer=True)

rp_in_standby_stmt = Statement(pattern=pat.rp_in_standby,
                               action=None,
                               args=None,
                               loop_continue=False,
                               continue_timer=False)

# Statements for commit, commit replace commands executed on xr.
pat = IOSXRPatterns()
commit_changes_stmt = Statement(pattern=pat.commit_changes_prompt,
                                action='sendline(yes)',
                                args=None,
                                loop_continue=True,
                                continue_timer=False)

commit_replace_stmt = Statement(pattern=pat.commit_replace_prompt,
                                action='sendline(yes)',
                                args=None,
                                loop_continue=True,
                                continue_timer=False)

confirm_y_prompt_stmt = Statement(pattern=pat.confirm_y_prompt,
                                  action='sendline(y)',
                                  args=None,
예제 #3
0
__author__ = "Syed Raza <*****@*****.**>"

from unicon.statemachine import StateMachine
from unicon.plugins.iosxr.patterns import IOSXRPatterns
from unicon.plugins.iosxr.statements import IOSXRStatements
from unicon.statemachine import State, Path
from unicon.eal.dialogs import Statement, Dialog

patterns = IOSXRPatterns()
statements = IOSXRStatements()

default_commands = [statements.more_prompt_stmt]


class IOSXRSingleRpStateMachine(StateMachine):

    # Make it easy for subclasses to pick these up.
    default_commands = default_commands

    def __init__(self, hostname=None):
        super().__init__(hostname)

    def create(self):
        enable = State('enable', patterns.enable_prompt)
        config = State('config', patterns.config_prompt)
        run = State('run', patterns.run_prompt)

        admin = State('admin', patterns.admin_prompt)
        admin_conf = State('admin_conf', patterns.admin_conf_prompt)
        admin_run = State('admin_run', patterns.admin_run_prompt)