77 "net/http"
88
99 "github.com/Azure/azure-container-networking/cns"
10- "github.com/Azure/azure-container-networking/log "
10+ "github.com/Azure/azure-container-networking/cns/logger "
1111)
1212
1313// CNSClient specifies a client to connect to Ipam Plugin.
@@ -55,42 +55,42 @@ func (cnsClient *CNSClient) GetNetworkConfiguration(orchestratorContext []byte)
5555
5656 httpc := & http.Client {}
5757 url := cnsClient .connectionURL + cns .GetNetworkContainerByOrchestratorContext
58- log .Printf ("GetNetworkConfiguration url %v" , url )
58+ logger .Printf ("GetNetworkConfiguration url %v" , url )
5959
6060 payload := & cns.GetNetworkContainerRequest {
6161 OrchestratorContext : orchestratorContext ,
6262 }
6363
6464 err := json .NewEncoder (& body ).Encode (payload )
6565 if err != nil {
66- log .Errorf ("encoding json failed with %v" , err )
66+ logger .Errorf ("encoding json failed with %v" , err )
6767 return nil , err
6868 }
6969
7070 res , err := httpc .Post (url , "application/json" , & body )
7171 if err != nil {
72- log .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
72+ logger .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
7373 return nil , err
7474 }
7575
7676 defer res .Body .Close ()
7777
7878 if res .StatusCode != http .StatusOK {
7979 errMsg := fmt .Sprintf ("[Azure CNSClient] GetNetworkConfiguration invalid http status code: %v" , res .StatusCode )
80- log .Errorf (errMsg )
80+ logger .Errorf (errMsg )
8181 return nil , fmt .Errorf (errMsg )
8282 }
8383
8484 var resp cns.GetNetworkContainerResponse
8585
8686 err = json .NewDecoder (res .Body ).Decode (& resp )
8787 if err != nil {
88- log .Errorf ("[Azure CNSClient] Error received while parsing GetNetworkConfiguration response resp:%v err:%v" , res .Body , err .Error ())
88+ logger .Errorf ("[Azure CNSClient] Error received while parsing GetNetworkConfiguration response resp:%v err:%v" , res .Body , err .Error ())
8989 return nil , err
9090 }
9191
9292 if resp .Response .ReturnCode != 0 {
93- log .Errorf ("[Azure CNSClient] GetNetworkConfiguration received error response :%v" , resp .Response .Message )
93+ logger .Errorf ("[Azure CNSClient] GetNetworkConfiguration received error response :%v" , resp .Response .Message )
9494 return nil , fmt .Errorf (resp .Response .Message )
9595 }
9696
@@ -107,20 +107,20 @@ func (cnsClient *CNSClient) CreateHostNCApipaEndpoint(
107107
108108 httpc := & http.Client {}
109109 url := cnsClient .connectionURL + cns .CreateHostNCApipaEndpointPath
110- log .Printf ("CreateHostNCApipaEndpoint url: %v for NC: %s" , url , networkContainerID )
110+ logger .Printf ("CreateHostNCApipaEndpoint url: %v for NC: %s" , url , networkContainerID )
111111
112112 payload := & cns.CreateHostNCApipaEndpointRequest {
113113 NetworkContainerID : networkContainerID ,
114114 }
115115
116116 if err = json .NewEncoder (& body ).Encode (payload ); err != nil {
117- log .Errorf ("encoding json failed with %v" , err )
117+ logger .Errorf ("encoding json failed with %v" , err )
118118 return "" , err
119119 }
120120
121121 res , err := httpc .Post (url , "application/json" , & body )
122122 if err != nil {
123- log .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
123+ logger .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
124124 return "" , err
125125 }
126126
@@ -129,20 +129,20 @@ func (cnsClient *CNSClient) CreateHostNCApipaEndpoint(
129129 if res .StatusCode != http .StatusOK {
130130 errMsg := fmt .Sprintf ("[Azure CNSClient] CreateHostNCApipaEndpoint: Invalid http status code: %v" ,
131131 res .StatusCode )
132- log .Errorf (errMsg )
132+ logger .Errorf (errMsg )
133133 return "" , fmt .Errorf (errMsg )
134134 }
135135
136136 var resp cns.CreateHostNCApipaEndpointResponse
137137
138138 if err = json .NewDecoder (res .Body ).Decode (& resp ); err != nil {
139- log .Errorf ("[Azure CNSClient] Error parsing CreateHostNCApipaEndpoint response resp: %v err: %v" ,
139+ logger .Errorf ("[Azure CNSClient] Error parsing CreateHostNCApipaEndpoint response resp: %v err: %v" ,
140140 res .Body , err .Error ())
141141 return "" , err
142142 }
143143
144144 if resp .Response .ReturnCode != 0 {
145- log .Errorf ("[Azure CNSClient] CreateHostNCApipaEndpoint received error response :%v" , resp .Response .Message )
145+ logger .Errorf ("[Azure CNSClient] CreateHostNCApipaEndpoint received error response :%v" , resp .Response .Message )
146146 return "" , fmt .Errorf (resp .Response .Message )
147147 }
148148
@@ -155,21 +155,21 @@ func (cnsClient *CNSClient) DeleteHostNCApipaEndpoint(networkContainerID string)
155155
156156 httpc := & http.Client {}
157157 url := cnsClient .connectionURL + cns .DeleteHostNCApipaEndpointPath
158- log .Printf ("DeleteHostNCApipaEndpoint url: %v for NC: %s" , url , networkContainerID )
158+ logger .Printf ("DeleteHostNCApipaEndpoint url: %v for NC: %s" , url , networkContainerID )
159159
160160 payload := & cns.DeleteHostNCApipaEndpointRequest {
161161 NetworkContainerID : networkContainerID ,
162162 }
163163
164164 err := json .NewEncoder (& body ).Encode (payload )
165165 if err != nil {
166- log .Errorf ("encoding json failed with %v" , err )
166+ logger .Errorf ("encoding json failed with %v" , err )
167167 return err
168168 }
169169
170170 res , err := httpc .Post (url , "application/json" , & body )
171171 if err != nil {
172- log .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
172+ logger .Errorf ("[Azure CNSClient] HTTP Post returned error %v" , err .Error ())
173173 return err
174174 }
175175
@@ -178,21 +178,21 @@ func (cnsClient *CNSClient) DeleteHostNCApipaEndpoint(networkContainerID string)
178178 if res .StatusCode != http .StatusOK {
179179 errMsg := fmt .Sprintf ("[Azure CNSClient] DeleteHostNCApipaEndpoint: Invalid http status code: %v" ,
180180 res .StatusCode )
181- log .Errorf (errMsg )
181+ logger .Errorf (errMsg )
182182 return fmt .Errorf (errMsg )
183183 }
184184
185185 var resp cns.DeleteHostNCApipaEndpointResponse
186186
187187 err = json .NewDecoder (res .Body ).Decode (& resp )
188188 if err != nil {
189- log .Errorf ("[Azure CNSClient] Error parsing DeleteHostNCApipaEndpoint response resp: %v err: %v" ,
189+ logger .Errorf ("[Azure CNSClient] Error parsing DeleteHostNCApipaEndpoint response resp: %v err: %v" ,
190190 res .Body , err .Error ())
191191 return err
192192 }
193193
194194 if resp .Response .ReturnCode != 0 {
195- log .Errorf ("[Azure CNSClient] DeleteHostNCApipaEndpoint received error response :%v" , resp .Response .Message )
195+ logger .Errorf ("[Azure CNSClient] DeleteHostNCApipaEndpoint received error response :%v" , resp .Response .Message )
196196 return fmt .Errorf (resp .Response .Message )
197197 }
198198
0 commit comments