Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.

13. Execution modules for Junos

Khelil Sator edited this page Jun 27, 2017 · 5 revisions

Documentation:

https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.junos.html

Examples:

junos.cli

# salt "vq*" junos.cli -d
junos.cli:

    Executes the CLI commands and returns the output in specified format.     (default is text) The ouput can also be stored in a file.

    Usage:

        salt 'device_name' junos.cli 'show system commit'

        salt 'device_name' junos.cli 'show version' dev_timeout=40

        salt 'device_name' junos.cli 'show system alarms' 'xml' dest=/home/user/cli_output.txt


    Parameters:
      Required
        * command:
          The command that need to be executed on Junos CLI. (default = None)
      Optional
        * format:
          Format in which to get the CLI output. (text or xml,             default = 'text')
        * kwargs: Keyworded arguments which can be provided like-
            * dev_timeout:
              Set NETCONF RPC timeout. Can be used for commands which
              take a while to execute. (default = 30 seconds)
            * dest:
              The destination file where the CLI output can be stored.               (default = None)
# salt "vq*" junos.cli "show version"
vqfx01:
    ----------
    message:
        
        fpc0:
        --------------------------------------------------------------------------
        Hostname: vqfx01
        Model: vqfx-10000
        Junos: 15.1X53-D63.9
        JUNOS Base OS boot [15.1X53-D63.9]
        JUNOS Base OS Software Suite [15.1X53-D63.9]
        JUNOS Online Documentation [15.1X53-D63.9]
        JUNOS Crypto Software Suite [15.1X53-D63.9]
        JUNOS Packet Forwarding Engine Support (qfx-10-f) [15.1X53-D63.9]
        JUNOS Kernel Software Suite [15.1X53-D63.9]
        JUNOS Web Management [15.1X53-D63.9]
        JUNOS Enterprise Software Suite [15.1X53-D63.9]
        JUNOS SDN Software Suite [15.1X53-D63.9]
        JUNOS Routing Software Suite [15.1X53-D63.9]
        JUNOS py-base-i386 [15.1X53-D63.9]
    out:
        True

junos.rpc

# salt "vq*" junos.rpc get-software-information
vqfx01:
    ----------
    out:
        True
    rpc_reply:
        ----------
        multi-routing-engine-results:
            ----------
            multi-routing-engine-item:
                ----------
                re-name:
                    fpc0
                software-information:
                    ----------
                    host-name:
                        vqfx01
                    junos-version:
                        15.1X53-D63.9
                    package-information:
                        |_
                          ----------
                          comment:
                              JUNOS Base OS boot [15.1X53-D63.9]
                          name:
                              junos
                        |_
                          ----------
                          comment:
                              JUNOS Base OS Software Suite [15.1X53-D63.9]
                          name:
                              jbase
                        |_
                          ----------
                          comment:
                              JUNOS Online Documentation [15.1X53-D63.9]
                          name:
                              jdocs
                        |_
                          ----------
                          comment:
                              JUNOS Crypto Software Suite [15.1X53-D63.9]
                          name:
                              jcrypto
                        |_
                          ----------
                          comment:
                              JUNOS Packet Forwarding Engine Support (qfx-10-f) [15.1X53-D63.9]
                          name:
                              jpfe
                        |_
                          ----------
                          comment:
                              JUNOS Kernel Software Suite [15.1X53-D63.9]
                          name:
                              jkernel
                        |_
                          ----------
                          comment:
                              JUNOS Web Management [15.1X53-D63.9]
                          name:
                              jweb
                        |_
                          ----------
                          comment:
                              JUNOS Enterprise Software Suite [15.1X53-D63.9]
                          name:
                              jswitch
                        |_
                          ----------
                          comment:
                              JUNOS SDN Software Suite [15.1X53-D63.9]
                          name:
                              jsdn-i386
                        |_
                          ----------
                          comment:
                              JUNOS Routing Software Suite [15.1X53-D63.9]
                          name:
                              jroute
                        |_
                          ----------
                          comment:
                              JUNOS py-base-i386 [15.1X53-D63.9]
                          name:
                              py-base-i386
                    product-model:
                        vqfx-10000
                    product-name:
                        vqfx-10000
# salt "vq*" junos.rpc get-software-information "" 'text'
vqfx01:
    ----------
    out:
        True
    rpc_reply:
        
        fpc0:
        --------------------------------------------------------------------------
        Hostname: vqfx01
        Model: vqfx-10000
        Junos: 15.1X53-D63.9
        JUNOS Base OS boot [15.1X53-D63.9]
        JUNOS Base OS Software Suite [15.1X53-D63.9]
        JUNOS Online Documentation [15.1X53-D63.9]
        JUNOS Crypto Software Suite [15.1X53-D63.9]
        JUNOS Packet Forwarding Engine Support (qfx-10-f) [15.1X53-D63.9]
        JUNOS Kernel Software Suite [15.1X53-D63.9]
        JUNOS Web Management [15.1X53-D63.9]
        JUNOS Enterprise Software Suite [15.1X53-D63.9]
        JUNOS SDN Software Suite [15.1X53-D63.9]
        JUNOS Routing Software Suite [15.1X53-D63.9]
        JUNOS py-base-i386 [15.1X53-D63.9]
# salt "vq*" junos.rpc get-software-information "file1" 'text'
vqfx01:
    ----------
    out:
        True
    rpc_reply:
        
        fpc0:
        --------------------------------------------------------------------------
        Hostname: vqfx01
        Model: vqfx-10000
        Junos: 15.1X53-D63.9
        JUNOS Base OS boot [15.1X53-D63.9]
        JUNOS Base OS Software Suite [15.1X53-D63.9]
        JUNOS Online Documentation [15.1X53-D63.9]
        JUNOS Crypto Software Suite [15.1X53-D63.9]
        JUNOS Packet Forwarding Engine Support (qfx-10-f) [15.1X53-D63.9]
        JUNOS Kernel Software Suite [15.1X53-D63.9]
        JUNOS Web Management [15.1X53-D63.9]
        JUNOS Enterprise Software Suite [15.1X53-D63.9]
        JUNOS SDN Software Suite [15.1X53-D63.9]
        JUNOS Routing Software Suite [15.1X53-D63.9]
        JUNOS py-base-i386 [15.1X53-D63.9]

# more file1 

fpc0:
--------------------------------------------------------------------------
Hostname: vqfx01
Model: vqfx-10000
Junos: 15.1X53-D63.9
JUNOS Base OS boot [15.1X53-D63.9]
JUNOS Base OS Software Suite [15.1X53-D63.9]
JUNOS Online Documentation [15.1X53-D63.9]
JUNOS Crypto Software Suite [15.1X53-D63.9]
JUNOS Packet Forwarding Engine Support (qfx-10-f) [15.1X53-D63.9]
JUNOS Kernel Software Suite [15.1X53-D63.9]
JUNOS Web Management [15.1X53-D63.9]
JUNOS Enterprise Software Suite [15.1X53-D63.9]
JUNOS SDN Software Suite [15.1X53-D63.9]
JUNOS Routing Software Suite [15.1X53-D63.9]
JUNOS py-base-i386 [15.1X53-D63.9]
# salt "vq*" junos.rpc 'get-interface-information' '/home/ksator/interface.log' 'text' interface_name='lo0' terse=True
vqfx01:
    ----------
    out:
        True
    rpc_reply:
        
        Interface               Admin Link Proto    Local                 Remote
        lo0                     up    up
        lo0.0                   up    up   inet    
                                           inet6    fe80::200:f:fc00:0
        lo0.16385               up    up   inet    

# more interface.log 

Interface               Admin Link Proto    Local                 Remote
lo0                     up    up
lo0.0                   up    up   inet    
                                   inet6    fe80::200:f:fc00:0
lo0.16385               up    up   inet    
# salt "vq*" junos.rpc 'get_config' '' 'text' filter='<configuration><system/></configuration>'