Open ousui opened 1 year ago
Although I haven't used 'salt' before, there is a workaround to enter enable mode without calling check_enable_mode
.
By passing the check_state
parameter as False
when calling enable
, you can bypass the process of determining the current enable mode and force the attempt to enter enable mode.
I have also encountered issues with many of netmiko's functionalities due to the presence of '#' in the hostname of my Cisco IOS devices.
However, I have been using the aforementioned workaround successfully.
If there is a part in the 'salt netmiko module' or your script where you can directly call the enable()
method, this workaround might be applicable.
Below is an example:
from netmiko import ConnectHandler
connection = ConnectHandler(
device_type="cisco_ios",
host="10.1.1.1",
username="user",
password="password",
secret="enable",
port=22,
)
print(connection.find_prompt())
# My device contains '#' in hostname.
#
# 3F_SWITCH_LAN2_#1>
connection.enable()
print(connection.send_command("show run"))
# It doesn't work.
#
# ^
# % Invalid input detected at '^' marker.
connection.enable(check_state=False)
print(connection.send_command("sh run"))
# It works.
#
# Building configuration...
#
# Current configuration : 13819 bytes
# !
# ...
I would say you really should change your hostname, you are likely going to have a lot of pain/extra work (if you try and keep the #
in your hostname).
I hava some cisco_ios like network devices and their hostname contain "#" character (alias: pound key, hash key, hash tag, number sign, # sign),
for example:
I use salt-statck as netmiko executor to manage network devices.
But this problem has nothing to do with salt-statck.
When salt-statck or scripts call function "check_enable_mode",
it always can found check string ("#") in output, so the result always must be "True"
How can I use "check_enable_mode" correct to check enable mode with out modify source code?
All of netmiko versions have this problem.
P.S. Version info:
Ref: