translib

package
v0.0.0-...-f33ab34 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 33 Imported by: 4

Documentation

Index

Constants

View Source
const (
	TABLE_SEPARATOR          = "|"
	KEY_SEPARATOR            = "|"
	ACL_TABLE                = "ACL_TABLE"
	RULE_TABLE               = "ACL_RULE"
	ACL_TYPE                 = "type"
	ACL_DESCRIPTION          = "policy_desc"
	SONIC_ACL_TYPE_L2        = "L2"
	SONIC_ACL_TYPE_IPV4      = "L3"
	SONIC_ACL_TYPE_IPV6      = "L3V6"
	OPENCONFIG_ACL_TYPE_IPV4 = "ACL_IPV4"
	OPENCONFIG_ACL_TYPE_IPV6 = "ACL_IPV6"
	OPENCONFIG_ACL_TYPE_L2   = "ACL_L2"
	OC_ACL_APP_MODULE_NAME   = "/openconfig-acl:acl"
	OC_ACL_YANG_PATH_PREFIX  = "/device/acl"

	MIN_PRIORITY = 1
	MAX_PRIORITY = 65536
)
View Source
const (
	LLDP_REMOTE_CAP_ENABLED      = "lldp_rem_sys_cap_enabled"
	LLDP_REMOTE_SYS_NAME         = "lldp_rem_sys_name"
	LLDP_REMOTE_PORT_DESC        = "lldp_rem_port_desc"
	LLDP_REMOTE_CHASS_ID         = "lldp_rem_chassis_id"
	LLDP_REMOTE_CAP_SUPPORTED    = "lldp_rem_sys_cap_supported"
	LLDP_REMOTE_PORT_ID_SUBTYPE  = "lldp_rem_port_id_subtype"
	LLDP_REMOTE_SYS_DESC         = "lldp_rem_sys_desc"
	LLDP_REMOTE_REM_TIME         = "lldp_rem_time_mark"
	LLDP_REMOTE_PORT_ID          = "lldp_rem_port_id"
	LLDP_REMOTE_REM_ID           = "lldp_rem_index"
	LLDP_REMOTE_CHASS_ID_SUBTYPE = "lldp_rem_chassis_id_subtype"
	LLDP_REMOTE_MAN_ADDR         = "lldp_rem_man_addr"
)
View Source
const (
	GET = 1 + iota
	CREATE
	REPLACE
	UPDATE
	DELETE
)
View Source
const (
	// MinSubscribeInterval is the lowest sample subscription interval supported by the system.
	// Value is in seconds. This is also used as the default value if apps do not provide one
	// or returns a lower value.
	MinSubscribeInterval = apis.SAMPLE_NOTIFICATION_MIN_INTERVAL
)

Variables

Functions

func GetYangModuleSetID

func GetYangModuleSetID() string

GetYangModuleSetID returns the ietf-yang-library's module-set-id value.

func GetYangPath

func GetYangPath() string

GetYangPath returns directory containing yang files. Use transformer.YangPath for now.

func SetSchemaRootURL

func SetSchemaRootURL(url string)

SetSchemaRootURL sets root URL for yang file download URLs.

func Stream

func Stream(req SubscribeRequest) error

Stream function streams the value for requested paths through a queue. Unlike Get, this function can return smaller chunks of response separately. Individual chunks are packed in a SubscribeResponse object and pushed to the req.Q. Pushes a SubscribeResponse with SyncComplete=true after data are pushed. Function will block until all values are returned. This can be used for handling "Sample" subscriptions (NotificationType.Sample). Client should be authorized to perform "subscribe" operation.

func Subscribe

func Subscribe(req SubscribeRequest) error

Subscribe - Subscribes to the paths requested and sends notifications when the data changes in DB

Types

type AclApp

type AclApp struct {
	// contains filtered or unexported fields
}

type ActionRequest

type ActionRequest struct {
	Path          string
	Payload       []byte
	User          UserRoles
	AuthEnabled   bool
	ClientVersion Version
}

type ActionResponse

type ActionResponse struct {
	Payload []byte
	ErrSrc  ErrSource
}

func Action

func Action(req ActionRequest) (ActionResponse, error)

type Bits

type Bits = utils.Bits

Bits is a set of 8 bit flags.

type BulkRequest

type BulkRequest struct {
	DeleteRequest  []SetRequest
	ReplaceRequest []SetRequest
	UpdateRequest  []SetRequest
	CreateRequest  []SetRequest
	User           UserRoles
	AuthEnabled    bool
	ClientVersion  Version
}

type BulkResponse

type BulkResponse struct {
	DeleteResponse  []SetResponse
	ReplaceResponse []SetResponse
	UpdateResponse  []SetResponse
	CreateResponse  []SetResponse
}

func Bulk

func Bulk(req BulkRequest) (BulkResponse, error)

type CommonApp

type CommonApp struct {
	// contains filtered or unexported fields
}

type Counter

type Counter uint64

Counter is a monotonically increasing unsigned integer.

func (*Counter) Next

func (c *Counter) Next() uint64

Next increments the counter and returns the new value

type EepromDb

type EepromDb struct {
	Product_Name        string
	Part_Number         string
	Serial_Number       string
	Base_MAC_Address    string
	Manufacture_Date    string
	Device_Version      string
	Label_Revision      string
	Platform_Name       string
	ONIE_Version        string
	MAC_Addresses       int
	Manufacturer        string
	Manufacture_Country string
	Vendor_Name         string
	Diag_Version        string
	Service_Tag         string
	Vendor_Extension    string
	Magic_Number        int
	Card_Type           string
	Hardware_Version    string
	Software_Version    string
	Model_Name          string
}

* Structures to read syseeprom from redis-db

type ErrSource

type ErrSource int
const (
	ProtoErr ErrSource = iota
	AppErr
)

type GetRequest

type GetRequest struct {
	Path          string
	FmtType       TranslibFmtType
	User          UserRoles
	AuthEnabled   bool
	ClientVersion Version
	QueryParams   QueryParameters
	Ctxt          context.Context
}

type GetResponse

type GetResponse struct {
	Payload   []byte
	ValueTree ygot.ValidatedGoStruct
	ErrSrc    ErrSource
}

func Get

func Get(req GetRequest) (GetResponse, error)

Get - Gets data from the redis DB and converts it to northbound format

type IsSubscribePath

type IsSubscribePath struct {
	ID   uint32           // Path ID for correlating with IsSubscribeResponse
	Path string           // Subscribe path
	Mode NotificationType // Requested subscribe mode
}

type IsSubscribeRequest

type IsSubscribeRequest struct {
	Paths         []IsSubscribePath
	User          UserRoles
	AuthEnabled   bool
	ClientVersion Version
	Session       *SubscribeSession
}

type IsSubscribeResponse

type IsSubscribeResponse struct {
	ID                  uint32 // Path ID
	Path                string
	IsSubPath           bool // Subpath of the requested path
	IsOnChangeSupported bool
	IsWildcardSupported bool // true if wildcard keys are supported in the path
	MinInterval         int
	Err                 error
	PreferredType       NotificationType
}

func IsSubscribeSupported

func IsSubscribeSupported(req IsSubscribeRequest) ([]*IsSubscribeResponse, error)

IsSubscribeSupported - Check if subscribe is supported on the given paths

type ModelData

type ModelData struct {
	Name string
	Org  string
	Ver  string
}

func GetModels

func GetModels() ([]ModelData, error)

GetModels - Gets all the models supported by Translib

type NotificationType

type NotificationType int
const (
	TargetDefined NotificationType = iota
	Sample
	OnChange
)

func (NotificationType) String

func (nt NotificationType) String() string

type PathInfo

type PathInfo struct {
	Path     string
	Template string
	Vars     map[string]string
}

PathInfo structure contains parsed path information.

func NewPathInfo

func NewPathInfo(path string) *PathInfo

NewPathInfo parses given path string into a PathInfo structure.

func (*PathInfo) HasPrefix

func (p *PathInfo) HasPrefix(s string) bool

HasPrefix checks if this path template starts with given prefix.. Shorthand for strings.HasPrefix(p.Template, s)

func (*PathInfo) HasSuffix

func (p *PathInfo) HasSuffix(s string) bool

HasSuffix checks if this path template ends with given suffix.. Shorthand for strings.HasSuffix(p.Template, s)

func (*PathInfo) HasVar

func (p *PathInfo) HasVar(name string) bool

HasVar checks if the PathInfo contains given variable.

func (*PathInfo) IntVar

func (p *PathInfo) IntVar(name string) (int, error)

IntVar returns the value for a path variable as an int. Returns 0 if no such variable exists. Returns an error if the value is not an integer.

func (*PathInfo) StringVar

func (p *PathInfo) StringVar(name, defalt string) string

StringVar returns the string value for a path variable if it exists; otherwise returns the specified default value.

func (*PathInfo) Var

func (p *PathInfo) Var(name string) string

Var returns the string value for a path variable. Returns empty string if no such variable exists.

type PlatformApp

type PlatformApp struct {
	// contains filtered or unexported fields
}

type ProcessState

type ProcessState struct {
	Args              []string
	CpuUsageSystem    uint64
	CpuUsageUser      uint64
	CpuUtilization    uint8
	MemoryUsage       uint64
	MemoryUtilization uint8
	Name              string
	Pid               uint64
	StartTime         uint64
	Uptime            uint64
}

type QueryParameters

type QueryParameters struct {
	Depth   uint     // range 1 to 65535, default is <U+0093>0<U+0094> i.e. all
	Content string   // all, config, non-config(REST)/state(GNMI), operational(GNMI only)
	Fields  []string // list of fields from NBI
}

type SetRequest

type SetRequest struct {
	Path             string
	Payload          []byte
	User             UserRoles
	AuthEnabled      bool
	ClientVersion    Version
	DeleteEmptyEntry bool
}

type SetResponse

type SetResponse struct {
	ErrSrc ErrSource
	Err    error
}

func Create

func Create(req SetRequest) (SetResponse, error)

Create - Creates entries in the redis DB pertaining to the path and payload

func Delete

func Delete(req SetRequest) (SetResponse, error)

Delete - Deletes entries in the redis DB pertaining to the path

func Replace

func Replace(req SetRequest) (SetResponse, error)

Replace - Replaces entries in the redis DB pertaining to the path and payload

func Update

func Update(req SetRequest) (SetResponse, error)

Update - Updates entries in the redis DB pertaining to the path and payload

type SubscribeRequest

type SubscribeRequest struct {
	Paths         []string
	Q             *queue.PriorityQueue
	Stop          chan struct{}
	User          UserRoles
	AuthEnabled   bool
	ClientVersion Version
	Session       *SubscribeSession
}

SubscribeRequest holds the request data for Subscribe and Stream APIs.

type SubscribeResponse

type SubscribeResponse struct {
	Path         string
	Update       ygot.ValidatedGoStruct // updated values
	Delete       []string               // deleted paths - relative to Path
	Timestamp    int64
	SyncComplete bool
	IsTerminated bool
}

func (SubscribeResponse) Compare

func (val SubscribeResponse) Compare(other queue.Item) int

Compare - Implement Compare method for priority queue for SubscribeResponse struct

type SubscribeSession

type SubscribeSession struct {
	ID string // session id
	// contains filtered or unexported fields
}

SubscribeSession is used to share session data between subscription related APIs - IsSubscribeSupported, Subscribe and Stream.

func NewSubscribeSession

func NewSubscribeSession() *SubscribeSession

NewSubscribeSession creates a new SubscribeSession. Caller MUST close the session object through CloseSubscribeSession call at the end.

func (*SubscribeSession) Close

func (ss *SubscribeSession) Close()

Close a SubscribeSession and release all resources it held by it. API client MUST close the sessions it creates; and not reuse the session after closing.

type SysApp

type SysApp struct {
	// contains filtered or unexported fields
}

type TranslibFmtType

type TranslibFmtType int
const (
	TRANSLIB_FMT_IETF_JSON TranslibFmtType = iota
	TRANSLIB_FMT_YGOT
)

type UserRoles

type UserRoles struct {
	Name  string
	Roles []string
}

type Version

type Version struct {
	Major uint32 // Major version number
	Minor uint32 // Minor version number
	Patch uint32 // Patch number
}

Version represents the semantic version number in Major.Minor.Patch format.

func GetYangBaseVersion

func GetYangBaseVersion() Version

GetYangBaseVersion returns the base version or min version of yang APIs supported by this server.

func GetYangBundleVersion

func GetYangBundleVersion() Version

GetYangBundleVersion returns the API version for yang bundle hosted on this server.

func NewVersion

func NewVersion(s string) (Version, error)

NewVersion creates a Version object from given version string

func (*Version) GetCompatibleBaseVersion

func (v *Version) GetCompatibleBaseVersion() Version

GetCompatibleBaseVersion returns the compatible base version for current version.

func (*Version) GreaterThan

func (v *Version) GreaterThan(other Version) bool

GreaterThan checks if the Version v is more than another version

func (*Version) IsNull

func (v *Version) IsNull() bool

IsNull checks if the version v is a null version (0.0.0)

func (*Version) Set

func (v *Version) Set(s string) error

Set parses a version string in X.Y.Z into a Version object v.

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
Config Session
Config Session
db
Package db implements a wrapper over the go-redis/redis.
Package db implements a wrapper over the go-redis/redis.
internal
Package path defines utilities to operate on translib path.
Package path defines utilities to operate on translib path.
Package tlerr defines the errors of the translib library.
Package tlerr defines the errors of the translib library.

Jump to

Keyboard shortcuts

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