Skip to content

Commit

Permalink
Convert linux methods to private methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed May 3, 2024
1 parent 7e6a747 commit 25aa143
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions netmiko/garderos/garderos_grs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def commit(self, commit: str = "commit") -> str:
sleep(1)
return commit_result

def save_config(
def save_config(
self,
cmd: str = "write startup-configuration",
confirm: bool = False,
Expand All @@ -116,7 +116,7 @@ def save_config(

return save_config_result

def check_linux_mode(self, check_string: str = "]#", pattern: str = "#") -> bool:
def _check_linux_mode(self, check_string: str = "]#", pattern: str = "#") -> bool:
"""Checks if the device is in Linux mode or not.
:param check_string: Identification of configuration mode from the device
Expand All @@ -127,33 +127,33 @@ def check_linux_mode(self, check_string: str = "]#", pattern: str = "#") -> bool
output = self.read_until_prompt(read_entire_line=True)
return check_string in output

def linux_mode(self, linux_command: str = "linux-shell", pattern: str = "") -> str:
def _linux_mode(self, linux_command: str = "linux-shell", pattern: str = "") -> str:
"""Enter into Linux mode.
:param config_command: Linux command to send to the device
:param pattern: Pattern to terminate reading of channel
"""
output = ""
if not self.check_linux_mode():
if not self._check_linux_mode():
self.write_channel(self.normalize_cmd(linux_command))
output = self.read_until_pattern(pattern=pattern)
if not self.check_linux_mode():
if not self._check_linux_mode():
raise ValueError("Failed to enter Linux mode.")
return output

def exit_linux_mode(self, exit_linux: str = "exit", pattern: str = "#") -> str:
def _exit_linux_mode(self, exit_linux: str = "exit", pattern: str = "#") -> str:
"""Exit from Linux mode.
:param exit_config: Command to exit Linux mode
:param pattern: Pattern to terminate reading of channel
"""
output = ""
if self.check_linux_mode():
if self._check_linux_mode():
self.write_channel(self.normalize_cmd(exit_linux))
output = self.read_until_pattern(pattern=pattern)
if self.check_linux_mode():
if self._check_linux_mode():
raise ValueError("Failed to exit Linux mode")
return output

Expand Down

0 comments on commit 25aa143

Please sign in to comment.