diff --git a/cvl/custom_validation/sonic_pac.go b/cvl/custom_validation/sonic_pac.go index d7024b703..cf74762b8 100644 --- a/cvl/custom_validation/sonic_pac.go +++ b/cvl/custom_validation/sonic_pac.go @@ -23,6 +23,7 @@ import ( "fmt" "strings" + util "github.com/Azure/sonic-mgmt-common/cvl/internal/util" log "github.com/golang/glog" ) @@ -48,7 +49,7 @@ func (t *CustomValidation) ValidatePacPortChannelIntf(vc *CustValidationCtxt) CV ErrCode: CVL_SEMANTIC_ERROR, TableName: "PAC_PORT_CONFIG_TABLE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s interface as it is a member of a portchannel.", if_name), + ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s interface as it is a member of a portchannel.", util.Format("ifname", if_name)), CVLErrDetails: "Config Validation Error", } } @@ -78,7 +79,7 @@ func (t *CustomValidation) ValidateMabPortChannelIntf(vc *CustValidationCtxt) CV ErrCode: CVL_SEMANTIC_ERROR, TableName: "MAB_PORT_CONFIG_TABLE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure MAB on %s interface as it is a member of a portchannel.", if_name), + ConstraintErrMsg: fmt.Sprintf("Cannot configure MAB on %s interface as it is a member of a portchannel.", util.Format("ifname", if_name)), CVLErrDetails: "Config Validation Error", } } @@ -108,7 +109,7 @@ func (t *CustomValidation) ValidatePacRoutingIntfCheck(vc *CustValidationCtxt) C ErrCode: CVL_SEMANTIC_ERROR, TableName: "PAC_PORT_CONFIG_TABLE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as it is a routing interface.", if_name), + ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as it is a routing interface.", util.Format("ifname", if_name)), CVLErrDetails: "Config Validation Error", } } @@ -137,7 +138,7 @@ func (t *CustomValidation) ValidateMabRoutingIntfCheck(vc *CustValidationCtxt) C ErrCode: CVL_SEMANTIC_ERROR, TableName: "MAB_PORT_CONFIG_TABLE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure MAB on %s as it is a routing interface.", if_name), + ConstraintErrMsg: fmt.Sprintf("Cannot configure MAB on %s as it is a routing interface.", util.Format("ifname", if_name)), CVLErrDetails: "Config Validation Error", } } @@ -166,7 +167,7 @@ func (t *CustomValidation) ValidatePacMirrorSessionDstPort(vc *CustValidationCtx return CVLErrorInfo{ ErrCode: CVL_SEMANTIC_ERROR, TableName: "PAC_PORT_CONFIG_TABLE", - ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as it is configured as destination port in a mirror session.", if_name), + ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as it is configured as destination port in a mirror session.", util.Format("ifname", if_name)), CVLErrDetails: "Config Validation Error", } } @@ -194,7 +195,7 @@ func (t *CustomValidation) ValidatePacPmsPort(vc *CustValidationCtxt) CVLErrorIn ErrCode: CVL_SEMANTIC_ERROR, TableName: "PAC_PORT_CONFIG_TABLE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as PMS is enabled on it.", ifname), + ConstraintErrMsg: fmt.Sprintf("Cannot configure PAC on %s as PMS is enabled on it.", util.Format("ifname", ifname)), CVLErrDetails: "Config Validation Error", } } diff --git a/cvl/custom_validation/sonic_subinterface.go b/cvl/custom_validation/sonic_subinterface.go index 78ce0ec66..2a3c47d7d 100644 --- a/cvl/custom_validation/sonic_subinterface.go +++ b/cvl/custom_validation/sonic_subinterface.go @@ -296,7 +296,7 @@ func (t *CustomValidation) ValidateSubInterfaceIntf(vc *CustValidationCtxt) CVLE ErrCode: CVL_SEMANTIC_ERROR, TableName: "VLAN_SUB_INTERFACE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure sub-interface as %s is a member of portchannel.", parentIfName), + ConstraintErrMsg: fmt.Sprintf("Cannot configure sub-interface as %s is a member of portchannel.", util.Format("ifname", parentIfName)), CVLErrDetails: "Config Validation Error", } } @@ -330,7 +330,7 @@ func (t *CustomValidation) ValidateSubInterfaceIntf(vc *CustValidationCtxt) CVLE ErrCode: CVL_SEMANTIC_ERROR, TableName: "VLAN_SUB_INTERFACE", Keys: strings.Split(vc.CurCfg.Key, "|"), - ConstraintErrMsg: fmt.Sprintf("Cannot configure sub-interface as %s has switchport config.", parentIfName), + ConstraintErrMsg: fmt.Sprintf("Cannot configure sub-interface as %s has switchport config.", util.Format("ifname", parentIfName)), CVLErrDetails: "Config Validation Error", } } diff --git a/cvl/cvl.go b/cvl/cvl.go index 4094bd0c7..bb99ebe83 100644 --- a/cvl/cvl.go +++ b/cvl/cvl.go @@ -1102,3 +1102,7 @@ func isMandatoryTrueNode(tblName, field string) bool { return false } + +func AddFormatterFunc(s string, f Formatter) error { + return AddToFormatterFuncsMap(s, f) +} diff --git a/cvl/internal/util/util.go b/cvl/internal/util/util.go index 5d7a20e1c..c22144bb7 100644 --- a/cvl/internal/util/util.go +++ b/cvl/internal/util/util.go @@ -68,6 +68,10 @@ const ENV_VAR_SONIC_DB_CONFIG_FILE = "DB_CONFIG_PATH" var sonic_db_config = make(map[string]interface{}) +type Formatter func(string) string + +var formatterFunctionsMap map[string]Formatter + //package init function func init() { if os.Getenv("CVL_SCHEMA_PATH") != "" { @@ -83,6 +87,8 @@ func init() { //Initialize DB settings dbCfgInit() + + formatterFunctionsMap = make(map[string]Formatter) } var cvlCfgMap map[string]string @@ -692,3 +698,21 @@ func GetTableAndKeyFromRedisKey(redisKey, delim string) (string, string) { return redisKey[:idx], redisKey[idx+1:] } + +func AddToFormatterFuncsMap(s string, f Formatter) error { + if _, ok := formatterFunctionsMap[s]; !ok { + formatterFunctionsMap[s] = f + } else { + return fmt.Errorf("Formatter '%s' is already registered", s) + } + + return nil +} + +func Format(fname string, val string) string { + if formatter, ok := formatterFunctionsMap[fname]; ok { + return formatter(val) + } else { + return val + } +} diff --git a/models/yang/sonic/sonic-mgmt-port.yang b/models/yang/sonic/sonic-mgmt-port.yang index dcc9664d8..b3a0a56be 100644 --- a/models/yang/sonic/sonic-mgmt-port.yang +++ b/models/yang/sonic/sonic-mgmt-port.yang @@ -48,8 +48,8 @@ module sonic-mgmt-port { } leaf autoneg { - type string; - default "on"; + type boolean; + default true; } leaf alias { diff --git a/translib/acl_app.go b/translib/acl_app.go index 579846766..974c728df 100644 --- a/translib/acl_app.go +++ b/translib/acl_app.go @@ -102,6 +102,7 @@ const ( ACL_CLIENT_L3_REDIRECT_ACL = "L3_REDIRECT_ACL@" ACL_CLIENT_L3V6_SECURITY_ACL = "L3V6_SECURITY_ACL@" ACL_CLIENT_L3V6_REDIRECT_ACL = "L3V6_REDIRECT_ACL@" + ACL_INTERNAL_FIELD_SOURCE = "_SOURCE" ) var IP_PROTOCOL_MAP = map[ocbinds.E_OpenconfigPacketMatchTypes_IP_PROTOCOL]uint8{ @@ -934,6 +935,7 @@ func (app *AclApp) convertDBAclToInternal(dbs [db.MaxDB]*db.DB, aclkey db.Key) e } if entry.IsPopulated() { if entry.Field[ACL_FIELD_TYPE] == SONIC_ACL_TYPE_L2 || entry.Field[ACL_FIELD_TYPE] == SONIC_ACL_TYPE_IPV4 || entry.Field[ACL_FIELD_TYPE] == SONIC_ACL_TYPE_IPV6 { + entry.Field[ACL_INTERNAL_FIELD_SOURCE] = "User" app.aclTableMap[aclkey.Get(0)] = entry app.ruleTableMap[aclkey.Get(0)] = make(map[string]db.Value) err = app.convertDBAclRulesToInternal(dbs, aclkey.Get(0), "", db.Key{}) @@ -1438,7 +1440,7 @@ func convertInternalAclBindingStatusTypeToOC(status string) ocbinds.E_Openconfig return ocStatusType } -func (app *AclApp) getAclExtStateInfoForNameStage(statedb *db.DB, intfId string, stage string, aclName string, aclType ocbinds.E_OpenconfigAcl_ACL_TYPE, aclSetState reflect.Value) error { +func (app *AclApp) getAclExtStateInfoForNameStage(statedb *db.DB, intfId string, stage string, aclName string, aclType ocbinds.E_OpenconfigAcl_ACL_TYPE, aclSetState reflect.Value, pacBinding *bool) error { log.Infof("Intf:%s stage:%s name:%s Type:%v", intfId, stage, aclName, aclType) bindingTblData, bindingTblErr := statedb.GetEntry(app.aclBindStateTs, db.Key{Comp: []string{intfId, stage}}) @@ -1452,6 +1454,7 @@ func (app *AclApp) getAclExtStateInfoForNameStage(statedb *db.DB, intfId string, prio, _ := strconv.ParseUint(parts[3], 10, 16) prio_uint := uint16(prio) source := convertInternalAclSourceTypeToOC(parts[1]) + *pacBinding = (SONIC_ACL_SOURCE_PAC == parts[1]) aclSetState.Elem().FieldByName("Priority").Set(reflect.ValueOf(&prio_uint)) aclSetState.Elem().FieldByName("Source").Set(reflect.ValueOf(source)) if parts[2] != "" { @@ -1477,7 +1480,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag // Validate and return error always. aclDbName := app.getAclKeyByCheckingDbForNameWithoutType(dbs[db.ConfigDB], aclName, aclType) - aclDataFromStateDB := false var aclData db.Value if len(app.aclTableMap) > 0 && len(app.aclStateTableMap) > 0 { var found bool @@ -1488,7 +1490,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag log.Infof("ACL:%s Type:%v not found", aclDbName, aclType) return tlerr.NotFound("ACL:%s:%v not found", aclName, aclType) } - aclDataFromStateDB = true } } else { var err error @@ -1498,7 +1499,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag if err != nil { return err } else { - aclDataFromStateDB = true app.aclStateTableMap[aclDbName] = aclData } } else { @@ -1516,20 +1516,13 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag return tlerr.NotFound("requested binding not found for %s and %s at %s", aclName, intfId, stage) } - if !aclDataFromStateDB { - aclSetCfg := aclSet.Elem().FieldByName("Config") - if !aclSetCfg.IsNil() { - aclSetCfg.Elem().FieldByName("SetName").Set(aclSet.Elem().FieldByName("SetName")) - aclSetCfg.Elem().FieldByName("Type").Set(aclSet.Elem().FieldByName("Type")) - } - } - + pacBinding := false aclSetState := aclSet.Elem().FieldByName("State") if !aclSetState.IsNil() { aclSetState.Elem().FieldByName("SetName").Set(aclSet.Elem().FieldByName("SetName")) aclSetState.Elem().FieldByName("Type").Set(aclSet.Elem().FieldByName("Type")) if intfId != ACL_GLOBAL_PORT && intfId != ACL_CTRL_PLANE_PORT { - err := app.getAclExtStateInfoForNameStage(dbs[db.StateDB], intfId, stage, aclName, aclType, aclSetState) + err := app.getAclExtStateInfoForNameStage(dbs[db.StateDB], intfId, stage, aclName, aclType, aclSetState, &pacBinding) if isNotFoundError(err) { return tlerr.NotFound("Binding not found for ACL %s on %s at %s", aclName, intfId, stage) } else if err != nil { @@ -1541,6 +1534,14 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag } } + if !pacBinding { + aclSetCfg := aclSet.Elem().FieldByName("Config") + if !aclSetCfg.IsNil() { + aclSetCfg.Elem().FieldByName("SetName").Set(aclSet.Elem().FieldByName("SetName")) + aclSetCfg.Elem().FieldByName("Type").Set(aclSet.Elem().FieldByName("Type")) + } + } + // At this stage we have verified that the ACL binding exists. Starts filling the actual data // Check if the data was requested for a specific Entry else find all the rules aclEntries := aclSet.Elem().FieldByName("AclEntries") @@ -3370,6 +3371,7 @@ func (app *AclApp) convertStateDBAclToInternal(dbs [db.MaxDB]*db.DB, aclkey db.K if entry.IsPopulated() { if entry.Field[ACL_CLIENT_FIELD_TYPE] == SONIC_ACL_TYPE_L2 || entry.Field[ACL_CLIENT_FIELD_TYPE] == SONIC_ACL_TYPE_IPV4 || entry.Field[ACL_CLIENT_FIELD_TYPE] == SONIC_ACL_TYPE_IPV6 { + entry.Field[ACL_INTERNAL_FIELD_SOURCE] = "PAC" app.aclStateTableMap[aclkey.Get(0)] = entry app.ruleStateTableMap[aclkey.Get(0)] = make(map[string]db.Value) err = app.convertStateDBAclRulesToInternal(dbs, aclkey.Get(0), "", db.Key{}) @@ -3398,6 +3400,7 @@ func (app *AclApp) convertStateDBInternalToOCAcl(aclName string, aclSets *ocbind if len(aclName) > 0 { aclData := app.aclStateTableMap[aclName] if aclSet != nil { + aclSet.Config = nil aclSet.State.Name = aclSet.Name aclSet.State.Type = aclSet.Type @@ -3407,6 +3410,13 @@ func (app *AclApp) convertStateDBInternalToOCAcl(aclName string, aclSets *ocbind aclSet.State.Description = &descr } else if k == "ports@" { continue + } else if k == ACL_INTERNAL_FIELD_SOURCE { + src := aclData.Get(k) + if src == "PAC" { + aclSet.State.Source = ocbinds.OpenconfigAclExt_ACL_SOURCE_TYPE_ACL_PAC_CREATED + } else { + aclSet.State.Source = ocbinds.OpenconfigAclExt_ACL_SOURCE_TYPE_ACL_USER_CREATED + } } } app.convertStateDBInternalToOCAclRule(aclName, aclSet.Type, "", aclSet, nil) diff --git a/translib/db/db.go b/translib/db/db.go index 410125015..7f2c326b8 100644 --- a/translib/db/db.go +++ b/translib/db/db.go @@ -559,7 +559,9 @@ func (d *DB) getEntry(ts *TableSpec, key Key, forceReadDB bool) (Value, error) { if !cacheHit && !txCacheHit { // Increase (i.e. more verbose) V() level if it gets too noisy. - glog.Info("getEntry: RedisCmd: ", d.Name(), ": ", "HGETALL ", entry) + if glog.V(3) { + glog.Info("getEntry: RedisCmd: ", d.Name(), ": ", "HGETALL ", entry) + } v, e = d.client.HGetAll(entry).Result() if len(v) != 0 { diff --git a/translib/path_validator.go b/translib/path_validator.go index 16a3e4b0d..51042c703 100644 --- a/translib/path_validator.go +++ b/translib/path_validator.go @@ -107,6 +107,9 @@ func (pv *pathValidator) getYangSchema() (*yang.Entry, error) { func (pv *pathValidator) getStructField(nodeName string) *reflect.StructField { var sField *reflect.StructField sval := reflect.ValueOf(pv.sValIntf).Elem() + if sval.Kind() != reflect.Struct { + return nil + } stype := sval.Type() for i := 0; i < sval.NumField(); i++ { fType := stype.Field(i) diff --git a/translib/transformer/xfmr_authmgr.go b/translib/transformer/xfmr_authmgr.go index 6ab67344f..a128728ff 100755 --- a/translib/transformer/xfmr_authmgr.go +++ b/translib/transformer/xfmr_authmgr.go @@ -131,7 +131,6 @@ var Subscribe_authmgr_port_config_xfmr = func(inParams XfmrSubscInParams) (XfmrS // handleAuthMgrGlobalConfigDeletion handles the delete operation on PAC_GLOBAL_CONFIG_TABLE. func handleAuthMgrGlobalConfigDeletion(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error - resMap := make(map[string]map[string]db.Value) subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) subResMap := make(map[string]map[string]db.Value) authMgrGlobalConfigMap := make(map[string]string) @@ -146,80 +145,49 @@ func handleAuthMgrGlobalConfigDeletion(inParams XfmrParams) (map[string]map[stri if targetUriPath == "/openconfig-authmgr:authmgr/authmgr-global-config" || targetUriPath == "/openconfig-authmgr:authmgr/authmgr-global-config/config" { - defaultGblTblDBValues := db.Value{Field: map[string]string{}} - //(&defaultGblTblDBValues).Set("authentication_enable ", AUTHMGR_DEFAULT_AUTH_ENABLE_STATUS) - (&defaultGblTblDBValues).Set("monitor_mode_enable", AUTHMGR_DEFAULT_AUTH_MONITOR_ENABLE_STATUS) - subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE] = make(map[string]db.Value) - subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE]["GLOBAL"] = defaultGblTblDBValues - /* - authMgrGlobalPortOrHostCtlCfgMap["port_control_mode"] = AUTHMGR_DEFAULT_PORT_CONTROL_MODE - authMgrGlobalPortOrHostCtlCfgMap["host_control_mode"] = AUTHMGR_DEFAULT_HOST_CONTROL_MODE - - err = enableAuthMgrPortOrHostMode(inParams.d, authMgrGlobalPortOrHostCtlCfgMap, authMgrPortConfigMap) - - if err != nil { - return resMap, err - } - - if len(authMgrPortConfigMap) != 0 { - subResMap[AUTHMGR_PORT_CONFIG_TABLE] = authMgrPortConfigMap - } - */ - subOpMap[db.ConfigDB] = subResMap - log.Info("handleAuthMgrGlobalConfigDeletion subOpMap: ", subOpMap) - inParams.subOpDataMap[UPDATE] = &subOpMap - return resMap, err + subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE] = nil + return subResMap, err } xpath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) - var fldName, valStr string + var fldName string /* var fldNamePortOrHost, valPortOrHostStr string if strings.HasSuffix(xpath, "authentication-enable") { fldName = "authentication_enable" - valStr = AUTHMGR_DEFAULT_AUTH_ENABLE_STATUS } */ if strings.HasSuffix(xpath, "monitor-mode-enable") { fldName = "monitor_mode_enable" - valStr = AUTHMGR_DEFAULT_AUTH_MONITOR_ENABLE_STATUS } /* if strings.HasSuffix(xpath, "max-reauth") { fldName = "max_reauth" - valStr = AUTHMGR_CRITICAL_RECOVERY_MAX_REAUTH } if strings.HasSuffix(xpath, "port-control-mode") { fldNamePortOrHost = "port_control_mode" - valPortOrHostStr = AUTHMGR_DEFAULT_PORT_CONTROL_MODE } if strings.HasSuffix(xpath, "host-control-mode") { fldNamePortOrHost = "host_control_mode" - valPortOrHostStr = AUTHMGR_DEFAULT_HOST_CONTROL_MODE } */ - if len(valStr) != 0 { - authMgrGlobalConfigMap[fldName] = valStr - } /* if len(valPortOrHostStr) != 0 { authMgrGlobalPortOrHostCtlCfgMap[fldNamePortOrHost] = valPortOrHostStr } */ - - if len(authMgrGlobalConfigMap) != 0 { - subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE] = make(map[string]db.Value) - subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: authMgrGlobalConfigMap} - } + authMgrGlobalConfigMap[fldName] = "" + subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[AUTHMGR_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: authMgrGlobalConfigMap} /* if len(authMgrGlobalPortOrHostCtlCfgMap) != 0 { err = enableAuthMgrPortOrHostMode(inParams.d, authMgrGlobalPortOrHostCtlCfgMap, authMgrPortConfigMap) if err != nil { - return resMap, err + return subResMap, err } } @@ -229,8 +197,8 @@ func handleAuthMgrGlobalConfigDeletion(inParams XfmrParams) (map[string]map[stri */ subOpMap[db.ConfigDB] = subResMap log.Info("handleAuthMgrGlobalConfigDeletion subOpMap: ", subOpMap) - inParams.subOpDataMap[UPDATE] = &subOpMap - return resMap, err + inParams.subOpDataMap[DELETE] = &subOpMap + return subResMap, err } var YangToDb_authmgr_global_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { @@ -314,7 +282,7 @@ func enableAuthMgrPortOrHostMode(d *db.DB, authMgrGlobalPortOrHostCtlCfgMap map[ func getAllInterfacesFromPacPortConfigTable(d *db.DB) ([]string, error) { var intfList []string - keys, err := d.GetKeys(&db.TableSpec{Name: "AUTHMGR_PORT_CONFIG_TABLE"}) + keys, err := d.GetKeys(&db.TableSpec{Name: AUTHMGR_PORT_CONFIG_TABLE}) if err != nil { return intfList, err } @@ -433,7 +401,6 @@ func convertInternalAuthMgrGlobalToOc(inParams XfmrParams, targetUriPath string, // handleAuthMgrPortConfigDeletion handles the delete operation on PAC_PORT_CONFIG_TABLE. func handleAuthMgrPortConfigDeletion(inParams XfmrParams, authMgrPortConfig *ocbinds.OpenconfigAuthmgr_Authmgr_AuthmgrPortConfig_Interface) (map[string]map[string]db.Value, error) { var err error - resMap := make(map[string]map[string]db.Value) subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) subResMap := make(map[string]map[string]db.Value) pathInfo := NewPathInfo(inParams.uri) @@ -441,6 +408,7 @@ func handleAuthMgrPortConfigDeletion(inParams XfmrParams, authMgrPortConfig *ocb uriIfName := pathInfo.Var("name") sonicIfName := utils.GetNativeNameFromUIName(&uriIfName) ifName := uriIfName + authMgrPortConfigMap := make(map[string]string) log.Infof("handleAuthMgrPortConfigDeletion: Interface name retrieved from alias : %s is %s", ifName, *sonicIfName) ifName = *sonicIfName @@ -448,164 +416,152 @@ func handleAuthMgrPortConfigDeletion(inParams XfmrParams, authMgrPortConfig *ocb if (targetUriPath == "/openconfig-authmgr:authmgr/authmgr-port-config") || (targetUriPath == "/openconfig-authmgr:authmgr/authmgr-port-config/interface/config") { - defaultPortTblDBValues := db.Value{Field: map[string]string{}} - (&defaultPortTblDBValues).Set("port_control_mode", AUTHMGR_DEFAULT_PORT_CONTROL_MODE) - (&defaultPortTblDBValues).Set("host_control_mode", AUTHMGR_DEFAULT_HOST_CONTROL_MODE) - (&defaultPortTblDBValues).Set("reauth_enable", AUTHMGR_DEFAULT_REAUTH_ENABLE) - //(&defaultPortTblDBValues).Set("quiet_period", AUTHMGR_DEFAULT_QUIET_PERIOD) - (&defaultPortTblDBValues).Set("reauth_period", AUTHMGR_DEFAULT_REAUTH_PERIOD) - (&defaultPortTblDBValues).Set("max_users_per_port", AUTHMGR_MULTI_AUTH_MODE_MAX_USERS) - (&defaultPortTblDBValues).Set("guest_vlan_id", AUTHMGR_DEFAULT_GUEST_VLAN) - (&defaultPortTblDBValues).Set("auth_fail_vlan_id", AUTHMGR_DEFAULT_AUTH_FAIL_VLAN) - //(&defaultPortTblDBValues).Set("max_reauth_attempts", AUTHMGR_MAX_AUTH_FAIL_ATTEMPTS) - (&defaultPortTblDBValues).Set("method_list@", AUTHMGR_DEFAULT_AUTH_METHOD_LIST) - (&defaultPortTblDBValues).Set("priority_list@", AUTHMGR_DEFAULT_AUTH_PRIORITY_LIST) - (&defaultPortTblDBValues).Set("open_authentication_mode", AUTHMGR_DEFAULT_OPEN_AUTH_MODE) - (&defaultPortTblDBValues).Set("reauth_period_from_server", AUTHMGR_REAUTH_PERIOD_FROM_SERVER) - (&defaultPortTblDBValues).Set("port_pae_role", AUTHMGR_DOT1X_PAE_DEFAULT_ROLE) - /* - (&defaultPortTblDBValues).Set("dead_server_critical_vlan", AUTHMGR_DEAD_SERVER_CRITICAL_VLAN) - (&defaultPortTblDBValues).Set("dead_server_action_voice", AUTHMGR_AUTH_EVENT_SERVER_DEAD_VOICE_ACTION) - (&defaultPortTblDBValues).Set("dead_server_action", AUTHMGR_AUTH_EVENT_SERVER_DEAD_ACTION) - (&defaultPortTblDBValues).Set("server_alive_action", AUTHMGR_DEFAULT_AUTH_DEAD_SERVER_ALIVE_ACTION) - */ + authMgrPortConfigMap["port_control_mode"] = "" + authMgrPortConfigMap["host_control_mode"] = "" + authMgrPortConfigMap["reauth_enable"] = "" + authMgrPortConfigMap["reauth_period"] = "" + authMgrPortConfigMap["guest_vlan_id"] = "" + authMgrPortConfigMap["auth-fail-vlan-id"] = "" + authMgrPortConfigMap["method_list@"] = "" + authMgrPortConfigMap["priority_list@"] = "" + authMgrPortConfigMap["open_authentication_mode"] = "" + authMgrPortConfigMap["reauth_period_from_server"] = "" + authMgrPortConfigMap["port_pae_role"] = "" subResMap[AUTHMGR_PORT_CONFIG_TABLE] = make(map[string]db.Value) - subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = defaultPortTblDBValues + subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = db.Value{Field: authMgrPortConfigMap} + subOpMap[db.ConfigDB] = subResMap - inParams.subOpDataMap[UPDATE] = &subOpMap - log.Info("handleAuthMgrPortConfigDeletion targetUriPath: ", targetUriPath) - return resMap, nil - } + inParams.subOpDataMap[DELETE] = &subOpMap - authMgrPortConfigMap := make(map[string]string) + return subResMap, err - var fldName, valStr string + } + + var fldName string xpath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) if strings.HasSuffix(xpath, "port-control-mode") { fldName = "port_control_mode" - valStr = AUTHMGR_DEFAULT_PORT_CONTROL_MODE } if strings.HasSuffix(xpath, "host-control-mode") { fldName = "host_control_mode" - valStr = AUTHMGR_DEFAULT_HOST_CONTROL_MODE } if strings.HasSuffix(xpath, "reauth-enable") { fldName = "reauth_enable" - valStr = AUTHMGR_DEFAULT_REAUTH_ENABLE } /* if strings.HasSuffix(xpath, "quiet-period") { fldName = "quiet_period" - valStr = AUTHMGR_DEFAULT_QUIET_PERIOD } */ if strings.HasSuffix(xpath, "reauth-period") { fldName = "reauth_period" - valStr = AUTHMGR_DEFAULT_REAUTH_PERIOD } /* if strings.HasSuffix(xpath, "dead-server-critical-vlan") { fldName = "dead_server_critical_vlan" - valStr = AUTHMGR_DEAD_SERVER_CRITICAL_VLAN } if strings.HasSuffix(xpath, "dead-server-action-voice") { fldName = "dead_server_action_voice" - valStr = AUTHMGR_AUTH_EVENT_SERVER_DEAD_VOICE_ACTION } */ if strings.HasSuffix(xpath, "max-users-per-port") { fldName = "max_users_per_port" - valStr = AUTHMGR_MULTI_AUTH_MODE_MAX_USERS } /* if strings.HasSuffix(xpath, "dead-server-action") { fldName = "dead_server_action" - valStr = AUTHMGR_AUTH_EVENT_SERVER_DEAD_ACTION } */ if strings.HasSuffix(xpath, "guest-vlan-id") { fldName = "guest_vlan_id" - valStr = AUTHMGR_DEFAULT_GUEST_VLAN } /* if strings.HasSuffix(xpath, "server-alive-action") { fldName = "server_alive_action" - valStr = AUTHMGR_DEFAULT_AUTH_DEAD_SERVER_ALIVE_ACTION } */ if strings.HasSuffix(xpath, "auth-fail-vlan-id") { fldName = "auth_fail_vlan_id" - valStr = AUTHMGR_DEFAULT_AUTH_FAIL_VLAN } /* if strings.HasSuffix(xpath, "max-reauth-attempts") { fldName = "max_reauth_attempts" - valStr = AUTHMGR_MAX_AUTH_FAIL_ATTEMPTS } */ if strings.HasSuffix(xpath, "method-list") { fldName = "method_list@" if authMgrPortConfig.Config.MethodList != nil { + var methodListTmp []string + methodListTmp = append(methodListTmp, "ignore") + MethodList := convertOcAuthmgrMethodListToInternalDel(inParams.d, ifName, authMgrPortConfig.Config.MethodList) - if MethodList != nil { - valStr = strings.Join(MethodList, ",") + isEqual := reflect.DeepEqual(MethodList, methodListTmp) + if (MethodList != nil) && (!isEqual) { + valStr := strings.Join(MethodList, ",") + authMgrPortConfigMap[fldName] = valStr + subResMap[AUTHMGR_PORT_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = db.Value{Field: authMgrPortConfigMap} + subOpMap[db.ConfigDB] = subResMap + log.Info("handleAuthMgrPortConfigDeletion subOpMap: ", subOpMap) + inParams.subOpDataMap[REPLACE] = &subOpMap + return subResMap, err + } else if isEqual { + return subResMap, err } - } else { - valStr = AUTHMGR_DEFAULT_AUTH_METHOD_LIST } } if strings.HasSuffix(xpath, "priority-list") { fldName = "priority_list@" if authMgrPortConfig.Config.PriorityList != nil { + var priorityListTmp []string + priorityListTmp = append(priorityListTmp, "ignore") + PriorityList := convertOcAuthmgrPriorityListToInternalDel(inParams.d, ifName, authMgrPortConfig.Config.PriorityList) - if PriorityList != nil { - valStr = strings.Join(PriorityList, ",") + isEqual := reflect.DeepEqual(PriorityList, priorityListTmp) + if (PriorityList != nil) && (!isEqual) { + valStr := strings.Join(PriorityList, ",") + authMgrPortConfigMap[fldName] = valStr + subResMap[AUTHMGR_PORT_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = db.Value{Field: authMgrPortConfigMap} + subOpMap[db.ConfigDB] = subResMap + log.Info("handleAuthMgrPortConfigDeletion subOpMap: ", subOpMap) + inParams.subOpDataMap[REPLACE] = &subOpMap + return subResMap, err + } else if isEqual { + return subResMap, err } - } else { - valStr = AUTHMGR_DEFAULT_AUTH_PRIORITY_LIST } } if strings.HasSuffix(xpath, "open-authentication-mode") { fldName = "open_authentication_mode" - valStr = AUTHMGR_DEFAULT_OPEN_AUTH_MODE } if strings.HasSuffix(xpath, "reauth-period-from-server") { fldName = "reauth_period_from_server" - valStr = AUTHMGR_REAUTH_PERIOD_FROM_SERVER } if strings.HasSuffix(xpath, "port-pae-role") { fldName = "port_pae_role" - valStr = AUTHMGR_DOT1X_PAE_DEFAULT_ROLE } - if len(valStr) != 0 { - authMgrPortConfigMap[fldName] = valStr - } - - if len(authMgrPortConfigMap) != 0 { - subResMap[AUTHMGR_PORT_CONFIG_TABLE] = make(map[string]db.Value) - subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = db.Value{Field: authMgrPortConfigMap} - } + authMgrPortConfigMap[fldName] = "" + subResMap[AUTHMGR_PORT_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[AUTHMGR_PORT_CONFIG_TABLE][ifName] = db.Value{Field: authMgrPortConfigMap} subOpMap[db.ConfigDB] = subResMap log.Info("handleAuthMgrPortConfigDeletion subOpMap: ", subOpMap) + inParams.subOpDataMap[DELETE] = &subOpMap + + return subResMap, err - if fldName == "priority_list@" || fldName == "method_list@" { - inParams.subOpDataMap[REPLACE] = &subOpMap - } else { - inParams.subOpDataMap[UPDATE] = &subOpMap - } - return resMap, err } func getAuthmgrRoot(s *ygot.GoStruct) *ocbinds.OpenconfigAuthmgr_Authmgr { @@ -1636,7 +1592,7 @@ func convertOcAuthmgrMethodListToInternalDel(d *db.DB, ifName string, ocMethodLi var methodList []string var existingMethodList []string - cmnAppTs := &db.TableSpec{Name: "AUTHMGR_PORT_CONFIG_TABLE"} + cmnAppTs := &db.TableSpec{Name: AUTHMGR_PORT_CONFIG_TABLE} existingEntry, _ := d.GetEntry(cmnAppTs, db.Key{Comp: []string{ifName}}) if existingEntry.IsPopulated() { @@ -1672,9 +1628,10 @@ func convertOcAuthmgrMethodListToInternalDel(d *db.DB, ifName string, ocMethodLi isEqual := reflect.DeepEqual(existingMethodList, methodList) if isEqual { - methodList = []string{"dot1x", "mab"} + methodList = nil } else { methodList = nil + methodList = append(methodList, "ignore") } } @@ -1686,7 +1643,7 @@ func convertOcAuthmgrPriorityListToInternalDel(d *db.DB, ifName string, ocPriori var priorityList []string var existingPriorityList []string - cmnAppTs := &db.TableSpec{Name: "AUTHMGR_PORT_CONFIG_TABLE"} + cmnAppTs := &db.TableSpec{Name: AUTHMGR_PORT_CONFIG_TABLE} existingEntry, _ := d.GetEntry(cmnAppTs, db.Key{Comp: []string{ifName}}) if existingEntry.IsPopulated() { @@ -1722,9 +1679,10 @@ func convertOcAuthmgrPriorityListToInternalDel(d *db.DB, ifName string, ocPriori isEqual := reflect.DeepEqual(existingPriorityList, priorityList) if isEqual { - priorityList = []string{"dot1x", "mab"} + priorityList = nil } else { priorityList = nil + priorityList = append(priorityList, "ignore") } } diff --git a/translib/transformer/xfmr_hostapd.go b/translib/transformer/xfmr_hostapd.go index aa8e1c0b4..97fe3a928 100755 --- a/translib/transformer/xfmr_hostapd.go +++ b/translib/transformer/xfmr_hostapd.go @@ -69,36 +69,36 @@ var DbToYang_hostapd_client_oper_info_key_xfmr KeyXfmrDbToYang = func(inParams X func handleHostapdGlobalConfigDeletion(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error - resMap := make(map[string]map[string]db.Value) + subResMap := make(map[string]map[string]db.Value) + subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) + hostapdGlobalConfigMap := make(map[string]string) pathInfo := NewPathInfo(inParams.uri) targetUriPath, _ := getYangPathFromUri(pathInfo.Path) log.Info("handleHostapdGlobalConfigDeletion targetUriPath: ", targetUriPath) - subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) - subResMap := make(map[string]map[string]db.Value) - hostapdGlobalConfigMap := make(map[string]string) - subResMap[HOSTAPD_GLOBAL_CONFIG_TABLE] = make(map[string]db.Value) + if targetUriPath == "/openconfig-hostapd:hostapd/hostapd-global-config" || + targetUriPath == "/openconfig-hostapd:hostapd/hostapd-global-config/config" { + subResMap[HOSTAPD_GLOBAL_CONFIG_TABLE] = nil + return subResMap, err + } xpath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) - var fldName, valStr string + var fldName string if strings.HasSuffix(xpath, "dot1x-system-auth-control") { fldName = "dot1x_system_auth_control" - valStr = HOSTAPD_DEFAULT_SYSTEM_AUTH_CONTROL } - hostapdGlobalConfigMap[fldName] = valStr - - if len(hostapdGlobalConfigMap) != 0 { - subResMap[HOSTAPD_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: hostapdGlobalConfigMap} - } + hostapdGlobalConfigMap[fldName] = "" + subResMap[HOSTAPD_GLOBAL_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[HOSTAPD_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: hostapdGlobalConfigMap} subOpMap[db.ConfigDB] = subResMap log.Info("handleHostapdGlobalConfigDeletion subOpMap: ", subOpMap) - inParams.subOpDataMap[UPDATE] = &subOpMap - return resMap, err + inParams.subOpDataMap[DELETE] = &subOpMap + return subResMap, err } var YangToDb_hostapd_global_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { diff --git a/translib/transformer/xfmr_intf.go b/translib/transformer/xfmr_intf.go index 366dc8272..b887ab62d 100644 --- a/translib/transformer/xfmr_intf.go +++ b/translib/transformer/xfmr_intf.go @@ -2519,7 +2519,7 @@ var DbToYang_intf_eth_auto_neg_xfmr FieldXfmrDbtoYang = func(inParams XfmrParams prtInst := pTbl[inParams.key] autoNeg, ok := prtInst.Field[PORT_AUTONEG] if ok { - if autoNeg == "on" { + if autoNeg == "on" || autoNeg == "true" { result["auto-negotiate"] = true } else { result["auto-negotiate"] = false @@ -2632,7 +2632,7 @@ var DbToYang_intf_eth_negotiated_port_speed_xfmr FieldXfmrDbtoYang = func(inPara /* According to the yang specification, negotiated-port-speed is set when auto-negotiate is set to TRUE, and the interface has completed auto-negotiation with the remote peer. */ - if autoNeg, ok := prtInst.Field[PORT_AUTONEG]; !ok || autoNeg != "on" { + if autoNeg, ok := prtInst.Field[PORT_AUTONEG]; !ok || (autoNeg != "on" && autoNeg != "true") { log.Info("negotiated_port_speed depends on auto-negotiate field to be set to TRUE") return nil, errors.New("negotiated_port_speed depends on auto-negotiate field to be set to TRUE") } @@ -2659,7 +2659,7 @@ var DbToYang_intf_eth_negotiated_port_fec_xfmr FieldXfmrDbtoYang = func(inParams if err != nil { return nil, tlerr.New(err.Error()) } - if autoNeg, ok := prtInst.Field[PORT_AUTONEG]; !ok || autoNeg != "on" { + if autoNeg, ok := prtInst.Field[PORT_AUTONEG]; !ok || (autoNeg != "on" && autoNeg != "true") { log.Info("negotiated-port-fec depends on auto-negotiate field to be set to TRUE") return nil, errors.New("negotiated-port-fec depends on auto-negotiate field to be set to TRUE") } @@ -6189,7 +6189,9 @@ var YangToDb_intf_eth_port_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrP err = validateSpeed(inParams.d, ifName, val) if err == nil { res_map[PORT_SPEED] = val - res_map[PORT_AUTONEG] = "off" + if IntfTypeMgmt != intfType { + res_map[PORT_AUTONEG] = "off" + } } } else { err = tlerr.InvalidArgs("Invalid speed %s", val) @@ -6214,7 +6216,9 @@ var YangToDb_intf_eth_port_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrP err = validateSpeed(inParams.d, ifName, val) if err == nil { res_map[PORT_SPEED] = val - res_map[PORT_AUTONEG] = "off" + if IntfTypeMgmt != intfType { + res_map[PORT_AUTONEG] = "off" + } if _, ok := updateMap[intTbl.cfgDb.portTN]; !ok { updateMap[intTbl.cfgDb.portTN] = make(map[string]db.Value) } @@ -6327,9 +6331,17 @@ var YangToDb_intf_eth_port_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrP autoNeg := intfObj.Ethernet.Config.AutoNegotiate var enStr string if *autoNeg { - enStr = "on" + if IntfTypeMgmt == intfType { + enStr = "true" + } else { + enStr = "on" + } } else { - enStr = "off" + if IntfTypeMgmt == intfType { + enStr = "false" + } else { + enStr = "off" + } } res_map[PORT_AUTONEG] = enStr @@ -6492,7 +6504,7 @@ var DbToYang_intf_eth_port_config_xfmr SubTreeXfmrDbToYang = func(inParams XfmrP autoNeg, ok := entry.Field[PORT_AUTONEG] if ok { var oc_auto_neg bool - if autoNeg == "on" { + if autoNeg == "on" || autoNeg == "true" { oc_auto_neg = true } else { oc_auto_neg = false diff --git a/translib/transformer/xfmr_mab.go b/translib/transformer/xfmr_mab.go index 359347ffa..074c9173b 100755 --- a/translib/transformer/xfmr_mab.go +++ b/translib/transformer/xfmr_mab.go @@ -119,13 +119,29 @@ var YangToDb_mab_port_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams func handleMabPortConfigDeletion(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error - resMap := make(map[string]map[string]db.Value) + subResMap := make(map[string]map[string]db.Value) + subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) pathInfo := NewPathInfo(inParams.uri) targetUriPath, _ := getYangPathFromUri(pathInfo.Path) uriIfName := pathInfo.Var("name") ifName := uriIfName + mabPortConfigMap := make(map[string]string) log.Info("handleMabPortConfigDeletion targetUriPath: ", targetUriPath) + + if (targetUriPath == "/openconfig-mab:mab/mab-port-config") || + (targetUriPath == "/openconfig-mab:mab/mab-port-config/interface/config") { + mabPortConfigMap["mab_enable"] = "" + mabPortConfigMap["mab_auth_type"] = "" + subResMap[MAB_PORT_CONFIG_TABLE] = make(map[string]db.Value) + subResMap[MAB_PORT_CONFIG_TABLE][ifName] = db.Value{Field: mabPortConfigMap} + + subOpMap[db.ConfigDB] = subResMap + inParams.subOpDataMap[DELETE] = &subOpMap + + return subResMap, err + } + /* if inParams.requestUri == "/openconfig-pac:pac" { log.Info("handleMabPortConfigDeletion Parent level delete Request URI: ", inParams.requestUri) @@ -136,35 +152,27 @@ func handleMabPortConfigDeletion(inParams XfmrParams) (map[string]map[string]db. log.Infof("handleMabPortConfigDeletion: Interface name retrieved from alias : %s is %s", ifName, *sonicIfName) ifName = *sonicIfName - subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) - subResMap := make(map[string]map[string]db.Value) subResMap[MAB_PORT_CONFIG_TABLE] = make(map[string]db.Value) - mabPortConfigMap := make(map[string]string) - var fldName, valStr string + var fldName string xpath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) if strings.HasSuffix(xpath, "mab-enable") { fldName = "mab_enable" - valStr = MAB_ENABLE_DEFAULT_MODE - mabPortConfigMap[fldName] = valStr } if strings.HasSuffix(xpath, "mab-auth-type") { fldName = "mab_auth_type" - valStr = MAB_DEFAULT_AUTH_TYPE - mabPortConfigMap[fldName] = valStr } - if len(mabPortConfigMap) != 0 { - subResMap[MAB_PORT_CONFIG_TABLE][ifName] = db.Value{Field: mabPortConfigMap} - } + mabPortConfigMap[fldName] = "" + subResMap[MAB_PORT_CONFIG_TABLE][ifName] = db.Value{Field: mabPortConfigMap} subOpMap[db.ConfigDB] = subResMap log.Info("handleMabPortConfigDeletion subOpMap: ", subOpMap) - inParams.subOpDataMap[UPDATE] = &subOpMap + inParams.subOpDataMap[DELETE] = &subOpMap - return resMap, err + return subResMap, err } func convertOcMabPortConfigToInternal(mabPortConfig *ocbinds.OpenconfigMab_Mab_MabPortConfig_Interface, mabPortConfigMap map[string]string) error { @@ -293,7 +301,6 @@ func convertInternalMabPortInterfaceConfigToOc(d *db.DB, ifName string, uriIfNam func handleMabGlobalConfigDeletion(inParams XfmrParams) (map[string]map[string]db.Value, error) { var err error - resMap := make(map[string]map[string]db.Value) subOpMap := make(map[db.DBNum]map[string]map[string]db.Value) subResMap := make(map[string]map[string]db.Value) mabGlobalConfigMap := make(map[string]string) @@ -306,45 +313,33 @@ func handleMabGlobalConfigDeletion(inParams XfmrParams) (map[string]map[string]d if targetUriPath == "/openconfig-mab:mab/mab-global-config" || targetUriPath == "/openconfig-mab:mab/mab-global-config/config" { - defaultDBValues := db.Value{Field: map[string]string{}} - (&defaultDBValues).Set("group_size", MAB_DEFAULT_GROUP_SIZE) - (&defaultDBValues).Set("separator", MAB_DEFAULT_SEPARATOR) - (&defaultDBValues).Set("case", MAB_DEFAULT_ATTR_CASE) - subResMap[MAB_GLOBAL_CONFIG_TABLE]["GLOBAL"] = defaultDBValues - subOpMap[db.ConfigDB] = subResMap - inParams.subOpDataMap[UPDATE] = &subOpMap - return resMap, err + subResMap[MAB_GLOBAL_CONFIG_TABLE] = nil + return subResMap, err } xpath, _, _ := XfmrRemoveXPATHPredicates(inParams.requestUri) - var fldName, valStr string + var fldName string if strings.HasSuffix(xpath, "group-size") { fldName = "group_size" - valStr = MAB_DEFAULT_GROUP_SIZE } if strings.HasSuffix(xpath, "separator") { fldName = "separator" - valStr = MAB_DEFAULT_SEPARATOR } if strings.HasSuffix(xpath, "case") { fldName = "case" - valStr = MAB_DEFAULT_ATTR_CASE } - mabGlobalConfigMap[fldName] = valStr - - if len(mabGlobalConfigMap) != 0 { - subResMap[MAB_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: mabGlobalConfigMap} - } + mabGlobalConfigMap[fldName] = "" + subResMap[MAB_GLOBAL_CONFIG_TABLE]["GLOBAL"] = db.Value{Field: mabGlobalConfigMap} subOpMap[db.ConfigDB] = subResMap log.Info("handleMabGlobalConfigDeletion subOpMap: ", subOpMap) - inParams.subOpDataMap[UPDATE] = &subOpMap - return resMap, err + inParams.subOpDataMap[DELETE] = &subOpMap + return subResMap, err } var YangToDb_mab_global_config_xfmr SubTreeXfmrYangToDb = func(inParams XfmrParams) (map[string]map[string]db.Value, error) { diff --git a/translib/transformer/xfmr_vlan.go b/translib/transformer/xfmr_vlan.go index de948d44e..b34b359e6 100644 --- a/translib/transformer/xfmr_vlan.go +++ b/translib/transformer/xfmr_vlan.go @@ -253,7 +253,7 @@ var YangToDb_reserved_vlan_name_xfmr FieldXfmrYangToDb = func(inParams XfmrParam } keys, _ := data1.GetKeys() if len(keys) >= 128 { - return res_map, errors.New("Maximum number of reserved vlan's 128 configured") + return res_map, tlerr.NotSupported("Maximum number of reserved vlan's 128 configured") } entry, dbErr := inParams.d.GetEntry(&db.TableSpec{Name: "RESERVED_VLAN"}, db.Key{Comp: []string{vlan_name}}) if dbErr != nil { diff --git a/translib/utils/utils.go b/translib/utils/utils.go index 8843c748c..396b3697c 100644 --- a/translib/utils/utils.go +++ b/translib/utils/utils.go @@ -167,6 +167,9 @@ func init() { populatePortDS() devMetaNotifSubscribe() mgmtPortNotifSubscribe() + if cvl.AddFormatterFunc("ifname", intfAliasCvlFormatter) != nil { + log.Error("Failed to register formatter function 'ifname'") + } } // GenerateMemberPortsSliceFromString Convert string to slice @@ -1017,3 +1020,7 @@ func EventNotify(dbs [db.MaxDB]*db.DB, name string, source string, action int, f } return err } + +func intfAliasCvlFormatter(intfName string) string { + return *(GetUINameFromNativeName(&intfName)) +}