7
7
"net/http"
8
8
9
9
"github.com/Azure/azure-container-networking/cns"
10
- "github.com/Azure/azure-container-networking/log "
10
+ "github.com/Azure/azure-container-networking/cns/logger "
11
11
)
12
12
13
13
// CNSClient specifies a client to connect to Ipam Plugin.
@@ -55,42 +55,42 @@ func (cnsClient *CNSClient) GetNetworkConfiguration(orchestratorContext []byte)
55
55
56
56
httpc := & http.Client {}
57
57
url := cnsClient .connectionURL + cns .GetNetworkContainerByOrchestratorContext
58
- log .Printf ("GetNetworkConfiguration url %v" , url )
58
+ logger .Printf ("GetNetworkConfiguration url %v" , url )
59
59
60
60
payload := & cns.GetNetworkContainerRequest {
61
61
OrchestratorContext : orchestratorContext ,
62
62
}
63
63
64
64
err := json .NewEncoder (& body ).Encode (payload )
65
65
if err != nil {
66
- log .Errorf ("encoding json failed with %v" , err )
66
+ logger .Errorf ("encoding json failed with %v" , err )
67
67
return nil , err
68
68
}
69
69
70
70
res , err := httpc .Post (url , "application/json" , & body )
71
71
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 ())
73
73
return nil , err
74
74
}
75
75
76
76
defer res .Body .Close ()
77
77
78
78
if res .StatusCode != http .StatusOK {
79
79
errMsg := fmt .Sprintf ("[Azure CNSClient] GetNetworkConfiguration invalid http status code: %v" , res .StatusCode )
80
- log .Errorf (errMsg )
80
+ logger .Errorf (errMsg )
81
81
return nil , fmt .Errorf (errMsg )
82
82
}
83
83
84
84
var resp cns.GetNetworkContainerResponse
85
85
86
86
err = json .NewDecoder (res .Body ).Decode (& resp )
87
87
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 ())
89
89
return nil , err
90
90
}
91
91
92
92
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 )
94
94
return nil , fmt .Errorf (resp .Response .Message )
95
95
}
96
96
@@ -107,20 +107,20 @@ func (cnsClient *CNSClient) CreateHostNCApipaEndpoint(
107
107
108
108
httpc := & http.Client {}
109
109
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 )
111
111
112
112
payload := & cns.CreateHostNCApipaEndpointRequest {
113
113
NetworkContainerID : networkContainerID ,
114
114
}
115
115
116
116
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 )
118
118
return "" , err
119
119
}
120
120
121
121
res , err := httpc .Post (url , "application/json" , & body )
122
122
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 ())
124
124
return "" , err
125
125
}
126
126
@@ -129,20 +129,20 @@ func (cnsClient *CNSClient) CreateHostNCApipaEndpoint(
129
129
if res .StatusCode != http .StatusOK {
130
130
errMsg := fmt .Sprintf ("[Azure CNSClient] CreateHostNCApipaEndpoint: Invalid http status code: %v" ,
131
131
res .StatusCode )
132
- log .Errorf (errMsg )
132
+ logger .Errorf (errMsg )
133
133
return "" , fmt .Errorf (errMsg )
134
134
}
135
135
136
136
var resp cns.CreateHostNCApipaEndpointResponse
137
137
138
138
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" ,
140
140
res .Body , err .Error ())
141
141
return "" , err
142
142
}
143
143
144
144
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 )
146
146
return "" , fmt .Errorf (resp .Response .Message )
147
147
}
148
148
@@ -155,21 +155,21 @@ func (cnsClient *CNSClient) DeleteHostNCApipaEndpoint(networkContainerID string)
155
155
156
156
httpc := & http.Client {}
157
157
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 )
159
159
160
160
payload := & cns.DeleteHostNCApipaEndpointRequest {
161
161
NetworkContainerID : networkContainerID ,
162
162
}
163
163
164
164
err := json .NewEncoder (& body ).Encode (payload )
165
165
if err != nil {
166
- log .Errorf ("encoding json failed with %v" , err )
166
+ logger .Errorf ("encoding json failed with %v" , err )
167
167
return err
168
168
}
169
169
170
170
res , err := httpc .Post (url , "application/json" , & body )
171
171
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 ())
173
173
return err
174
174
}
175
175
@@ -178,21 +178,21 @@ func (cnsClient *CNSClient) DeleteHostNCApipaEndpoint(networkContainerID string)
178
178
if res .StatusCode != http .StatusOK {
179
179
errMsg := fmt .Sprintf ("[Azure CNSClient] DeleteHostNCApipaEndpoint: Invalid http status code: %v" ,
180
180
res .StatusCode )
181
- log .Errorf (errMsg )
181
+ logger .Errorf (errMsg )
182
182
return fmt .Errorf (errMsg )
183
183
}
184
184
185
185
var resp cns.DeleteHostNCApipaEndpointResponse
186
186
187
187
err = json .NewDecoder (res .Body ).Decode (& resp )
188
188
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" ,
190
190
res .Body , err .Error ())
191
191
return err
192
192
}
193
193
194
194
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 )
196
196
return fmt .Errorf (resp .Response .Message )
197
197
}
198
198
0 commit comments