junos

JunOS module.

class homer.transports.junos.ConnectedDevice(fqdn: 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.

close() → None[source]

Close the connection with the device.

commit(config: str, callback: Callable) → None[source]

Commit the loaded configuration.

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

  • 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) → 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) → Iterator[ConnectedDevice][source]

Context manager to perform actions on a connected Juniper device.

Parameters

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

Yields

ConnectedDevice -- the Juniper connected device instance.