scrapli.driver.core.cisco_nxos.base_driver
NXOSDriverBase
Source code in driver/core/cisco_nxos/base_driver.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | class NXOSDriverBase:
# NXOSDriverBase Mixin values set in init of sync/async NetworkDriver classes
privilege_levels: Dict[str, PrivilegeLevel]
def _create_configuration_session(self, session_name: str) -> None:
"""
Handle configuration session creation tasks for consistency between sync/async versions
Args:
session_name: name of session to register
Returns:
None
Raises:
ScrapliValueError: if a session of given name already exists
"""
if session_name in self.privilege_levels.keys():
msg = (
f"session name `{session_name}` already registered as a privilege level, chose a "
"unique session name"
)
raise ScrapliValueError(msg)
pattern = r"^[a-z0-9.\-_@/:]{1,32}\(config\-s[a-z0-9.\-@/:]{0,32}\)#\s?$"
name = session_name
config_session = PrivilegeLevel(
pattern=pattern,
name=name,
previous_priv="privilege_exec",
deescalate="end",
escalate=f"configure session {session_name}",
escalate_auth=False,
escalate_prompt="",
)
self.privilege_levels[name] = config_session
|