Documentation ¶
Index ¶
- Constants
- Variables
- func AddModelCpbltInfo() map[string]*mdlInfo
- func CallRpcMethod(path string, body []byte, dbs [db.MaxDB]*db.DB) ([]byte, error)
- func DbToYangType(yngTerminalNdDtType yang.TypeKind, fldXpath string, dbFldVal string, ...) (interface{}, interface{}, error)
- func DbValToInt(dbFldVal string, base int, size int, isUint bool) (interface{}, error)
- func GetAndXlateFromDB(uri string, ygRoot *ygot.GoStruct, dbs [db.MaxDB]*db.DB, txCache interface{}, ...) ([]byte, bool, error)
- func GetModuleNmFromPath(uri string) (string, error)
- func GetOrdTblList(xfmrTbl string, uriModuleNm string) []string
- func GetTablesToWatch(xfmrTblList []string, uriModuleNm string) []string
- func GetXfmrOrdTblList(xfmrTbl string) []string
- func IsLeafListNode(uri string) bool
- func IsLeafNode(uri string) bool
- func IsListNode(uri string) bool
- func IsTerminalNode(uri string) (bool, error)
- func IsXlateFuncBinded(name string) bool
- func NewSubscribeNotfRespXlator(ctxID interface{}, gPath *gnmi.Path, dbNum db.DBNum, table *db.TableSpec, ...) (*subscribeNotfRespXlator, error)
- func NewSubscribeReqXlator(subReqId interface{}, reqUri string, reqMode NotificationType, ...) (*subscribeReqXlator, error)
- func SonicUriHasSingletonContainer(uri string) bool
- func SortSncTableDbKeys(tableName string, dbKeyMap map[string]db.Value) []string
- func SplitPath(path string) []string
- func TraverseDb(dbs [db.MaxDB]*db.DB, spec KeySpec, ...) error
- func XfmrRemoveXPATHPredicates(uri string) (string, []string, error)
- func XlateFromDb(uri string, ygRoot *ygot.GoStruct, dbs [db.MaxDB]*db.DB, data RedisDbMap, ...) ([]byte, bool, error)
- func XlateFuncBind(name string, fn interface{}) (err error)
- func XlateFuncCall(name string, params ...interface{}) (result []reflect.Value, err error)
- func XlateToDb(path string, oper int, d *db.DB, yg *ygot.GoStruct, yt *interface{}, ...) (map[Operation]RedisDbMap, map[string]map[string]db.Value, ...)
- func XlateUriToKeySpec(uri string, requestUri string, ygRoot *ygot.GoStruct, t *interface{}, ...) (*[]KeySpec, error)
- type ContentType
- type DBKeyYgNodeInfo
- type DbFldYgPathInfo
- type DbToYangXfmrInputArgs
- type DbYangKeyResolver
- type DbYgXlateInfo
- type FieldXfmrDbtoYang
- type FieldXfmrYangToDb
- type HostResult
- type KeySpec
- type KeyXfmrDbToYang
- type KeyXfmrYangToDb
- type ModProfile
- type NotificationType
- type OnchangeMode
- type Operation
- type PathInfo
- type PathXfmrDbToYangFunc
- type PostXfmrFunc
- type PreXfmrFunc
- type PruneQPStats
- type QueryParams
- type RedisDbMap
- type RedisDbSubscribeMap
- type RedisDbYgNodeMap
- type RpcCallpoint
- type Sflow
- type SflowCol
- type SflowIntf
- type SonicKeyXfmrDbToYang
- type SonicXfmrParams
- type SubTreeXfmrDbToYang
- type SubTreeXfmrSubscribe
- type SubTreeXfmrYangToDb
- type SubscProcType
- type TableXfmrFunc
- type ValidateCallpoint
- type ValueXfmrFunc
- type XfmrDbParams
- type XfmrDbTblCbkMethod
- type XfmrDbTblCbkParams
- type XfmrDbToYgPathParams
- type XfmrInterface
- type XfmrParams
- type XfmrSubscInParams
- type XfmrSubscOutParams
- type XfmrSubscribePathXlateInfo
- type XfmrSubscribeReqXlateInfo
- type XfmrTranslateSubscribeInfo
Constants ¶
const ( TARGET_NODE xlateNodeType = 1 + iota CHILD_NODE )
const ( XPATH_SEP_FWD_SLASH = "/" XFMR_EMPTY_STRING = "" XFMR_NONE_STRING = "NONE" SONIC_TABLE_INDEX = 2 SONIC_TBL_CHILD_INDEX = 3 SONIC_FIELD_INDEX = 4 SONIC_NESTEDLIST_FIELD_INDEX = 5 SONIC_TOPCONTR_INDEX = 1 SONIC_MDL_PFX = "sonic" OC_MDL_PFX = "openconfig-" IETF_MDL_PFX = "ietf-" IANA_MDL_PFX = "iana-" PATH_XFMR_RET_ARGS = 1 PATH_XFMR_RET_ERR_INDX = 0 YANG_CONTAINER_NM_CONFIG = "config" CONFIG_CNT_SUFFIXED_XPATH = "/config" STATE_CNT_SUFFIXED_XPATH = "/state" CONFIG_CNT_WITHIN_XPATH = "/config/" STATE_CNT_WITHIN_XPATH = "/state/" )
const ( YANG_MODULE yangElementType = iota + 1 YANG_LIST YANG_CONTAINER YANG_LEAF YANG_LEAF_LIST YANG_CHOICE YANG_CASE YANG_RPC YANG_NOTIF )
const ( XFMR_INVALID = iota - 1 XFMR_DISABLE XFMR_ENABLE XFMR_DEFAULT_ENABLE )
const ( QUERY_CONTENT_MISMATCH_ERR = "Query Parameter Content mismatch" QUERY_PARAMETER_SBT_PRUNING_ERR = "Query Parameter processing unsuccessful" )
const ( /* sFlow tables */ SFLOW_GLOBAL_TBL = "SFLOW" SFLOW_COL_TBL = "SFLOW_COLLECTOR" SFLOW_SESS_TBL = "SFLOW_SESSION_TABLE" /* Session table in ApplDb */ SFLOW_INTF_TBL = "SFLOW_SESSION" /* Session table in ConfigDb */ /* sFlow keys */ SFLOW_GLOBAL_KEY = "global" SFLOW_ADMIN_KEY = "admin_state" SFLOW_POLLING_INT_KEY = "polling_interval" SFLOW_SAMPL_RATE_KEY = "sample_rate" SFLOW_AGENT_KEY = "agent_id" SFLOW_INTF_NAME_KEY = "name" SFLOW_COL_IP_KEY = "collector_ip" SFLOW_COL_PORT_KEY = "collector_port" SFLOW_COL_VRF_KEY = "collector_vrf" /* sFlow default values */ DEFAULT_POLLING_INT = 20 DEFAULT_AGENT = "default" DEFAULT_VRF_NAME = "default" DEFAULT_COL_PORT = "6343" /* sFlow URIs */ SAMPLING = "/openconfig-sampling-sflow:sampling" SAMPLING_SFLOW = "/openconfig-sampling-sflow:sampling/sflow" SAMPLING_SFLOW_CONFIG = "/openconfig-sampling-sflow:sampling/sflow/config" SAMPLING_SFLOW_CONFIG_ENABLED = "/openconfig-sampling-sflow:sampling/sflow/config/enabled" SAMPLING_SFLOW_CONFIG_POLLING_INT = "/openconfig-sampling-sflow:sampling/sflow/config/polling-interval" SAMPLING_SFLOW_CONFIG_AGENT = "/openconfig-sampling-sflow:sampling/sflow/config/agent" SAMPLING_SFLOW_STATE = "/openconfig-sampling-sflow:sampling/sflow/state" SAMPLING_SFLOW_STATE_ENABLED = "/openconfig-sampling-sflow:sampling/sflow/state/enabled" SAMPLING_SFLOW_STATE_POLLING_INT = "/openconfig-sampling-sflow:sampling/sflow/state/polling-interval" SAMPLING_SFLOW_STATE_AGENT = "/openconfig-sampling-sflow:sampling/sflow/state/agent" SAMPLING_SFLOW_COLS = "/openconfig-sampling-sflow:sampling/sflow/collectors" SAMPLING_SFLOW_COLS_COL = "/openconfig-sampling-sflow:sampling/sflow/collectors/collector" SAMPLING_SFLOW_COLS_COL_CONFIG = "/openconfig-sampling-sflow:sampling/sflow/collectors/collector/config" SAMPLING_SFLOW_COLS_COL_STATE = "/openconfig-sampling-sflow:sampling/sflow/collectors/collector/state" SAMPLING_SFLOW_INTFS = "/openconfig-sampling-sflow:sampling/sflow/interfaces" SAMPLING_SFLOW_INTFS_INTF = "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface" SAMPLING_SFLOW_INTFS_INTF_CONFIG = "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface/config" SAMPLING_SFLOW_INTFS_INTF_CONFIG_SAMPL_RATE = "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface/config/sampling-rate" SAMPLING_SFLOW_INTFS_INTF_CONFIG_ENABLED = "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface/config/enabled" SAMPLING_SFLOW_INTFS_INTF_STATE = "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface/state" /* IPv4/v6 localhost address */ IPV4_LOCALHOST = "127.0.0.1" IPV6_LOCALHOST = "::1" )
const DEL_AS_UPDATE = "@DEL_AS_UPDATE"
const FIELD_CURSOR = "@FIELD_CURSOR"
const KEY_COMP_CNT = "@KEY_COMP_CNT"
KEY_COMP_CNT - To specify the number of key components for the given key in the RedisDbSubscribeMap map
Variables ¶
var (
ErrParamsNotAdapted = errors.New("The number of params is not adapted.")
)
var ModelsListFile = "models_list"
var TblInfoJsonFile = "sonic_table_info.json"
var XlateFuncs = make(map[string]reflect.Value)
var YangPath = "/usr/models/yang/" // OpenConfig-*.yang and sonic yang models path
Functions ¶
func AddModelCpbltInfo ¶
func AddModelCpbltInfo() map[string]*mdlInfo
func CallRpcMethod ¶
func DbToYangType ¶
func DbValToInt ¶
func GetAndXlateFromDB ¶
func GetModuleNmFromPath ¶
func GetOrdTblList ¶
func GetTablesToWatch ¶
func GetXfmrOrdTblList ¶
func IsLeafListNode ¶
func IsLeafNode ¶
func IsListNode ¶
func IsTerminalNode ¶
func IsXlateFuncBinded ¶
func NewSubscribeReqXlator ¶
func SortSncTableDbKeys ¶
func TraverseDb ¶
func XlateFromDb ¶
func XlateFuncBind ¶
func XlateFuncCall ¶
func XlateUriToKeySpec ¶
Types ¶
type ContentType ¶
type ContentType uint8
const ( QUERY_CONTENT_ALL ContentType = iota QUERY_CONTENT_CONFIG QUERY_CONTENT_NONCONFIG QUERY_CONTENT_OPERATIONAL )
func (ContentType) String ¶
func (ct ContentType) String() string
type DBKeyYgNodeInfo ¶
type DBKeyYgNodeInfo struct {
// contains filtered or unexported fields
}
DBKeyYgNodeInfo holds yang node info for a db key. Can be used as value in RedisDbYgNodeMap.
type DbFldYgPathInfo ¶
type DbToYangXfmrInputArgs ¶
type DbYangKeyResolver ¶
type DbYangKeyResolver struct {
// contains filtered or unexported fields
}
type DbYgXlateInfo ¶
type DbYgXlateInfo struct {
// contains filtered or unexported fields
}
type FieldXfmrDbtoYang ¶
type FieldXfmrDbtoYang func(inParams XfmrParams) (map[string]interface{}, error)
FieldXfmrDbtoYang type is defined to use for conversion of DB field to Yang field Transformer function definition. Param: XfmrParams structure having Database info, operation, DB data in multidimensional map, output param YgotRoot Return: error
type FieldXfmrYangToDb ¶
type FieldXfmrYangToDb func(inParams XfmrParams) (map[string]string, error)
FieldXfmrYangToDb type is defined to use for conversion of yang Field to DB field Transformer function definition. Param: Database info, YgotRoot, operation, Xpath Return: multi dimensional map to hold the DB data, error
type HostResult ¶
type HostResult struct { Body []interface{} Err error }
HostResult contains the body of the response and the error if any, when the endpoint finishes servicing the D-Bus request.
func HostQuery ¶
func HostQuery(endpoint string, args ...interface{}) (result HostResult)
HostQuery calls the corresponding D-Bus endpoint on the host and returns any error and response body
type KeyXfmrDbToYang ¶
type KeyXfmrDbToYang func(inParams XfmrParams) (map[string]interface{}, error)
KeyXfmrDbToYang type is defined to use for conversion of DB key to Yang key, Transformer function definition. Param: XfmrParams structure having Database info, operation, Database keys to access db entry Return: multi dimensional map to hold the yang key attributes of complete xpath, error */
type KeyXfmrYangToDb ¶
type KeyXfmrYangToDb func(inParams XfmrParams) (string, error)
KeyXfmrYangToDb type is defined to use for conversion of Yang key to DB Key, Transformer function definition. Param: XfmrParams structure having Database info, YgotRoot, operation, Xpath Return: Database keys to access db entry, error
type ModProfile ¶
type ModProfile map[string]interface{}
type NotificationType ¶
type NotificationType int
const ( TargetDefined NotificationType = iota Sample OnChange )
type OnchangeMode ¶
type OnchangeMode int
const ( OnchangeDefault OnchangeMode = iota OnchangeEnable OnchangeDisable )
type PathInfo ¶
PathInfo structure contains parsed path information.
func NewPathInfo ¶
NewPathInfo parses given path string into a PathInfo structure.
func (*PathInfo) HasWildcard ¶
HasWildcard checks if the path contains wildcard variable "*".
type PathXfmrDbToYangFunc ¶
type PathXfmrDbToYangFunc func(params XfmrDbToYgPathParams) error
PathXfmrDbToYangFunc type is defined to convert the given db table key into the yang key for all the list node in the given yang URI path. ygPathKeys map will be used to store the yang key as value in the map for each yang key leaf node path of the given yang URI. Param : XfmrDbToYgPathParams structure has current yang uri path, subscribe path, table name, table key, db pointer slice, current db pointer, db number, map to hold path and yang keys Return: error
var DbToYangPath_sflow_collector_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { log.V(3).Info("DbToYangPath_sflow_collector fmr: tbl:", params.tblName) sflowCollRoot := "/openconfig-sampling-sflow:sampling/sflow/collectors/collector" if params.tblName != SFLOW_COL_TBL { oper_err := errors.New("wrong config DB table sent") log.Errorf("Sflow collector Path-xfmr: table name %s not in sflow view", params.tblName) return oper_err } else { if len(params.tblKeyComp) > 0 { key_parts := strings.Split(params.tblKeyComp[0], "_") if len(key_parts) != 3 { oper_err := errors.New("Invalid key " + params.tblKeyComp[0]) log.Errorf("sflow_collector_path_xfmr: Invalid Key %s", params.tblKeyComp[0]) return oper_err } params.ygPathKeys[sflowCollRoot+"/address"] = key_parts[0] params.ygPathKeys[sflowCollRoot+"/port"] = key_parts[1] params.ygPathKeys[sflowCollRoot+"/network-instance"] = key_parts[2] } else { oper_err := errors.New("Missing DB key.") log.Errorf("Missing DB Key") return oper_err } } log.V(3).Info("DbToYangPath sflow_collector ygPathKeys: ", params.ygPathKeys) return nil }
var DbToYangPath_sflow_interface_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { log.V(3).Info("DbToYangPath_sflow_interface fmr: tbl:", params.tblName) sflowCollRoot := "/openconfig-sampling-sflow:sampling/sflow/interfaces/interface" if params.tblName != SFLOW_SESS_TBL { oper_err := errors.New("wrong config DB table sent") log.Errorf("Sflow interface Path-xfmr: table name %s not in sflow view", params.tblName) return oper_err } else { if len(params.tblKeyComp) > 0 { params.ygPathKeys[sflowCollRoot+"/name"] = params.tblKeyComp[0] } else { oper_err := errors.New("Missing DB key.") log.Errorf("Missing DB Key") return oper_err } } log.V(3).Info("DbToYangPath sflow_interface ygPathKeys: ", params.ygPathKeys) return nil }
type PostXfmrFunc ¶
PostXfmrFunc type is defined to use for handling any default handling operations required as part of the CREATE Transformer function definition. Param: XfmrParams structure having database pointers, current db, operation, DB data in multidimensional map, YgotRoot, uri Return: Multi dimensional map to hold the DB data Map (tblName, key and Fields), error
type PreXfmrFunc ¶
type PreXfmrFunc func(inParams XfmrParams) error
PreXfmrFunc type is defined to use for handling any default handling operations required as part of the CREATE, UPDATE, REPLACE, DELETE & GET Transformer function definition. Param: XfmrParams structure having database pointers, current db, operation, DB data in multidimensional map, YgotRoot, uri Return: error
type PruneQPStats ¶
type PruneQPStats struct { Hits uint `json:"hits"` Time time.Duration `json:"total-time"` Peak time.Duration `json:"peak-time"` Last time.Duration `json:"last-time"` PeakUri string `json:"peak-uri"` LastUri string `json:"last-uri"` }
func GetPruneQPStats ¶
func GetPruneQPStats() *PruneQPStats
func (*PruneQPStats) ClearPruneQPStats ¶
func (pqps *PruneQPStats) ClearPruneQPStats()
func (*PruneQPStats) String ¶
func (pqps *PruneQPStats) String() string
type QueryParams ¶
type QueryParams struct {
// contains filtered or unexported fields
}
func NewQueryParams ¶
func NewQueryParams(depth uint, content string, fields []string) (QueryParams, error)
func (*QueryParams) IsContentEnabled ¶
func (qp *QueryParams) IsContentEnabled() bool
func (*QueryParams) IsEnabled ¶
func (qp *QueryParams) IsEnabled() bool
IsEnabled : Exported version. translib.common_app needs this.
func (QueryParams) String ¶
func (qp QueryParams) String() string
type RedisDbSubscribeMap ¶
type RpcCallpoint ¶
RpcCallpoint is used to invoke a callback for action Param : []byte input payload, dbi indices Return : []byte output payload, error
type SonicKeyXfmrDbToYang ¶
type SonicKeyXfmrDbToYang func(inParams SonicXfmrParams) (map[string]interface{}, error)
SonicKeyXfmrDbToYang type is defined to use for conversion of DB key to Yang key, Transformer function definition. Param: SonicXfmrParams structure having DB number, table, key and xpath Return: multi dimensional map to hold the yang key attributes, error */
type SonicXfmrParams ¶
type SonicXfmrParams struct {
// contains filtered or unexported fields
}
SonicXfmrParams represents input parameters for key-transformer on sonic-yang
func (SonicXfmrParams) String ¶
func (inPm SonicXfmrParams) String() string
type SubTreeXfmrDbToYang ¶
type SubTreeXfmrDbToYang func(inParams XfmrParams) error
SubTreeXfmrDbToYang type is defined to use for handling the DB to Yang subtree Transformer function definition. Param : XfmrParams structure having Database pointers, current db, operation, DB data in multidimensional map, output param YgotRoot, uri Return : error
var DbToYang_sflow_collector_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { pathInfo := NewPathInfo(inParams.uri) log.V(3).Infof("Received GET for sFlow Collector path: %s, vars: %v", pathInfo.Path, pathInfo.Vars) log.V(3).Info("inParams.Uri:", inParams.requestUri) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) return getSflowCol(getSflowRootObject(inParams.ygRoot), targetUriPath, inParams.uri, inParams.dbs[db.ConfigDB]) }
var DbToYang_sflow_interface_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { pathInfo := NewPathInfo(inParams.uri) log.V(3).Infof("Received GET for sFlow Interface path: %s, vars: %v", pathInfo.Path, pathInfo.Vars) log.V(3).Info("inParams.Uri:", inParams.requestUri) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) return getSflowIntf(getSflowRootObject(inParams.ygRoot), targetUriPath, inParams.uri, inParams.dbs[db.ApplDB]) }
var DbToYang_sflow_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { pathInfo := NewPathInfo(inParams.uri) log.V(3).Infof("Received GET for sFlow path: %s, vars: %v", pathInfo.Path, pathInfo.Vars) log.V(3).Info("inParams.Uri:", inParams.requestUri) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) return getSflow(getSflowRootObject(inParams.ygRoot), targetUriPath, inParams.uri, inParams.dbs[:]) }
type SubTreeXfmrSubscribe ¶
type SubTreeXfmrSubscribe func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error)
SubTreeXfmrSubscribe type is defined to use for handling subscribe(translateSubscribe & processSubscribe) subtree Transformer function definition. Param : XfmrSubscInParams structure having uri, database pointers, subcribe process(translate/processSusbscribe), DB data in multidimensional map Return : XfmrSubscOutParams structure (db data in multiD map, needCache, pType, onChange, minInterval), error
var Subscribe_sflow_collector_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams result.dbDataMap = make(RedisDbSubscribeMap) pathInfo := NewPathInfo(inParams.uri) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.uri) log.V(3).Infof("Subscribe_sflow_collector_xfmr: pathInfo %v targetUri %v ", pathInfo, targetUriPath) ip := pathInfo.Var("address") if ip == "" { ip = "*" } port := pathInfo.Var("port") if port == "" { port = "*" } vrf := pathInfo.Var("network-instance") if vrf == "" { vrf = "*" } var name string if ip == "*" && port == "*" && vrf == "*" { name = "*" } else { name = ip + "_" + port + "_" + vrf } log.V(3).Infof("Subscribe_sflow_collector_xfmr: key %s", name) result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: {SFLOW_COL_TBL: {name: { "collector_ip": "address", "collector_port": "port", "collector_vrf": "network-instance"}}}} return result, err }
var Subscribe_sflow_interface_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams result.dbDataMap = make(RedisDbSubscribeMap) key := NewPathInfo(inParams.uri).Var("name") if key == "" { key = "*" } log.V(3).Infof("XfmrSubscribe_sflow_interface_xfmr key %s ", key) result.dbDataMap = RedisDbSubscribeMap{db.ApplDB: {SFLOW_SESS_TBL: {key: { "ifname": "name", "admin_state": "enabled", "sample_rate": "sampling-rate"}}}} return result, err }
var Subscribe_sflow_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams if inParams.subscProc != TRANSLATE_SUBSCRIBE { result.isVirtualTbl = true log.V(3).Info("Subscribe_sflow_xfmr :- result. isVirtualTbl: ", result.isVirtualTbl) return result, nil } result.dbDataMap = make(RedisDbSubscribeMap) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.uri) log.V(3).Infof("Subscribe_sflow_xfmr: targetUri %v ", targetUriPath) if targetUriPath == SAMPLING_SFLOW || targetUriPath == SAMPLING_SFLOW_CONFIG || targetUriPath == SAMPLING_SFLOW_STATE { result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: {SFLOW_GLOBAL_TBL: { SFLOW_GLOBAL_KEY: {"admin_state": "enabled", "polling_interval": "polling-interval", "agent_id": "agent"}}}} result.onChange = OnchangeEnable result.nOpts = ¬ificationOpts{} result.nOpts.pType = OnChange result.isVirtualTbl = false } return result, err }
type SubTreeXfmrYangToDb ¶
SubTreeXfmrYangToDb type is defined to use for handling the yang subtree to DB Transformer function definition. Param: XfmrParams structure having Database info, YgotRoot, operation, Xpath Return: multi dimensional map to hold the DB data, error
var YangToDb_sflow_collector_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error res_map := make(map[string]map[string]db.Value) log.V(3).Info("sFlow Collector YangToDBSubTreeXfmr: ", inParams.uri) col_map := make(map[string]db.Value) sflowObj := getSflowRootObject(inParams.ygRoot) key := makeColKey(inParams.uri) if inParams.oper == DELETE { if key != "" { col_map[key] = db.Value{Field: make(map[string]string)} } res_map[SFLOW_COL_TBL] = col_map return res_map, err } if key != "" { ip := NewPathInfo(inParams.uri).Var("address") port := NewPathInfo(inParams.uri).Var("port") vrf := NewPathInfo(inParams.uri).Var("network-instance") col_map[key] = db.Value{Field: make(map[string]string)} col_map[key].Field[SFLOW_COL_IP_KEY] = ip col_map[key].Field[SFLOW_COL_PORT_KEY] = port col_map[key].Field[SFLOW_COL_VRF_KEY] = vrf } else { for col := range sflowObj.Sflow.Collectors.Collector { port := strconv.FormatUint(uint64(col.Port), 10) key = col.Address + "_" + port + "_" + col.NetworkInstance col_map[key] = db.Value{Field: make(map[string]string)} col_map[key].Field[SFLOW_COL_IP_KEY] = col.Address col_map[key].Field[SFLOW_COL_PORT_KEY] = port col_map[key].Field[SFLOW_COL_VRF_KEY] = col.NetworkInstance } } res_map[SFLOW_COL_TBL] = col_map return res_map, err }
var YangToDb_sflow_interface_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error res_map := make(map[string]map[string]db.Value) log.V(3).Info("sFlow Interface YangToDBSubTreeXfmr: ", inParams.uri) intf_map := make(map[string]db.Value) sflowObj := getSflowRootObject(inParams.ygRoot) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) log.V(3).Infof("Subscribe_sflow_xfmr: targetUri %v ", targetUriPath) if inParams.oper == DELETE { if !strings.Contains(targetUriPath, SAMPLING_SFLOW_INTFS_INTF) { return res_map, tlerr.NotSupportedError{Format: "DELETE not supported", Path: targetUriPath} } name := NewPathInfo(inParams.uri).Var("name") if name == "" { return res_map, tlerr.InvalidArgs("Missing interface name") } intf_map[name] = db.Value{Field: make(map[string]string)} switch targetUriPath { case SAMPLING_SFLOW_INTFS_INTF_CONFIG_SAMPL_RATE: intf_map[name].Field[SFLOW_SAMPL_RATE_KEY] = "" case SAMPLING_SFLOW_INTFS_INTF_CONFIG_ENABLED: intf_map[name].Field[SFLOW_ADMIN_KEY] = "" case SAMPLING_SFLOW_INTFS_INTF: default: return res_map, errors.New("DELETE not supported on attribute or container") } } else { for _, intf := range sflowObj.Sflow.Interfaces.Interface { if intf.Name == nil { return res_map, errors.New("sFlow Interface: No interface name") } if intf.Config == nil { log.V(3).Infof("sFlow Inteface: No configuration") continue } name := *(intf.Name) intf_map[name] = db.Value{Field: make(map[string]string)} if intf.Config.Enabled != nil { if *(intf.Config.Enabled) { intf_map[name].Field[SFLOW_ADMIN_KEY] = "up" } else { intf_map[name].Field[SFLOW_ADMIN_KEY] = "down" } } if intf.Config.SamplingRate != nil { intf_map[name].Field[SFLOW_SAMPL_RATE_KEY] = strconv.FormatUint(uint64(*(intf.Config.SamplingRate)), 10) } } } res_map[SFLOW_INTF_TBL] = intf_map return res_map, err }
var YangToDb_sflow_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error res_map := make(map[string]map[string]db.Value) log.V(3).Info("sFlow SubTreeXfmr: ", inParams.uri) global_map := make(map[string]db.Value) sflowObj := getSflowRootObject(inParams.ygRoot) targetUriPath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) global_map[SFLOW_GLOBAL_KEY] = db.Value{Field: make(map[string]string)} if inParams.oper == DELETE { switch targetUriPath { case SAMPLING_SFLOW_CONFIG_AGENT: global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_AGENT_KEY] = "" case SAMPLING_SFLOW_CONFIG_POLLING_INT: global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_POLLING_INT_KEY] = "" default: return res_map, errors.New("DELETE not supported on attribute") } res_map[SFLOW_GLOBAL_TBL] = global_map return res_map, err } if sflowObj.Sflow.Config.Enabled != nil { if *(sflowObj.Sflow.Config.Enabled) { global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_ADMIN_KEY] = "up" } else { global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_ADMIN_KEY] = "down" } } if sflowObj.Sflow.Config.PollingInterval != nil { global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_POLLING_INT_KEY] = strconv.FormatUint(uint64(*(sflowObj.Sflow.Config.PollingInterval)), 10) } if sflowObj.Sflow.Config.Agent != nil { global_map[SFLOW_GLOBAL_KEY].Field[SFLOW_AGENT_KEY] = *(sflowObj.Sflow.Config.Agent) } res_map[SFLOW_GLOBAL_TBL] = global_map return res_map, err }
type SubscProcType ¶
type SubscProcType int
SubscProcType represents subcription process type identifying the type of subscription request made from translib.
const ( TRANSLATE_EXISTS SubscProcType = iota TRANSLATE_SUBSCRIBE PROCESS_SUBSCRIBE )
type TableXfmrFunc ¶
type TableXfmrFunc func(inParams XfmrParams) ([]string, error)
TableXfmrFunc type is defined to use for table transformer function for dynamic derviation of redis table. Param: XfmrParams structure having database pointers, current db, operation, DB data in multidimensional map, YgotRoot, uri Return: List of table names, error
type ValidateCallpoint ¶
type ValidateCallpoint func(inParams XfmrParams) bool
ValidateCallpoint is used to validate a YANG node during data translation back to YANG as a response to GET Param : XfmrParams structure having Database pointers, current db, operation, DB data in multidimensional map, output param YgotRoot, uri Return : bool
type ValueXfmrFunc ¶
type ValueXfmrFunc func(inParams XfmrDbParams) (string, error)
ValueXfmrFunc type is defined to use for conversion of DB field value from one forma to another Transformer function definition. Param: XfmrDbParams structure having Database info, operation, db-number, table, key, field, value Return: value string, error
type XfmrDbParams ¶
type XfmrDbParams struct {
// contains filtered or unexported fields
}
XfmrDbParams represents input paraDeters for value-transformer
func (XfmrDbParams) String ¶
func (inPm XfmrDbParams) String() string
type XfmrDbTblCbkMethod ¶
type XfmrDbTblCbkMethod func(inParams XfmrDbTblCbkParams) error
type XfmrDbTblCbkParams ¶
type XfmrDbTblCbkParams struct {
// contains filtered or unexported fields
}
func (XfmrDbTblCbkParams) String ¶
func (inPm XfmrDbTblCbkParams) String() string
type XfmrDbToYgPathParams ¶
type XfmrDbToYgPathParams struct {
// contains filtered or unexported fields
}
XfmrDbToYgPathParams represents input parameters for path-transformer Fields in the new structs are getting flagged as unused.
type XfmrInterface ¶
type XfmrInterface interface {
// contains filtered or unexported methods
}
XfmrInterface is a validation interface for validating the callback registration of app modules transformer methods.
type XfmrParams ¶
type XfmrParams struct {
// contains filtered or unexported fields
}
XfmrParams represents input parameters for table-transformer, key-transformer, field-transformer & subtree-transformer
func (XfmrParams) String ¶
func (inPm XfmrParams) String() string
type XfmrSubscInParams ¶
type XfmrSubscInParams struct {
// contains filtered or unexported fields
}
XfmrSubscInParams represents input to subscribe subtree callbacks - request uri, DBs info access-pointers, DB info for request uri and subscription process type from translib.
type XfmrSubscOutParams ¶
type XfmrSubscOutParams struct {
// contains filtered or unexported fields
}
XfmrSubscOutParams represents output from subscribe subtree callback - DB data for request uri, Need cache, OnChange, subscription preference and interval.
type XfmrSubscribePathXlateInfo ¶
type XfmrSubscribePathXlateInfo struct { Path *gnmipb.Path // subscribe path DbKeyXlateInfo []*dbTableKeyInfo MinInterval int // min interval NeedCache bool PType NotificationType OnChange OnchangeMode TrgtNodeChld bool // to indicate the immediate child level pathXlate info of the target node HandlerFunc apis.ProcessOnChange // if its true, stop traversing the ygXpathNode's child nodes further IsDataSrcDynamic bool // contains filtered or unexported fields }
type XfmrSubscribeReqXlateInfo ¶
type XfmrSubscribeReqXlateInfo struct { TrgtPathInfo *XfmrSubscribePathXlateInfo ChldPathsInfo []*XfmrSubscribePathXlateInfo // contains filtered or unexported fields }
type XfmrTranslateSubscribeInfo ¶
type XfmrTranslateSubscribeInfo struct { DbDataMap RedisDbMap MinInterval int NeedCache bool PType NotificationType OnChange bool }
Source Files ¶
- host_comm.go
- subscribe_req_xlate.go
- subscribe_resp_xlate.go
- transformer.go
- xconst.go
- xfmr_dbtbl_cbk_interface.go
- xfmr_interface.go
- xfmr_path_utils.go
- xfmr_sflow.go
- xfmr_showtech.go
- xlate.go
- xlate_cascade_del.go
- xlate_datastructs.go
- xlate_del_to_db.go
- xlate_from_db.go
- xlate_prune.go
- xlate_prune_stats.go
- xlate_tbl_info.go
- xlate_to_db.go
- xlate_utils.go
- xlate_xfmr_handler.go
- xspec.go