From 3549a51f8b75377db2f408e559cde794030c81b9 Mon Sep 17 00:00:00 2001 From: gravi638 Date: Tue, 2 Jun 2026 22:14:42 +0530 Subject: [PATCH 1/4] Adding Changes to add Accounttype only for specific models --- config/sample_xconfwebconfig.conf | 2 + dataapi/estb_firmware_context.go | 40 ++++-- dataapi/feature_control_context.go | 59 +++++++-- dataapi/log_uploader_context.go | 37 +++++- dataapi/router.go | 195 +++++++++++++++-------------- 5 files changed, 221 insertions(+), 112 deletions(-) diff --git a/config/sample_xconfwebconfig.conf b/config/sample_xconfwebconfig.conf index d38e1dff..923ddd88 100644 --- a/config/sample_xconfwebconfig.conf +++ b/config/sample_xconfwebconfig.conf @@ -234,6 +234,8 @@ xconfwebconfig { mac_tags_prefix_list = "t_" // Prefix list for MAC tags account_tags_prefix_list = "t_;p_" // Prefix list for account tags partner_tags_prefix_list = "t_" // Prefix list for partner tags + accounttype_model_list = "" + enable_account_type_for_all_models = false return_account_id = true // Return account ID in responses return_account_hash = true // Return account hash in responses estb_recovery_firmware_versions = ".* .*" // Regex for recovery firmware versions diff --git a/dataapi/estb_firmware_context.go b/dataapi/estb_firmware_context.go index ceb808b6..2d474d3e 100644 --- a/dataapi/estb_firmware_context.go +++ b/dataapi/estb_firmware_context.go @@ -243,9 +243,7 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m //default flow calling xac/ada keyspace if Xc.EnableXacGroupService { - //metrics for IncreaseUnknownIdCounter var macAddress string - //this is for metrics unknown accntId if util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) || contextMap[common.ACCOUNT_ID] == "" || util.IsUnknownValue(contextMap[common.PARTNER_ID]) { xhttp.IncreaseUnknownIdCounter(contextMap[common.MODEL], contextMap[common.PARTNER_ID]) if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { @@ -265,14 +263,40 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m if xAccountId != nil && err == nil { accountId = xAccountId.GetAccountId() - accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_ID] = accountId - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } log.WithFields(fields).Debugf("AddEstbFirmwareContext Successfully fetched AcntId='%s' and AcntType='%s' from Grp Svc", accountId, accountType) } if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { - log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID]) + log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' received from grpsvc,now fetching AccntPrds", contextMap[common.ACCOUNT_ID]) + + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { + macAddress = contextMap[common.ESTB_MAC] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + + if xAccountId == nil && err != nil { + if util.IsValidMacAddress(contextMap[common.ECM_MAC_ADDRESS]) { + macAddress = contextMap[common.ECM_MAC_ADDRESS] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ECM_MAC_ADDRESS]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + + if xAccountId != nil && err == nil { + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } + } + } + + } accountProducts, err = ws.GroupServiceConnector.GetAccountProducts(accountId, fields) if err != nil { log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountProducts information from Grp Service for AccountId=%s", contextMap[common.ACCOUNT_ID]) @@ -288,8 +312,10 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m contextMap[common.TIME_ZONE] = TimeZone } - if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { + contextMap[common.ACCOUNT_TYPE] = accountType + } } if raw, ok := accountProducts["AccountProducts"]; ok && raw != "" { diff --git a/dataapi/feature_control_context.go b/dataapi/feature_control_context.go index d3ebc3d5..5eed1ebb 100644 --- a/dataapi/feature_control_context.go +++ b/dataapi/feature_control_context.go @@ -125,6 +125,7 @@ func getAccountInfoFromGrpService(ws *xhttp.XconfServer, contextMap map[string]s var td *AccountServiceData var xAccountId *conversion.XBOAccount + var accountType string var err error snURL := SN_PREFIX + contextMap[common.SERIAL_NUM] @@ -137,9 +138,11 @@ func getAccountInfoFromGrpService(ws *xhttp.XconfServer, contextMap map[string]s } if xAccountId != nil { accountId := xAccountId.GetAccountId() - accountType := xAccountId.GetAccountType() contextMap[common.ACCOUNT_ID] = accountId - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } contextMap[common.ACCOUNT_HASH] = util.CalculateHash(accountId) log.WithFields(fields).Debugf("AddContextForPods Successfully fetched AcntId='%s' and AcntType='%s' from Grp Svc", accountId, accountType) @@ -162,8 +165,10 @@ func getAccountInfoFromGrpService(ws *xhttp.XconfServer, contextMap map[string]s contextMap[common.COUNTRY_CODE] = countryCode } - if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { + contextMap[common.ACCOUNT_TYPE] = accountType + } } if raw, ok := accountProducts["AccountProducts"]; ok && raw != "" { @@ -330,6 +335,7 @@ func AddContextForPods(ws *xhttp.XconfServer, contextMap map[string]string, satT func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMap map[string]string, satToken string, vargs ...log.Fields) *AccountServiceData { var td *AccountServiceData var accountId string + var accountType string var fields log.Fields if len(vargs) > 0 { fields = vargs[0] @@ -362,9 +368,11 @@ func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMa } else { if xAccountId != nil && xAccountId.GetAccountId() != "" { accountId = xAccountId.GetAccountId() - accountType := xAccountId.GetAccountType() contextMap[common.ACCOUNT_ID] = accountId - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } log.WithFields(fields).Debugf("AddFeatureControlContextFromAccountService Successfully fetched AcntId='%s' and AcntType='%s' from Grp Svc", accountId, accountType) } @@ -389,8 +397,10 @@ func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMa contextMap[common.TIME_ZONE] = TimeZone } - if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { + contextMap[common.ACCOUNT_TYPE] = accountType + } } if raw, ok := accountProducts["AccountProducts"]; ok && raw != "" { @@ -410,7 +420,7 @@ func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMa } xhttp.IncreaseGrpServiceFetchCounter(contextMap[common.MODEL], contextMap[common.PARTNER_ID]) - log.WithFields(fields).Debugf("AddFeatureControlContextFromAccountService AcntId='%s' ,AccntPrd='%v' successfully retrieved from xac/ada", contextMap[common.ACCOUNT_ID], contextMap) + log.WithFields(fields).Debugf("AddFeatureControlContextFromAccountService AcntId='%s' ,AccntPrd='%v' successfully retrieved from grp svc", contextMap[common.ACCOUNT_ID], contextMap) return td } } @@ -498,6 +508,9 @@ func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap var fields log.Fields var podData *PodData var td *AccountServiceData + var macAddress string + var accountType string + var xAccountId *conversion.XBOAccount if len(vargs) > 0 { fields = vargs[0] } else { @@ -516,7 +529,33 @@ func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap if Xc.EnableXacGroupService { if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { - log.WithFields(fields).Debugf("AddFeatureControlContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID]) + log.WithFields(fields).Debugf("AddFeatureControlContext AcntId='%s' already present", contextMap[common.ACCOUNT_ID]) + + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { + macAddress = contextMap[common.ESTB_MAC] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + + if xAccountId == nil && err != nil { + if util.IsValidMacAddress(contextMap[common.ECM_MAC_ADDRESS]) { + macAddress = contextMap[common.ECM_MAC_ADDRESS] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ECM_MAC_ADDRESS]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + } + + if xAccountId != nil && err == nil { + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } + } else { + log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountId information from Grp Service for Mac=%s", macAddress) + } + } + accountProducts, err := ws.GroupServiceConnector.GetAccountProducts(contextMap[common.ACCOUNT_ID], fields) if err != nil { log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountProducts information from Grp Service for AccountId=%s", contextMap[common.ACCOUNT_ID]) diff --git a/dataapi/log_uploader_context.go b/dataapi/log_uploader_context.go index bffef684..7cbdb8a6 100644 --- a/dataapi/log_uploader_context.go +++ b/dataapi/log_uploader_context.go @@ -52,6 +52,7 @@ func NormalizeLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, context func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, usePartnerAppType bool, vargs ...log.Fields) ([]string, error) { var fields log.Fields var accountId string + var accountType string if len(vargs) > 0 { fields = vargs[0] } else { @@ -90,14 +91,40 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma if xAccountId != nil && err == nil { accountId = xAccountId.GetAccountId() - accountType := xAccountId.GetAccountType() contextMap[common.ACCOUNT_ID] = accountId - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } log.WithFields(fields).Debugf("AddLogUploaderContext Successfully fetched AcntId='%s' and AcntType='%s' from Grp Svc", accountId, accountType) } if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { log.WithFields(fields).Debugf("AddLogUploaderContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID]) + + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { + macAddress = contextMap[common.ESTB_MAC] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + + if xAccountId == nil && err != nil { + if util.IsValidMacAddress(contextMap[common.ECM_MAC_ADDRESS]) { + macAddress = contextMap[common.ECM_MAC_ADDRESS] + macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ECM_MAC_ADDRESS]) + xAccountId, err = ws.GroupServiceConnector.GetAccountIdData(macPart, fields) + } + } + + if xAccountId != nil && err == nil { + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + accountType = xAccountId.GetAccountType() + contextMap[common.ACCOUNT_TYPE] = accountType + } + } + } + accountProducts, err := ws.GroupServiceConnector.GetAccountProducts(accountId, fields) if err != nil { log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountProducts information from Grp Service for AccountId=%s", accountId) @@ -116,8 +143,10 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma contextMap[common.TIME_ZONE] = TimeZone } - if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { + contextMap[common.ACCOUNT_TYPE] = accountType + } } if raw, ok := accountProducts["AccountProducts"]; ok && raw != "" { diff --git a/dataapi/router.go b/dataapi/router.go index 9e32b564..3dc2e436 100644 --- a/dataapi/router.go +++ b/dataapi/router.go @@ -44,52 +44,54 @@ import ( ) type XconfConfigs struct { - DeriveAppTypeFromPartnerId bool - PartnerApplicationTypes []string // List of partner's application type - EnableDeviceService bool - EnableDeviceDBLookup bool - EnableMacAccountServiceCall bool - AccountServiceMacPrefix string - EnableAccountService bool - EnableXacGroupService bool - EnableTaggingService bool - EnableTaggingServiceRFC bool - IPv4NetworkMaskPrefixLength int32 - IPv6NetworkMaskPrefixLength int32 - EnableFwDownloadLogs bool - EnableRfcPrecook bool - EnableRfcPrecookForOfferedFw bool - EnableRfcPrecook304 bool - RfcPrecookStartTime string - RfcPrecookEndTime string - RfcPrecookTimeZone *time.Location - RfcPrecookTimeFormat string - EnableGroupService bool - EnableFtGroups bool - EnableFtMacTags bool - EnableFtAccountTags bool - EnableFtPartnerTags bool - GroupServiceModelSet util.Set - MacTagsModelSet util.Set - AccountTagsModelSet util.Set - PartnerTagsModelSet util.Set - MacTagsPrefixList []string - AccountTagsPrefixList []string - PartnerTagsPrefixList []string - ReturnAccountId bool - ReturnAccountHash bool - EstbRecoveryFirmwareVersions string - DiagnosticAPIsEnabled bool - Account_mgmt string - GroupServiceCacheEnabled bool - RfcReturnCountryCode bool - RfcCountryCodeModelsSet util.Set - RfcCountryCodePartnersSet util.Set - AuxiliaryFirmwareList []AuxiliaryFirmware - PartnerIdValidationEnabled bool - ValidPartnerIdRegex *regexp.Regexp - SecurityTokenManagerEnabled bool - EnableTaggingComparison bool + DeriveAppTypeFromPartnerId bool + PartnerApplicationTypes []string // List of partner's application type + EnableDeviceService bool + EnableDeviceDBLookup bool + EnableMacAccountServiceCall bool + AccountServiceMacPrefix string + EnableAccountService bool + EnableXacGroupService bool + EnableTaggingService bool + EnableTaggingServiceRFC bool + IPv4NetworkMaskPrefixLength int32 + IPv6NetworkMaskPrefixLength int32 + EnableFwDownloadLogs bool + EnableRfcPrecook bool + EnableRfcPrecookForOfferedFw bool + EnableRfcPrecook304 bool + RfcPrecookStartTime string + RfcPrecookEndTime string + RfcPrecookTimeZone *time.Location + RfcPrecookTimeFormat string + EnableGroupService bool + EnableFtGroups bool + EnableFtMacTags bool + EnableFtAccountTags bool + EnableFtPartnerTags bool + GroupServiceModelSet util.Set + MacTagsModelSet util.Set + AccountTagsModelSet util.Set + PartnerTagsModelSet util.Set + MacTagsPrefixList []string + AccountTagsPrefixList []string + PartnerTagsPrefixList []string + ReturnAccountId bool + ReturnAccountHash bool + EstbRecoveryFirmwareVersions string + DiagnosticAPIsEnabled bool + Account_mgmt string + GroupServiceCacheEnabled bool + RfcReturnCountryCode bool + RfcCountryCodeModelsSet util.Set + RfcCountryCodePartnersSet util.Set + AuxiliaryFirmwareList []AuxiliaryFirmware + PartnerIdValidationEnabled bool + ValidPartnerIdRegex *regexp.Regexp + SecurityTokenManagerEnabled bool + EnableTaggingComparison bool + AccountTypeModelSet util.Set + EnableAccountTypeForAllModels bool } // Function to register the table name and the corresponding model/struct constructor @@ -294,52 +296,63 @@ func GetXconfConfigs(conf *conf.Config) *XconfConfigs { validPartnerIdRegex = regexp.MustCompile(defaultValidPartnerIdRegex) } + gatewayModelSet := util.NewSet() + gatewayModelList := conf.GetString("xconfwebconfig.xconf.accounttype_model_list") + if !util.IsBlank(gatewayModelList) { + xb10Models := strings.Split(gatewayModelList, ";") + for _, model := range xb10Models { + gatewayModelSet.Add(strings.ToUpper(strings.TrimSpace(model))) + } + } + xc := &XconfConfigs{ - DeriveAppTypeFromPartnerId: conf.GetBoolean("xconfwebconfig.xconf.derive_application_type_from_partner_id"), - PartnerApplicationTypes: appTypes, - EnableDeviceService: conf.GetBoolean("xconfwebconfig.xconf.enable_device_service"), - EnableDeviceDBLookup: conf.GetBoolean("xconfwebconfig.xconf.enable_device_db_lookup"), - EnableMacAccountServiceCall: conf.GetBoolean("xconfwebconfig.xconf.enable_mac_accountservice_call"), - EnableAccountService: conf.GetBoolean("xconfwebconfig.xconf.enable_account_service"), - EnableXacGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_xac_ada_keyspace"), - EnableTaggingService: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service"), - EnableTaggingServiceRFC: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service_rfc"), - ReturnAccountId: conf.GetBoolean("xconfwebconfig.xconf.return_account_id"), - ReturnAccountHash: conf.GetBoolean("xconfwebconfig.xconf.return_account_hash"), - EstbRecoveryFirmwareVersions: conf.GetString("xconfwebconfig.xconf.estb_recovery_firmware_versions"), - DiagnosticAPIsEnabled: conf.GetBoolean("xconfwebconfig.xconf.diagnostic_apis_enabled"), - AccountServiceMacPrefix: conf.GetString("xconfwebconfig.xconf.account_service_mac_prefix"), - IPv4NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv4_network_mask_prefix_length"), - IPv6NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv6_network_mask_prefix_length"), - EnableFwDownloadLogs: conf.GetBoolean("xconfwebconfig.xconf.enable_fw_download_logs"), - EnableRfcPrecook: rfcPrecookEnabled, - EnableRfcPrecookForOfferedFw: rfcPrecookForOfferedFwEnabled, - EnableRfcPrecook304: conf.GetBoolean("xconfwebconfig.xconf.enable_rfc_precook_304"), - RfcPrecookStartTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_start_time"), - RfcPrecookEndTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_end_time"), - RfcPrecookTimeZone: timezone, - RfcPrecookTimeFormat: conf.GetString("xconfwebconfig.xconf.rfc_precook_time_format"), - EnableGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_group_service"), - EnableFtMacTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_mac_tags"), - EnableFtAccountTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_account_tags"), - EnableFtPartnerTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_partner_tags"), - EnableFtGroups: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_xdp_groups"), - GroupServiceModelSet: GroupServiceModelSet, - MacTagsModelSet: macTagsModelSet, - AccountTagsModelSet: accountTagsModelSet, - PartnerTagsModelSet: partnerTagsModelSet, - MacTagsPrefixList: macTagsPrefixList, - AccountTagsPrefixList: accountTagsPrefixList, - PartnerTagsPrefixList: partnerTagsPrefixList, - GroupServiceCacheEnabled: conf.GetBoolean(fmt.Sprintf("xconfwebconfig.%v.cache_enabled", conf.GetString("xconfwebconfig.xconf.group_service_name"))), - RfcReturnCountryCode: conf.GetBoolean("xconfwebconfig.xconf.rfc_return_country_code"), - RfcCountryCodeModelsSet: rfcCountryCodeModelsSet, - RfcCountryCodePartnersSet: rfcCountryCodePartnersSet, - AuxiliaryFirmwareList: auxFirmwareList, - ValidPartnerIdRegex: validPartnerIdRegex, - PartnerIdValidationEnabled: partnerIdValidationEnabled, - SecurityTokenManagerEnabled: conf.GetBoolean("xconfwebconfig.xconf.security_token_manager_enabled"), - EnableTaggingComparison: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_comparison"), + DeriveAppTypeFromPartnerId: conf.GetBoolean("xconfwebconfig.xconf.derive_application_type_from_partner_id"), + PartnerApplicationTypes: appTypes, + EnableDeviceService: conf.GetBoolean("xconfwebconfig.xconf.enable_device_service"), + EnableDeviceDBLookup: conf.GetBoolean("xconfwebconfig.xconf.enable_device_db_lookup"), + EnableMacAccountServiceCall: conf.GetBoolean("xconfwebconfig.xconf.enable_mac_accountservice_call"), + EnableAccountService: conf.GetBoolean("xconfwebconfig.xconf.enable_account_service"), + EnableXacGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_xac_ada_keyspace"), + EnableTaggingService: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service"), + EnableTaggingServiceRFC: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service_rfc"), + ReturnAccountId: conf.GetBoolean("xconfwebconfig.xconf.return_account_id"), + ReturnAccountHash: conf.GetBoolean("xconfwebconfig.xconf.return_account_hash"), + EstbRecoveryFirmwareVersions: conf.GetString("xconfwebconfig.xconf.estb_recovery_firmware_versions"), + DiagnosticAPIsEnabled: conf.GetBoolean("xconfwebconfig.xconf.diagnostic_apis_enabled"), + AccountServiceMacPrefix: conf.GetString("xconfwebconfig.xconf.account_service_mac_prefix"), + IPv4NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv4_network_mask_prefix_length"), + IPv6NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv6_network_mask_prefix_length"), + EnableFwDownloadLogs: conf.GetBoolean("xconfwebconfig.xconf.enable_fw_download_logs"), + EnableRfcPrecook: rfcPrecookEnabled, + EnableRfcPrecookForOfferedFw: rfcPrecookForOfferedFwEnabled, + EnableRfcPrecook304: conf.GetBoolean("xconfwebconfig.xconf.enable_rfc_precook_304"), + RfcPrecookStartTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_start_time"), + RfcPrecookEndTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_end_time"), + RfcPrecookTimeZone: timezone, + RfcPrecookTimeFormat: conf.GetString("xconfwebconfig.xconf.rfc_precook_time_format"), + EnableGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_group_service"), + EnableFtMacTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_mac_tags"), + EnableFtAccountTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_account_tags"), + EnableFtPartnerTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_partner_tags"), + EnableFtGroups: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_xdp_groups"), + GroupServiceModelSet: GroupServiceModelSet, + MacTagsModelSet: macTagsModelSet, + AccountTagsModelSet: accountTagsModelSet, + PartnerTagsModelSet: partnerTagsModelSet, + AccountTypeModelSet: gatewayModelSet, + EnableAccountTypeForAllModels: conf.GetBoolean("xconfwebconfig.xconf.enable_account_type_for_all_models"), + MacTagsPrefixList: macTagsPrefixList, + AccountTagsPrefixList: accountTagsPrefixList, + PartnerTagsPrefixList: partnerTagsPrefixList, + GroupServiceCacheEnabled: conf.GetBoolean(fmt.Sprintf("xconfwebconfig.%v.cache_enabled", conf.GetString("xconfwebconfig.xconf.group_service_name"))), + RfcReturnCountryCode: conf.GetBoolean("xconfwebconfig.xconf.rfc_return_country_code"), + RfcCountryCodeModelsSet: rfcCountryCodeModelsSet, + RfcCountryCodePartnersSet: rfcCountryCodePartnersSet, + AuxiliaryFirmwareList: auxFirmwareList, + ValidPartnerIdRegex: validPartnerIdRegex, + PartnerIdValidationEnabled: partnerIdValidationEnabled, + SecurityTokenManagerEnabled: conf.GetBoolean("xconfwebconfig.xconf.security_token_manager_enabled"), + EnableTaggingComparison: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_comparison"), } return xc } From adc5e949677c7599609052da5336e05fb6572cf0 Mon Sep 17 00:00:00 2001 From: gravi21 Date: Wed, 3 Jun 2026 08:47:32 +0530 Subject: [PATCH 2/4] Removed extra config and refactored the code --- dataapi/estb_firmware_context.go | 8 +- dataapi/feature_control_context.go | 18 +-- dataapi/log_uploader_context.go | 8 +- dataapi/router.go | 200 ++++++++++++++--------------- 4 files changed, 117 insertions(+), 117 deletions(-) diff --git a/dataapi/estb_firmware_context.go b/dataapi/estb_firmware_context.go index 2d474d3e..e5a181bb 100644 --- a/dataapi/estb_firmware_context.go +++ b/dataapi/estb_firmware_context.go @@ -264,7 +264,7 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m if xAccountId != nil && err == nil { accountId = xAccountId.GetAccountId() contextMap[common.ACCOUNT_ID] = accountId - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -274,7 +274,7 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' received from grpsvc,now fetching AccntPrds", contextMap[common.ACCOUNT_ID]) - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { macAddress = contextMap[common.ESTB_MAC] macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) @@ -289,7 +289,7 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m } if xAccountId != nil && err == nil { - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -312,7 +312,7 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m contextMap[common.TIME_ZONE] = TimeZone } - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { contextMap[common.ACCOUNT_TYPE] = accountType } diff --git a/dataapi/feature_control_context.go b/dataapi/feature_control_context.go index 5eed1ebb..dd963630 100644 --- a/dataapi/feature_control_context.go +++ b/dataapi/feature_control_context.go @@ -139,7 +139,7 @@ func getAccountInfoFromGrpService(ws *xhttp.XconfServer, contextMap map[string]s if xAccountId != nil { accountId := xAccountId.GetAccountId() contextMap[common.ACCOUNT_ID] = accountId - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -165,7 +165,7 @@ func getAccountInfoFromGrpService(ws *xhttp.XconfServer, contextMap map[string]s contextMap[common.COUNTRY_CODE] = countryCode } - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { contextMap[common.ACCOUNT_TYPE] = accountType } @@ -369,7 +369,7 @@ func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMa if xAccountId != nil && xAccountId.GetAccountId() != "" { accountId = xAccountId.GetAccountId() contextMap[common.ACCOUNT_ID] = accountId - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -397,7 +397,7 @@ func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMa contextMap[common.TIME_ZONE] = TimeZone } - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { contextMap[common.ACCOUNT_TYPE] = accountType } @@ -531,7 +531,7 @@ func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { log.WithFields(fields).Debugf("AddFeatureControlContext AcntId='%s' already present", contextMap[common.ACCOUNT_ID]) - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { macAddress = contextMap[common.ESTB_MAC] macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) @@ -547,7 +547,7 @@ func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap } if xAccountId != nil && err == nil { - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -577,8 +577,10 @@ func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap contextMap[common.TIME_ZONE] = TimeZone } - if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { - contextMap[common.ACCOUNT_TYPE] = accountType + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { + contextMap[common.ACCOUNT_TYPE] = accountType + } } if raw, ok := accountProducts["AccountProducts"]; ok && raw != "" { diff --git a/dataapi/log_uploader_context.go b/dataapi/log_uploader_context.go index 7cbdb8a6..4e878dd8 100644 --- a/dataapi/log_uploader_context.go +++ b/dataapi/log_uploader_context.go @@ -92,7 +92,7 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma if xAccountId != nil && err == nil { accountId = xAccountId.GetAccountId() contextMap[common.ACCOUNT_ID] = accountId - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -102,7 +102,7 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { log.WithFields(fields).Debugf("AddLogUploaderContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID]) - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { macAddress = contextMap[common.ESTB_MAC] macPart := util.RemoveNonAlphabeticSymbols(contextMap[common.ESTB_MAC]) @@ -118,7 +118,7 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma } if xAccountId != nil && err == nil { - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } @@ -143,7 +143,7 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma contextMap[common.TIME_ZONE] = TimeZone } - if Xc.EnableAccountTypeForAllModels || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { + if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" { contextMap[common.ACCOUNT_TYPE] = accountType } diff --git a/dataapi/router.go b/dataapi/router.go index 3dc2e436..7c3b4596 100644 --- a/dataapi/router.go +++ b/dataapi/router.go @@ -44,54 +44,53 @@ import ( ) type XconfConfigs struct { - DeriveAppTypeFromPartnerId bool - PartnerApplicationTypes []string // List of partner's application type - EnableDeviceService bool - EnableDeviceDBLookup bool - EnableMacAccountServiceCall bool - AccountServiceMacPrefix string - EnableAccountService bool - EnableXacGroupService bool - EnableTaggingService bool - EnableTaggingServiceRFC bool - IPv4NetworkMaskPrefixLength int32 - IPv6NetworkMaskPrefixLength int32 - EnableFwDownloadLogs bool - EnableRfcPrecook bool - EnableRfcPrecookForOfferedFw bool - EnableRfcPrecook304 bool - RfcPrecookStartTime string - RfcPrecookEndTime string - RfcPrecookTimeZone *time.Location - RfcPrecookTimeFormat string - EnableGroupService bool - EnableFtGroups bool - EnableFtMacTags bool - EnableFtAccountTags bool - EnableFtPartnerTags bool - GroupServiceModelSet util.Set - MacTagsModelSet util.Set - AccountTagsModelSet util.Set - PartnerTagsModelSet util.Set - MacTagsPrefixList []string - AccountTagsPrefixList []string - PartnerTagsPrefixList []string - ReturnAccountId bool - ReturnAccountHash bool - EstbRecoveryFirmwareVersions string - DiagnosticAPIsEnabled bool - Account_mgmt string - GroupServiceCacheEnabled bool - RfcReturnCountryCode bool - RfcCountryCodeModelsSet util.Set - RfcCountryCodePartnersSet util.Set - AuxiliaryFirmwareList []AuxiliaryFirmware - PartnerIdValidationEnabled bool - ValidPartnerIdRegex *regexp.Regexp - SecurityTokenManagerEnabled bool - EnableTaggingComparison bool - AccountTypeModelSet util.Set - EnableAccountTypeForAllModels bool + DeriveAppTypeFromPartnerId bool + PartnerApplicationTypes []string // List of partner's application type + EnableDeviceService bool + EnableDeviceDBLookup bool + EnableMacAccountServiceCall bool + AccountServiceMacPrefix string + EnableAccountService bool + EnableXacGroupService bool + EnableTaggingService bool + EnableTaggingServiceRFC bool + IPv4NetworkMaskPrefixLength int32 + IPv6NetworkMaskPrefixLength int32 + EnableFwDownloadLogs bool + EnableRfcPrecook bool + EnableRfcPrecookForOfferedFw bool + EnableRfcPrecook304 bool + RfcPrecookStartTime string + RfcPrecookEndTime string + RfcPrecookTimeZone *time.Location + RfcPrecookTimeFormat string + EnableGroupService bool + EnableFtGroups bool + EnableFtMacTags bool + EnableFtAccountTags bool + EnableFtPartnerTags bool + GroupServiceModelSet util.Set + MacTagsModelSet util.Set + AccountTagsModelSet util.Set + PartnerTagsModelSet util.Set + MacTagsPrefixList []string + AccountTagsPrefixList []string + PartnerTagsPrefixList []string + ReturnAccountId bool + ReturnAccountHash bool + EstbRecoveryFirmwareVersions string + DiagnosticAPIsEnabled bool + Account_mgmt string + GroupServiceCacheEnabled bool + RfcReturnCountryCode bool + RfcCountryCodeModelsSet util.Set + RfcCountryCodePartnersSet util.Set + AuxiliaryFirmwareList []AuxiliaryFirmware + PartnerIdValidationEnabled bool + ValidPartnerIdRegex *regexp.Regexp + SecurityTokenManagerEnabled bool + EnableTaggingComparison bool + AccountTypeModelSet util.Set } // Function to register the table name and the corresponding model/struct constructor @@ -296,63 +295,62 @@ func GetXconfConfigs(conf *conf.Config) *XconfConfigs { validPartnerIdRegex = regexp.MustCompile(defaultValidPartnerIdRegex) } - gatewayModelSet := util.NewSet() - gatewayModelList := conf.GetString("xconfwebconfig.xconf.accounttype_model_list") - if !util.IsBlank(gatewayModelList) { - xb10Models := strings.Split(gatewayModelList, ";") - for _, model := range xb10Models { - gatewayModelSet.Add(strings.ToUpper(strings.TrimSpace(model))) + accountTypeModelSet := util.NewSet() + accountTypeModelList := conf.GetString("xconfwebconfig.xconf.accounttype_model_list") + if !util.IsBlank(accountTypeModelList) { + accountTypeModels := strings.Split(accountTypeModelList, ",") + for _, model := range accountTypeModels { + accountTypeModelSet.Add(strings.ToUpper(strings.TrimSpace(model))) } } xc := &XconfConfigs{ - DeriveAppTypeFromPartnerId: conf.GetBoolean("xconfwebconfig.xconf.derive_application_type_from_partner_id"), - PartnerApplicationTypes: appTypes, - EnableDeviceService: conf.GetBoolean("xconfwebconfig.xconf.enable_device_service"), - EnableDeviceDBLookup: conf.GetBoolean("xconfwebconfig.xconf.enable_device_db_lookup"), - EnableMacAccountServiceCall: conf.GetBoolean("xconfwebconfig.xconf.enable_mac_accountservice_call"), - EnableAccountService: conf.GetBoolean("xconfwebconfig.xconf.enable_account_service"), - EnableXacGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_xac_ada_keyspace"), - EnableTaggingService: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service"), - EnableTaggingServiceRFC: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service_rfc"), - ReturnAccountId: conf.GetBoolean("xconfwebconfig.xconf.return_account_id"), - ReturnAccountHash: conf.GetBoolean("xconfwebconfig.xconf.return_account_hash"), - EstbRecoveryFirmwareVersions: conf.GetString("xconfwebconfig.xconf.estb_recovery_firmware_versions"), - DiagnosticAPIsEnabled: conf.GetBoolean("xconfwebconfig.xconf.diagnostic_apis_enabled"), - AccountServiceMacPrefix: conf.GetString("xconfwebconfig.xconf.account_service_mac_prefix"), - IPv4NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv4_network_mask_prefix_length"), - IPv6NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv6_network_mask_prefix_length"), - EnableFwDownloadLogs: conf.GetBoolean("xconfwebconfig.xconf.enable_fw_download_logs"), - EnableRfcPrecook: rfcPrecookEnabled, - EnableRfcPrecookForOfferedFw: rfcPrecookForOfferedFwEnabled, - EnableRfcPrecook304: conf.GetBoolean("xconfwebconfig.xconf.enable_rfc_precook_304"), - RfcPrecookStartTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_start_time"), - RfcPrecookEndTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_end_time"), - RfcPrecookTimeZone: timezone, - RfcPrecookTimeFormat: conf.GetString("xconfwebconfig.xconf.rfc_precook_time_format"), - EnableGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_group_service"), - EnableFtMacTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_mac_tags"), - EnableFtAccountTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_account_tags"), - EnableFtPartnerTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_partner_tags"), - EnableFtGroups: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_xdp_groups"), - GroupServiceModelSet: GroupServiceModelSet, - MacTagsModelSet: macTagsModelSet, - AccountTagsModelSet: accountTagsModelSet, - PartnerTagsModelSet: partnerTagsModelSet, - AccountTypeModelSet: gatewayModelSet, - EnableAccountTypeForAllModels: conf.GetBoolean("xconfwebconfig.xconf.enable_account_type_for_all_models"), - MacTagsPrefixList: macTagsPrefixList, - AccountTagsPrefixList: accountTagsPrefixList, - PartnerTagsPrefixList: partnerTagsPrefixList, - GroupServiceCacheEnabled: conf.GetBoolean(fmt.Sprintf("xconfwebconfig.%v.cache_enabled", conf.GetString("xconfwebconfig.xconf.group_service_name"))), - RfcReturnCountryCode: conf.GetBoolean("xconfwebconfig.xconf.rfc_return_country_code"), - RfcCountryCodeModelsSet: rfcCountryCodeModelsSet, - RfcCountryCodePartnersSet: rfcCountryCodePartnersSet, - AuxiliaryFirmwareList: auxFirmwareList, - ValidPartnerIdRegex: validPartnerIdRegex, - PartnerIdValidationEnabled: partnerIdValidationEnabled, - SecurityTokenManagerEnabled: conf.GetBoolean("xconfwebconfig.xconf.security_token_manager_enabled"), - EnableTaggingComparison: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_comparison"), + DeriveAppTypeFromPartnerId: conf.GetBoolean("xconfwebconfig.xconf.derive_application_type_from_partner_id"), + PartnerApplicationTypes: appTypes, + EnableDeviceService: conf.GetBoolean("xconfwebconfig.xconf.enable_device_service"), + EnableDeviceDBLookup: conf.GetBoolean("xconfwebconfig.xconf.enable_device_db_lookup"), + EnableMacAccountServiceCall: conf.GetBoolean("xconfwebconfig.xconf.enable_mac_accountservice_call"), + EnableAccountService: conf.GetBoolean("xconfwebconfig.xconf.enable_account_service"), + EnableXacGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_xac_ada_keyspace"), + EnableTaggingService: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service"), + EnableTaggingServiceRFC: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_service_rfc"), + ReturnAccountId: conf.GetBoolean("xconfwebconfig.xconf.return_account_id"), + ReturnAccountHash: conf.GetBoolean("xconfwebconfig.xconf.return_account_hash"), + EstbRecoveryFirmwareVersions: conf.GetString("xconfwebconfig.xconf.estb_recovery_firmware_versions"), + DiagnosticAPIsEnabled: conf.GetBoolean("xconfwebconfig.xconf.diagnostic_apis_enabled"), + AccountServiceMacPrefix: conf.GetString("xconfwebconfig.xconf.account_service_mac_prefix"), + IPv4NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv4_network_mask_prefix_length"), + IPv6NetworkMaskPrefixLength: conf.GetInt32("xconfwebconfig.xconf.ipv6_network_mask_prefix_length"), + EnableFwDownloadLogs: conf.GetBoolean("xconfwebconfig.xconf.enable_fw_download_logs"), + EnableRfcPrecook: rfcPrecookEnabled, + EnableRfcPrecookForOfferedFw: rfcPrecookForOfferedFwEnabled, + EnableRfcPrecook304: conf.GetBoolean("xconfwebconfig.xconf.enable_rfc_precook_304"), + RfcPrecookStartTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_start_time"), + RfcPrecookEndTime: conf.GetString("xconfwebconfig.xconf.rfc_precook_end_time"), + RfcPrecookTimeZone: timezone, + RfcPrecookTimeFormat: conf.GetString("xconfwebconfig.xconf.rfc_precook_time_format"), + EnableGroupService: conf.GetBoolean("xconfwebconfig.xconf.enable_group_service"), + EnableFtMacTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_mac_tags"), + EnableFtAccountTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_account_tags"), + EnableFtPartnerTags: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_partner_tags"), + EnableFtGroups: conf.GetBoolean("xconfwebconfig.xconf.enable_ft_xdp_groups"), + GroupServiceModelSet: GroupServiceModelSet, + MacTagsModelSet: macTagsModelSet, + AccountTagsModelSet: accountTagsModelSet, + PartnerTagsModelSet: partnerTagsModelSet, + AccountTypeModelSet: accountTypeModelSet, + MacTagsPrefixList: macTagsPrefixList, + AccountTagsPrefixList: accountTagsPrefixList, + PartnerTagsPrefixList: partnerTagsPrefixList, + GroupServiceCacheEnabled: conf.GetBoolean(fmt.Sprintf("xconfwebconfig.%v.cache_enabled", conf.GetString("xconfwebconfig.xconf.group_service_name"))), + RfcReturnCountryCode: conf.GetBoolean("xconfwebconfig.xconf.rfc_return_country_code"), + RfcCountryCodeModelsSet: rfcCountryCodeModelsSet, + RfcCountryCodePartnersSet: rfcCountryCodePartnersSet, + AuxiliaryFirmwareList: auxFirmwareList, + ValidPartnerIdRegex: validPartnerIdRegex, + PartnerIdValidationEnabled: partnerIdValidationEnabled, + SecurityTokenManagerEnabled: conf.GetBoolean("xconfwebconfig.xconf.security_token_manager_enabled"), + EnableTaggingComparison: conf.GetBoolean("xconfwebconfig.xconf.enable_tagging_comparison"), } return xc } From ad90bcac7ef35e756baff2645fe019585c5ee062 Mon Sep 17 00:00:00 2001 From: gravi21 Date: Wed, 3 Jun 2026 09:58:17 +0530 Subject: [PATCH 3/4] removed extra config --- config/sample_xconfwebconfig.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/config/sample_xconfwebconfig.conf b/config/sample_xconfwebconfig.conf index 923ddd88..13d6520c 100644 --- a/config/sample_xconfwebconfig.conf +++ b/config/sample_xconfwebconfig.conf @@ -235,7 +235,6 @@ xconfwebconfig { account_tags_prefix_list = "t_;p_" // Prefix list for account tags partner_tags_prefix_list = "t_" // Prefix list for partner tags accounttype_model_list = "" - enable_account_type_for_all_models = false return_account_id = true // Return account ID in responses return_account_hash = true // Return account hash in responses estb_recovery_firmware_versions = ".* .*" // Regex for recovery firmware versions From bc7f2f1e7f2b23f3158c83f3340d00f3d831a0c7 Mon Sep 17 00:00:00 2001 From: gravi638 Date: Wed, 3 Jun 2026 18:05:23 +0530 Subject: [PATCH 4/4] Few err log improvements --- dataapi/estb_firmware_context.go | 2 ++ dataapi/log_uploader_context.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dataapi/estb_firmware_context.go b/dataapi/estb_firmware_context.go index e5a181bb..ec47c06c 100644 --- a/dataapi/estb_firmware_context.go +++ b/dataapi/estb_firmware_context.go @@ -293,6 +293,8 @@ func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap m accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } + } else { + log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountId information from Grp Service for Mac=%s", macAddress) } } diff --git a/dataapi/log_uploader_context.go b/dataapi/log_uploader_context.go index 4e878dd8..a88a1b4f 100644 --- a/dataapi/log_uploader_context.go +++ b/dataapi/log_uploader_context.go @@ -100,7 +100,7 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma } if contextMap[common.ACCOUNT_ID] != "" && !util.IsUnknownValue(contextMap[common.ACCOUNT_ID]) { - log.WithFields(fields).Debugf("AddLogUploaderContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID]) + log.WithFields(fields).Debugf("AddLogUploaderContext AcntId='%s' already present,fetching AccntPrds directly from grp svc", contextMap[common.ACCOUNT_ID]) if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { @@ -122,6 +122,8 @@ func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap ma accountType = xAccountId.GetAccountType() contextMap[common.ACCOUNT_TYPE] = accountType } + } else { + log.WithFields(log.Fields{"error": err}).Errorf("Error getting accountId information from Grp Service for Mac=%s", macAddress) } }