custom_validation

package
v0.0.0-...-562cd84 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_NONE   CVLOperation = 0      //Used to just validate the config without any operation
	OP_CREATE              = 1 << 0 //For Create operation
	OP_UPDATE              = 1 << 1 //For Update operation
	OP_DELETE              = 1 << 2 //For Delete operation
)
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 MAX_ACL_RULE_INSTANCES = 65536

Custom validation code for sonic-acl.yang// /////////////////////////////////////////// Path : /sonic-acl/ACL_RULE/ACL_RULE_LIST Purpose: Allow maximum 65536 ACL rules vc : Custom Validation Context Returns - CVL Error object

Variables

This section is empty.

Functions

This section is empty.

Types

type CVLEditConfigData

type CVLEditConfigData struct {
	VType CVLValidateType   //Validation type
	VOp   CVLOperation      //Operation type
	Key   string            //Key format : "PORT|Ethernet4"
	Data  map[string]string //Value :  {"alias": "40GE0/28", "mtu" : 9100,  "admin_status":  down}
}

Strcture for key and data in API

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
}

CVL Error Structure.

func InvokeCustomValidation

func InvokeCustomValidation(cv *CustomValidation, name string, args ...interface{}) CVLErrorInfo

Common function to invoke custom validation TBD should we do this using GO plugin feature ?

type CVLOperation

type CVLOperation uint

type CVLRetCode

type CVLRetCode int

Error code

type CVLValidateType

type CVLValidateType uint
const (
	VALIDATE_NONE      CVLValidateType = iota //Data is used as dependent data
	VALIDATE_SYNTAX                           //Syntax is checked and data is used as dependent data
	VALIDATE_SEMANTICS                        //Semantics is checked
	VALIDATE_ALL                              //Syntax and Semantics are checked
)

type CustValidationCache

type CustValidationCache struct {
	Data interface{}
}

type CustValidationCtxt

type CustValidationCtxt struct {
	ReqData   []CVLEditConfigData  //All request data
	CurCfg    *CVLEditConfigData   //Current request data for which validation should be done
	YNodeName string               //YANG node name
	YNodeVal  string               //YANG node value, leaf-list will have "," separated value
	YCur      *xmlquery.Node       //YANG data tree
	SessCache *CustValidationCache //Session cache, can be used for storing data, persistent in session
	RClient   *redis.Client        //Redis client
}

Custom validation context passed to custom validation function

type CustomValidation

type CustomValidation struct{}

func (*CustomValidation) ValidateAclRuleIPAddress

func (t *CustomValidation) ValidateAclRuleIPAddress(
	vc *CustValidationCtxt) CVLErrorInfo

Path : /sonic-acl/ACL_RULE/ACL_RULE_LIST/IP_TYPE Purpose: Check correct for IP address provided

based on type IP_TYPE

vc : Custom Validation Context Returns - CVL Error object

func (*CustomValidation) ValidateCollectorIp

func (t *CustomValidation) ValidateCollectorIp(vc *CustValidationCtxt) CVLErrorInfo

Validate ip address of sflow collector ip

func (*CustomValidation) ValidateIpv4UnnumIntf

func (t *CustomValidation) ValidateIpv4UnnumIntf(vc *CustValidationCtxt) CVLErrorInfo

Custom validation for Unnumbered interface

func (*CustomValidation) ValidateMaxAclRule

func (t *CustomValidation) ValidateMaxAclRule(
	vc *CustValidationCtxt) CVLErrorInfo

func (*CustomValidation) ValidatePtp

func (t *CustomValidation) ValidatePtp(
	vc *CustValidationCtxt) CVLErrorInfo

Path : /sonic-ptp/PTP_CLOCK Purpose: Check correct platform Returns - CVL Error object

func (*CustomValidation) ValidatePtpUnderlyingInterface

func (t *CustomValidation) ValidatePtpUnderlyingInterface(
	vc *CustValidationCtxt) CVLErrorInfo

Path : /sonic-ptp/PTP_PORT/PTP_PORT_LIST/underlying-interface Purpose: Check correct for correct agent_id vc : Custom Validation Context Returns - CVL Error object

func (*CustomValidation) ValidateSflowAgentId

func (t *CustomValidation) ValidateSflowAgentId(
	vc *CustValidationCtxt) CVLErrorInfo

Path : /sonic-sflow/SFLOW/SFLOW_LIST/agent_id Purpose: Check correct for correct agent_id vc : Custom Validation Context Returns - CVL Error object

func (*CustomValidation) ValidateTAMFeature

func (t *CustomValidation) ValidateTAMFeature(vc *CustValidationCtxt) CVLErrorInfo

Validate if feature is enabled for Broadview features

func (*CustomValidation) ValidateUniqueVNI

func (t *CustomValidation) ValidateUniqueVNI(vc *CustValidationCtxt) CVLErrorInfo

Validate unique vni across all vlan-vni mappings

func (*CustomValidation) ValidateUniqueVlan

func (t *CustomValidation) ValidateUniqueVlan(vc *CustValidationCtxt) CVLErrorInfo

Validate unique vlan across all vlan-vni mappings

func (*CustomValidation) ValidateVrfVNI

func (t *CustomValidation) ValidateVrfVNI(vc *CustValidationCtxt) CVLErrorInfo

Validate Vrf VNI mappings

func (*CustomValidation) ValidateVxlanMapDelete

func (t *CustomValidation) ValidateVxlanMapDelete(vc *CustValidationCtxt) CVLErrorInfo

Validate Vxlan Map entry delete

type VxlanMap

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

Jump to

Keyboard shortcuts

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