goeapi

package module
v0.0.0-...-ace24d6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2015 License: Apache-2.0 Imports: 12 Imported by: 2

README

Using Arista eAPI with the Go programming language

  • JSON-RPC over HTML - not supported in the standard library JSON-RPC package
  • Specific structs for switch information

Web

web directory is an attempt at creating REST API

Main

main directory is an example application

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCodes

func ParseCodes(fields []string) ([]string, int)

func ParseMetric

func ParseMetric(s string) (int, int)

func RawCall

func RawCall(url string, cmds []string, format string) []byte

Types

type EosNode

type EosNode struct {
	Transport string
	Username  string
	Password  string
	Hostname  string
}

func (*EosNode) Call

func (e *EosNode) Call(cmds []string) (JsonRpcResponse, error)

func (*EosNode) CapiUrl

func (e *EosNode) CapiUrl() string

func (*EosNode) ShowInterfaces

func (e *EosNode) ShowInterfaces(intf string) (ShowInterfacesResponse, error)

func (*EosNode) ShowLldpNeighbors

func (e *EosNode) ShowLldpNeighbors() (ShowLldpNeighbors, error)

func (*EosNode) ShowVlan

func (e *EosNode) ShowVlan(intf string) (ShowVlanResponse, error)

type EthInterfaceCounters

type EthInterfaceCounters struct {
	CounterRefreshTime float64
	InBroadcastPkts    int
	InDiscards         int
	InMulticastPkts    int
	InOctets           int
	InUcastPkts        int
	InputErrorsDetail  PhysicalInputErrors
	LastClear          float64
	LinkStatusChanges  int
	OutBroadcastPkts   int
	OutDiscards        int
	OutMulticastPkts   int
	OutOctets          int
	OutUcastPkts       int
	OutErrorsDetail    PhysicalOutputErrors
	TotalInErrors      int
	TotalOutErrors     int
}

type Flow

type Flow struct {
	Priority   int
	MatchBytes int
	Name       string
}

type Interface

type Interface struct {
	Bandwidth                 int
	BurnedInAddress           string
	Description               string //`json:"description"`
	ForwardingModel           string
	Hardware                  string
	InterfaceAddress          []InterfaceAddress
	InterfaceCounters         EthInterfaceCounters
	InterfaceMembership       string
	InterfaceStatistics       InterfaceStatistics
	InterfaceStatus           string
	L2Mtu                     int
	LastStatusChangeTimestamp float64
	LineProtocolStatus        string
	Mtu                       int
	Name                      string
	PhysicalAddress           string
}

todo: account for different interface types, this is specific to Eth

type InterfaceAddress

type InterfaceAddress struct {
	BroadcastAddress       string
	PrimaryIp              IpAddress
	SecondaryIps           interface{}
	SecondaryIpOrderedList []IpAddress
	VirtualIp              IpAddress
}

type InterfaceNames

type InterfaceNames struct {
	NameVlan map[string]VlanProperty
}

type InterfaceStatistics

type InterfaceStatistics struct {
	InBitsRate     float64
	OutBitsRate    float64
	InPktsRate     float64
	UpdateInterval float64
	OutPktsRate    float64
}

type IpAddress

type IpAddress struct {
	Address string
	MaskLen int
}

type JsonRpcResponse

type JsonRpcResponse struct {
	Jsonrpc string                   `json:"jsonrpc"`
	Result  []map[string]interface{} `json:"result"`
	Error   map[string]interface{}   `json:"error"`
	Id      string                   `json:"id"`
}

func Call

func Call(url string, cmds []string, format string) JsonRpcResponse

type JsonRpcResponseInterface

type JsonRpcResponseInterface struct {
	Jsonrpc string                 `json:"jsonrpc"`
	Result  []interface{}          `json:"result"`
	Error   map[string]interface{} `json:"error"`
	Id      string                 `json:"id"`
}

type LldpNeighbor

type LldpNeighbor struct {
	NeighborDevice string
	NeighborPort   string
	Port           string
	Ttl            int
}

type NextHop

type NextHop struct {
	Address   net.IP
	Interface string
}

func ParseNextHop

func ParseNextHop(fields []string) NextHop

type OpenstackNetworks

type OpenstackNetworks struct {
	Regions   map[string]OpenstackRegion
	Neighbors interface{}
	Hosts     interface{}
}

type OpenstackRegion

type OpenstackRegion struct {
	Tenants          interface{}
	ServiceEndPoints interface{}
	RegionName       string
}

type Parameters

type Parameters struct {
	Version int      `json:"version"`
	Cmds    []string `json:"cmds"`
	Format  string   `json:"format"`
}

type PhysicalInputErrors

type PhysicalInputErrors struct {
	AlignmentErrots int
	FcsErrors       int
	GiantFrames     int
	RuntFrames      int
	RxPause         int
	SymbolErrors    int
}

type PhysicalOutputErrors

type PhysicalOutputErrors struct {
	Collisions            int
	DeferredTransmissions int
	LateCollisions        int
	TxPause               int
}

type RawJsonRpcResponse

type RawJsonRpcResponse struct {
	Jsonrpc string                 `json:"jsonrpc"`
	Result  []json.RawMessage      `json:"result"`
	Error   map[string]interface{} `json:"error"`
	Id      string                 `json:"id"`
}

type Request

type Request struct {
	Jsonrpc string     `json:"jsonrpc"`
	Method  string     `json:"method"`
	Params  Parameters `json:"params"`
	Id      string     `json:"id"`
}

type Route

type Route struct {
	Codes     []string
	Network   *net.IPNet
	AdminDist int
	Metric    int
	NextHops  []NextHop
}

func NewIpRoute

func NewIpRoute(s string) Route

func ParseShowIpRoute

func ParseShowIpRoute(s string) []Route

type ShowDirectFlowFlows

type ShowDirectFlowFlows struct {
	Flows []Flow
}

type ShowInterfaces

type ShowInterfaces struct {
	Interfaces map[string]Interface `json:"interfaces"`
}

TODO: May need to replace Interface with a generic interface

type ShowInterfacesResponse

type ShowInterfacesResponse struct {
	Jsonrpc string
	Result  []ShowInterfaces
	Error   map[string]interface{}
	Id      string
}

func CallShowInterfaces

func CallShowInterfaces(url, intf string) ShowInterfacesResponse

type ShowLldpNeighbors

type ShowLldpNeighbors struct {
	TablesDeletes        int            `json:"tablesDeletes"`
	TablesAgeOuts        int            `json:"tablesAgeOuts"`
	TablesDrops          int            `json:"tablesDrops"`
	TablesInserts        int            `json:"tablesInserts"`
	TablesLastChangeTime float64        `json:"tablesLastChangeTime"`
	LldpNeighbors        []LldpNeighbor `json:"lldpNeighbors"`
}

func CallShowLldpNeighbors

func CallShowLldpNeighbors(url string) ShowLldpNeighbors

type ShowLldpNeighborsResponse

type ShowLldpNeighborsResponse struct {
	Jsonrpc string
	Result  []ShowLldpNeighbors
	Error   map[string]interface{}
	Id      string
}

type ShowVersion

type ShowVersion struct {
	ModelName        string  `json:"modelName"`
	InternalVersion  string  `json:"internalVersion"`
	SystemMacAddress string  `json:"systemMacAddress"`
	SerialNumber     string  `json:"serialNumber"`
	MemTotal         float64 `json:"memTotal"`
	BootupTimestap   float64 `json:"bootupTimestamp"`
	MemFree          float64 `json:"memFree"`
	Version          string  `json:"version"`
	Architecture     string  `json:"architecture"`
	InternalBuildId  string  `json:"internalBuildId"`
	HardwareRevision string  `json:"hardwareRevision"`
}

type ShowVlan

type ShowVlan struct {
	SourceDetail string              `json:"sourceDetail"`
	Vlans        map[string]VlanInfo `json:"vlans"`
}

type ShowVlanResponse

type ShowVlanResponse struct {
	Jsonrpc string
	Result  []ShowVlan
	Error   map[string]interface{}
	Id      string
}

func CallShowVlan

func CallShowVlan(url, intf string) ShowVlanResponse

type VlanInfo

type VlanInfo struct {
	Status     string                    `json:"status"`
	Name       string                    `json:"name"`
	Interfaces map[string]InterfaceNames `json:"interfaces"`
	Dynamic    bool                      `json:"dynamic"`
}

type VlanProperty

type VlanProperty struct {
	Property map[string]bool `json:"privatePromoted"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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