junos
JunOS module.
- class homer.transports.junos.ConnectedDevice(fqdn: str, *, username: str = '', ssh_config: str | None = None, port: int = 22, timeout: int = 30)[source]
Bases:
objectJuniper transport to manage a JunOS connected device.
Initialize the instance and open the connection to the device.
- Parameters:
fqdn (
str) -- the FQDN of the Juniper device.username (
str, default:'') -- the username to use to connect to the Juniper device.ssh_config (
typing.Optional[str], default:None) -- an ssh_config file if you want other than ~/.ssh/configport (
int, default:22) -- the port to use to connect to the device.timeout (
int, default:30) -- the timeout in seconds to use when operating on the device.
- commit(config: homer.templates.DeviceConfigurationBase, message: str, *, ignore_warning: bool | str | list[str] = False, is_retry: bool = False) None[source]
Commit the loaded configuration.
- Parameters:
config (
homer.templates.DeviceConfigurationBase) -- the device new configuration.message (
str) -- the commit message to use.ignore_warning (
typing.Union[bool,str,list[str]], default:False) -- the warnings to tell JunOS to ignore, see below docs https://junos-pyez.readthedocs.io/en/2.3.0/jnpr.junos.utils.html#jnpr.junos.utils.config.Config.load also note the comments in the pyez decorators.py, substring match is default, regex is also possibleis_retry (
bool, default:False) -- whether this is a retry and the commit_check should be run anyway, also if the diff is empty.
- Raises:
homer.exceptions.HomerTimeoutError -- on timeout.
homer.exceptions.HomerError -- on commit error.
Exception -- on generic failure.
- Return type:
- commit_check(config: homer.templates.DeviceConfigurationBase, ignore_warning: bool | str | list[str] = False) Tuple[bool, str | None][source]
Perform commit check, return the diff and rollback.
- Parameters:
config (
homer.templates.DeviceConfigurationBase) -- the device new configuration.- Return type:
- Returns:
A two-element tuple with a boolean as first item that is
Trueon success andFalseon failure and a string as second item with the difference between the current configuration and the new one, empty string on no diff andNoneon failure.
- homer.transports.junos.connected_device(fqdn: str, *, username: str = '', ssh_config: str | None = None, port: int = 22, timeout: int = 30) Iterator[homer.transports.junos.ConnectedDevice][source]
Context manager to perform actions on a connected Juniper device.
- Parameters:
fqdn (
str) -- the FQDN of the Juniper device.username (
str, default:'') -- the username to use to connect to the Juniper device.ssh_config (
typing.Optional[str], default:None) -- an ssh_config file if you want other than ~/.ssh/configport (
int, default:22) -- the port to use to connect to the device.timeout (
int, default:30) -- the timeout in seconds to use when operating on the device.
- Yields:
The Juniper connected device instance.
- Return type: