Documentation
¶
Index ¶
- Constants
- func NewClientConn(device string) (*grpc.ClientConn, error)
- type EAPIClient
- func (e *EAPIClient) AddConfigToDevice(ctx context.Context, config string, diffCmd *exec.Cmd, maxLockAge int) ([]string, error)
- func (e *EAPIClient) CheckConfigChanges(sessionName string, diffCmd *exec.Cmd) (string, error)
- func (e *EAPIClient) GetBgpNeighbors(ctx context.Context) (map[string][]string, error)
- func (e *EAPIClient) GetLocalTunnelTargetIPs(ctx context.Context) ([]net.IP, error)
- type IPInterfaceAddress
- type IPInterfaceAddressIPAddr
- type IPInterfaceBrief
- type IPInterfacesBriefResponse
- type MockEAPIClient
- type Peer
- type Session
- type ShowBgpNeighborsResponse
- type ShowConfigurationLock
- type ShowConfigurationSessions
- type UserInfo
- type VRF
Constants ¶
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 ¶
CheckConfigChanges determines whether any changes were made during the configuration session.
func (*EAPIClient) GetBgpNeighbors ¶
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 ¶
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 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 (m *MockEAPIClient) RunConfigCmds(ctx context.Context, in *aristapb.RunConfigCmdsRequest, opts ...grpc.CallOption) (*aristapb.RunConfigCmdsResponse, error)
func (*MockEAPIClient) RunShowCmd ¶
func (m *MockEAPIClient) RunShowCmd(ctx context.Context, req *aristapb.RunShowCmdRequest, opts ...grpc.CallOption) (*aristapb.RunShowCmdResponse, error)
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 ShowConfigurationLock ¶
type ShowConfigurationLock struct {
UserInfo UserInfo `json:"userInfo"`
}
type ShowConfigurationSessions ¶
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 } } ]