Documentation
¶
Overview ¶
Package ftutilities contains utility functions used by functional translators.
Index ¶
- Variables
- func ConfigToState(p *gnmipb.Path) *gnmipb.Path
- func Filter(notification *gnmipb.Notification, ...) *gnmipb.Notification
- func FilterStructToState(s ygot.GoStruct, ts int64, origin, target string) (*gnmipb.SubscribeResponse, error)
- func FilterUpdates(update []*gnmipb.Update, fn func(up *gnmipb.Update) bool) []*gnmipb.Update
- func ForcePathPrefix(s, prefix string) string
- func GNMIPathToSchemaString(p *gnmipb.Path, setOCIfOriginMissing bool) string
- func GNMIPathToSchemaStrings(path *gnmipb.Path, setOCIfOriginMissing bool) []string
- func Join(p1, p2 *gnmipb.Path) *gnmipb.Path
- func LoadSubscribeResponse(path string) (*gnmipb.SubscribeResponse, error)
- func MatchPath(path, pattern *gnmipb.Path) bool
- func MaybeConvertOptical(portName string, opticsType string) (newPortName string, wanted bool)
- func MustStringMapPaths(m map[string][]string) map[string][]*gnmipb.Path
- func PathInList(p *gnmipb.Path, paths []*gnmipb.Path) bool
- func SortByYgotString(s []*gnmipb.Path) func(i, j int) bool
- func StateLeaves(up *gnmipb.Update) bool
- func StringToPath(s string) (*gnmipb.Path, error)
- func StripPathPrefix(s, prefix string) string
- type AristaMACSecMapCache
- func (c *AristaMACSecMapCache) ClearAllTargetMacSecInfo()
- func (c *AristaMACSecMapCache) CreateOrUpdateTargetMacSecInfo(targetHostname string) *TargetMacSecInfo
- func (c *AristaMACSecMapCache) DeleteTargetMacSecInfo(targetHostname string)
- func (c *AristaMACSecMapCache) RetrieveTargetMacSecInfo(targetHostname string) (*TargetMacSecInfo, bool)
- func (c *AristaMACSecMapCache) SetTargetMacSecInfo(targetHostname string, info *TargetMacSecInfo)
- type CKNInfo
- type InterfaceMacSecInfo
- func (i *InterfaceMacSecInfo) CloneStatuses() map[string]*CKNInfo
- func (i *InterfaceMacSecInfo) CreateOrGetCKN(ckn string) *CKNInfo
- func (i *InterfaceMacSecInfo) IntfCPStatus() (bool, bool)
- func (i *InterfaceMacSecInfo) IntfPrincipal(ckn string) (bool, bool)
- func (i *InterfaceMacSecInfo) IntfSuccess(ckn string) (bool, bool)
- func (i *InterfaceMacSecInfo) IsComplete(ckn string) bool
- func (i *InterfaceMacSecInfo) RemoveCkn(ckn string)
- func (i *InterfaceMacSecInfo) ResetCPStatus()
- func (i *InterfaceMacSecInfo) SetIntfCPStatus(b bool)
- func (i *InterfaceMacSecInfo) SetIntfPrincipal(ckn string, b bool)
- func (i *InterfaceMacSecInfo) SetIntfSuccess(ckn string, b bool)
- type MemberInterfaceInfo
- func (m *MemberInterfaceInfo) CloneQueues() map[string]*QueueCounters
- func (m *MemberInterfaceInfo) SetDroppedBytes(queueID string, val uint64)
- func (m *MemberInterfaceInfo) SetDroppedPackets(queueID string, val uint64)
- func (m *MemberInterfaceInfo) SetTxBytes(queueID string, val uint64)
- func (m *MemberInterfaceInfo) SetTxPackets(queueID string, val uint64)
- type PortChannelInfo
- type QoSAggregationMapCache
- type QueueCounters
- type TargetMacSecInfo
- type TargetQoSInfo
- func (t *TargetQoSInfo) CreateOrRetrievePortChannel(pcName string) *PortChannelInfo
- func (t *TargetQoSInfo) FindAndRemoveMember(memberName string) (string, bool)
- func (t *TargetQoSInfo) PortChannelInfo(pcName string) (*PortChannelInfo, bool)
- func (t *TargetQoSInfo) RetrievePortChannelForMember(memberName string) (string, bool)
- func (t *TargetQoSInfo) SetPortChannelForMember(memberName, pcName string)
Constants ¶
This section is empty.
Variables ¶
var ( AristaMACSecMap = &AristaMACSecMapCache{ data: make(map[string]*TargetMacSecInfo), } )
Global instance of the AristaMACSecMapCache.
var ( QoSAggMap = &QoSAggregationMapCache{ data: make(map[string]*TargetQoSInfo), } )
QoSAggMap is the global instance of the QoSAggregationMapCache.
var ValidOrigins = map[string]struct{}{
"openconfig": {},
"eos_native": {},
"Cisco-IOS-XR-controller-optics-oper": {},
"Cisco-IOS-XR-fabric-plane-health-oper": {},
"Cisco-IOS-XR-infra-statsd-oper": {},
"Cisco-IOS-XR-ipv4-arp-oper": {},
"Cisco-IOS-XR-ipv4-io-oper": {},
"Cisco-IOS-XR-ipv6-ma-oper": {},
"Cisco-IOS-XR-ipv6-nd-oper": {},
"Cisco-IOS-XR-platforms-ofa-oper": {},
"Cisco-IOS-XR-shellutil-filesystem-oper": {},
"Cisco-IOS-XR-show-fpd-loc-ng-oper": {},
"Cisco-IOS-XR-switch-oper": {},
"Cisco-IOS-XR-qos-ma-oper": {},
"Cisco-IOS-XR-envmon-oper": {},
}
ValidOrigins is the set of valid origins for gNMI paths. If they occur as the first element of a path or as the first non-empty string in a stringified path, they are used to set the origin.
Functions ¶
func ConfigToState ¶
ConfigToState replaces "config" elements with "state" elements.
func Filter ¶
func Filter(notification *gnmipb.Notification, fn func(path *gnmipb.Path, isDelete bool) bool) *gnmipb.Notification
Filter returns a new notification with only the updates that return true from the provided fn.
func FilterStructToState ¶
func FilterStructToState(s ygot.GoStruct, ts int64, origin, target string) (*gnmipb.SubscribeResponse, error)
FilterStructToState converts a ygot struct to a gNMI subscribe response.
func FilterUpdates ¶
FilterUpdates returns a slice containing updates that return true from the provided fn.
func ForcePathPrefix ¶
ForcePathPrefix adds the prefix to the string if it is not already present, even if the string is empty.
func GNMIPathToSchemaString ¶
GNMIPathToSchemaString converts a gNMI path to a string.
func GNMIPathToSchemaStrings ¶
GNMIPathToSchemaStrings extracts the schema path and converts it into a slice of strings. Origin is prepended as the first element, if present. setOCOriginIfMissing specifies if that path should include the origin. This is necessary because Arista does not set the origin, and we would have to forcibly set the origin as openConfig.
func Join ¶
Join returns a new gNMI path with the elements of p1 and p2 concatenated. The origin and target of p1 are used, if present, and replaced with the values from p2 otherwise.
func LoadSubscribeResponse ¶
func LoadSubscribeResponse(path string) (*gnmipb.SubscribeResponse, error)
LoadSubscribeResponse loads a subscribe response from a file.
func MatchPath ¶
MatchPath returns true if path matches against the provided pattern. A wildcard character "*" in the pattern matches all path elements.
func MaybeConvertOptical ¶
MaybeConvertOptical returns the modified port name based on the optics type. Breakout child interfaces are ignored, as telemetry is provided through the parent interface. This is used by CISCOXR WBB devices when using the native path, which is of the form "Optics0/0/0/0" and the openconfig path is of the form "HundredGigE0/0/0/0", etc.
func MustStringMapPaths ¶
MustStringMapPaths converts each string in the slices, into a list of gnmi Paths. it fails if there is an error.
func PathInList ¶
PathInList returns True if the path is in the list of paths.
func SortByYgotString ¶
SortByYgotString returns a function to sort gnmi paths by their stringified value.
func StateLeaves ¶
StateLeaves returns true if one of the path elements has name "state".
func StringToPath ¶
StringToPath converts a string to a gNMI path, potentially including an origin. The string must be in the format "origin/path/to/element", "/origin/path/to/element", "path/to/element", or "/path/to/element". The origin is only parsed if it is in the ValidOrigins map.
func StripPathPrefix ¶
StripPathPrefix strips the prefix from the path.
Types ¶
type AristaMACSecMapCache ¶
type AristaMACSecMapCache struct {
// contains filtered or unexported fields
}
AristaMACSecMapCache is a thread-safe cache for AristaMACSecMap. It stores cached boolean values from distinct native Arista MACsec paths per target/interface/CKN. Although Functional Translators (FTs) are typically stateless, this map is required as an exception to hold values from these multiple source paths, necessary for deriving the single OpenConfig MACsec status. Declaring it here allows access by both the FT logic and the FT registration process, where it is cleared to prevent using stale information between registrations or updates.
func (*AristaMACSecMapCache) ClearAllTargetMacSecInfo ¶
func (c *AristaMACSecMapCache) ClearAllTargetMacSecInfo()
ClearAllTargetMacSecInfo removes all entries from the cache.
func (*AristaMACSecMapCache) CreateOrUpdateTargetMacSecInfo ¶
func (c *AristaMACSecMapCache) CreateOrUpdateTargetMacSecInfo(targetHostname string) *TargetMacSecInfo
CreateOrUpdateTargetMacSecInfo retrieves an existing TargetMacSecInfo for the given target or creates a new one if it doesn't exist, then stores it in the cache.
func (*AristaMACSecMapCache) DeleteTargetMacSecInfo ¶
func (c *AristaMACSecMapCache) DeleteTargetMacSecInfo(targetHostname string)
DeleteTargetMacSecInfo removes the TargetMacSecInfo for a given target hostname.
func (*AristaMACSecMapCache) RetrieveTargetMacSecInfo ¶
func (c *AristaMACSecMapCache) RetrieveTargetMacSecInfo(targetHostname string) (*TargetMacSecInfo, bool)
RetrieveTargetMacSecInfo fetches the TargetMacSecInfo for a given target hostname. It returns the info and a boolean indicating if the target was found.
func (*AristaMACSecMapCache) SetTargetMacSecInfo ¶
func (c *AristaMACSecMapCache) SetTargetMacSecInfo(targetHostname string, info *TargetMacSecInfo)
SetTargetMacSecInfo adds or updates the TargetMacSecInfo for a given target hostname.
type CKNInfo ¶
type CKNInfo struct {
// contains filtered or unexported fields
}
CKNInfo holds principal and success status for a specific CKN.
type InterfaceMacSecInfo ¶
type InterfaceMacSecInfo struct {
// contains filtered or unexported fields
}
InterfaceMacSecInfo holds MACsec status information for a specific interface.
func (*InterfaceMacSecInfo) CloneStatuses ¶
func (i *InterfaceMacSecInfo) CloneStatuses() map[string]*CKNInfo
CloneStatuses returns a copy of the CKN statuses map.
func (*InterfaceMacSecInfo) CreateOrGetCKN ¶
func (i *InterfaceMacSecInfo) CreateOrGetCKN(ckn string) *CKNInfo
CreateOrGetCKN returns the CKNInfo for the given CKN, creating it if it doesn't exist.
func (*InterfaceMacSecInfo) IntfCPStatus ¶
func (i *InterfaceMacSecInfo) IntfCPStatus() (bool, bool)
IntfCPStatus returns the cpStatus and a boolean indicating if it has been set.
func (*InterfaceMacSecInfo) IntfPrincipal ¶
func (i *InterfaceMacSecInfo) IntfPrincipal(ckn string) (bool, bool)
IntfPrincipal returns the principal status for a given CKN and a boolean indicating if it has been set.
func (*InterfaceMacSecInfo) IntfSuccess ¶
func (i *InterfaceMacSecInfo) IntfSuccess(ckn string) (bool, bool)
IntfSuccess returns the success status for a given CKN and a boolean indicating if it has been set.
func (*InterfaceMacSecInfo) IsComplete ¶
func (i *InterfaceMacSecInfo) IsComplete(ckn string) bool
IsComplete checks if all necessary MACsec CKN status values have been set.
func (*InterfaceMacSecInfo) RemoveCkn ¶
func (i *InterfaceMacSecInfo) RemoveCkn(ckn string)
RemoveCkn removes MACsec information for a specific CKN.
func (*InterfaceMacSecInfo) ResetCPStatus ¶
func (i *InterfaceMacSecInfo) ResetCPStatus()
ResetCPStatus marks the cpStatus as not set and resets its value. This is used when the native source for cpStatus is deleted.
func (*InterfaceMacSecInfo) SetIntfCPStatus ¶
func (i *InterfaceMacSecInfo) SetIntfCPStatus(b bool)
SetIntfCPStatus sets the cpStatus and marks it as set.
func (*InterfaceMacSecInfo) SetIntfPrincipal ¶
func (i *InterfaceMacSecInfo) SetIntfPrincipal(ckn string, b bool)
SetIntfPrincipal sets the principal status for a given CKN and marks it as set.
func (*InterfaceMacSecInfo) SetIntfSuccess ¶
func (i *InterfaceMacSecInfo) SetIntfSuccess(ckn string, b bool)
SetIntfSuccess sets the success status for a given CKN and marks it as set.
type MemberInterfaceInfo ¶
type MemberInterfaceInfo struct {
Queues map[string]*QueueCounters // map[QueueID]*QueueCounters
// contains filtered or unexported fields
}
MemberInterfaceInfo holds QoS queue information for a specific member interface.
func NewMemberInterfaceInfo ¶
func NewMemberInterfaceInfo(interfaceName string) *MemberInterfaceInfo
NewMemberInterfaceInfo creates a new MemberInterfaceInfo instance.
func (*MemberInterfaceInfo) CloneQueues ¶
func (m *MemberInterfaceInfo) CloneQueues() map[string]*QueueCounters
CloneQueues returns a copy of the Queues map.
func (*MemberInterfaceInfo) SetDroppedBytes ¶
func (m *MemberInterfaceInfo) SetDroppedBytes(queueID string, val uint64)
SetDroppedBytes sets the DroppedBytes counter for a given queue and marks it as set.
func (*MemberInterfaceInfo) SetDroppedPackets ¶
func (m *MemberInterfaceInfo) SetDroppedPackets(queueID string, val uint64)
SetDroppedPackets sets the DroppedPackets counter for a given queue and marks it as set.
func (*MemberInterfaceInfo) SetTxBytes ¶
func (m *MemberInterfaceInfo) SetTxBytes(queueID string, val uint64)
SetTxBytes sets the TxBytes counter for a given queue and marks it as set.
func (*MemberInterfaceInfo) SetTxPackets ¶
func (m *MemberInterfaceInfo) SetTxPackets(queueID string, val uint64)
SetTxPackets sets the TxPackets counter for a given queue and marks it as set.
type PortChannelInfo ¶
type PortChannelInfo struct {
Members map[string]*MemberInterfaceInfo // map[InterfaceName]*MemberInterfaceInfo
// contains filtered or unexported fields
}
PortChannelInfo holds QoS information for a specific port-channel, including all its member interfaces.
func (*PortChannelInfo) AddMemberInfo ¶
func (p *PortChannelInfo) AddMemberInfo(memberInfo *MemberInterfaceInfo)
AddMemberInfo adds a pre-existing MemberInterfaceInfo object to the PortChannel. This is used to move a member from the "waiting room" into the PortChannel.
func (*PortChannelInfo) ClearMemberInfo ¶
func (p *PortChannelInfo) ClearMemberInfo(intf string)
ClearMemberInfo removes QoS information for a specific member interface.
func (*PortChannelInfo) CloneMembers ¶
func (p *PortChannelInfo) CloneMembers() map[string]*MemberInterfaceInfo
CloneMembers returns a thread-safe copy of the Members map.
func (*PortChannelInfo) CreateOrRetrieveMember ¶
func (p *PortChannelInfo) CreateOrRetrieveMember(interfaceName string) *MemberInterfaceInfo
CreateOrRetrieveMember returns the MemberInterfaceInfo for the given interface name, creating it if it doesn't exist.
type QoSAggregationMapCache ¶
type QoSAggregationMapCache struct {
// contains filtered or unexported fields
}
QoSAggregationMapCache is a thread-safe cache for TargetQoSInfo. It stores cached QoS counter values from distinct OC paths per target/port-channel/interface/queue.
func (*QoSAggregationMapCache) ClearAllTargetQoSInfo ¶
func (c *QoSAggregationMapCache) ClearAllTargetQoSInfo()
ClearAllTargetQoSInfo removes all entries from the cache.
func (*QoSAggregationMapCache) CreateOrUpdateTargetQoSInfo ¶
func (c *QoSAggregationMapCache) CreateOrUpdateTargetQoSInfo(targetHostname string) *TargetQoSInfo
CreateOrUpdateTargetQoSInfo retrieves an existing TargetQoSInfo for the given target or creates a new one if it doesn't exist, then stores it in the cache.
func (*QoSAggregationMapCache) RetrieveTargetQoSInfo ¶
func (c *QoSAggregationMapCache) RetrieveTargetQoSInfo(targetHostname string) (*TargetQoSInfo, bool)
RetrieveTargetQoSInfo fetches the TargetQoSInfo for a given target hostname. It returns the info and a boolean indicating if the target was found.
type QueueCounters ¶
type QueueCounters struct {
TxPackets uint64
TxBytes uint64
DroppedPackets uint64
DroppedBytes uint64
TxPacketsSet bool
TxBytesSet bool
DroppedPacketsSet bool
DroppedBytesSet bool
}
QueueCounters holds the 4 counters for a specific QoS queue. It also tracks whether each counter has been explicitly set.
type TargetMacSecInfo ¶
type TargetMacSecInfo struct {
TargetHostname string
Interfaces map[string]*InterfaceMacSecInfo // map[InterfaceName]*InterfaceMacSecInfo
// contains filtered or unexported fields
}
TargetMacSecInfo holds MACsec information for all interfaces on a target.
func NewTargetMacSecInfo ¶
func NewTargetMacSecInfo(targetHostname string) *TargetMacSecInfo
NewTargetMacSecInfo creates a new TargetMacSecInfo for the given target hostname.
func (*TargetMacSecInfo) ClearInterfaceInfo ¶
func (t *TargetMacSecInfo) ClearInterfaceInfo(intf string)
ClearInterfaceInfo removes MACsec information for a specific interface.
func (*TargetMacSecInfo) CreateOrGetInterface ¶
func (t *TargetMacSecInfo) CreateOrGetInterface(interfaceName string) *InterfaceMacSecInfo
CreateOrGetInterface returns the InterfaceMacSecInfo for the given interface name, creating it if it doesn't exist. It also initializes the CKN statuses map if it doesn't exist.
func (*TargetMacSecInfo) InterfaceInfo ¶
func (t *TargetMacSecInfo) InterfaceInfo(intf string) (*InterfaceMacSecInfo, bool)
InterfaceInfo retrieves the MACsec info for a specific interface.
type TargetQoSInfo ¶
type TargetQoSInfo struct {
TargetHostname string
PortChannels map[string]*PortChannelInfo // map[PortChannelName]*PortChannelInfo
MemberToPCMap map[string]string // map[InterfaceName]PortChannelName
UnassociatedMembers map[string]*MemberInterfaceInfo // "Waiting room"
// contains filtered or unexported fields
}
TargetQoSInfo holds QoS information for all port-channels on a target.
func (*TargetQoSInfo) CreateOrRetrievePortChannel ¶
func (t *TargetQoSInfo) CreateOrRetrievePortChannel(pcName string) *PortChannelInfo
CreateOrRetrievePortChannel returns the PortChannelInfo for the given port-channel name, creating it if it doesn't exist.
func (*TargetQoSInfo) FindAndRemoveMember ¶
func (t *TargetQoSInfo) FindAndRemoveMember(memberName string) (string, bool)
FindAndRemoveMember finds a member, removes it from its old PortChannel's member list, and removes it from the reverse map. It returns the old Port-Channel name and true if found.
func (*TargetQoSInfo) PortChannelInfo ¶
func (t *TargetQoSInfo) PortChannelInfo(pcName string) (*PortChannelInfo, bool)
PortChannelInfo retrieves the QoS info for a specific port-channel.
func (*TargetQoSInfo) RetrievePortChannelForMember ¶
func (t *TargetQoSInfo) RetrievePortChannelForMember(memberName string) (string, bool)
RetrievePortChannelForMember returns the parent Port-Channel name for a member.
func (*TargetQoSInfo) SetPortChannelForMember ¶
func (t *TargetQoSInfo) SetPortChannelForMember(memberName, pcName string)
SetPortChannelForMember sets the parent Port-Channel for a member.