File tree Expand file tree Collapse file tree 5 files changed +12
-13
lines changed Expand file tree Collapse file tree 5 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,12 @@ type GetIPAddressesRequest struct {
238238
239239// GetIPAddressStateResponse is used in CNS IPAM mode as a response to get IP address state
240240type GetIPAddressStateResponse struct {
241+ IPAddresses []IPAddressState
242+ Response Response
243+ }
244+
245+ // GetIPAddressStatusResponse is used in CNS IPAM mode as a response to get IP address, state and Pod info
246+ type GetIPAddressStatusResponse struct {
241247 IPConfigurationStatus [] IPConfigurationStatus
242248 Response Response
243249}
Original file line number Diff line number Diff line change @@ -93,6 +93,6 @@ func printIPAddresses(addrSlice []cns.IPConfigurationStatus) {
9393 })
9494
9595 for _ , addr := range addrSlice {
96- fmt . Printf ( "%+v \n " , addr )
96+ cns . IPConfigurationStatus . String ( addr )
9797 }
9898}
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ func (cnsClient *CNSClient) ReleaseIPAddress(orchestratorContext []byte) error {
321321// usage GetIPAddressesWithStates(cns.Available, cns.Allocated)
322322func (cnsClient * CNSClient ) GetIPAddressesMatchingStates (StateFilter ... string ) ([]cns.IPConfigurationStatus , error ) {
323323 var (
324- resp cns.GetIPAddressStateResponse
324+ resp cns.GetIPAddressStatusResponse
325325 err error
326326 res * http.Response
327327 body bytes.Buffer
Original file line number Diff line number Diff line change @@ -233,8 +233,7 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
233233 t .Fatalf ("Expected to not fail when releasing IP reservation found with context: %+v" , err )
234234 }
235235
236- ipaddresses , err := cnsClient .GetIPAddressesMatchingStates ("Available" )
237- fmt .Println (ipaddresses )
236+ ipaddresses , err := cnsClient .GetIPAddressesMatchingStates (cns .Available )
238237 if err != nil {
239238 t .Fatalf ("Get allocated IP addresses failed %+v" , err )
240239 }
@@ -246,4 +245,5 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
246245 if ipaddresses [0 ].IPAddress != desiredIpAddress && ipaddresses [0 ].State != cns .Available {
247246 t .Fatalf ("Available IP address does not match expected, address state: %+v" , ipaddresses )
248247 }
248+ fmt .Println (ipaddresses )
249249}
Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ func (service *HTTPRestService) GetPendingProgramIPConfigs() []cns.IPConfigurati
193193func (service * HTTPRestService ) getIPAddressesHandler (w http.ResponseWriter , r * http.Request ) {
194194 var (
195195 req cns.GetIPAddressesRequest
196- resp cns.GetIPAddressStateResponse
196+ resp cns.GetIPAddressStatusResponse
197197 statusCode int
198198 returnMessage string
199199 err error
@@ -237,14 +237,7 @@ func filterIPConfigsMatchingState(toBeAdded map[string]cns.IPConfigurationStatus
237237 vsf := make ([]cns.IPConfigurationStatus , 0 )
238238 for _ , v := range toBeAdded {
239239 if f (v , states ) {
240- ipconfigstate := cns.IPConfigurationStatus {
241- IPAddress : v .IPAddress ,
242- State : v .State ,
243- OrchestratorContext : v .OrchestratorContext ,
244- NCID : v .NCID ,
245- ID : v .ID ,
246- }
247- vsf = append (vsf , ipconfigstate )
240+ vsf = append (vsf , v )
248241 }
249242 }
250243 return vsf
You can’t perform that action at this time.
0 commit comments