salt.modules.junos

Module for interfacing to Junos devices.

salt.modules.junos.cli(command=None)

Executes the CLI commands and reuturns the text output.

Usage:

salt 'device_name' junos.cli 'show version'
Options:
  • command: The command that need to be executed on Junos CLI.
salt.modules.junos.commit()

To commit the changes loaded in the candidate configuration.

Usage:

salt 'device_name' junos.commit
salt.modules.junos.diff()

Gives the difference between the candidate and the current configuration.

Usage:

salt 'device_name' junos.diff
salt.modules.junos.facts()

Displays the facts gathered during the connection.

Usage:

salt 'device_name' junos.facts
salt.modules.junos.facts_refresh()

Reload the facts dictionary from the device. Usually only needed if the device configuration is changed by some other actor.

Usage:

salt 'device_name' junos.facts_refresh
salt.modules.junos.file_copy(src=None, dest=None)

Copies the file from the local device to the junos device.

Usage:

salt 'device_name' junos.file_copy /home/m2/info.txt info_copy.txt
Options
  • src: The sorce path where the file is kept.
  • dest: The destination path where the file will be copied.
salt.modules.junos.install_config(path=None, **kwargs)

Installs the given configuration file into the candidate configuration. Commits the changes if the commit checks or throws an error.

Usage:

salt 'device_name' junos.install_config '/home/user/config.set' timeout=300
Options:
  • path: Path where the configuration file is present.
  • kwargs: keyworded arguments taken by load fucntion of PyEZ
salt.modules.junos.install_os(path=None, **kwargs)

Installs the given image on the device. After the installation is complete the device is rebooted, if reboot=True is given as a keyworded argument.

Usage:

salt 'device_name' junos.install_os '/home/user/junos_image.tgz' reboot=True
Options
  • path: Path where the image file is present.
  • kwargs: keyworded arguments to be given such as timeout, reboot etc
salt.modules.junos.ping()

To check the connection with the device

Usage:

salt 'device_name' junos.ping
salt.modules.junos.rollback()

To rollback the last committed configuration changes

Usage:

salt 'device_name' junos.rollback
salt.modules.junos.rpc(cmd=None, dest=None, format='xml', *args, **kwargs)

This function executes the rpc provided as arguments on the junos device. The returned data can be stored in a file whose destination can be specified with 'dest' keyword in the arguments.

Usage:

salt 'device' junos.rpc 'get_config' 'text' filter='<configuration><system/></configuration>'

salt 'device' junos.rpc 'get-interface-information' '/home/user/interface.log' interface_name='lo0' terse=True
Options:
  • cmd: the rpc to be executed
  • dest: destination file where the rpc ouput is dumped
  • format: the format in which the rpc reply must be stored in file specified in the dest (used only when dest is specified)
  • args: other arguments as taken by rpc call of PyEZ
  • kwargs: keyworded arguments taken by rpc call of PyEZ
salt.modules.junos.set_hostname(hostname=None, commit_change=True)

To set the name of the device.

Usage:

salt 'device_name' junos.set_hostname hostname=salt-device
Options:
  • hostname: The name to be set.
  • commit_change: Whether to commit the changes.(default=True)
salt.modules.junos.shutdown(time=0)

Shuts down the device after the given time.

Usage:

salt 'device_name' junos.shutdown 10
Options:
  • time: Time in seconds after which the device should shutdown (default=0)
salt.modules.junos.zeroize()

Resets the device to default factory settings

Usage:

salt 'device_name' junos.zeroize