Help us shape the future of Go! Take the 2026 Go Developer Survey

arista

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPInterfaceInterfaceStatusConnected = "connected"
	IPInterfaceLineProtocolStatusUp     = "up"
)

Variables

This section is empty.

Functions

func NewClientConn

func NewClientConn(device string) (*grpc.ClientConn, error)

NewClientConn creates a new instance grpc client

Types

type EAPIClient

type EAPIClient struct {
	Client aristapb.EapiMgrServiceClient
	// contains filtered or unexported fields
}

EAPIClient encapsulates the gRPC client and connection logic for interacting with the Arista device

func NewEAPIClient

func NewEAPIClient(log *slog.Logger, client aristapb.EapiMgrServiceClient) *EAPIClient

NewEAPIClient creates a new instance of EAPIClient with the provided context and device address. If clientConn is set to nil, generate a new clientConn using the specified device. Unit tests can use this to pass in a mock clientConn.

func (*EAPIClient) AddConfigToDevice

func (e *EAPIClient) AddConfigToDevice(ctx context.Context, config string, diffCmd *exec.Cmd, maxLockAge int) ([]string, error)

Apply the Arista EOS configuration commands we received from the controller to the local device

func (*EAPIClient) CheckConfigChanges

func (e *EAPIClient) CheckConfigChanges(sessionName string, diffCmd *exec.Cmd) (string, error)

CheckConfigChanges determines whether any changes were made during the configuration session.

func (*EAPIClient) GetBgpNeighbors

func (e *EAPIClient) GetBgpNeighbors(ctx context.Context) (map[string][]string, error)

Retrieve a list of BGP neighbor IP addresses from the local switch. (The slice of strings return value is intended to be used only by unit tests)

func (*EAPIClient) GetLocalTunnelTargetIPs

func (e *EAPIClient) GetLocalTunnelTargetIPs(ctx context.Context) ([]net.IP, error)

GetLocalTunnelTargetIPs returns the local tunnel target IPs from the Arista EAPI client.

Example "show ip interface brief" JSON response from the Arista EAPI client:

{
  "interfaces": {
    "Ethernet1": {
      "name": "Ethernet1",
      "interfaceStatus": "connected",
      "lineProtocolStatus": "up",
      "mtu": 1500,
      "ipv4Routable240": false,
      "ipv4Routable0": false,
      "interfaceAddress": {
        "ipAddr": {
          "address": "10.157.67.16",
          "maskLen": 24
        }
      },
      "nonRoutableClassEIntf": false
    },
    "Loopback0": {
      "name": "Loopback0",
      "interfaceStatus": "connected",
      "lineProtocolStatus": "up",
      "mtu": 65535,
      "ipv4Routable240": false,
      "ipv4Routable0": false,
      "interfaceAddress": {
        "ipAddr": {
          "address": "8.8.8.8",
          "maskLen": 32
        }
      },
      "nonRoutableClassEIntf": false
    },
    "Management0": {
      "name": "Management0",
      "interfaceStatus": "connected",
      "lineProtocolStatus": "up",
      "mtu": 1500,
      "ipv4Routable240": false,
      "ipv4Routable0": false,
      "interfaceAddress": {
        "ipAddr": {
          "address": "172.27.0.7",
          "maskLen": 16
        }
      },
      "nonRoutableClassEIntf": false
    },
    "Tunnel1": {
      "name": "Tunnel1",
      "interfaceStatus": "connected",
      "lineProtocolStatus": "up",
      "mtu": 1476,
      "ipv4Routable240": false,
      "ipv4Routable0": false,
      "interfaceAddress": {
        "ipAddr": {
          "address": "172.16.0.1",
          "maskLen": 31
        }
      },
      "nonRoutableClassEIntf": false
    }
  }
}

type IPInterfaceAddress

type IPInterfaceAddress struct {
	IPAddr IPInterfaceAddressIPAddr `json:"ipAddr"`
}

type IPInterfaceAddressIPAddr

type IPInterfaceAddressIPAddr struct {
	Address string `json:"address"`
	MaskLen uint8  `json:"maskLen"`
}

type IPInterfaceBrief

type IPInterfaceBrief struct {
	Name               string             `json:"name"`
	InterfaceStatus    string             `json:"interfaceStatus"`
	LineProtocolStatus string             `json:"lineProtocolStatus"`
	InterfaceAddress   IPInterfaceAddress `json:"interfaceAddress"`
}

type IPInterfacesBriefResponse

type IPInterfacesBriefResponse struct {
	Interfaces map[string]IPInterfaceBrief `json:"interfaces"`
}

type MockEAPIClient

type MockEAPIClient struct {
	RunShowCmdFunc    func(ctx context.Context, req *aristapb.RunShowCmdRequest, opts ...grpc.CallOption) (*aristapb.RunShowCmdResponse, error)
	RunConfigCmdsFunc func(ctx context.Context, in *aristapb.RunConfigCmdsRequest, opts ...grpc.CallOption) (*aristapb.RunConfigCmdsResponse, error)
}

func (*MockEAPIClient) RunConfigCmds

func (*MockEAPIClient) RunShowCmd

type Peer

type Peer struct {
	PeerAddress string `json:"peerAddress"`
}

[{ "vrfs": { "default": { "peerList": [{"peerAddress": "192.168.1.1", "asn": "65342", "linkType": "internal", "routerId": "0.0.0.0", "vrf": "default"}]}}}]

type Session

type Session struct {
	State string `json:"state"`
}

show configuration sessions: [{ "sessions": { "doublezero-agent-12345678": { "state": "pending", "completedTime": 1736543591.7642765, "commitUser": "", "description": "", "instances": { "868": { "user": "root", "terminal": "vty5", "currentTerminal": false } } }, "blah1": { "state": "pending", "commitUser": "", "description": "", "instances": {} } }, "maxSavedSessions": 1, "maxOpenSessions": 5, "mergeOnCommit": false, "saveToStartupConfigOnCommit": false }]

type ShowBgpNeighborsResponse

type ShowBgpNeighborsResponse struct {
	VRFs map[string]VRF `json:"vrfs"`
}

type ShowConfigurationLock

type ShowConfigurationLock struct {
	UserInfo UserInfo `json:"userInfo"`
}

type ShowConfigurationSessions

type ShowConfigurationSessions struct {
	Sessions map[string]Session `json:"sessions"`
}

Define a struct for the overall config that includes the sessions map.

type UserInfo

type UserInfo struct {
	Username        string  `json:"username"`
	TransactionName string  `json:"transactionName"`
	LockAcquireTime float64 `json:"lockAcquireTime"`
}

show configuration lock: [{ "userInfo": { "username": "root", "userTty": "vty4", "transactionName": "doublezero", "lockAcquireTime": 1739312029.188106 } } ]

type VRF

type VRF struct {
	Peers []Peer `json:"peerList"`
}

Jump to

Keyboard shortcuts

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