pythoncisconetmiko

Netmiko - confirmation in configuration mode


I just start using netmiko and have a problem with one script. The script should delete a user and create another one. The problem that I have is with confirmation in configuration mode I don`t know how to handle it.

R1(config)#no username admin
This operation will remove all username related configurations with same name.Do you want to continue? [confirm]

Thank you.


Solution

  • you would a use an expect string.

    output = net_connect.send_command(
        command_string=command,
        expect_string=r"Delete filename",
        strip_prompt=False,
        strip_command=False
    )
    output += net_connect.send_command(
        command_string="\n",
        expect_string=r"confirm",
        strip_prompt=False,
        strip_command=False