junos

package module
v0.0.0-...-77be6f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 13 Imported by: 0

README

go-junos

A Go package that interacts with Junos devices, and allows you to do the following:

  • Run operational mode commands, such as show, request, etc..
  • Compare the active configuration to a rollback configuration (diff).
  • Rollback the configuration to a given state or a "rescue" config.
  • Configure devices by submitting commands, uploading a local file or from a remote FTP/HTTP server.
  • Commit operations: lock, unlock, commit, commit at, commit confirmed, commit full.
  • Device views - This will allow you to quickly get all the information on the device for the specified view.
  • [SRX] Convert from a zone-based address book to a global one.

Installation

go get -u github.com/adammmmm/go-junos

Note: This package makes all of it's calls using netconf over ssh using the netconf package from nemith. Please make sure you allow Netconf communication to your devices:

set system services netconf ssh
set security zones security-zone <xxx> interfaces <xxx> host-inbound-traffic system-services netconf

Authentication Methods

There are two different ways you can authenticate against to device. Standard username/password combination, or use SSH keys. There is an AuthMethod struct which defines these methods that you will need to use in your code. Here is an example of connecting to a device using only a username and password.

auth := &junos.AuthMethod{
    Credentials: []string{"scott", "deathstar"},
}

jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
    fmt.Println(err)
}

If you are using SSH keys, here is an example of how to connect:

auth := &junos.AuthMethod{
    Username:   "scott",
    PrivateKey: "/home/scott/.ssh/id_rsa",
    Passphrase: "mysecret",
}

jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
    fmt.Println(err)
}

If you do not have a passphrase tied to your private key, then you can omit the Passphrase field entirely. In the above example, we are connecting from a *nix/Mac device, as shown by the private key path. No matter the OS, as long as you provide the location of the private key file, you should be fine.

If you are running Windows, and using PuTTY for all your SSH needs, then you will need to generate a public/private key pair by using Puttygen. Once you have generated it, you will need to export your private key using the OpenSSH format, and save it somewhere as shown below:

alt-text

Examples

j-cli is one example for how to use it.

Connect to a device, and view the current config to rollback 1.

auth := &junos.AuthMethod{
    Credentials: []string{"admin", "Juniper123!"},
}

jnpr, err := junos.NewSession("qfx-switch.company.com", auth)
if err != nil {
    fmt.Println(err)
}

defer jnpr.Close()

diff, err := jnpr.Diff(1)
if err != nil {
    fmt.Println(err)
}

fmt.Println(diff)

// Will output the following

[edit vlans]
-   zzz-Test {
-       vlan-id 999;
-   }
-   zzz-Test2 {
-       vlan-id 1000;
-   }

View the routing-instance configuration.

auth := &junos.AuthMethod{
    Username:   "admin",
    PrivateKey: "/home/scott/.ssh/id_rsa",
}

jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
    fmt.Println(err)
}

defer jnpr.Close()

riConfig, err := jnpr.GetConfig("text", "routing-instances")
if err != nil {
    fmt.Println(err)
}

fmt.Println(riConfig)

// Will output the following

## Last changed: 2017-03-24 12:26:58 EDT
routing-instances {
    default-ri {
        instance-type virtual-router;
        interface lo0.0;
        interface reth1.0;
        routing-options {
            static {
                route 0.0.0.0/0 next-hop 10.1.1.1;
            }
        }
    }
}

Views

Device views allow you to quickly gather information regarding a specific "view," so that you may use that information however you wish. A good example, is using the "interface" view to gather all of the interface information on the device, then iterate over that view to see statistics, interface settings, etc.

Note: Some of the views aren't available for all platforms, such as the ethernetswitch and virtualchassis on an SRX or MX.

Current out-of-the-box, built-in views are:

Views CLI equivilent
arp show arp
route show route
bgp show bgp summary
interface show interfaces
vlan show vlans
ethernetswitch show ethernet-switching table
inventory show chassis hardware
virtualchassis show virtual-chassis status
staticnat show security nat static rule all
sourcenat show security nat source rule all
storage show system storage
firewallpolicy show security policies (SRX only)
lldp show lldp neighbors
environment show chassis environment
ike show ike security-associations
ipsec show ipsec security-associations
ospfneighbor show ospf neighbor
ospfdatabase show ospf database
lsp show mpls lsp

NOTE: Clustered SRX's will only show the NAT rules from one of the nodes, since they are duplicated on the other.

When using the interface view, by default it will return all of the interfaces on the device. If you wish to see only a particular interface and all of it's logical interfaces, you can optionally specify the name of an interface using the option parameter, e.g.:

jnpr.View("interface", "ge-0/0/0")

The lsp view has a similar option to choose ingress, egress or transit, e.g.:

jnpr.View("lsp", "ingress")

Creating Custom Views

You can even create a custom view by creating a struct that models the XML output from using the GetConfig() function. Granted, this is a little more work, and requires you to know a bit more about the Go language (such as unmarshalling XML), but if there's a custom view that you want to see, it's possible to do this for anything you want.

Example: View the ARP table on a device

view, err := jnpr.View("arp")
if err != nil {
    fmt.Println(err)
}

fmt.Printf("# ARP entries: %d\n\n", view.Arp.Count)
for _, a := range view.Arp.Entries {
    fmt.Printf("MAC: %s\n", a.MACAddress)
    fmt.Printf("IP: %s\n", a.IPAddress)
    fmt.Printf("Interface: %s\n\n", a.Interface)
}

// Will print out the following

# ARP entries: 4

MAC: 00:01:ab:cd:4d:73
IP: 10.1.1.28
Interface: reth0.1

MAC: 00:01:ab:cd:0a:93
IP: 10.1.1.30
Interface: reth0.1

MAC: 00:01:ab:cd:4f:8c
IP: 10.1.1.33
Interface: reth0.1

MAC: 00:01:ab:cd:f8:30
IP: 10.1.1.36
Interface: reth0.1

There's also a String() function on the *View which will try to print it pretty well:

output, err := jnpr.View("arp")
if err != nil {
    fmt.Println(err)
}
fmt.Println(output)

// Will print this

arp-entry-count: 4
arp-table-entry:
  - mac-address: 00:01:ab:cd:4d:73
    ip-address: 10.1.1.28
    interface-name: reth0.1
  - mac-address: 00:01:ab:cd:4d:74
    ip-address: 10.1.1.30
    interface-name: reth0.1
  - mac-address: 00:01:ab:cd:4e:73
    ip-address: 10.1.1.33
    interface-name: reth0.1
  - mac-address: 00:01:ab:cd:4f:73
    ip-address: 10.1.1.36
    interface-name: reth0.1
  - mac-address: 00:01:ab:cd:4f:74
    ip-address: 10.1.1.39
    interface-name: reth0.1

Documentation

Overview

Package junos provides automation for Junos (Juniper Networks) devices, as well as interaction with Junos Space.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressEntry

type AddressEntry struct {
	Name     string `xml:"name"`
	IP       string `xml:"ip-prefix,omitempty"`
	DNSName  string `xml:"dns-name>name,omitempty"`
	Wildcard string `xml:"wildcard-address>name,omitempty"`
}

AddressEntry contains information about each individual address-book entry.

type AddressFamily

type AddressFamily struct {
	Name               TrimmedString `xml:"address-family-name"`
	AggregatedEthernet TrimmedString `xml:"ae-bundle-name,omitempty"`
	CIDR               TrimmedString `xml:"interface-address>ifa-destination"`
	IPAddress          TrimmedString `xml:"interface-address>ifa-local"`
	MTU                TrimmedString `xml:"mtu"`
}

type AddressSet

type AddressSet struct {
	Name           string         `xml:"name"`
	AddressEntries []AddressEntry `xml:"address"`
}

AddressSet contains all of the address-sets (groups) in the address-book.

type ArpEntry

type ArpEntry struct {
	MACAddress TrimmedString `xml:"mac-address"`
	IPAddress  TrimmedString `xml:"ip-address"`
	Interface  TrimmedString `xml:"interface-name"`
}

ArpEntry holds each individual ARP entry.

type ArpTable

type ArpTable struct {
	Count   int        `xml:"arp-entry-count"`
	Entries []ArpEntry `xml:"arp-table-entry"`
}

ArpTable contains the ARP table on the device.

type AuthMethod

type AuthMethod struct {
	Credentials []string
	Username    string
	PrivateKey  string
	Passphrase  string
}

AuthMethod defines how we want to authenticate to the device. If using a username and password to authenticate, the Credentials field must be populated like so:

[]string{"user", "password"}

If you are using an SSH prviate key for authentication, you must provide the username, path to the private key, and passphrase. On most systems, the private key is found in the following location:

~/.ssh/id_rsa

If you do not have a passphrase tied to your private key, then you can omit this field.

type BGPPeer

type BGPPeer struct {
	Address            TrimmedString `xml:"peer-address"`
	ASN                int           `xml:"peer-as"`
	InputMessages      int           `xml:"input-messages"`
	OutputMessages     int           `xml:"output-messages"`
	QueuedRoutes       int           `xml:"route-queue-count"`
	Flaps              int           `xml:"flap-count"`
	ElapsedTime        TrimmedString `xml:"elapsed-time"`
	State              TrimmedString `xml:"peer-state"`
	RoutingTable       TrimmedString `xml:"bgp-rib>name"`
	ActivePrefixes     int           `xml:"bgp-rib>active-prefix-count"`
	ReceivedPrefixes   int           `xml:"bgp-rib>received-prefix-count"`
	AcceptedPrefixes   int           `xml:"bgp-rib>accepted-prefix-count"`
	SuppressedPrefixes int           `xml:"bgp-rib>suppressed-prefix-count"`
}

BGPPeer contains information about each individual BGP peer.

type BGPTable

type BGPTable struct {
	TotalGroups int       `xml:"group-count"`
	TotalPeers  int       `xml:"peer-count"`
	DownPeers   int       `xml:"down-peer-count"`
	Entries     []BGPPeer `xml:"bgp-peer"`
}

BGPTable contains information about every BGP peer configured on the device.

type Chassis

type Chassis struct {
	Name         TrimmedString `xml:"name"`
	SerialNumber TrimmedString `xml:"serial-number"`
	Description  TrimmedString `xml:"description"`
	Modules      []Module      `xml:"chassis-module"`
}

Chassis contains all of the hardware information for each chassis, such as a clustered pair of SRX's or a virtual-chassis configuration.

type CommitEntry

type CommitEntry struct {
	Sequence  int    `xml:"sequence-number"`
	User      string `xml:"user"`
	Method    string `xml:"client"`
	Log       string `xml:"log"`
	Comment   string `xml:"comment"`
	Timestamp string `xml:"date-time"`
}

CommitEntry holds information about each prevous commit.

type CommitHistory

type CommitHistory struct {
	Entries []CommitEntry `xml:"commit-history"`
}

CommitHistory holds all of the commit entries.

func (CommitHistory) String

func (c CommitHistory) String() string

type EnvironmentItem

type EnvironmentItem struct {
	Name        TrimmedString `xml:"name"`
	Class       TrimmedString `xml:"class"`
	Status      TrimmedString `xml:"status"`
	Temperature TrimmedString `xml:"temperature"`
}

type EnvironmentTable

type EnvironmentTable struct {
	EnvironmentItems []EnvironmentItem `xml:"environment-item"`
}

type EthernetSwitchingTable

type EthernetSwitchingTable struct {
	Entries []L2MACEntry `xml:"l2ng-l2ald-mac-entry-vlan"`
}

EthernetSwitchingTable contains the ethernet-switching table on the device.

type FileSystem

type FileSystem struct {
	Name            TrimmedString `xml:"filesystem-name"`
	TotalBlocks     int           `xml:"total-blocks"`
	UsedBlocks      int           `xml:"used-blocks"`
	AvailableBlocks int           `xml:"available-blocks"`
	UsedPercent     TrimmedString `xml:"used-percent"`
	MountedOn       TrimmedString `xml:"mounted-on"`
}

FileSystem contains the information for each partition.

type FirewallPolicy

type FirewallPolicy struct {
	XMLName xml.Name          `xml:"security-policies"`
	Entries []SecurityContext `xml:"security-context"`
}

FirewallPolicy contains the entire firewall policy for the device.

type HardwareInventory

type HardwareInventory struct {
	Chassis []Chassis `xml:"chassis"`
}

HardwareInventory contains all the hardware information about the device.

type IKESAs

type IKESAs struct {
	IKESecurityAssociations []IKESecurityAssociation `xml:"ike-security-associations"`
}

get-ike-security-associations-information

type IKESecurityAssociation

type IKESecurityAssociation struct {
	IKESARemoteAddress   TrimmedString `xml:"ike-sa-remote-address"`
	IKESAIndex           int           `xml:"ike-sa-index"`
	IKESAState           TrimmedString `xml:"ike-sa-state"`
	IKESAInitiatorCookie TrimmedString `xml:"ike-sa-initiator-cookie"`
	IKESAResponderCookie TrimmedString `xml:"ike-sa-responder-cookie"`
	IKESAExchangeType    TrimmedString `xml:"ike-sa-exchange-type"`
}

type IPSecSABlock

type IPSecSABlock struct {
	SABlockState              TrimmedString              `xml:"sa-block-state"`
	IPSecSecurityAssociations []IPSecSecurityAssociation `xml:"ipsec-security-associations"`
}

type IPSecSAs

type IPSecSAs struct {
	TotalActiveTunnels             int          `xml:"total-active-tunnels"`
	TotalIPSecSAs                  int          `xml:"total-ipsec-sas"`
	IPSecSecurityAssociationsBlock IPSecSABlock `xml:"ipsec-security-associations-block"`
}

get-security-associations-information

type IPSecSecurityAssociation

type IPSecSecurityAssociation struct {
	SADirection             TrimmedString `xml:"sa-direction"`
	SATunnelIndex           int           `xml:"sa-tunnel-index"`
	SASPI                   TrimmedString `xml:"sa-spi"`
	SAAUXSPI                TrimmedString `xml:"sa-aux-spi"`
	SARemoteGateway         TrimmedString `xml:"sa-remote-gateway"`
	SAPort                  int           `xml:"sa-port"`
	SAVPNMonitoringState    TrimmedString `xml:"sa-vpn-monitoring-state"`
	SAProtocol              TrimmedString `xml:"sa-protocol"`
	SAESPEncryptionProtocol TrimmedString `xml:"sa-esp-encryption-protocol"`
	SAHMACAlgorithm         TrimmedString `xml:"sa-hmac-algorithm"`
	SAHardLifetime          int           `xml:"sa-hard-lifetime"`
	SALifesizeRemaining     TrimmedString `xml:"sa-lifesize-remaining"`
	SAVirtualSystem         TrimmedString `xml:"sa-virtual-system"`
}

type ISISDatabaseEntry

type ISISDatabaseEntry struct {
	LSPID             TrimmedString `xml:"lsp-id"`
	SequenceNumber    TrimmedString `xml:"sequence-number"`
	Checksum          TrimmedString `xml:"checksum"`
	RemainingLifetime int           `xml:"remaining-lifetime"`
	LSPAttributes     TrimmedString `xml:"lsp-attributes"`
}

type ISISDatabaseTable

type ISISDatabaseTable struct {
	Level               int                 `xml:"level"`
	LSPCount            int                 `xml:"lsp-count"`
	ISISDatabaseEntries []ISISDatabaseEntry `xml:"isis-database-entry"`
}

get-isis-database-information

type Interfaces

type Interfaces struct {
	Entries []PhysicalInterface `xml:"physical-interface"`
}

Interfaces contains information about every interface on the device.

type Junos

type Junos struct {
	Session        *netconf.Session
	Hostname       string
	RoutingEngines int
	Platform       []RoutingEngine
	CommitTimeout  time.Duration
}

Junos contains our session state.

func NewSession

func NewSession(host string, auth *AuthMethod) (*Junos, error)

NewSession establishes a new connection to a Junos device that we will use to run our commands against. Authentication methods are defined using the AuthMethod struct, and are as follows:

username and password, SSH private key (with or without passphrase)

Please view the package documentation for AuthMethod on how to use these methods.

NOTE: most users should use this function, instead of the other NewSession* functions

func NewSessionFromNetconf

func NewSessionFromNetconf(s *netconf.Session) (*Junos, error)

NewSessionFromNetconf uses an existing netconf.Session to run our commands against

This is especially useful if you need to customize the SSH connection beyond what's supported in NewSession().

func NewSessionWithConfig

func NewSessionWithConfig(host string, clientConfig *ssh.ClientConfig) (*Junos, error)

NewSessionWithConfig establishes a new connection to a Junos device that we will use to run our commands against.

This is especially useful if you need to customize the SSH connection beyond what's supported in NewSession().

func (*Junos) Close

func (j *Junos) Close() error

func (*Junos) Command

func (j *Junos) Command(cmd string, format ...string) (string, error)

Command executes any operational mode command, such as "show" or "request". If you wish to return the results of the command, specify the format, which must be "text" or "xml" as the second parameter (optional).

func (*Junos) CommandText

func (j *Junos) CommandText(cmd string) (string, error)

func (*Junos) Commit

func (j *Junos) Commit() error

Commit commits the configuration.

func (*Junos) CommitAt

func (j *Junos) CommitAt(timeStr string, message ...string) error

func (*Junos) CommitCheck

func (j *Junos) CommitCheck() error

func (*Junos) CommitConfirm

func (j *Junos) CommitConfirm(delay int) error

func (*Junos) CommitFull

func (j *Junos) CommitFull() error

CommitFull does a full commit on the configuration, which requires all daemons to check and evaluate the new configuration. Useful for when you get an error with a commit or when you've changed the configuration significantly.

func (*Junos) CommitHistory

func (j *Junos) CommitHistory() (*CommitHistory, error)

CommitHistory gathers all the information about the previous 5 commits.

func (*Junos) Config

func (j *Junos) Config(path interface{}, format string, commit bool) error

Config loads a given configuration file from your local machine, a remote (FTP or HTTP server) location, or via configuration statements from variables (type string or []string) within your script. Format must be "set", "text" or "xml".

func (*Junos) ConvertAddressBook

func (j *Junos) ConvertAddressBook() []string

ConvertAddressBook will generate the configuration needed to migrate from a zone-based address book to a global one. You can then use Config() to apply the changes if necessary.

func (*Junos) Diff

func (j *Junos) Diff(rollback int) (string, error)

Diff compares candidate config to current (rollback 0) or previous rollback. This is equivalent to 'show | compare' or 'show | compare rollback X' when in configuration mode.

func (*Junos) GatherFacts

func (j *Junos) GatherFacts() error

func (*Junos) GetConfig

func (j *Junos) GetConfig(format string, section ...string) (string, error)

GetConfig returns the configuration starting at the given section. If section is omitted, the entire configuration is returned. Format must be "text" or "xml".

func (*Junos) HasPendingChanges

func (j *Junos) HasPendingChanges() (bool, error)

HasPendingChanges reports whether there are uncommitted candidate configuration changes.

func (*Junos) Lock

func (j *Junos) Lock() error

func (*Junos) RPC

func (j *Junos) RPC(rpc string) (string, error)

RPC executes an arbitrary NETCONF RPC against the device.

func (*Junos) Reboot

func (j *Junos) Reboot() error

Reboot will reboot the device.

func (*Junos) Rescue

func (j *Junos) Rescue(action string) error

Rescue will create or delete the rescue configuration given "save" or "delete" for the action.

func (*Junos) Rollback

func (j *Junos) Rollback(option interface{}) error

Rollback loads and commits the configuration of a given rollback number or rescue state, by specifying "rescue".

func (*Junos) SetCommitTimeout

func (j *Junos) SetCommitTimeout(delay int)

SetCommitTimeout will add the given delay time (in seconds) to the following commit functions: Lock(), Commit() and Unlock(). When configuring multiple devices, or having a large configuration to push, this can greatly reduce errors (especially if you're dealing with latency).

func (*Junos) Unlock

func (j *Junos) Unlock() error

func (*Junos) View

func (j *Junos) View(view string, option ...string) (*Views, error)

type L2MACEntry

type L2MACEntry struct {
	GlobalMACCount  int           `xml:"mac-count-global"`
	LearnedMACCount int           `xml:"learnt-mac-count"`
	RoutingInstance TrimmedString `xml:"l2ng-l2-mac-routing-instance"`
	VlanID          int           `xml:"l2ng-l2-vlan-id"`
	MACEntries      []MACEntry    `xml:"l2ng-mac-entry"`
}

L2MACEntry contains information about every MAC address on each VLAN.

type LLDPNeighbor

type LLDPNeighbor struct {
	LocalPortId              TrimmedString `xml:"lldp-local-port-id"`
	LocalParentInterfaceName TrimmedString `xml:"lldp-local-parent-interface-name"`
	RemoteChassisIdSubtype   TrimmedString `xml:"lldp-remote-chassis-id-subtype"`
	RemoteChassisId          TrimmedString `xml:"lldp-remote-chassis-id"`
	RemotePortDescription    TrimmedString `xml:"lldp-remote-port-description"`
	RemotePortId             TrimmedString `xml:"lldp-remote-port-id"`
	RemoteSystemName         TrimmedString `xml:"lldp-remote-system-name"`
}

type LLDPNeighbors

type LLDPNeighbors struct {
	Entries []LLDPNeighbor `xml:"lldp-neighbor-information"`
}

type LogicalInterface

type LogicalInterface struct {
	Name             TrimmedString   `xml:"name"`
	LocalIndex       int             `xml:"local-index"`
	SNMPIndex        int             `xml:"snmp-index"`
	Encapsulation    TrimmedString   `xml:"encapsulation"`
	LAGInputPackets  uint64          `xml:"lag-traffic-statistics>lag-bundle>input-packets"`
	LAGInputPps      int             `xml:"lag-traffic-statistics>lag-bundle>input-pps"`
	LAGInputBytes    int             `xml:"lag-traffic-statistics>lag-bundle>input-bytes"`
	LAGInputBps      int             `xml:"lag-traffic-statistics>lag-bundle>input-bps"`
	LAGOutputPackets uint64          `xml:"lag-traffic-statistics>lag-bundle>output-packets"`
	LAGOutputPps     int             `xml:"lag-traffic-statistics>lag-bundle>output-pps"`
	LAGOutputBytes   int             `xml:"lag-traffic-statistics>lag-bundle>output-bytes"`
	LAGOutputBps     int             `xml:"lag-traffic-statistics>lag-bundle>output-bps"`
	ZoneName         TrimmedString   `xml:"logical-interface-zone-name"`
	InputPackets     uint64          `xml:"traffic-statistics>input-packets"`
	OutputPackets    uint64          `xml:"traffic-statistics>output-packets"`
	AddressFamilies  []AddressFamily `xml:"address-family"`
	LinkAddress      TrimmedString   `xml:"link-address,omitempty"`
}

LogicalInterface contains information about the logical interfaces tied to a physical interface.

type MACEntry

type MACEntry struct {
	VlanName         TrimmedString `xml:"l2ng-l2-mac-vlan-name"`
	MACAddress       TrimmedString `xml:"l2ng-l2-mac-address"`
	Age              TrimmedString `xml:"l2ng-l2-mac-age"`
	Flags            TrimmedString `xml:"l2ng-l2-mac-flags"`
	LogicalInterface TrimmedString `xml:"l2ng-l2-mac-logical-interface"`
}

MACEntry contains information about each individual MAC address. Flags are: S - static MAC, D - dynamic MAC, L - locally learned, P - persistent static, SE - statistics enabled, NM - non configured MAC, R - remote PE MAC, O - ovsdb MAC.

type MPLSLSPEntry

type MPLSLSPEntry struct {
	DestinationAddress TrimmedString `xml:"destination-address"`
	SourceAddress      TrimmedString `xml:"source-address"`
	LSPState           TrimmedString `xml:"lsp-state"`
	RouteCount         int           `xml:"route-count"`
	ActivePath         TrimmedString `xml:"active-path"`
	IsPrimary          bool          `xml:"is-primary"`
	Name               TrimmedString `xml:"lsp-name"`
	LSPDescription     TrimmedString `xml:"lsp-description"`
}

type MPLSLSPTable

type MPLSLSPTable struct {
	RSVPSessionDataEntry RSVPSessionData `xml:"rsvp-session-data"`
}

type Module

type Module struct {
	Name         TrimmedString `xml:"name"`
	Version      TrimmedString `xml:"version,omitempty"`
	PartNumber   TrimmedString `xml:"part-number"`
	SerialNumber TrimmedString `xml:"serial-number"`
	Description  TrimmedString `xml:"description"`
	CLEICode     TrimmedString `xml:"clei-code"`
	ModuleNumber TrimmedString `xml:"module-number"`
	SubModules   []SubModule   `xml:"chassis-sub-module"`
}

Module contains information about each individual module.

type NetconfOK

type NetconfOK struct {
	XMLName xml.Name `xml:"ok"`
}

type OSPFAreaHeader

type OSPFAreaHeader struct {
	OSPFArea TrimmedString `xml:"ospf-area"`
}

type OSPFDatabaseEntry

type OSPFDatabaseEntry struct {
	LSAType           TrimmedString `xml:"lsa-type"`
	LSAID             TrimmedString `xml:"lsa-id"`
	AdvertisingRouter TrimmedString `xml:"advertising-router"`
	SequenceNumber    TrimmedString `xml:"sequence-number"`
	Age               int           `xml:"age"`
	Options           TrimmedString `xml:"options"`
	Checksum          TrimmedString `xml:"checksum"`
	LSALength         int           `xml:"lsa-length"`
	OurEntry          bool          `xml:"our-entry"`
}

type OSPFDatabaseTable

type OSPFDatabaseTable struct {
	OSPFAreaHeaders     []OSPFAreaHeader    `xml:"ospf-area-header"`
	OSPFDatabaseEntries []OSPFDatabaseEntry `xml:"ospf-database"`
}

type OSPFNeighbor

type OSPFNeighbor struct {
	NeighborAddress   TrimmedString `xml:"neighbor-address"`
	InterfaceName     TrimmedString `xml:"interface-name"`
	OSPFNeighborState TrimmedString `xml:"ospf-neighbor-state"`
	NeighborID        TrimmedString `xml:"neighbor-id"`
	NeighborPriority  int           `xml:"neighbor-priority"`
	ActivityTimer     int           `xml:"activity-timer"`
}

type OSPFNeighborTable

type OSPFNeighborTable struct {
	OSPFNeighbors []OSPFNeighbor `xml:"ospf-neighbor"`
}

type PhysicalInterface

type PhysicalInterface struct {
	Name                    TrimmedString      `xml:"name"`
	AdminStatus             TrimmedString      `xml:"admin-status"`
	OperStatus              TrimmedString      `xml:"oper-status"`
	LocalIndex              int                `xml:"local-index"`
	SNMPIndex               int                `xml:"snmp-index"`
	LinkLevelType           TrimmedString      `xml:"link-level-type"`
	InterfaceType           TrimmedString      `xml:"if-type"`
	MTU                     TrimmedString      `xml:"mtu"`
	LinkMode                TrimmedString      `xml:"link-mode"`
	Speed                   TrimmedString      `xml:"speed"`
	FlowControl             TrimmedString      `xml:"if-flow-control"`
	AutoNegotiation         TrimmedString      `xml:"if-auto-negotiation"`
	HardwarePhysicalAddress TrimmedString      `xml:"hardware-physical-address"`
	Flapped                 TrimmedString      `xml:"interface-flapped"`
	InputBps                int                `xml:"traffic-statistics>input-bps"`
	InputPps                int                `xml:"traffic-statistics>input-pps"`
	OutputBps               int                `xml:"traffic-statistics>output-bps"`
	OutputPps               int                `xml:"traffic-statistics>output-pps"`
	LogicalInterfaces       []LogicalInterface `xml:"logical-interface"`
}

PhysicalInterface contains information about each individual physical interface.

type RSVPSession

type RSVPSession struct {
	MPLSLSP MPLSLSPEntry `xml:"mpls-lsp"`
}

type RSVPSessionData

type RSVPSessionData struct {
	SessionType  TrimmedString `xml:"session-type"`
	Count        int           `xml:"session-count"`
	RSVPSessions []RSVPSession `xml:"rsvp-session"`
	DisplayCount int           `xml:"display-count"`
	UpCount      int           `xml:"up-count"`
	DownCount    int           `xml:"down-count"`
}

type Route

type Route struct {
	Destination           TrimmedString `xml:"rt-destination"`
	Active                TrimmedString `xml:"rt-entry>active-tag"`
	Protocol              TrimmedString `xml:"rt-entry>protocol-name"`
	Preference            int           `xml:"rt-entry>preference"`
	Age                   TrimmedString `xml:"rt-entry>age"`
	NextHop               TrimmedString `xml:"rt-entry>nh>to,omitempty"`
	NextHopInterface      TrimmedString `xml:"rt-entry>nh>via,omitempty"`
	NextHopTable          TrimmedString `xml:"rt-entry>nh>nh-table,omitempty"`
	NextHopLocalInterface TrimmedString `xml:"rt-entry>nh>nh-local-interface,omitempty"`
}

Route holds information about each individual route.

type RouteTable

type RouteTable struct {
	Name           TrimmedString `xml:"table-name"`
	TotalRoutes    int           `xml:"total-route-count"`
	ActiveRoutes   int           `xml:"active-route-count"`
	HolddownRoutes int           `xml:"holddown-route-count"`
	HiddenRoutes   int           `xml:"hidden-routes"`
	Entries        []Route       `xml:"rt"`
}

RouteTable holds all the route information for each table.

type RoutingEngine

type RoutingEngine struct {
	Model   string
	Version string
}

RoutingEngine contains the hardware and software information for each route engine.

type RoutingTable

type RoutingTable struct {
	RouteTables []RouteTable `xml:"route-table"`
}

RoutingTable contains every routing table on the device.

type Rule

type Rule struct {
	Name                 TrimmedString   `xml:"policy-name"`
	State                TrimmedString   `xml:"policy-state"`
	Identifier           int             `xml:"policy-identifier"`
	ScopeIdentifier      int             `xml:"scope-policy-identifier"`
	SequenceNumber       int             `xml:"policy-sequence-number"`
	SourceAddresses      []TrimmedString `xml:"source-addresses>source-address>address-name"`
	DestinationAddresses []TrimmedString `xml:"destination-addresses>destination-address>address-name"`
	Applications         []TrimmedString `xml:"applications>application>application-name"`
	SourceIdentities     []TrimmedString `xml:"source-identities>source-identity>role-name"`
	PolicyAction         TrimmedString   `xml:"policy-action>action-type"`
	PolicyTCPOptions     struct {
		SYNCheck      TrimmedString `xml:"policy-tcp-options-syn-check"`
		SequenceCheck TrimmedString `xml:"policy-tcp-options-sequence-check"`
	} `xml:"policy-action>policy-tcp-options"`
}

Rule contains each individual element that makes up a security policy rule.

type SecurityContext

type SecurityContext struct {
	SourceZone      TrimmedString `xml:"context-information>source-zone-name"`
	DestinationZone TrimmedString `xml:"context-information>destination-zone-name"`
	Rules           []Rule        `xml:"policies>policy-information"`
}

SecurityContext contains the policies for each context, such as rules from trust to untrust zones.

type SecurityZones

type SecurityZones struct {
	XMLName xml.Name `xml:"configuration"`
	Zones   []Zone   `xml:"security>zones>security-zone"`
}

SecurityZones contains all of our security-zone information.

type SourceNatEntry

type SourceNatEntry struct {
	Name                     TrimmedString   `xml:"rule-name"`
	SetName                  TrimmedString   `xml:"rule-set-name"`
	ID                       TrimmedString   `xml:"rule-id"`
	RuleMatchingPosition     int             `xml:"rule-matching-position"`
	FromContext              TrimmedString   `xml:"rule-from-context"`
	FromZone                 TrimmedString   `xml:"rule-from-context-name"`
	ToContext                TrimmedString   `xml:"rule-to-context"`
	ToZone                   TrimmedString   `xml:"rule-to-context-name"`
	SourceAddressLowRange    TrimmedString   `xml:"source-address-range-entry>rule-source-address-low-range"`
	SourceAddressHighRange   TrimmedString   `xml:"source-address-range-entryrule-source-address-high-range"`
	SourceAddresses          []TrimmedString `xml:"source-address-range-entry>rule-source-address"`
	DestinationAddresses     []TrimmedString `xml:"destination-address-range-entry>rule-destination-address"`
	DestinationPortLow       int             `xml:"destination-port-entry>rule-destination-port-low"`
	DestinationPortHigh      int             `xml:"destination-port-entry>rule-destination-port-high"`
	SourcePortLow            int             `xml:"source-port-entry>rule-source-port-low"`
	SourcePortHigh           int             `xml:"source-port-entry>rule-source-port-high"`
	SourceNatProtocol        TrimmedString   `xml:"src-nat-protocol-entry"`
	RuleAction               TrimmedString   `xml:"source-nat-rule-action-entry>source-nat-rule-action"`
	PersistentNatType        TrimmedString   `xml:"source-nat-rule-action-entry>persistent-nat-type"`
	PersistentNatMappingType TrimmedString   `xml:"source-nat-rule-action-entry>persistent-nat-mapping-type"`
	PersistentNatTimeout     int             `xml:"source-nat-rule-action-entry>persistent-nat-timeout"`
	PersistentNatMaxSession  int             `xml:"source-nat-rule-action-entry>persistent-nat-max-session"`
	TranslationHits          int             `xml:"source-nat-rule-hits-entry>rule-translation-hits"`
	SuccessfulSessions       int             `xml:"source-nat-rule-hits-entry>succ-hits"`
	ConcurrentHits           int             `xml:"source-nat-rule-hits-entry>concurrent-hits"`
}

SourceNatEntry holds each individual source NAT entry.

type SourceNats

type SourceNats struct {
	Count   int
	Entries []SourceNatEntry `xml:"source-nat-rule-entry"`
}

SourceNats contains the source NATs configured on the device.

type StaticNatEntry

type StaticNatEntry struct {
	Name                    TrimmedString `xml:"rule-name"`
	SetName                 TrimmedString `xml:"rule-set-name"`
	ID                      TrimmedString `xml:"rule-id"`
	RuleMatchingPosition    int           `xml:"rule-matching-position"`
	FromContext             TrimmedString `xml:"rule-from-context"`
	FromZone                TrimmedString `xml:"rule-from-context-name"`
	SourceAddressLowRange   TrimmedString `xml:"static-source-address-range-entry>rule-source-address-low-range"`
	SourceAddressHighRange  TrimmedString `xml:"static-source-address-range-entry>rule-source-address-high-range"`
	DestinaionAddressPrefix TrimmedString `xml:"rule-destination-address-prefix"`
	DestinationPortLow      int           `xml:"rule-destination-port-low"`
	DestinationPortHigh     int           `xml:"rule-destination-port-high"`
	HostAddressPrefix       TrimmedString `xml:"rule-host-address-prefix"`
	HostPortLow             int           `xml:"rule-host-port-low"`
	HostPortHigh            int           `xml:"rule-host-port-high"`
	Netmask                 TrimmedString `xml:"rule-address-netmask"`
	RoutingInstance         TrimmedString `xml:"rule-host-routing-instance"`
	TranslationHits         int           `xml:"rule-translation-hits"`
	SuccessfulSessions      int           `xml:"succ-hits"`
	ConcurrentHits          int           `xml:"concurrent-hits"`
}

StaticNatEntry holds each individual static NAT entry.

type StaticNats

type StaticNats struct {
	Count   int
	Entries []StaticNatEntry `xml:"static-nat-rule-entry"`
}

StaticNats contains the static NATs configured on the device.

type Storage

type Storage struct {
	Entries []SystemStorage `xml:"system-storage-information"`
}

Storage contains information about all of the file systems on the device.

type SubModule

type SubModule struct {
	Name          TrimmedString  `xml:"name"`
	Version       TrimmedString  `xml:"version,omitempty"`
	PartNumber    TrimmedString  `xml:"part-number"`
	SerialNumber  TrimmedString  `xml:"serial-number"`
	Description   TrimmedString  `xml:"description"`
	CLEICode      TrimmedString  `xml:"clei-code"`
	ModuleNumber  TrimmedString  `xml:"module-number"`
	SubSubModules []SubSubModule `xml:"chassis-sub-sub-module"`
}

SubModule contains information about each individual sub-module.

type SubSubModule

type SubSubModule struct {
	Name             TrimmedString     `xml:"name"`
	Version          TrimmedString     `xml:"version,omitempty"`
	PartNumber       TrimmedString     `xml:"part-number"`
	SerialNumber     TrimmedString     `xml:"serial-number"`
	Description      TrimmedString     `xml:"description"`
	SubSubSubModules []SubSubSubModule `xml:"chassis-sub-sub-sub-module"`
}

SubSubModule contains information about each sub-sub module, such as SFP's.

type SubSubSubModule

type SubSubSubModule struct {
	Name         TrimmedString `xml:"name"`
	Version      TrimmedString `xml:"version,omitempty"`
	PartNumber   TrimmedString `xml:"part-number"`
	SerialNumber TrimmedString `xml:"serial-number"`
	Description  TrimmedString `xml:"description"`
}

SubSubSubModule contains information about each sub-sub-sub module, such as SFP's on a PIC, which is tied to a MIC on an MX.

type SystemStorage

type SystemStorage struct {
	FileSystems []FileSystem `xml:"filesystem"`
}

SystemStorage stores the file system information for each node, routing-engine, etc. on the device.

type TrimmedString

type TrimmedString string

func (TrimmedString) String

func (t TrimmedString) String() string

func (*TrimmedString) UnmarshalXML

func (t *TrimmedString) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type VCMember

type VCMember struct {
	Status       TrimmedString      `xml:"member-status"`
	ID           int                `xml:"member-id"`
	FPCSlot      TrimmedString      `xml:"fpc-slot"`
	SerialNumber TrimmedString      `xml:"member-serial-number"`
	Model        TrimmedString      `xml:"member-model"`
	Priority     int                `xml:"member-priority"`
	MixedMode    TrimmedString      `xml:"member-mixed-mode"`
	RouteMode    TrimmedString      `xml:"member-route-mode"`
	Role         TrimmedString      `xml:"member-role"`
	Neighbors    []VCMemberNeighbor `xml:"neighbor-list>neighbor"`
}

VCMember contains information about each individual virtual-chassis member.

type VCMemberNeighbor

type VCMemberNeighbor struct {
	ID        int           `xml:"neighbor-id"`
	Interface TrimmedString `xml:"neighbor-interface"`
}

VCMemberNeighbor contains information about each virtual-chassis member neighbor.

type Views

type Views struct {
	Arp            ArpTable
	BGP            BGPTable
	EthernetSwitch EthernetSwitchingTable
	FirewallPolicy FirewallPolicy
	Interface      Interfaces
	Inventory      HardwareInventory
	LLDPNeighbors  LLDPNeighbors
	Route          RoutingTable
	SourceNat      SourceNats
	StaticNat      StaticNats
	Storage        Storage
	VirtualChassis VirtualChassis
	Vlan           Vlans
	Environment    EnvironmentTable
	IKESAs         IKESAs
	IPSecSAs       IPSecSAs
	OSPFNeighbor   OSPFNeighborTable
	OSPFDatabase   OSPFDatabaseTable
	ISISDatabase   ISISDatabaseTable
	LSPs           MPLSLSPTable
}

Views contains the information for the specific views. Note that some views aren't available for specific hardware platforms, such as the "VirtualChassis" view on an SRX.

func (*Views) String

func (v *Views) String() string

type VirtualChassis

type VirtualChassis struct {
	PreProvisionedVCID   TrimmedString `xml:"preprovisioned-virtual-chassis-information>virtual-chassis-id"`
	PreProvisionedVCMode TrimmedString `xml:"preprovisioned-virtual-chassis-information>virtual-chassis-mode"`
	Members              []VCMember    `xml:"member-list>member"`
}

VirtualChassis contains information regarding the virtual-chassis setup for the device.

type Vlan

type Vlan struct {
	Name             TrimmedString   `xml:"l2ng-l2rtb-vlan-name"`
	Tag              int             `xml:"l2ng-l2rtb-vlan-tag"`
	MemberInterfaces []TrimmedString `xml:"l2ng-l2rtb-vlan-member>l2ng-l2rtb-vlan-member-interface"`
}

Vlan contains information about each individual VLAN.

type Vlans

type Vlans struct {
	Entries []Vlan `xml:"l2ng-l2ald-vlan-instance-group"`
}

Vlans contains all of the VLAN information on the device.

type Zone

type Zone struct {
	Name           string          `xml:"name"`
	AddressEntries []AddressEntry  `xml:"address-book>address"`
	AddressSets    []AddressSet    `xml:"address-book>address-set"`
	ZoneInterfaces []ZoneInterface `xml:"interfaces"`
}

Zone contains information about each individual security-zone.

type ZoneInterface

type ZoneInterface struct {
	Name string `xml:"name"`
}

ZoneInterface contains a list of all interfaces that belong to the zone.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL