Skip to content

Commit 963bae8

Browse files
committed
loxicmd needs to print result body after each command - success or fail reason
1 parent 226de99 commit 963bae8

29 files changed

+63
-62
lines changed

cmd/create/create_endpoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ ex) loxicmd create endpoint 32.32.32.1 --desc=zone1host --probetype=http --probe
106106
defer resp.Body.Close()
107107

108108
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
109-
if resp.StatusCode != http.StatusOK {
110-
PrintCreateLbResult(resp, *restOptions)
109+
if resp.StatusCode == http.StatusOK {
110+
PrintCreateResult(resp, *restOptions)
111111
return
112112
}
113113
},

cmd/create/create_fdb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ ex) loxicmd create fdb aa:aa:aa:aa:bb:bb eno7
5555
}
5656
defer resp.Body.Close()
5757

58-
if resp.StatusCode != http.StatusOK {
59-
PrintCreateLbResult(resp, *restOptions)
58+
if resp.StatusCode == http.StatusOK {
59+
PrintCreateResult(resp, *restOptions)
6060
return
6161
}
6262

cmd/create/create_firewall.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ ex) loxicmd create firewall --firewallRule="sourceIP:1.2.3.2/32,destinationIP:2.
9292
defer resp.Body.Close()
9393

9494
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
95-
if resp.StatusCode != http.StatusOK {
96-
PrintCreateLbResult(resp, *restOptions)
95+
if resp.StatusCode == http.StatusOK {
96+
PrintCreateResult(resp, *restOptions)
9797
return
9898
}
9999

cmd/create/create_ipaddress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ ex) loxicmd create ip 192.168.0.1/24 eno7
5656
}
5757
defer resp.Body.Close()
5858

59-
if resp.StatusCode != http.StatusOK {
60-
PrintCreateLbResult(resp, *restOptions)
59+
if resp.StatusCode == http.StatusOK {
60+
PrintCreateResult(resp, *restOptions)
6161
return
6262
}
6363

cmd/create/create_loadbalancer.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ ex) loxicmd create lb 192.168.0.200 --tcp=80:32015 --endpoints=10.212.0.1:1,10.2
198198
fmt.Printf("Error: %s\n", err.Error())
199199
return
200200
}
201+
201202
defer resp.Body.Close()
202203

203204
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
204-
if resp.StatusCode != http.StatusOK {
205-
PrintCreateLbResult(resp, *restOptions)
205+
if resp.StatusCode == http.StatusOK {
206+
PrintCreateResult(resp, *restOptions)
206207
return
207208
}
208209
}
@@ -226,10 +227,10 @@ ex) loxicmd create lb 192.168.0.200 --tcp=80:32015 --endpoints=10.212.0.1:1,10.2
226227
return createLbCmd
227228
}
228229

229-
func PrintCreateLbResult(resp *http.Response, o api.RESTOptions) {
230+
func PrintCreateResult(resp *http.Response, o api.RESTOptions) {
230231
result := CreateLoadBalancerResult{}
231232
resultByte, err := io.ReadAll(resp.Body)
232-
fmt.Printf("Debug: response.Body: %s\n", string(resultByte))
233+
//fmt.Printf("Debug: response.Body: %s\n", string(resultByte))
233234

234235
if err != nil {
235236
fmt.Printf("Error: Failed to read HTTP response: (%s)\n", err.Error())

cmd/create/create_mirror.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ ex) loxicmd create mirror mirr-1 --mirrorInfo="type:0,port:hs0" --targetObject="
8484
defer resp.Body.Close()
8585

8686
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
87-
if resp.StatusCode != http.StatusOK {
88-
PrintCreateLbResult(resp, *restOptions)
87+
if resp.StatusCode == http.StatusOK {
88+
PrintCreateResult(resp, *restOptions)
8989
return
9090
}
9191

cmd/create/create_neighbor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ ex) loxicmd create neighbor 192.168.0.1 eno7 --macAddress=aa:aa:aa:aa:aa:aa
6363
}
6464
defer resp.Body.Close()
6565

66-
if resp.StatusCode != http.StatusOK {
67-
PrintCreateLbResult(resp, *restOptions)
66+
if resp.StatusCode == http.StatusOK {
67+
PrintCreateResult(resp, *restOptions)
6868
return
6969
}
7070

cmd/create/create_route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ ex) loxicmd create route 192.168.212.0/24 172.17.0.254
5656
}
5757
defer resp.Body.Close()
5858

59-
if resp.StatusCode != http.StatusOK {
60-
PrintCreateLbResult(resp, *restOptions)
59+
if resp.StatusCode == http.StatusOK {
60+
PrintCreateResult(resp, *restOptions)
6161
return
6262
}
6363

cmd/create/create_session.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ ex) loxicmd create session user1 192.168.20.1 --accessNetworkTunnel=1:1.232.16.1
7979
defer resp.Body.Close()
8080

8181
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
82-
if resp.StatusCode != http.StatusOK {
83-
PrintCreateLbResult(resp, *restOptions)
82+
if resp.StatusCode == http.StatusOK {
83+
PrintCreateResult(resp, *restOptions)
8484
return
8585
}
8686

cmd/create/create_sessionulcl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ ex) loxicmd create sessionulcl user1 --ulclArgs=16:192.33.125.1
7373
defer resp.Body.Close()
7474

7575
fmt.Printf("Debug: response.StatusCode: %d\n", resp.StatusCode)
76-
if resp.StatusCode != http.StatusOK {
77-
PrintCreateLbResult(resp, *restOptions)
76+
if resp.StatusCode == http.StatusOK {
77+
PrintCreateResult(resp, *restOptions)
7878
return
7979
}
8080

0 commit comments

Comments
 (0)