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: object

Juniper 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/config

  • port (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.

close() None[source]

Close the connection with the device.

Return type:

None

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:
Raises:
Return type:

None

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:

typing.Tuple[bool, typing.Optional[str]]

Returns:

A two-element tuple with a boolean as first item that is True on success and False on failure and a string as second item with the difference between the current configuration and the new one, empty string on no diff and None on 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/config

  • port (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:

typing.Iterator[homer.transports.junos.ConnectedDevice]