-
Notifications
You must be signed in to change notification settings - Fork 7
Adding Changes to add Accounttype only for specific models #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,42 @@ 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.AccountTypeModelSet.IsEmpty() || 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.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { | ||
| if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gravi21 Can we cache the value of checking if mac address is valid so that we don't to do the same check again on line 285? |
||
| 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]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to call check again. |
||
| 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.AccountTypeModelSet.IsEmpty() || 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(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 +314,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.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 != "" { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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.AccountTypeModelSet.IsEmpty() || 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.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 != "" { | ||
|
|
@@ -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.AccountTypeModelSet.IsEmpty() || 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.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @gravi21 |
||
| 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.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) { | ||
| if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should cache value if mac is valid so don't have to call gain. |
||
| 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.AccountTypeModelSet.IsEmpty() || 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]) | ||
|
|
@@ -538,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 != "" { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,42 @@ 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.AccountTypeModelSet.IsEmpty() || 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]) | ||
| 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]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should cache value if mac is valid so don't have to call gain. |
||
| 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.AccountTypeModelSet.IsEmpty() || 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(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 +145,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.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 != "" { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @gravi21
I see the same AccountTypeModelSet.IsEmpty() || AccountTypeModelSet.Contains(...) condition being checked at both line 267 and line 277. Since contextMap[common.MODEL] doesn't change between these two points, the inner check at line 277 appears to be redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RahulRengeshOfficial in line 277 case is for when we already have accountId in the request from device and in line 267 is for unknown accountId case.
All these is for workround until we get accounttype in /ada keyspace