juniper

package
v0.0.0-...-d1a32ca Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SetAction represents the action to set a configuration.
	SetAction = "set"
	// DeleteAction represents the action to delete a configuration.
	DeleteAction = "delete"
)

Variables

View Source
var InterfaceConfigs []string

InterfaceConfigs stores configuration strings for switch interfaces.

Functions

func DeleteInterfaces

func DeleteInterfaces(currentSession *JunosSession, interfaceNames []string) error

DeleteInterfaces deletes given interfaces.

func DisableSwitchInterface

func DisableSwitchInterface(currentSession *JunosSession, switchInterface string) error

DisableSwitchInterface disables a specified switch interface.

func DumpInterfaceConfigs

func DumpInterfaceConfigs(currentSession *JunosSession, switchInterfaces []string) error

DumpInterfaceConfigs fetches and stores interface configurations for the specified switch interfaces.

func EnableSwitchInterface

func EnableSwitchInterface(currentSession *JunosSession, switchInterface string) error

EnableSwitchInterface enables a specified switch interface.

func IsSwitchInterfaceUp

func IsSwitchInterfaceUp(currentSession *JunosSession, switchInterface string) (bool, error)

IsSwitchInterfaceUp checks if a switch interface is up.

func RemoveAllConfigurationFromInterfaces

func RemoveAllConfigurationFromInterfaces(currentSession *JunosSession, switchInterfaces []string) error

RemoveAllConfigurationFromInterfaces removes all configuration from given switch interfaces.

func RestoreSwitchInterfacesConfiguration

func RestoreSwitchInterfacesConfiguration(currentSession *JunosSession, switchInterfaces []string) error

RestoreSwitchInterfacesConfiguration restores the configuration of specified switch interfaces.

func SetNonLacpLag

func SetNonLacpLag(currentSession *JunosSession, slaveInterfaceNames []string, aggregatedInterfaceName string) error

SetNonLacpLag configures non-LACP Link Aggregated ports on Junos devices.

func SetVlanOnTrunkInterface

func SetVlanOnTrunkInterface(currentSession *JunosSession, vlan, switchInterface string) error

SetVlanOnTrunkInterface configures VLAN on a trunk interface.

Types

type InterfaceStatus

type InterfaceStatus struct {
	InterfaceInformation []struct {
		PhysicalInterface []struct {
			Name []struct {
				Data string `json:"data"`
			} `json:"name"`
			AdminStatus []struct {
				Data       string `json:"data"`
				Attributes struct {
					JunosFormat string `json:"junos:format"`
				} `json:"attributes"`
			} `json:"admin-status"`
			OperStatus []struct {
				Data string `json:"data"`
			} `json:"oper-status"`
			MTU []struct {
				Data string `json:"data"`
			} `json:"mtu"`
			Speed []struct {
				Data string `json:"data"`
			} `json:"speed"`
		} `json:"physical-interface"`
	} `json:"interface-information"`
}

InterfaceStatus represents the status information of a network interface.

type JunosSession

type JunosSession struct {
	Session           *netconf.Session
	SwitchCredentials SwitchCredentials
}

JunosSession represents a connection to a Juniper network device.

func NewSession

func NewSession(host, user, password string) (*JunosSession, error)

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

func (*JunosSession) ApplyConfigInterface

func (j *JunosSession) ApplyConfigInterface(config string) error

ApplyConfigInterface applies given interface configuration to a switch.

func (*JunosSession) Close

func (j *JunosSession) Close()

Close disconnects the session to the device.

func (*JunosSession) Config

func (j *JunosSession) Config(commands []string) error

Config sends commands to a Juniper switch.

func (*JunosSession) GetInterfaceConfig

func (j *JunosSession) GetInterfaceConfig(switchInterface string) (string, error)

GetInterfaceConfig returns configuration for given interface.

func (*JunosSession) RunOperationalCMD

func (j *JunosSession) RunOperationalCMD(cmd string) (string, error)

RunOperationalCMD executes any operational mode command, such as "show" or "request".

type SwitchCredentials

type SwitchCredentials struct {
	// User is the username for authenticating with the switch.
	User string
	// Password is the password for authenticating with the switch.
	Password string
	// SwitchIP is the IP address of the network switch.
	SwitchIP string
}

SwitchCredentials stores the authentication and connection details for a network switch.

func NewSwitchCredentials

func NewSwitchCredentials() (*SwitchCredentials, error)

NewSwitchCredentials is the constructor for the SwitchCredentials object.

Jump to

Keyboard shortcuts

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