cvl

package
v0.0.0-...-8719034 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

README

  1. Install latest version of pyang tool.

  2. Install libyang from https://github.com/CESNET/libyang along with its dependency.

  3. Run 'make' from top level 'cvl' directory.

  4. Refer to top level makefile rules for compiling individual targets.

  5. 'schema' directory should contain all .yin files

  6. On the target the 'schema' directory needs to be present in the same directory where application executable file is present.

Debugging Info:

Below steps need to be done to enable CVL logging.

  1. Find the CVL json config file in mgmt-framework docker in switch at "/usr/sbin/cvl_cfg.json" .

  2. Change the logging flags from "false" to "true" as below:

	{
		"TRACE_CACHE": "true",
		"TRACE_LIBYANG": "true",
		"TRACE_YPARSER": "true",
		"TRACE_CREATE": "true",
		"TRACE_UPDATE": "true",
		"TRACE_DELETE": "true",
		"TRACE_SEMANTIC": "true",
		"TRACE_SYNTAX": "true",
		"TRACE_ONERROR": "true",
		"__comment1__": "Set LOGTOSTDER to 'true' to log on standard error",
		"LOGTOSTDERR": "false",
		"__comment2__": "Log messages to standard error at or above this severity level",
		"STDERRTHRESHOLD": "ERROR",
		"__comment3__": "Log to /tmp/cvl.log file",
		"LOG_TO_FILE": "true",
		"__comment4__": "Limit log file size in bytes, 0 means no limit, default 10MB",
		"LOG_FILE_SIZE": "10485760",
		"__comment5__": "Set verbosity level(1 to 8) for verbose logs",
		"VERBOSITY": "0",
		"SKIP_VALIDATION": "false",
		"SKIP_SEMANTIC_VALIDATION": "false"
	}
  1. Below environment variables need to be set at the end in /usr/bin/rest-server.sh in mgmt-framework docker.

    export CVL_DEBUG=1 export CVL_CFG_FILE=/usr/sbin/cvl_cfg.json

Note : CVL_CFG_FILE enviroment variable can point to other location also.

  1. CVL Traces can be enabled both with restart and without mgmt-framework docker restart .

    With Restart:

    Restart mgmt-framework docker after which updated cvl_cfg.json file will be read.

    Without Restart:

    Issue SIGUSR2 to rest process(kill -SIGUSR2 , to read changed cvl_cfg.json with logging enabled.

  2. After following above steps, CVL traces can be seen in syslog file in host container at /var/log/syslog.

  3. To disable CVL traces , disable the fields in cvl_cfg.json file and then perform same steps as in Step 4.

Documentation

Index

Constants

View Source
const (
	APPL_DB uint8 = 0 + iota
	ASIC_DB
	COUNTERS_DB
	LOGLEVEL_DB
	CONFIG_DB
	PFC_WD_DB
	FLEX_COUNTER_DB = PFC_WD_DB
	STATE_DB
	SNMP_OVERLAY_DB
	INVALID_DB
)

DB number

View Source
const (
	CVL_SUCCESS CVLRetCode = iota
	CVL_ERROR
	CVL_NOT_IMPLEMENTED
	CVL_INTERNAL_UNKNOWN
	CVL_FAILURE
	CVL_SYNTAX_ERROR                    = CVLRetCode(yparser.YP_SYNTAX_ERROR)
	CVL_SEMANTIC_ERROR                  = CVLRetCode(yparser.YP_SEMANTIC_ERROR)
	CVL_SYNTAX_MISSING_FIELD            = CVLRetCode(yparser.YP_SYNTAX_MISSING_FIELD)
	CVL_SYNTAX_INVALID_FIELD            = CVLRetCode(yparser.YP_SYNTAX_INVALID_FIELD)            /* Invalid Field  */
	CVL_SYNTAX_INVALID_INPUT_DATA       = CVLRetCode(yparser.YP_SYNTAX_INVALID_INPUT_DATA)       /*Invalid Input Data */
	CVL_SYNTAX_MULTIPLE_INSTANCE        = CVLRetCode(yparser.YP_SYNTAX_MULTIPLE_INSTANCE)        /* Multiple Field Instances */
	CVL_SYNTAX_DUPLICATE                = CVLRetCode(yparser.YP_SYNTAX_DUPLICATE)                /* Duplicate Fields  */
	CVL_SYNTAX_ENUM_INVALID             = CVLRetCode(yparser.YP_SYNTAX_ENUM_INVALID)             /* Invalid enum value */
	CVL_SYNTAX_ENUM_INVALID_NAME        = CVLRetCode(yparser.YP_SYNTAX_ENUM_INVALID_NAME)        /* Invalid enum name  */
	CVL_SYNTAX_ENUM_WHITESPACE          = CVLRetCode(yparser.YP_SYNTAX_ENUM_WHITESPACE)          /* Enum name with leading/trailing whitespaces */
	CVL_SYNTAX_OUT_OF_RANGE             = CVLRetCode(yparser.YP_SYNTAX_OUT_OF_RANGE)             /* Value out of range/length/pattern (data) */
	CVL_SYNTAX_MINIMUM_INVALID          = CVLRetCode(yparser.YP_SYNTAX_MINIMUM_INVALID)          /* min-elements constraint not honored  */
	CVL_SYNTAX_MAXIMUM_INVALID          = CVLRetCode(yparser.YP_SYNTAX_MAXIMUM_INVALID)          /* max-elements constraint not honored */
	CVL_SEMANTIC_DEPENDENT_DATA_MISSING = CVLRetCode(yparser.YP_SEMANTIC_DEPENDENT_DATA_MISSING) /* Dependent Data is missing */
	CVL_SEMANTIC_MANDATORY_DATA_MISSING = CVLRetCode(yparser.YP_SEMANTIC_MANDATORY_DATA_MISSING) /* Mandatory Data is missing */
	CVL_SEMANTIC_KEY_ALREADY_EXIST      = CVLRetCode(yparser.YP_SEMANTIC_KEY_ALREADY_EXIST)      /* Key already existing. */
	CVL_SEMANTIC_KEY_NOT_EXIST          = CVLRetCode(yparser.YP_SEMANTIC_KEY_NOT_EXIST)          /* Key is missing. */
	CVL_SEMANTIC_KEY_DUPLICATE          = CVLRetCode(yparser.YP_SEMANTIC_KEY_DUPLICATE)          /* Duplicate key. */
	CVL_SEMANTIC_KEY_INVALID            = CVLRetCode(yparser.YP_SEMANTIC_KEY_INVALID)
)
View Source
const DEFAULT_CACHE_DURATION uint16 = 300 /* 300 sec */
View Source
const MAX_BULK_ENTRIES_IN_PIPELINE int = 50
View Source
const MAX_DEVICE_METADATA_FETCH_RETRY = 60
View Source
const PLATFORM_SCHEMA_PATH = "platform/"

Variables

This section is empty.

Functions

func AddFormatterFunc

func AddFormatterFunc(s string, f Formatter) error

func CVL_LOG

func CVL_LOG(level CVLLogLevel, fmtStr string, args ...interface{})

func ClearValidationTimeStats

func ClearValidationTimeStats()

ClearValidationTimeStats Clear global stats

func CreateFindKeyExpression

func CreateFindKeyExpression(tableName string, keyFldValPair map[string]string) string

CreateFindKeyExpression Create expression for searching DB entries based on given key fields and values. Expressions created will be like CFG_L2MC_STATIC_MEMBER_TABLE|*|*|Ethernet0

func Debug

func Debug(on bool)

func Finish

func Finish()

func GetErrorString

func GetErrorString(retCode CVLRetCode) string

GetErrorString Fetch the Error Message from CVL Return Code.

func ReconfigureRedisOptions

func ReconfigureRedisOptions(opt redis.Options)

func RunLua

func RunLua(name string, args ...interface{}) (interface{}, error)

RunLua is a temporary API to run a named lua script in ConfigDb. Script name can be one of "count_entries" or "filter_entries". TODO move the script definitions to DBAL and remove this API

func SplitRedisKey

func SplitRedisKey(key string) (string, string)

func TRACE_LOG

func TRACE_LOG(tracelevel CVLTraceLevel, fmtStr string, args ...interface{})

func ValidationSessOpen

func ValidationSessOpen(dbAccess cmn.DBAccess) (*CVL, CVLRetCode)

Types

type CVL

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

CVL Struct for CVL session

func (*CVL) GetAllReferringTables

func (c *CVL) GetAllReferringTables(tableName string) map[string][]string

GetAllReferringTables Returns list of all tables and fields which has leaf-ref to given table. For ex. tableName="PORT" will return all tables and fields which has leaf-ref to "PORT" table.

func (*CVL) GetDepDataForDelete

func (c *CVL) GetDepDataForDelete(redisKey string) []CVLDepDataForDelete

GetDepDataForDelete Get the dependent (Redis keys) to be deleted or modified for a given entry getting deleted

func (*CVL) GetDepTables

func (c *CVL) GetDepTables(yangModule string, tableName string) ([]string, CVLRetCode)

GetDepTables Get the list of dependent tables for a given table in a YANG module

func (*CVL) GetOrderedDepTables

func (c *CVL) GetOrderedDepTables(yangModule, tableName string) ([]string, CVLRetCode)

func (*CVL) GetOrderedTables

func (c *CVL) GetOrderedTables(yangModule string) ([]string, CVLRetCode)

GetOrderedTables Get the order list(parent then child) of tables in a given YANG module within a single model this is obtained using leafref relation

func (*CVL) LoadHint

func (c *CVL) LoadHint(key string) (interface{}, bool)

LoadHint is used only for Go UT

func (*CVL) SortDepList

func (c *CVL) SortDepList(inTables []string) ([]string, CVLRetCode)

SortDepList Sort list of given tables as per their dependency, returns LIST names, useful for testing

func (*CVL) SortDepTables

func (c *CVL) SortDepTables(inTableList []string) ([]string, CVLRetCode)

SortDepTables Sort list of given tables as per their dependency

func (*CVL) StoreHint

func (c *CVL) StoreHint(key string, value interface{}) CVLRetCode

StoreHint saves hints which are passed to the Custom Validation Callbacks Caller guarantees that no other CRUD ops are in progress key == nil: Clear all Hints

func (*CVL) ValidateConfig

func (c *CVL) ValidateConfig(jsonData string) CVLRetCode

ValidateConfig Validate data for operation

func (*CVL) ValidateEditConfig

func (c *CVL) ValidateEditConfig(cfgData []cmn.CVLEditConfigData) (cvlErr CVLErrorInfo, ret CVLRetCode)

ValidateEditConfig Validate config data based on edit operation

func (*CVL) ValidateFields

func (c *CVL) ValidateFields(key string, field string, value string) CVLRetCode

ValidateFields Validate key, field and value

func (*CVL) ValidateIncrementalConfig

func (c *CVL) ValidateIncrementalConfig(jsonData string) CVLRetCode

ValidateIncrementalConfig Steps:

Check config data syntax
Fetch the depedent data
Merge config and dependent data
Finally validate

func (*CVL) ValidateKeyData

func (c *CVL) ValidateKeyData(key string, data string) CVLRetCode

ValidateKeyData Validate key and data

func (*CVL) ValidateKeys

func (c *CVL) ValidateKeys(key []string) CVLRetCode

ValidateKeys Validate key only

func (*CVL) ValidateStartupConfig

func (c *CVL) ValidateStartupConfig(jsonData string) CVLRetCode

type CVLDepDataForDelete

type CVLDepDataForDelete struct {
	RefKey string                       //Ref Key which is getting deleted
	Entry  map[string]map[string]string //Entry or field which should be deleted as a result
}

CVLDepDataForDelete Structure for dependent entry to be deleted

type CVLErrorInfo

type CVLErrorInfo struct {
	TableName        string     /* Table having error */
	ErrCode          CVLRetCode /* CVL Error return Code. */
	CVLErrDetails    string     /* CVL Error Message details. */
	Keys             []string   /* Keys of the Table having error. */
	Value            string     /* Field Value throwing error */
	Field            string     /* Field Name throwing error . */
	Msg              string     /* Detailed error message. */
	ConstraintErrMsg string     /* Constraint error message. */
	ErrAppTag        string
}

CVLErrorInfo Struct for CVL Error Info

func (CVLErrorInfo) Message

func (err CVLErrorInfo) Message() string

Message returns the user defined error message if it exists; an auto formatted message otherwise. It may not be suitable for end user consumption always.

func (CVLErrorInfo) String

func (err CVLErrorInfo) String() string

type CVLRetCode

type CVLRetCode int

CVLRetCode CVL Error codes

func Initialize

func Initialize() CVLRetCode

func ValidationSessClose

func ValidationSessClose(c *CVL) CVLRetCode

type DepDataCacheType

type DepDataCacheType map[string]interface{}

DepDataCacheType cache type for dependent data

type DepDataCallBack

type DepDataCallBack func(ctxt interface{}, redisKeys []string, redisKeyFilter, keyNames, pred, fields, count string) string

type DepDataCountCallBack

type DepDataCountCallBack func(ctxt interface{}, redisKeyFilter, keyNames, pred, field string) float64

type ValidationTimeStats

type ValidationTimeStats struct {
	Hits uint
	Time time.Duration
	Peak time.Duration
}

ValidationTimeStats CVL validations stats Maintain time stats for call to ValidateEditConfig(). Hits : Total number of times ValidateEditConfig() called Time : Total time spent in ValidateEditConfig() Peak : Highest time spent in ValidateEditConfig()

func GetValidationTimeStats

func GetValidationTimeStats() ValidationTimeStats

GetValidationTimeStats Retrieve global stats

type YValidator

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

YValidator YANG Validator used for external semantic validation including custom/platform validation

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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