Documentation ¶
Index ¶
- Constants
- Variables
- func AddLayer2Link(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, metadata graph.Metadata) (*graph.Edge, error)
- func AddLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, ...) (*graph.Edge, error)
- func AddOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node, metadata graph.Metadata) (*graph.Edge, error)
- func ChassisInterfaceMetricMetadataDecoder(raw json.RawMessage) (common.Getter, error)
- func GetFirstEdge(g *graph.Graph, node *graph.Node, em graph.ElementMatcher) *graph.Edge
- func GetOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node) *graph.Edge
- func GetPeer(g *graph.Graph, node *graph.Node, edge *graph.Edge, f graph.ElementMatcher) *graph.Node
- func HaveLayer2Link(g *graph.Graph, node1 *graph.Node, node2 *graph.Node) bool
- func HaveLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string) bool
- func HaveOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node) bool
- func InterfaceMetricMetadataDecoder(raw json.RawMessage) (common.Getter, error)
- func IsInterfaceUp(node *graph.Node) bool
- func IsOwnershipLinked(g *graph.Graph, node *graph.Node) bool
- func Layer2Metadata() graph.Metadata
- func NamespaceFromNode(g *graph.Graph, n *graph.Node) (string, string, error)
- func NeighborMetadataDecoder(raw json.RawMessage) (common.Getter, error)
- func NewLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, ...) (*graph.Edge, error)
- func NewNetNSContextByNode(g *graph.Graph, n *graph.Node) (*common.NetNSContext, error)
- func OwnershipMetadata() graph.Metadata
- func RoutingTablesMetadataDecoder(raw json.RawMessage) (common.Getter, error)
- type ChassisInterfaceMetric
- func (im *ChassisInterfaceMetric) Add(m common.Metric) common.Metric
- func (im *ChassisInterfaceMetric) GetLast() int64
- func (im *ChassisInterfaceMetric) GetStart() int64
- func (im *ChassisInterfaceMetric) IsZero() bool
- func (im *ChassisInterfaceMetric) SetLast(last int64)
- func (im *ChassisInterfaceMetric) SetStart(start int64)
- func (im *ChassisInterfaceMetric) Split(cut int64) (common.Metric, common.Metric)
- func (im *ChassisInterfaceMetric) Sub(m common.Metric) common.Metric
- type HostNodeTIDMap
- type InterfaceMetric
- func (im *InterfaceMetric) Add(m common.Metric) common.Metric
- func (im *InterfaceMetric) GetLast() int64
- func (im *InterfaceMetric) GetStart() int64
- func (im *InterfaceMetric) IsZero() bool
- func (im *InterfaceMetric) SetLast(last int64)
- func (im *InterfaceMetric) SetStart(start int64)
- func (im *InterfaceMetric) Split(cut int64) (common.Metric, common.Metric)
- func (im *InterfaceMetric) Sub(m common.Metric) common.Metric
- type Neighbor
- type Neighbors
- type NextHop
- type Prefix
- type Route
- type RoutingTable
- type RoutingTables
- type SchemaValidator
- type TIDMapper
Constants ¶
const ( OwnershipLink = "ownership" Layer2Link = "layer2" )
ErrNetworkPathNotFound
Variables ¶
var ( // IPv4DefaultRoute default IPv4 route IPv4DefaultRoute = net.IPNet{IP: net.IPv4zero, Mask: net.CIDRMask(0, 8*net.IPv4len)} // IPv6DefaultRoute default IPv6 route IPv6DefaultRoute = net.IPNet{IP: net.IPv6zero, Mask: net.CIDRMask(0, 8*net.IPv6len)} )
var ErrInvalidSchema = errors.New("Invalid schema")
ErrInvalidSchema is return when a JSON schema is invalid
var ( // ErrNoPathToHost is called when no host could be found as the parent of a node ErrNoPathToHost = func(name string) error { return fmt.Errorf("Failed to determine network namespace path for %s", name) } )
Functions ¶
func AddLayer2Link ¶
func AddLayer2Link(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, metadata graph.Metadata) (*graph.Edge, error)
AddLayer2Link links the parent and the child node
func AddLink ¶
func AddLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, metadata graph.Metadata) (*graph.Edge, error)
AddLink links the parent and the child node with the specified relation type and metadata
func AddOwnershipLink ¶
func AddOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node, metadata graph.Metadata) (*graph.Edge, error)
AddOwnershipLink Link between the parent and the child node, the child can have only one parent, previous will be overwritten
func ChassisInterfaceMetricMetadataDecoder ¶
func ChassisInterfaceMetricMetadataDecoder(raw json.RawMessage) (common.Getter, error)
ChassisInterfaceMetricMetadataDecoder implements a json message raw decoder
func GetFirstEdge ¶
func GetOwnershipLink ¶
GetOwnershipLink get ownership Link between the parent and the child node or nil
func HaveLayer2Link ¶
HaveLayer2Link returns true if parent and child have the same layer 2
func HaveOwnershipLink ¶
HaveOwnershipLink returns true if parent and child have an ownership link
func InterfaceMetricMetadataDecoder ¶
func InterfaceMetricMetadataDecoder(raw json.RawMessage) (common.Getter, error)
InterfaceMetricMetadataDecoder implements a json message raw decoder
func IsInterfaceUp ¶
IsInterfaceUp returns whether an interface has the flag UP set
func IsOwnershipLinked ¶
IsOwnershipLinked checks whether the node has an OwnershipLink
func Layer2Metadata ¶
Layer2Metadata returns metadata for a layer2 link
func NamespaceFromNode ¶
NamespaceFromNode returns the namespace name and the path of a node in the graph
func NeighborMetadataDecoder ¶
func NeighborMetadataDecoder(raw json.RawMessage) (common.Getter, error)
NeighborMetadataDecoder implements a json message raw decoder
func NewLink ¶
func NewLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, metadata graph.Metadata) (*graph.Edge, error)
NewLink creates a link between a parent and a child node with the specified relation type and metadata
func NewNetNSContextByNode ¶
NewNetNSContextByNode creates a new network namespace context based on the node
func OwnershipMetadata ¶
OwnershipMetadata returns metadata for an ownership link
func RoutingTablesMetadataDecoder ¶
func RoutingTablesMetadataDecoder(raw json.RawMessage) (common.Getter, error)
RoutingTablesMetadataDecoder implements a json message raw decoder
Types ¶
type ChassisInterfaceMetric ¶
type ChassisInterfaceMetric struct { IfInOctets int64 `json:"IfInOctets,omitempty"` IfInUcastPkts int64 `json:"IfInUcastPkts,omitempty"` IfInMulticastPkts int64 `json:"IfInMulticastPkts,omitempty"` IfInBroadcastPkts int64 `json:"IfInBroadcastPkts,omitempty"` IfInDiscards int64 `json:"IfInDiscards,omitempty"` IfInErrors int64 `json:"IfInErrors,omitempty"` IfInUnknownProtos int64 `json:"IfInUnknownProtos,omitempty"` IfOutOctets int64 `json:"IfOutOctets,omitempty"` IfOutUcastPkts int64 `json:"IfOutUcastPkts,omitempty"` IfOutMulticastPkts int64 `json:"IfOutMulticastPkts,omitempty"` IfOutBroadcastPkts int64 `json:"IfOutBroadcastPkts,omitempty"` IfOutDiscards int64 `json:"IfOutDiscards,omitempty"` IfOutErrors int64 `json:"IfOutErrors,omitempty"` Start int64 `json:"Start,omitempty"` Last int64 `json:"Last,omitempty"` }
ChassisInterfaceMetric the interface packets counters easyjson:json gendecoder
func (*ChassisInterfaceMetric) Add ¶
func (im *ChassisInterfaceMetric) Add(m common.Metric) common.Metric
Add sum two metrics and return a new Metrics object
func (*ChassisInterfaceMetric) GetLast ¶
func (im *ChassisInterfaceMetric) GetLast() int64
GetLast returns last time
func (*ChassisInterfaceMetric) GetStart ¶
func (im *ChassisInterfaceMetric) GetStart() int64
GetStart returns start time
func (*ChassisInterfaceMetric) IsZero ¶
func (im *ChassisInterfaceMetric) IsZero() bool
IsZero returns true if all the values are equal to zero
func (*ChassisInterfaceMetric) SetLast ¶
func (im *ChassisInterfaceMetric) SetLast(last int64)
SetLast set last tome
func (*ChassisInterfaceMetric) SetStart ¶
func (im *ChassisInterfaceMetric) SetStart(start int64)
SetStart set start time
type HostNodeTIDMap ¶
HostNodeTIDMap a map that store the value node TID and the key node host
func BuildHostNodeTIDMap ¶
func BuildHostNodeTIDMap(nodes []*graph.Node) HostNodeTIDMap
BuildHostNodeTIDMap creates a new node and host (key) map
type InterfaceMetric ¶
type InterfaceMetric struct { Collisions int64 `json:"Collisions,omitempty"` Multicast int64 `json:"Multicast,omitempty"` RxBytes int64 `json:"RxBytes,omitempty"` RxCompressed int64 `json:"RxCompressed,omitempty"` RxCrcErrors int64 `json:"RxCrcErrors,omitempty"` RxDropped int64 `json:"RxDropped,omitempty"` RxErrors int64 `json:"RxErrors,omitempty"` RxFifoErrors int64 `json:"RxFifoErrors,omitempty"` RxFrameErrors int64 `json:"RxFrameErrors,omitempty"` RxLengthErrors int64 `json:"RxLengthErrors,omitempty"` RxMissedErrors int64 `json:"RxMissedErrors,omitempty"` RxOverErrors int64 `json:"RxOverErrors,omitempty"` RxPackets int64 `json:"RxPackets,omitempty"` TxAbortedErrors int64 `json:"TxAbortedErrors,omitempty"` TxBytes int64 `json:"TxBytes,omitempty"` TxCarrierErrors int64 `json:"TxCarrierErrors,omitempty"` TxCompressed int64 `json:"TxCompressed,omitempty"` TxDropped int64 `json:"TxDropped,omitempty"` TxErrors int64 `json:"TxErrors,omitempty"` TxFifoErrors int64 `json:"TxFifoErrors,omitempty"` TxHeartbeatErrors int64 `json:"TxHeartbeatErrors,omitempty"` TxPackets int64 `json:"TxPackets,omitempty"` TxWindowErrors int64 `json:"TxWindowErrors,omitempty"` Start int64 `json:"Start,omitempty"` Last int64 `json:"Last,omitempty"` }
InterfaceMetric the interface packets counters easyjson:json gendecoder
func (*InterfaceMetric) Add ¶
func (im *InterfaceMetric) Add(m common.Metric) common.Metric
Add sum two metrics and return a new Metrics object
func (*InterfaceMetric) GetLast ¶
func (im *InterfaceMetric) GetLast() int64
GetLast returns last time
func (*InterfaceMetric) GetStart ¶
func (im *InterfaceMetric) GetStart() int64
GetStart returns start time
func (*InterfaceMetric) IsZero ¶
func (im *InterfaceMetric) IsZero() bool
IsZero returns true if all the values are equal to zero
func (*InterfaceMetric) SetLast ¶
func (im *InterfaceMetric) SetLast(last int64)
SetLast set last tome
func (*InterfaceMetric) SetStart ¶
func (im *InterfaceMetric) SetStart(start int64)
SetStart set start time
type Neighbor ¶
type Neighbor struct { Flags []string `json:"Flags,omitempty"` MAC string `json:"MAC,omitempty"` IP net.IP `json:"IP,omitempty"` State []string `json:"State,omitempty"` Vlan int64 `json:"Vlan,omitempty"` VNI int64 `json:"VNI,omitempty"` IfIndex int64 }
Neighbor describes a member of the forwarding database easyjson:json gendecoder
type Neighbors ¶
type Neighbors []*Neighbor
Neighbors describes a list of neighbors easyjson:json gendecoder
type NextHop ¶
type NextHop struct { Priority int64 `json:"Priority"` IP net.IP `json:"IP,omitempty"` MAC string `json:"MAC,omitempty"` IfIndex int64 `json:"IfIndex"` }
NextHop describes a next hop easyjson:json gendecoder
type Prefix ¶
Prefix describes prefix
func (*Prefix) IsDefaultRoute ¶
IsDefaultRoute return whether the given cidr is a default route
func (*Prefix) MarshalJSON ¶
MarshalJSON custom marshal function
func (*Prefix) UnmarshalJSON ¶
UnmarshalJSON custom unmarshal function
type Route ¶
type Route struct { Protocol int64 `json:"Protocol"` Prefix Prefix `json:"Prefix"` NextHops []*NextHop `json:"NextHops"` }
Route describes a route easyjson:json gendecoder
func (*Route) GetNextHop ¶
GetNextHop returns the nexthop for the given ip and ifindex
type RoutingTable ¶
type RoutingTable struct { ID int64 `json:"ID"` Src net.IP `json:"Src"` Routes []*Route `json:"Routes"` }
RoutingTable describes a list of Routes easyjson:json gendecoder
func (*RoutingTable) GetOrCreateRoute ¶
func (rt *RoutingTable) GetOrCreateRoute(protocol int64, prefix net.IPNet) *Route
GetOrCreateRoute creates if not existing a new route and returns it
type RoutingTables ¶
type RoutingTables []*RoutingTable
RoutingTables describes a list of routing table easyjson:json gendecoder
type SchemaValidator ¶
type SchemaValidator struct {
// contains filtered or unexported fields
}
SchemaValidator validates graph nodes and edges using a JSON schema
func NewSchemaValidator ¶
func NewSchemaValidator() (*SchemaValidator, error)
NewSchemaValidator returns a new JSON schema validator for graph nodes and edges. based on JSON schema bundled with go-bindata
func (*SchemaValidator) ValidateEdge ¶
func (v *SchemaValidator) ValidateEdge(edge *graph.Edge) error
ValidateEdge valides a graph edge
func (*SchemaValidator) ValidateNode ¶
func (v *SchemaValidator) ValidateNode(node *graph.Node) error
ValidateNode valides a graph node
type TIDMapper ¶
type TIDMapper struct { graph.DefaultGraphListener Graph *graph.Graph // contains filtered or unexported fields }
TIDMapper describes the hostID nodes stored in a graph the mapper will broadcast node event to the registered listeners
func NewTIDMapper ¶
NewTIDMapper creates a new node mapper in the graph g
func (*TIDMapper) OnEdgeDeleted ¶
OnEdgeDeleted event
func (*TIDMapper) OnEdgeUpdated ¶
OnEdgeUpdated event
func (*TIDMapper) OnNodeUpdated ¶
OnNodeUpdated event