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 ValidateIntfProvisionedForRelay(d *db.DB, ifName string, prefixIp string, entry *db.Value) (bool, 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 CounterData
- type DBKeyYgNodeInfo
- type DbFldYgPathInfo
- type DbToYangXfmrInputArgs
- type DbYangKeyResolver
- type DbYgXlateInfo
- type E_InterfaceSubType
- type E_InterfaceType
- type FieldXfmrDbtoYang
- type FieldXfmrYangToDb
- type HostResult
- type IntfTblData
- type KeySpec
- type KeyXfmrDbToYang
- type KeyXfmrYangToDb
- type ModProfile
- type NotificationType
- type OnchangeMode
- type Operation
- type PathInfo
- type PathXfmrDbToYangFunc
- type PopulateIntfCounters
- 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 TblData
- 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 ( PORTCHANNEL_TABLE = "PORTCHANNEL" DEFAULT_PORTCHANNEL_MIN_LINKS = "1" DEFAULT_PORTCHANNEL_SPEED = "0" )
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 ( PORT_ADMIN_STATUS = "admin_status" PORT_SPEED = "speed" PORT_AUTONEG = "autoneg" PORTCHANNEL_INTERFACE_TN = "PORTCHANNEL_INTERFACE" PORTCHANNEL_MEMBER_TN = "PORTCHANNEL_MEMBER" DEFAULT_MTU = "9100" )
const ( PIPE = "|" COLON = ":" ETHERNET = "Eth" PORTCHANNEL = "PortChannel" )
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 DbToYang_intf_eth_aggr_id_xfmr = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) log.Info("DbToYang_intf_eth_aggr_id_xfmr, interface name ", inParams.key) intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_eth_aggr_id_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } if IntfTypeEthernet != intfType { return result, nil } intf_lagId, _ := retrievePortChannelAssociatedWithIntf(&inParams, &inParams.key) if intf_lagId != nil { lagPrefix := "PortChannel" if strings.HasPrefix(*intf_lagId, lagPrefix) { result["aggregate-id"] = intf_lagId } } log.Infof("DbToYang_intf_eth_aggr_id_xfmr result %v", result) return result, err }
var (
ErrParamsNotAdapted = errors.New("The number of params is not adapted.")
)
var IntfTypeTblMap = map[E_InterfaceType]IntfTblData{ IntfTypeEthernet: IntfTblData{ CountersHdl: CounterData{OIDTN: "COUNTERS_PORT_NAME_MAP", CountersTN: "COUNTERS", PopulateCounters: populatePortCounters}, // contains filtered or unexported fields }, IntfTypePortChannel: IntfTblData{ // contains filtered or unexported fields }, }
var ModelsListFile = "models_list"
var Subscribe_intf_ip_addr_xfmr = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { if log.V(3) { log.Info("Entering Subscribe_intf_ip_addr_xfmr") } var err error var result XfmrSubscOutParams pathInfo := NewPathInfo(inParams.uri) origTargetUriPath := pathInfo.YangPath log.Infof("Subscribe_intf_ip_addr_xfmr:- subscProc:%v URI: %s", inParams.subscProc, inParams.uri) log.Infof("Subscribe_intf_ip_addr_xfmr:- Target URI path: %s", origTargetUriPath) if inParams.subscProc == TRANSLATE_EXISTS { result.isVirtualTbl = true return result, nil } if inParams.subscProc == TRANSLATE_SUBSCRIBE { ifBasePath := "/openconfig-interfaces:interfaces/interface" targetUriPath := origTargetUriPath[len(ifBasePath):] if strings.HasPrefix(targetUriPath, "/subinterfaces") { targetUriPath = targetUriPath[len("/subinterfaces/subinterface"):] } if strings.HasPrefix(targetUriPath, "/openconfig-if-ip:ipv4") { targetUriPath = targetUriPath[len("/openconfig-if-ip:ipv4/addresses"):] } else { targetUriPath = targetUriPath[len("/openconfig-if-ip:ipv6/addresses"):] } if targetUriPath == "" || targetUriPath == "/address" { result.isVirtualTbl = true log.Info("Subscribe_intf_ip_addr_xfmr:- result.isVirtualTbl: ", result.isVirtualTbl) return result, err } result.onChange = OnchangeEnable result.nOpts = ¬ificationOpts{} result.nOpts.pType = OnChange result.isVirtualTbl = false tableName := "" ipKey := "" ifKey := "" ifKey = pathInfo.StringVar("name", "*") addressConfigPath := "/address/config" addressStatePath := "/address/state" idx := pathInfo.Var("index") if ifKey != "" { if idx == "0" { intfType, _, _ := getIntfTypeByName(ifKey) intTbl := IntfTypeTblMap[intfType] if targetUriPath == addressStatePath { tableName = intTbl.appDb.intfTN } else { tableName = intTbl.cfgDb.intfTN } } else { err_str := "Subinterfaces not supported" return result, tlerr.NotSupported(err_str) } } ipKey = pathInfo.Var("ip") if ipKey == "" { ipKey = "*" } if ipKey != "*" { ipKey = ipKey + "/*" } log.Infof("path:%v ifKey:%v, ipKey:%v tbl:[%v]", origTargetUriPath, ifKey, ipKey, tableName) keyName := "" if targetUriPath == addressConfigPath { keyName = ifKey + "|" + ipKey if tableName != "" { result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: {tableName: {keyName: {}}}} } else { result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: {"INTERFACE": {keyName: {}}, "PORTCHANNEL_INTERFACE": {keyName: {}}}} } } else if targetUriPath == addressStatePath { keyName = ifKey + ":" + ipKey if tableName != "" { result.dbDataMap = RedisDbSubscribeMap{db.ApplDB: {tableName: {keyName: {KEY_COMP_CNT: "2", DEL_AS_UPDATE: "true"}}}} } else { result.dbDataMap = RedisDbSubscribeMap{db.ApplDB: {"INTF_TABLE": {keyName: {KEY_COMP_CNT: "2", DEL_AS_UPDATE: "true"}}}} } } log.Info("Subscribe_intf_ip_addr_xfmr:- result dbDataMap: ", result.dbDataMap) log.Info("Subscribe_intf_ip_addr_xfmr:- result secDbDataMap: ", result.secDbDataMap) return result, err } result.isVirtualTbl = false result.dbDataMap = make(RedisDbSubscribeMap) uriIfName := pathInfo.Var("name") idx := pathInfo.Var("index") sonicIfName := &uriIfName keyName := *sonicIfName if keyName != "" { intfType, _, _ := getIntfTypeByName(keyName) intTbl := IntfTypeTblMap[intfType] tblName := intTbl.cfgDb.intfTN if idx != "" && idx != "0" { err_str := "Subinterfaces not supported" return result, tlerr.NotSupported(err_str) } result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: {tblName: {keyName: {}}}} } log.Info("Returning Subscribe_intf_ip_addr_xfmr, result:", result) result.needCache = true result.nOpts = new(notificationOpts) result.nOpts.mInterval = 15 result.nOpts.pType = OnChange log.Info("Returning Subscribe_intf_ip_addr_xfmr, result:", result) return result, err }
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 ValidateIntfProvisionedForRelay ¶
func ValidateIntfProvisionedForRelay(d *db.DB, ifName string, prefixIp string, entry *db.Value) (bool, error)
ValidateIntfProvisionedForRelay helper function to validate IP address deletion if DHCP relay is provisioned
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 CounterData ¶
type CounterData struct { OIDTN string CountersTN string PopulateCounters PopulateIntfCounters }
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 E_InterfaceSubType ¶
type E_InterfaceSubType int64
const (
IntfSubTypeUnset E_InterfaceSubType = 0
)
type E_InterfaceType ¶
type E_InterfaceType int64
const ( IntfTypeUnset E_InterfaceType = 0 IntfTypeEthernet E_InterfaceType = 1 IntfTypePortChannel E_InterfaceType = 2 )
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
var DbToYang_intf_admin_status_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) data := (*inParams.dbDataMap)[inParams.curDb] intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_admin_status_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } intTbl := IntfTypeTblMap[intfType] tblName, _ := getPortTableNameByDBId(intTbl, inParams.curDb) if _, ok := data[tblName]; !ok { log.Info("DbToYang_intf_admin_status_xfmr table not found : ", tblName) return result, errors.New("table not found : " + tblName) } pTbl := data[tblName] if _, ok := pTbl[inParams.key]; !ok { log.Info("DbToYang_intf_admin_status_xfmr Interface not found : ", inParams.key) return result, errors.New("Interface not found : " + inParams.key) } prtInst := pTbl[inParams.key] adminStatus, ok := prtInst.Field[PORT_ADMIN_STATUS] var status ocbinds.E_OpenconfigInterfaces_Interfaces_Interface_State_AdminStatus if ok { if adminStatus == "up" { status = ocbinds.OpenconfigInterfaces_Interfaces_Interface_State_AdminStatus_UP } else { status = ocbinds.OpenconfigInterfaces_Interfaces_Interface_State_AdminStatus_DOWN } result["admin-status"] = ocbinds.E_OpenconfigInterfaces_Interfaces_Interface_State_AdminStatus.ΛMap(status)["E_OpenconfigInterfaces_Interfaces_Interface_State_AdminStatus"][int64(status)].Name } else { log.Info("Admin status field not found in DB") } return result, err }
var DbToYang_intf_enabled_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) data := (*inParams.dbDataMap)[inParams.curDb] intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_enabled_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } intTbl := IntfTypeTblMap[intfType] tblName, _ := getPortTableNameByDBId(intTbl, inParams.curDb) if _, ok := data[tblName]; !ok { log.Info("DbToYang_intf_enabled_xfmr table not found : ", tblName) return result, errors.New("table not found : " + tblName) } pTbl := data[tblName] if _, ok := pTbl[inParams.key]; !ok { log.Info("DbToYang_intf_enabled_xfmr Interface not found : ", inParams.key) return result, errors.New("Interface not found : " + inParams.key) } prtInst := pTbl[inParams.key] adminStatus, ok := prtInst.Field[PORT_ADMIN_STATUS] if ok { if adminStatus == "up" { result["enabled"] = true } else { result["enabled"] = false } } else { log.Info("Admin status field not found in DB") } return result, err }
var DbToYang_intf_eth_auto_neg_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) data := (*inParams.dbDataMap)[inParams.curDb] intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_eth_auto_neg_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } if IntfTypeEthernet != intfType { return result, nil } intTbl := IntfTypeTblMap[intfType] tblName, _ := getPortTableNameByDBId(intTbl, inParams.curDb) pTbl := data[tblName] prtInst := pTbl[inParams.key] autoNeg, ok := prtInst.Field[PORT_AUTONEG] if ok { if autoNeg == "on" || autoNeg == "true" { result["auto-negotiate"] = true } else { result["auto-negotiate"] = false } } else { log.Info("auto-negotiate field not found in DB") } return result, err }
var DbToYang_intf_eth_port_speed_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) data := (*inParams.dbDataMap)[inParams.curDb] intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_eth_port_speed_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } intTbl := IntfTypeTblMap[intfType] tblName, _ := getPortTableNameByDBId(intTbl, inParams.curDb) pTbl := data[tblName] prtInst := pTbl[inParams.key] speed, ok := prtInst.Field[PORT_SPEED] portSpeed := ocbinds.OpenconfigIfEthernet_ETHERNET_SPEED_UNSET if ok { portSpeed, err = getDbToYangSpeed(speed) result["port-speed"] = ocbinds.E_OpenconfigIfEthernet_ETHERNET_SPEED.ΛMap(portSpeed)["E_OpenconfigIfEthernet_ETHERNET_SPEED"][int64(portSpeed)].Name } else { log.Info("Speed field not found in DB") } return result, err }
var DbToYang_intf_mtu_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { var err error result := make(map[string]interface{}) data := (*inParams.dbDataMap)[inParams.curDb] intfType, _, ierr := getIntfTypeByName(inParams.key) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_mtu_xfmr - Invalid interface type IntfTypeUnset") return result, errors.New("Invalid interface type IntfTypeUnset") } intTbl := IntfTypeTblMap[intfType] tblName, _ := getPortTableNameByDBId(intTbl, inParams.curDb) if _, ok := data[tblName]; !ok { log.Info("DbToYang_intf_mtu_xfmr table not found : ", tblName) return result, errors.New("table not found : " + tblName) } pTbl := data[tblName] if _, ok := pTbl[inParams.key]; !ok { log.Info("DbToYang_intf_mtu_xfmr Interface not found : ", inParams.key) return result, errors.New("Interface not found : " + inParams.key) } prtInst := pTbl[inParams.key] mtuStr, ok := prtInst.Field["mtu"] if ok { mtuVal, err := strconv.ParseUint(mtuStr, 10, 16) if err != nil { return result, err } result["mtu"] = mtuVal } return result, err }
var DbToYang_ipv6_enabled_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { if log.V(3) { log.Info("Entering DbToYang_ipv6_enabled_xfmr") } res_map := make(map[string]interface{}) if log.V(3) { log.Info("DbToYang_ipv6_enabled_xfmr, inParams.key ", inParams.key) } pathInfo := NewPathInfo(inParams.uri) ifName := pathInfo.Var("name") ifUIName := &ifName log.Info("Interface Name = ", *ifUIName) intfType, _, _ := getIntfTypeByName(inParams.key) intTbl := IntfTypeTblMap[intfType] tblName, _ := getIntfTableNameByDBId(intTbl, inParams.curDb) data := (*inParams.dbDataMap)[inParams.curDb] res_map["enabled"] = false ipv6_status, ok := data[tblName][inParams.key].Field["ipv6_use_link_local_only"] if ok && ipv6_status == "enable" { res_map["enabled"] = true } return res_map, nil }
DbToYang_ipv6_enabled_xfmr is a DbToYang Field transformer for IPv6 config "enabled". */
var DbToYang_lag_min_links_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { if log.V(3) { log.Info("Entering DbToYang_lag_min_links_xfmr") } var err error result := make(map[string]interface{}) err = validatePortChannel(inParams.d, inParams.key) if err != nil { log.Infof("DbToYang_lag_min_links_xfmr Error: %v ", err) return result, err } data := (*inParams.dbDataMap)[inParams.curDb] links, ok := data[PORTCHANNEL_TABLE][inParams.key].Field["min_links"] if ok { linksUint16, err := uint16Conv(links) if err != nil { return result, err } result["min-links"] = linksUint16 } else { if log.V(3) { log.Info("min-links set to 1 (default value)") } linksUint16, err := uint16Conv(DEFAULT_PORTCHANNEL_MIN_LINKS) if err != nil { return result, err } result["min-links"] = linksUint16 } return result, err }
var DbToYang_subif_index_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams) (map[string]interface{}, error) { res_map := make(map[string]interface{}) pathInfo := NewPathInfo(inParams.uri) id := pathInfo.Var("index") log.Info("DbToYang_subif_index_xfmr: Sub-interface Index = ", id) i64, _ := strconv.ParseUint(id, 10, 32) i32 := uint32(i64) if i32 != 0 { err_str := "Subinterfaces not supported" return res_map, tlerr.NotSupported(err_str) } res_map["index"] = i64 return res_map, nil }
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
var YangToDb_intf_enabled_xfmr FieldXfmrYangToDb = func(inParams XfmrParams) (map[string]string, error) { res_map := make(map[string]string) intfsObj := getIntfsRoot(inParams.ygRoot) if intfsObj == nil || len(intfsObj.Interface) < 1 { return res_map, nil } enabled, _ := inParams.param.(*bool) var enStr string if *enabled { enStr = "up" } else { enStr = "down" } res_map[PORT_ADMIN_STATUS] = enStr return res_map, nil }
var YangToDb_intf_mtu_xfmr FieldXfmrYangToDb = func(inParams XfmrParams) (map[string]string, error) { res_map := make(map[string]string) var ifName string intfsObj := getIntfsRoot(inParams.ygRoot) if intfsObj == nil || len(intfsObj.Interface) < 1 { return res_map, nil } else { for infK := range intfsObj.Interface { ifName = infK } } intfType, _, _ := getIntfTypeByName(ifName) if inParams.oper == DELETE { log.Infof("Updating the Interface: %s with default MTU", ifName) err := updateDefaultMtu(&inParams, &ifName, intfType, res_map) if err != nil { log.Errorf("Updating Default MTU for Interface: %s failed", ifName) return res_map, err } return res_map, nil } intfTypeVal, _ := inParams.param.(*uint16) intTypeValStr := strconv.FormatUint(uint64(*intfTypeVal), 10) if IntfTypePortChannel == intfType { updateMemberPortsMtu(&inParams, &ifName, &intTypeValStr) } else if IntfTypeEthernet == intfType { lagId, _ := retrievePortChannelAssociatedWithIntf(&inParams, &ifName) if lagId != nil { log.Infof("%s is member of %s", ifName, *lagId) errStr := "Configuration not allowed when port is member of Portchannel." return nil, tlerr.InvalidArgsError{Format: errStr} } } res_map["mtu"] = intTypeValStr return res_map, nil }
var YangToDb_ipv6_enabled_xfmr FieldXfmrYangToDb = func(inParams XfmrParams) (map[string]string, error) { if log.V(3) { log.Info("Entering YangToDb_ipv6_enabled_xfmr") } var err error res_map := make(map[string]string) pathInfo := NewPathInfo(inParams.uri) ifUIName := pathInfo.Var("name") intfType, _, ierr := getIntfTypeByName(ifUIName) if ierr != nil || intfType == IntfTypeUnset { return res_map, errors.New("YangToDb_ipv6_enabled_xfmr, Error: Unsupported Interface: " + ifUIName) } if ifUIName == "" { errStr := "Interface KEY not present" log.Info("YangToDb_ipv6_enabled_xfmr: " + errStr) return res_map, errors.New(errStr) } if inParams.param == nil { return res_map, err } if len(pathInfo.Vars) < 2 { return res_map, errors.New("YangToDb_ipv6_enabled_xfmr, Error: Invalid Key length") } if log.V(3) { log.Info("YangToDb_ipv6_enabled_xfmr, inParams.key: ", inParams.key) } ifName := &ifUIName intTbl := IntfTypeTblMap[intfType] tblName := intTbl.cfgDb.intfTN ipMap, _ := getIntfIpByName(inParams.d, tblName, *ifName, true, true, "") var enStr string subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) subOpTblMap := make(map[string]map[string]db.Value) field_map := make(map[string]db.Value) res_values := db.Value{Field: map[string]string{}} IntfMap := make(map[string]string) enabled, _ := inParams.param.(*bool) if *enabled { enStr = "enable" } else { enStr = "disable" } IntfMapObj, err := inParams.d.GetEntry(&db.TableSpec{Name: tblName}, db.Key{Comp: []string{*ifName}}) if err == nil || IntfMapObj.IsPopulated() { IntfMap = IntfMapObj.Field } val, fieldExists := IntfMap["ipv6_use_link_local_only"] if fieldExists && val == enStr { log.Info("IPv6 is already %s.", enStr) return nil, nil } res_map["ipv6_use_link_local_only"] = enStr if log.V(3) { log.Info("YangToDb_ipv6_enabled_xfmr, res_map: ", res_map) } if enStr == "disable" { if len(IntfMap) == 0 { return nil, nil } keys := make([]string, 0, len(IntfMap)) for k := range IntfMap { keys = append(keys, k) } check_keys := []string{"NULL", "ipv6_use_link_local_only"} sort.Strings(keys) if !((reflect.DeepEqual(keys, check_keys) || reflect.DeepEqual(keys, check_keys[1:])) && len(ipMap) == 0) { if !fieldExists { return nil, nil } log.Info("YangToDb_ipv6_enabled_xfmr, deleting ipv6_use_link_local_only field") (&res_values).Set("ipv6_use_link_local_only", enStr) } field_map[*ifName] = res_values subOpTblMap[tblName] = field_map subOpMap[db.ConfigDB] = subOpTblMap inParams.subOpDataMap[DELETE] = &subOpMap if log.V(3) { log.Info("YangToDb_ipv6_enabled_xfmr, subOpMap: ", subOpMap) } return nil, nil } return res_map, nil }
YangToDb_ipv6_enabled_xfmr is a YangToDB Field transformer for IPv6 config "enabled".
var YangToDb_lag_min_links_xfmr FieldXfmrYangToDb = func(inParams XfmrParams) (map[string]string, error) { if log.V(3) { log.Info("Entering YangToDb_lag_min_links_xfmr") } res_map := make(map[string]string) var err error pathInfo := NewPathInfo(inParams.uri) ifKey := pathInfo.Var("name") log.Infof("Received Min links config for path: %s; template: %s vars: %v ifKey: %s", pathInfo.Path, pathInfo.YangPath, pathInfo.Vars, ifKey) if inParams.param == nil { if log.V(3) { log.Info("YangToDb_lag_min_links_xfmr Error: No Params") } return res_map, err } minLinks, _ := inParams.param.(*uint16) if int(*minLinks) > 32 || int(*minLinks) < 0 { errStr := "Min links value is invalid for the PortChannel: " + ifKey log.Info(errStr) err = tlerr.InvalidArgsError{Format: errStr} return res_map, err } res_map["min_links"] = strconv.Itoa(int(*minLinks)) return res_map, nil }
YangToDb_lag_min_links_xfmr is a Yang to DB translation overloaded method for handle min-links config
var YangToDb_subif_index_xfmr FieldXfmrYangToDb = func(inParams XfmrParams) (map[string]string, error) { res_map := make(map[string]string) var err error pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") log.Info(uriIfName) ifName := uriIfName res_map["parent"] = ifName log.Info("YangToDb_subif_index_xfmr: res_map:", res_map) return res_map, err }
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 IntfTblData ¶
type IntfTblData struct { CountersHdl CounterData // contains filtered or unexported fields }
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 */
var DbToYang_intf_counters_key KeyXfmrDbToYang = func(inParams XfmrParams) (map[string]interface{}, error) { rmap := make(map[string]interface{}) var err error return rmap, err }
var DbToYang_intf_subintfs_xfmr KeyXfmrDbToYang = func(inParams XfmrParams) (map[string]interface{}, error) { if log.V(3) { log.Info("Entering DbToYang_intf_subintfs_xfmr") } var idx string idx = inParams.key var i32 uint32 i32 = 0 rmap := make(map[string]interface{}) var err error i64, _ := strconv.ParseUint(idx, 10, 32) i32 = uint32(i64) if i32 != 0 { log.Info("DbToYang_intf_subintfs_xfmr - rmap ", rmap) err_str := "Subinterfaces not supported" return rmap, tlerr.NotSupported(err_str) } rmap["index"] = i64 log.Info("DbToYang_intf_subintfs_xfmr rmap ", rmap) return rmap, err }
var DbToYang_intf_tbl_key_xfmr KeyXfmrDbToYang = func(inParams XfmrParams) (map[string]interface{}, error) { if log.V(3) { log.Info("Entering DbToYang_intf_tbl_key_xfmr") } res_map := make(map[string]interface{}) pathInfo := NewPathInfo(inParams.uri) reqpathInfo := NewPathInfo(inParams.requestUri) requestUriPath := reqpathInfo.YangPath log.Infof("DbToYang_intf_tbl_key_xfmr: inParams.uri: %s, pathInfo: %s, inParams.requestUri: %s", inParams.uri, pathInfo, requestUriPath) idx := reqpathInfo.Var("index") var i32 uint32 i32 = 0 if idx != "" { i64, _ := strconv.ParseUint(idx, 10, 32) i32 = uint32(i64) } log.Infof("DbToYang_intf_tbl_key_xfmr: i32: %s", i32) if i32 != 0 { err_str := "Subinterfaces not supported" return res_map, tlerr.NotSupported(err_str) } log.Info("DbToYang_intf_tbl_key_xfmr: Interface Name = ", inParams.key) res_map["name"] = inParams.key return res_map, nil }
var DbToYang_subintf_ipv6_tbl_key_xfmr KeyXfmrDbToYang = func(inParams XfmrParams) (map[string]interface{}, error) { if log.V(3) { log.Info("Entering DbToYang_subintf_ipv6_tbl_key_xfmr") } rmap := make(map[string]interface{}) return rmap, nil }
DbToYang_subintf_ipv6_tbl_key_xfmr is a DbToYang key transformer for IPv6 config.
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
var YangToDb_intf_counters_key KeyXfmrYangToDb = func(inParams XfmrParams) (string, error) { pathInfo := NewPathInfo(inParams.uri) intfName := pathInfo.Var("name") oid, oiderr := getIntfCountersTblKey(inParams.dbs[inParams.curDb], intfName) return oid, oiderr }
var YangToDb_intf_subintfs_xfmr KeyXfmrYangToDb = func(inParams XfmrParams) (string, error) { var subintf_key string var err error log.Info("YangToDb_intf_subintfs_xfmr - inParams.uri ", inParams.uri) pathInfo := NewPathInfo(inParams.uri) ifName := pathInfo.Var("name") if ifName == "*" { return ifName, nil } intfType, _, ierr := getIntfTypeByName(ifName) if intfType == IntfTypeUnset || ierr != nil { return ifName, errors.New("Invalid interface type IntfTypeUnset") } idx := pathInfo.Var("index") if idx != "0" && idx != "*" && idx != "" { err_str := "Subinterfaces not supported" return subintf_key, tlerr.NotSupported(err_str) } else if inParams.oper == SUBSCRIBE && idx == "0" { subintf_key = ifName } else { subintf_key = idx } log.Info("YangToDb_intf_subintfs_xfmr - return subintf_key ", subintf_key) return subintf_key, err }
var YangToDb_intf_tbl_key_xfmr KeyXfmrYangToDb = func(inParams XfmrParams) (string, error) { var err error pathInfo := NewPathInfo(inParams.uri) reqpathInfo := NewPathInfo(inParams.requestUri) requestUriPath := reqpathInfo.YangPath log.Infof("YangToDb_intf_tbl_key_xfmr: inParams.uri: %s, pathInfo: %s, inParams.requestUri: %s", inParams.uri, pathInfo, requestUriPath) ifName := pathInfo.Var("name") idx := reqpathInfo.Var("index") var i32 uint32 i32 = 0 if idx != "" { i64, _ := strconv.ParseUint(idx, 10, 32) i32 = uint32(i64) } log.Infof("YangToDb_intf_tbl_key_xfmr: i32: %s", i32) if i32 != 0 { err_str := "Subinterfaces not supported" return ifName, tlerr.NotSupported(err_str) } if ifName == "*" { return ifName, nil } if ifName != "" { log.Info("YangToDb_intf_tbl_key_xfmr: ifName: ", ifName) intfType, _, ierr := getIntfTypeByName(ifName) if ierr != nil { log.Errorf("Extracting Interface type for Interface: %s failed!", ifName) return "", tlerr.New(ierr.Error()) } err = performIfNameKeyXfmrOp(&inParams, &requestUriPath, &ifName, intfType, i32) if err != nil { return "", tlerr.InvalidArgsError{Format: err.Error()} } } return ifName, err }
var YangToDb_subintf_ip_addr_key_xfmr KeyXfmrYangToDb = func(inParams XfmrParams) (string, error) { if log.V(3) { log.Info("Entering YangToDb_subintf_ip_addr_key_xfmr") } var err error var inst_key string pathInfo := NewPathInfo(inParams.uri) inst_key = pathInfo.Var("ip") log.Infof("URI:%v Interface IP:%v", inParams.uri, inst_key) return inst_key, err }
var YangToDb_subintf_ipv6_tbl_key_xfmr KeyXfmrYangToDb = func(inParams XfmrParams) (string, error) { if log.V(3) { log.Info("Entering YangToDb_subintf_ipv6_tbl_key_xfmr") } var err error var inst_key string pathInfo := NewPathInfo(inParams.uri) ifName := pathInfo.Var("name") if log.V(3) { log.Info("inParams.requestUri: ", inParams.requestUri) } inst_key = ifName log.Info("Exiting YangToDb_subintf_ipv6_tbl_key_xfmr, key ", inst_key) return inst_key, err }
YangToDb_subintf_ipv6_tbl_key_xfmr is a YangToDB Key transformer for IPv6 config.
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_intf_eth_port_config_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { log.V(3).Info("DbToYangPath_intf_eth_port_config_path_xfmr: params: ", params) intfRoot := "/openconfig-interfaces:interfaces/interface" if params.tblName != "PORT" { log.Info("DbToYangPath_intf_eth_port_config_path_xfmr: from wrong table: ", params.tblName) return nil } if (params.tblName == "PORT") && (len(params.tblKeyComp) > 0) { params.ygPathKeys[intfRoot+"/name"] = params.tblKeyComp[0] } else { log.Info("DbToYangPath_intf_eth_port_config_path_xfmr, wrong param: tbl ", params.tblName, " key ", params.tblKeyComp) return nil } log.Info("DbToYangPath_intf_eth_port_config_path_xfmr: params.ygPathkeys: ", params.ygPathKeys) return nil }
var DbToYangPath_intf_get_counters_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { log.Info("DbToYangPath_intf_get_counters_path_xfmr: params: ", params) intfRoot := "/openconfig-interfaces:interfaces/interface" if params.tblName != "COUNTERS_PORT_NAME_MAP" { log.Info("DbToYangPath_intf_get_counters_path_xfmr: from wrong table: ", params.tblName) return nil } if (params.tblName == "COUNTERS_PORT_NAME_MAP") && (len(params.tblKeyComp) > 0) { params.ygPathKeys[intfRoot+"/name"] = params.tblKeyComp[0] } else { log.Info("DbToYangPath_intf_get_counters_path_xfmr, wrong param: tbl ", params.tblName, " key ", params.tblKeyComp) return nil } log.Info("DbToYangPath_intf_get_counters_path_xfmr: params.ygPathkeys: ", params.ygPathKeys) return nil }
var DbToYangPath_intf_ip_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { ifRoot := "/openconfig-interfaces:interfaces/interface" subIf := ifRoot + "/subinterfaces/subinterface" dbKey := "" log.Info("DbToYangPath_intf_ip_path_xfmr: params: ", params) uiName := ¶ms.tblKeyComp[0] ifParts := strings.Split(*uiName, ".") params.ygPathKeys[ifRoot+"/name"] = ifParts[0] if params.tblName == "INTERFACE" || params.tblName == "INTF_TABLE" || params.tblName == "PORTCHANNEL_INTERFACE" { addrPath := "/openconfig-if-ip:ipv4/addresses/address/ip" dbKey = strings.Join(params.tblKeyComp[1:], ":") if len(params.tblKeyComp) > 2 || strings.Contains(dbKey, ":") { addrPath = "/openconfig-if-ip:ipv6/addresses/address/ip" } ipKey := strings.Split(dbKey, "/") if len(ifParts) > 1 { err_str := "Subinterfaces not supported" return tlerr.NotSupported(err_str) } else { params.ygPathKeys[subIf+"/index"] = "0" } params.ygPathKeys[subIf+addrPath] = ipKey[0] } log.Infof("DbToYangPath_intf_ip_path_xfmr: tblName:%v dbKey:[%v] params.ygPathKeys: %v", params.tblName, dbKey, params.ygPathKeys) return nil }
var DbToYangPath_intf_lag_state_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { intfRoot := "/openconfig-interfaces:interfaces/interface" if (params.tblName != "PORTCHANNEL") && (params.tblName != "PORTCHANNEL_MEMBER") { log.Info("DbToYangPath_intf_lag_state_path_xfmr: from wrong table ", params.tblName) return nil } if (params.tblName == "PORTCHANNEL") && (len(params.tblKeyComp) > 0) { params.ygPathKeys[intfRoot+"/name"] = params.tblKeyComp[0] } else if (params.tblName == "PORTCHANNEL_MEMBER") && (len(params.tblKeyComp) > 1) { params.ygPathKeys[intfRoot+"/name"] = params.tblKeyComp[0] } else { log.Info("DbToYangPath_intf_lag_state_path_xfmr, wrong param: tbl ", params.tblName, " key ", params.tblKeyComp) return nil } log.Info("DbToYangPath_intf_lag_state_path_xfmr: params.ygPathkeys: ", params.ygPathKeys) return nil }
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 PopulateIntfCounters ¶
type PopulateIntfCounters func(inParams XfmrParams, counters interface{}) error
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_intf_eth_port_config_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { var err error intfsObj := getIntfsRoot(inParams.ygRoot) pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") ifName := uriIfName log.V(3).Infof("DbToYang_intf_eth_port_config_xfmr: Interface name : %s ", ifName) intfType, _, err := getIntfTypeByName(ifName) if err != nil { errStr := "Invalid Interface" err = tlerr.InvalidArgsError{Format: errStr} return err } intTbl := IntfTypeTblMap[intfType] tblName := intTbl.cfgDb.portTN entry, dbErr := inParams.dbs[db.ConfigDB].GetEntry(&db.TableSpec{Name: tblName}, db.Key{Comp: []string{ifName}}) if dbErr != nil { errStr := "Invalid Interface" err = tlerr.InvalidArgsError{Format: errStr} return err } targetUriPath := pathInfo.YangPath if strings.HasPrefix(targetUriPath, "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config") { get_cfg_obj := false var intfObj *ocbinds.OpenconfigInterfaces_Interfaces_Interface if intfsObj != nil && intfsObj.Interface != nil && len(intfsObj.Interface) > 0 { var ok bool = false if intfObj, ok = intfsObj.Interface[uriIfName]; !ok { intfObj, _ = intfsObj.NewInterface(uriIfName) } ygot.BuildEmptyTree(intfObj) } else { ygot.BuildEmptyTree(intfsObj) intfObj, _ = intfsObj.NewInterface(uriIfName) ygot.BuildEmptyTree(intfObj) } ygot.BuildEmptyTree(intfObj.Ethernet) ygot.BuildEmptyTree(intfObj.Ethernet.Config) if targetUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config" { get_cfg_obj = true } var errStr string if get_cfg_obj || targetUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id" { is_id_populated := false intf_lagId, _ := retrievePortChannelAssociatedWithIntf(&inParams, &ifName) if intf_lagId != nil { if strings.HasPrefix(*intf_lagId, "PortChannel") { intfObj.Ethernet.Config.AggregateId = intf_lagId is_id_populated = true } } if !is_id_populated { errStr = "aggregate-id not set" } if (targetUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id") && (!is_id_populated) { err = tlerr.NotFoundError{Format: "Resource not found"} return err } } if entry.IsPopulated() { if get_cfg_obj || targetUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config/auto-negotiate" { autoNeg, ok := entry.Field[PORT_AUTONEG] if ok { var oc_auto_neg bool if autoNeg == "on" || autoNeg == "true" { oc_auto_neg = true } else { oc_auto_neg = false } intfObj.Ethernet.Config.AutoNegotiate = &oc_auto_neg } else { errStr = "auto-negotiate not set" } } if get_cfg_obj || targetUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config/port-speed" { speed, ok := entry.Field[PORT_SPEED] portSpeed := ocbinds.OpenconfigIfEthernet_ETHERNET_SPEED_UNSET if ok { portSpeed, err = getDbToYangSpeed(speed) intfObj.Ethernet.Config.PortSpeed = portSpeed } else { errStr = "port-speed not set" } } } else { errStr = "Attribute not set" } if !get_cfg_obj && errStr != "" { err = tlerr.InvalidArgsError{Format: errStr} } } return err }
DbToYang_intf_eth_port_config_xfmr is to handle DB to yang translation of port-speed, auto-neg and aggregate-id config.
var DbToYang_intf_get_counters_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { var err error intfsObj := getIntfsRoot(inParams.ygRoot) pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") ifName := uriIfName targetUriPath := pathInfo.YangPath log.Info("targetUriPath is ", targetUriPath) if !strings.Contains(targetUriPath, "/openconfig-interfaces:interfaces/interface/state/counters") { log.Infof("%s is redundant", targetUriPath) return err } intfType, _, ierr := getIntfTypeByName(ifName) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_get_counters_xfmr - Invalid interface type IntfTypeUnset") return errors.New("Invalid interface type IntfTypeUnset") } intTbl := IntfTypeTblMap[intfType] if intTbl.CountersHdl.PopulateCounters == nil { log.Infof("Counters for Interface: %s not supported!", ifName) return nil } var state_counters *ocbinds.OpenconfigInterfaces_Interfaces_Interface_State_Counters if intfsObj != nil && intfsObj.Interface != nil && len(intfsObj.Interface) > 0 { var ok bool = false var intfObj *ocbinds.OpenconfigInterfaces_Interfaces_Interface if intfObj, ok = intfsObj.Interface[uriIfName]; !ok { intfObj, _ = intfsObj.NewInterface(uriIfName) ygot.BuildEmptyTree(intfObj) } ygot.BuildEmptyTree(intfObj) if intfObj.State == nil || intfObj.State.Counters == nil { ygot.BuildEmptyTree(intfObj.State) } state_counters = intfObj.State.Counters } else { ygot.BuildEmptyTree(intfsObj) intfObj, _ := intfsObj.NewInterface(uriIfName) ygot.BuildEmptyTree(intfObj) state_counters = intfObj.State.Counters } err = intTbl.CountersHdl.PopulateCounters(inParams, state_counters) if log.V(3) { log.Info("DbToYang_intf_get_counters_xfmr - ", state_counters) } return err }
var DbToYang_intf_get_ether_counters_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { var err error intfsObj := getIntfsRoot(inParams.ygRoot) pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") ifName := uriIfName log.Info("Ether counters subtree and ifname: ", ifName) targetUriPath := pathInfo.YangPath intfType, _, ierr := getIntfTypeByName(ifName) if intfType == IntfTypeUnset || ierr != nil { log.Info("DbToYang_intf_get_ether_counters_xfmr - Invalid interface type IntfTypeUnset") return errors.New("Invalid interface type IntfTypeUnset") } if !strings.Contains(targetUriPath, "/openconfig-interfaces:interfaces/interface/ethernet/state/counters") && !strings.Contains(targetUriPath, "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/state/counters") { log.Infof("%s is redundant", targetUriPath) return err } var intfObj *ocbinds.OpenconfigInterfaces_Interfaces_Interface var eth_counters *ocbinds.OpenconfigInterfaces_Interfaces_Interface_Ethernet_State_Counters if intfsObj != nil && intfsObj.Interface != nil && len(intfsObj.Interface) > 0 { var ok bool = false if intfObj, ok = intfsObj.Interface[uriIfName]; !ok { intfObj, _ = intfsObj.NewInterface(uriIfName) } ygot.BuildEmptyTree(intfObj) } else { ygot.BuildEmptyTree(intfsObj) intfObj, _ = intfsObj.NewInterface(uriIfName) ygot.BuildEmptyTree(intfObj) } ygot.BuildEmptyTree(intfObj.Ethernet) ygot.BuildEmptyTree(intfObj.Ethernet.State) ygot.BuildEmptyTree(intfObj.Ethernet.State.Counters) eth_counters = intfObj.Ethernet.State.Counters return populatePortCounters(inParams, eth_counters) }
var DbToYang_intf_ip_addr_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { var err error intfsObj := getIntfsRoot(inParams.ygRoot) pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") ifName := uriIfName targetUriPath := pathInfo.YangPath log.Infof("DbToYang_intf_ip_addr_xfmr: uri:%v path:%v", inParams.uri, targetUriPath) reqPathInfo := NewPathInfo(inParams.requestUri) requestUriPath := reqPathInfo.YangPath var reqUriIfName string = reqPathInfo.Var("name") if (inParams.oper == GET) && ((requestUriPath == "/openconfig-interfaces:interfaces" || requestUriPath == "/openconfig-interfaces:interfaces/interface") && reqUriIfName == "") { _, present := inParams.txCache.Load("interface_subinterface_ip_read_once") if present { log.Info("DbToYang_intf_ip_addr_xfmr, top level GET, interface_subinterface_ip_read_once already cached") return nil } intfTypeList := [2]E_InterfaceType{IntfTypeEthernet, IntfTypePortChannel} for i := 0; i < len(intfTypeList); i++ { intfTbl := IntfTypeTblMap[intfTypeList[i]] handleAllIntfIPGetForTable(inParams, intfTbl.cfgDb.intfTN, false) } handleAllIntfIPGetForTable(inParams, "INTF_TABLE", true) inParams.txCache.Store("interface_subinterface_ip_read_once", true) return nil } else { // Handle GET requests for given interface var intfObj *ocbinds.OpenconfigInterfaces_Interfaces_Interface ifName = *(&uriIfName) if strings.HasPrefix(targetUriPath, "/openconfig-interfaces:interfaces/interface/subinterfaces") { if intfsObj != nil && intfsObj.Interface != nil && len(intfsObj.Interface) > 0 { var ok bool = false if intfObj, ok = intfsObj.Interface[uriIfName]; !ok { intfObj, _ = intfsObj.NewInterface(uriIfName) } ygot.BuildEmptyTree(intfObj) if intfObj.Subinterfaces == nil { ygot.BuildEmptyTree(intfObj.Subinterfaces) } } else { ygot.BuildEmptyTree(intfsObj) intfObj, _ = intfsObj.NewInterface(uriIfName) ygot.BuildEmptyTree(intfObj) } err = handleIntfIPGetByTargetURI(inParams, targetUriPath, ifName, intfObj) if err != nil { return err } } else { err = errors.New("Invalid URI : " + targetUriPath) } } return err }
var DbToYang_intf_lag_state_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error { var err error intfsObj := getIntfsRoot(inParams.ygRoot) if intfsObj == nil || intfsObj.Interface == nil { errStr := "Failed to Get root object!" log.Errorf(errStr) return errors.New(errStr) } pathInfo := NewPathInfo(inParams.uri) ifName := pathInfo.Var("name") if _, ok := intfsObj.Interface[ifName]; !ok { obj, _ := intfsObj.NewInterface(ifName) ygot.BuildEmptyTree(obj) } intfObj := intfsObj.Interface[ifName] if intfObj.Aggregation == nil { ygot.BuildEmptyTree(intfObj) } if intfObj.Aggregation.State == nil { ygot.BuildEmptyTree(intfObj.Aggregation) } intfType, _, err := getIntfTypeByName(ifName) if intfType != IntfTypePortChannel || err != nil { intfTypeStr := strconv.Itoa(int(intfType)) errStr := "TableXfmrFunc - Invalid interface type: " + intfTypeStr log.Warning(errStr) return errors.New(errStr) } err = validatePortChannel(inParams.d, ifName) if err != nil { return err } targetUriPath := pathInfo.YangPath log.Info("targetUriPath is ", targetUriPath) lagInfoMap := make(map[string]db.Value) ocAggregationStateVal := intfObj.Aggregation.State err = fillLagInfoForIntf(inParams, inParams.d, &ifName, lagInfoMap, &targetUriPath) if err != nil { log.Errorf("Failed to get info: %s failed!", ifName) return err } log.Info("Succesfully completed DB map population!", lagInfoMap) switch targetUriPath { case "/openconfig-interfaces:interfaces/interface/openconfig-if-aggregate:aggregation/state/min-links": log.Info("Get is for min-links") attr := "min-links" err = getLagStateAttr(&attr, &ifName, lagInfoMap, ocAggregationStateVal) if err != nil { return err } case "/openconfig-interfaces:interfaces/interface/openconfig-if-aggregate:aggregation/state": log.Info("Get is for State Container!") err = getLagState(inParams, inParams.d, &ifName, lagInfoMap, ocAggregationStateVal) if err != nil { return err } default: log.Infof(targetUriPath + " - Not an supported Get attribute") } return err }
DbToYang_intf_lag_state_xfmr is a DB to Yang translation overloaded method for PortChannel GET operation
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_intf_eth_port_config_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams if inParams.subscProc == TRANSLATE_SUBSCRIBE { log.V(3).Info("Subscribe_intf_eth_port_config_xfmr: inParams.subscProc: ", inParams.subscProc) pathInfo := NewPathInfo(inParams.uri) targetUriPath := pathInfo.YangPath log.V(3).Infof("Subscribe_intf_eth_port_config_xfmr:- URI:%s pathinfo:%s ", inParams.uri, pathInfo.Path) log.V(3).Infof("Subscribe_intf_eth_port_config_xfmr:- Target URI path:%s", targetUriPath) result.nOpts = new(notificationOpts) result.nOpts.pType = OnChange result.nOpts.mInterval = 15 result.isVirtualTbl = false result.needCache = true ifName := pathInfo.StringVar("name", "*") log.V(3).Info("Subscribe_intf_eth_port_config_xfmr: ifName: ", ifName) result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: { "PORT": {ifName: {"autoneg": "auto-negotiate", "speed": "port-speed"}}}} log.V(3).Info("Subscribe_intf_eth_port_config_xfmr: result ", result) } return result, err }
var Subscribe_intf_get_counters_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams if inParams.subscProc == TRANSLATE_SUBSCRIBE { log.Info("Subscribe_intf_get_counters_xfmr: inParams.subscProc: ", inParams.subscProc) pathInfo := NewPathInfo(inParams.uri) targetUriPath := pathInfo.YangPath log.Infof("Subscribe_intf_get_counters_xfmr:- URI:%s pathinfo:%s ", inParams.uri, pathInfo.Path) log.Infof("Subscribe_intf_get_counters_xfmr:- Target URI path:%s", targetUriPath) result.nOpts = new(notificationOpts) result.nOpts.pType = Sample result.nOpts.mInterval = 30 result.isVirtualTbl = false result.needCache = true ifName := pathInfo.Var("name") log.Info("Subscribe_intf_get_counters_xfmr: ifName: ", ifName) if ifName == "" || ifName == "*" { if strings.HasPrefix(targetUriPath, "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/state/counters") { ifName = "Eth" + "*" } else { ifName = "*" } } result.dbDataMap = RedisDbSubscribeMap{db.CountersDB: {"COUNTERS_PORT_NAME_MAP": {"": {FIELD_CURSOR: ifName}}}} log.Info("Subscribe_intf_eth_port_config_xfmr: result ", result) } return result, err }
var Subscribe_intf_get_ether_counters_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { return Subscribe_intf_get_counters_xfmr(inParams) }
var Subscribe_intf_lag_state_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) { var err error var result XfmrSubscOutParams if inParams.subscProc == TRANSLATE_SUBSCRIBE { log.Info("Subscribe_intf_lag_state_xfmr: inParams.subscProc: ", inParams.subscProc) pathInfo := NewPathInfo(inParams.uri) targetUriPath := pathInfo.YangPath log.Infof("Subscribe_intf_lag_state_xfmr:- URI:%s pathinfo:%s ", inParams.uri, pathInfo.Path) log.Infof("Subscribe_intf_lag_state_xfmr:- Target URI path:%s", targetUriPath) result.nOpts = new(notificationOpts) result.nOpts.pType = OnChange result.nOpts.mInterval = 15 result.isVirtualTbl = false result.needCache = true ifName := pathInfo.Var("name") log.Info("Subscribe_intf_lag_state_xfmr: ifName: ", ifName) po_mem_key := "*" + "|" + "*" if ifName == "" { ifName = "*" } else if ifName != "*" { po_mem_key = ifName + "|" + "*" } result.secDbDataMap = RedisDbYgNodeMap{db.ConfigDB: { "PORTCHANNEL_MEMBER": {po_mem_key: DBKeyYgNodeInfo{}}, "PORTCHANNEL": {ifName: map[string]string{"min_links": "min-links"}}}} log.Info("Subscribe_intf_lag_state_xfmr: result ", result) } return result, err }
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_intf_eth_port_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error var lagStr string memMap := make(map[string]map[string]db.Value) pathInfo := NewPathInfo(inParams.uri) requestUriPath := (NewPathInfo(inParams.requestUri)).YangPath uriIfName := pathInfo.Var("name") ifName := uriIfName intfType, _, err := getIntfTypeByName(ifName) if err != nil { errStr := "Invalid Interface" err = tlerr.InvalidArgsError{Format: errStr} return nil, err } intfsObj := getIntfsRoot(inParams.ygRoot) intfObj := intfsObj.Interface[uriIfName] if inParams.oper == DELETE { if intfObj.Ethernet == nil || intfObj.Ethernet.Config == nil || (intfObj.Ethernet.Config != nil && requestUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config") { lagId, err := retrievePortChannelAssociatedWithIntf(&inParams, &ifName) if lagId != nil { log.Infof("%s is member of %s", ifName, *lagId) } if err != nil { errStr := "Retrieveing PortChannel associated with Interface: " + ifName + " failed!" return nil, errors.New(errStr) } if lagId != nil { lagStr = *lagId intTbl := IntfTypeTblMap[IntfTypePortChannel] tblName, _ := getMemTableNameByDBId(intTbl, inParams.curDb) m := make(map[string]string) value := db.Value{Field: m} m["NULL"] = "NULL" intfKey := lagStr + "|" + ifName if _, ok := memMap[tblName]; !ok { memMap[tblName] = make(map[string]db.Value) } memMap[tblName][intfKey] = value } return memMap, err } } if intfObj.Ethernet.Config.AggregateId != nil { if !strings.HasPrefix(ifName, ETHERNET) { return nil, errors.New("Invalid config request") } intTbl := IntfTypeTblMap[IntfTypePortChannel] tblName, _ := getMemTableNameByDBId(intTbl, inParams.curDb) switch inParams.oper { case CREATE: fallthrough case REPLACE: fallthrough case UPDATE: log.Info("Add member port") lagId := intfObj.Ethernet.Config.AggregateId lagStr = *lagId intfType, _, err := getIntfTypeByName(ifName) if intfType != IntfTypeEthernet || err != nil { intfTypeStr := strconv.Itoa(int(intfType)) errStr := "Invalid interface type" + intfTypeStr log.Error(errStr) return nil, tlerr.InvalidArgsError{Format: errStr} } err = validateIntfExists(inParams.d, intTbl.cfgDb.portTN, lagStr) if err != nil { return nil, err } case DELETE: lagId, err := retrievePortChannelAssociatedWithIntf(&inParams, &ifName) if lagId != nil { log.Infof("%s is member of %s", ifName, *lagId) } if lagId == nil || err != nil { return nil, nil } lagStr = *lagId } if len(lagStr) != 0 { m := make(map[string]string) value := db.Value{Field: m} m["NULL"] = "NULL" intfKey := lagStr + "|" + ifName if _, ok := memMap[tblName]; !ok { memMap[tblName] = make(map[string]db.Value) } memMap[tblName][intfKey] = value } } if intfObj.Ethernet.Config.PortSpeed != 0 { res_map := make(map[string]string) value := db.Value{Field: res_map} intTbl := IntfTypeTblMap[intfType] portSpeed := intfObj.Ethernet.Config.PortSpeed val, ok := intfOCToSpeedMap[portSpeed] if ok { err = nil res_map[PORT_SPEED] = val res_map[PORT_AUTONEG] = "off" } else { err = tlerr.InvalidArgs("Invalid speed %s", val) } if err == nil { if _, ok := memMap[intTbl.cfgDb.portTN]; !ok { memMap[intTbl.cfgDb.portTN] = make(map[string]db.Value) } memMap[intTbl.cfgDb.portTN][ifName] = value } } else if requestUriPath == "/openconfig-interfaces:interfaces/interface/openconfig-if-ethernet:ethernet/config/port-speed" { if inParams.oper == DELETE { err_str := "DELETE request not allowed for port-speed" return nil, tlerr.NotSupported(err_str) } else { log.Error("Unexpected oper ", inParams.oper) } } res_map := make(map[string]string) value := db.Value{Field: res_map} if intfObj.Ethernet.Config.AutoNegotiate != nil { if intfType == IntfTypeEthernet { intTbl := IntfTypeTblMap[intfType] autoNeg := intfObj.Ethernet.Config.AutoNegotiate var enStr string if *autoNeg { enStr = "on" } else { enStr = "off" } res_map[PORT_AUTONEG] = enStr if _, ok := memMap[intTbl.cfgDb.portTN]; !ok { memMap[intTbl.cfgDb.portTN] = make(map[string]db.Value) } memMap[intTbl.cfgDb.portTN][ifName] = value } else { return nil, errors.New("AutoNegotiate config not supported for given Interface type") } } return memMap, err }
YangToDb_intf_eth_port_config_xfmr handles port-speed, auto-neg, and aggregate-id config.
var YangToDb_intf_ip_addr_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err, oerr error subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) subIntfmap := make(map[string]map[string]db.Value) subIntfmap_del := make(map[string]map[string]db.Value) var value db.Value var overlapIP string pathInfo := NewPathInfo(inParams.uri) uriIfName := pathInfo.Var("name") idx := pathInfo.Var("index") i64, err := strconv.ParseUint(idx, 10, 32) i32 := uint32(i64) ifName := uriIfName sonicIfName := &uriIfName log.Infof("YangToDb_intf_ip_addr_xfmr: Interface name retrieved from alias : %s is %s", ifName, *sonicIfName) ifName = *sonicIfName intfType, _, ierr := getIntfTypeByName(ifName) intfsObj := getIntfsRoot(inParams.ygRoot) if intfsObj == nil || len(intfsObj.Interface) < 1 { log.Info("YangToDb_intf_subintf_ip_xfmr : IntfsObj/interface list is empty.") return subIntfmap, errors.New("IntfsObj/Interface is not specified") } if ifName == "" { errStr := "Interface KEY not present" log.Info("YangToDb_intf_subintf_ip_xfmr : " + errStr) return subIntfmap, errors.New(errStr) } if intfType == IntfTypeUnset || ierr != nil { errStr := "Invalid interface type IntfTypeUnset" log.Info("YangToDb_intf_subintf_ip_xfmr : " + errStr) return subIntfmap, errors.New(errStr) } if inParams.invokeCRUSubtreeOnce != nil { *inParams.invokeCRUSubtreeOnce = true } prefixType := "" if strings.Contains(inParams.uri, "ipv4") { prefixType = "ipv4" } else if strings.Contains(inParams.uri, "ipv6") { prefixType = "ipv6" } if inParams.oper == DELETE { dhcpProv, _ := ValidateIntfProvisionedForRelay(inParams.d, ifName, prefixType, nil) if dhcpProv { errStr := "IP address cannot be deleted. DHCP Relay is configured on the interface." return subIntfmap, tlerr.InvalidArgsError{Format: errStr} } } if _, ok := intfsObj.Interface[uriIfName]; !ok { errStr := "Interface entry not found in Ygot tree, ifname: " + ifName log.Info("YangToDb_intf_subintf_ip_xfmr : " + errStr) return subIntfmap, errors.New(errStr) } intTbl := IntfTypeTblMap[intfType] tblName, _ := getIntfTableNameByDBId(intTbl, inParams.curDb) intfObj := intfsObj.Interface[uriIfName] if intfObj.Subinterfaces == nil || len(intfObj.Subinterfaces.Subinterface) < 1 { if inParams.oper == DELETE { log.Info("Top level Interface instance delete or subinterfaces container delete for Interface: ", ifName) return intf_ip_addr_del(inParams.d, ifName, tblName, nil) } errStr := "SubInterface node doesn't exist" log.Info("YangToDb_intf_subintf_ip_xfmr : " + errStr) err = tlerr.InvalidArgsError{Format: errStr} return subIntfmap, err } if _, ok := intfObj.Subinterfaces.Subinterface[i32]; !ok { log.Info("YangToDb_intf_subintf_ip_xfmr : No IP address handling required") errStr := "SubInterface index 0 doesn't exist" err = tlerr.InvalidArgsError{Format: errStr} return subIntfmap, err } subIntfObj := intfObj.Subinterfaces.Subinterface[i32] if inParams.oper == DELETE { return intf_ip_addr_del(inParams.d, ifName, tblName, subIntfObj) } entry, dbErr := inParams.d.GetEntry(&db.TableSpec{Name: intTbl.cfgDb.intfTN}, db.Key{Comp: []string{ifName}}) if dbErr != nil || !entry.IsPopulated() { ifdb := make(map[string]string) ifdb["NULL"] = "NULL" value := db.Value{Field: ifdb} if _, ok := subIntfmap[tblName]; !ok { subIntfmap[tblName] = make(map[string]db.Value) } subIntfmap[tblName][ifName] = value } if subIntfObj.Ipv4 != nil && subIntfObj.Ipv4.Addresses != nil { for ip := range subIntfObj.Ipv4.Addresses.Address { addr := subIntfObj.Ipv4.Addresses.Address[ip] if addr.Config != nil { if addr.Config.Ip == nil { addr.Config.Ip = new(string) *addr.Config.Ip = ip } log.Info("Ip:=", *addr.Config.Ip) if addr.Config.PrefixLength == nil { log.Error("Prefix Length empty!") errStr := "Prefix Length not present" err = tlerr.InvalidArgsError{Format: errStr} return subIntfmap, err } log.Info("prefix:=", *addr.Config.PrefixLength) ipPref := *addr.Config.Ip + "/" + strconv.Itoa(int(*addr.Config.PrefixLength)) overlapIP, oerr = validateIpOverlap(inParams.d, ifName, ipPref, tblName, true) ipEntry, _ := inParams.d.GetEntry(&db.TableSpec{Name: intTbl.cfgDb.intfTN}, db.Key{Comp: []string{ifName, ipPref}}) ipMap, _ := getIntfIpByName(inParams.d, intTbl.cfgDb.intfTN, ifName, true, false, "") m := make(map[string]string) alrdyCfgredIP, primaryIpAlrdyCfgred, err := utlValidateIpTypeForCfgredDiffIp(m, ipMap, &ipEntry, &ipPref, &ifName) if err != nil { return nil, err } if primaryIpAlrdyCfgred && len(alrdyCfgredIP) != 0 && alrdyCfgredIP != ipPref { subIntfmap_del[tblName] = make(map[string]db.Value) key := ifName + "|" + alrdyCfgredIP subIntfmap_del[tblName][key] = value subOpMap[db.ConfigDB] = subIntfmap_del log.Info("subOpMap: ", subOpMap) inParams.subOpDataMap[DELETE] = &subOpMap } intf_key := intf_intf_tbl_key_gen(ifName, *addr.Config.Ip, int(*addr.Config.PrefixLength), "|") m["family"] = "IPv4" value := db.Value{Field: m} if _, ok := subIntfmap[tblName]; !ok { subIntfmap[tblName] = make(map[string]db.Value) } subIntfmap[tblName][intf_key] = value if log.V(3) { log.Info("tblName :", tblName, " intf_key: ", intf_key, " data : ", value) } } } } if subIntfObj.Ipv6 != nil && subIntfObj.Ipv6.Addresses != nil { for ip := range subIntfObj.Ipv6.Addresses.Address { addr := subIntfObj.Ipv6.Addresses.Address[ip] if addr.Config != nil { if addr.Config.Ip == nil { addr.Config.Ip = new(string) *addr.Config.Ip = ip } log.Info("Ipv6 IP:=", *addr.Config.Ip) if addr.Config.PrefixLength == nil { log.Error("Prefix Length empty!") errStr := "Prefix Length not present" err = tlerr.InvalidArgsError{Format: errStr} return subIntfmap, err } log.Info("Ipv6 prefix:=", *addr.Config.PrefixLength) ipPref := *addr.Config.Ip + "/" + strconv.Itoa(int(*addr.Config.PrefixLength)) overlapIP, oerr = validateIpOverlap(inParams.d, ifName, ipPref, tblName, true) m := make(map[string]string) intf_key := intf_intf_tbl_key_gen(ifName, *addr.Config.Ip, int(*addr.Config.PrefixLength), "|") m["family"] = "IPv6" value := db.Value{Field: m} if _, ok := subIntfmap[tblName]; !ok { subIntfmap[tblName] = make(map[string]db.Value) } subIntfmap[tblName][intf_key] = value log.Info("tblName :", tblName, "intf_key: ", intf_key, "data : ", value) } } } if oerr != nil { if overlapIP == "" { log.Error(oerr) return nil, tlerr.InvalidArgsError{Format: oerr.Error()} } else { subIntfmap_del[tblName] = make(map[string]db.Value) key := ifName + "|" + overlapIP subIntfmap_del[tblName][key] = value subOpMap[db.ConfigDB] = subIntfmap_del log.Info("subOpMap: ", subOpMap) inParams.subOpDataMap[DELETE] = &subOpMap } } log.Info("YangToDb_intf_subintf_ip_xfmr : subIntfmap : ", subIntfmap) return subIntfmap, err }
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
- sw_portchannel.go
- transformer.go
- xconst.go
- xfmr_dbtbl_cbk_interface.go
- xfmr_interface.go
- xfmr_intf.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