Skip to content

Commit ae21576

Browse files
committed
Use nmagent.(HomeAZResponse).ContainsFixes in CNS
This alters the response to use the ContainsFixes method added to the HomeAzResponse. Rather than using API Version directly, the more semantically-meaningful constants from the nmagent package are used instead to indicate whether or not some bugfixes have been applied.
1 parent 50c6509 commit ae21576

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

cns/restserver/homeazmonitor.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,7 @@ func (h *HomeAzMonitor) Populate(ctx context.Context) {
154154
h.update(returnCode, returnMessage, cns.HomeAzResponse{IsSupported: true})
155155
return
156156
}
157-
// validate APIVersion value
158-
if !azResponse.Valid() {
159-
returnMessage := fmt.Sprintf("[HomeAzMonitor] invalid APIVersion value from nmagent: %d", azResponse.APIVersion)
160-
returnCode := types.UnexpectedError
161-
h.update(returnCode, returnMessage, cns.HomeAzResponse{IsSupported: true})
162-
return
163-
}
164-
h.update(types.Success, "Get Home Az succeeded", cns.HomeAzResponse{IsSupported: true, HomeAz: azResponse.HomeAz, NmaAppliedTheIPV6Fix: azResponse.NmaAppliedTheIPV6Fix()})
157+
h.update(types.Success, "Get Home Az succeeded", cns.HomeAzResponse{IsSupported: true, HomeAz: azResponse.HomeAz, NmaAppliedTheIPV6Fix: azResponse.ContainsFixes(nmagent.HomeAZFixIPv6)})
165158
}
166159

167160
// update constructs a GetHomeAzResponse entity and update its cache

cns/restserver/homeazmonitor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestHomeAzMonitor(t *testing.T) {
2828
return []string{"GetHomeAz"}, nil
2929
},
3030
GetHomeAzF: func(_ context.Context) (nmagent.AzResponse, error) {
31-
return nmagent.AzResponse{HomeAz: uint(1), APIVersion: uint(2)}, nil
31+
return nmagent.AzResponse{HomeAz: uint(1), AppliedFixes: []nmagent.HomeAZFix{nmagent.HomeAZFixIPv6}}, nil
3232
},
3333
},
3434
cns.HomeAzResponse{IsSupported: true, HomeAz: uint(1), NmaAppliedTheIPV6Fix: true},
@@ -67,7 +67,7 @@ func TestHomeAzMonitor(t *testing.T) {
6767
return []string{GetHomeAzAPIName}, nil
6868
},
6969
GetHomeAzF: func(_ context.Context) (nmagent.AzResponse, error) {
70-
return nmagent.AzResponse{HomeAz: uint(1), APIVersion: uint(1)}, nil
70+
return nmagent.AzResponse{HomeAz: uint(1), AppliedFixes: []nmagent.HomeAZFix{nmagent.HomeAZFixIPv6}}, nil
7171
},
7272
},
7373
cns.HomeAzResponse{IsSupported: true},

0 commit comments

Comments
 (0)