junos

JunOS module.

class homer.transports.junos.ConnectedDevice(fqdn: str, username: str = '')[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) -- the username to use to connect to the Juniper device.

close() → None[source]

Close the connection with the device.

commit(config: str, message: str, callback: Callable, ignore_warning: Union[bool, str, List[str]] = False) → None[source]

Commit the loaded configuration.

Parameters
  • config (str) -- the device new configuration.

  • message (str) -- the commit message to use.

  • callback (callable) -- a callable function that accepts two parameters: a string with the FQDN of the current device and a string with the diff between the current configuration and the new one. The callback must raise any exception if the execution should be interrupted and the config rollbacked or return None.

Raises

HomerError -- when failing to commit the configuration.

commit_check(config: str, ignore_warning: Union[bool, str, List[str]] = False) → Tuple[bool, str][source]

Perform commit check, reuturn the diff and rollback.

Parameters

config (str) -- the device new configuration.

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 or an empty string on failure.

Return type

tuple

homer.transports.junos.connected_device(fqdn: str, username: str = '') → Iterator[ConnectedDevice][source]

Context manager to perform actions on a connected Juniper device.

Parameters
  • fqdn (str) -- the FQDN of the Juniper device.

  • username (str) -- the username to use to connect to the Juniper device.

Yields

ConnectedDevice -- the Juniper connected device instance.