Closed sagarnikam123 closed 6 years ago
Thanks for the test code. Testing against Docker image store/citrix/netscalercpx:12.0-56.20
:
2018/05/11 12:03:34 [TRACE] go-nitro: Resourcejson is {"route":{"gateway":"192.168.13.2","netmask":"255.255.255.0","network":"192.168.13.15"}}
2018/05/11 12:03:34 [DEBUG] go-nitro: Creating resource of type route
2018/05/11 12:03:34 [TRACE] go-nitro: url is http://localhost:32768/nitro/v1/config/route?idempotent=yes
2018/05/11 12:03:34 [DEBUG] go-nitro: response Status: 599 Netscaler specific error
2018/05/11 12:03:34 [INFO] go-nitro: error = { "errorcode": 604, "message": "The gateway is not directly reachable", "severity": "ERROR" }
Changing the payload (so that the route is valid):
2018/05/11 12:06:15 [TRACE] go-nitro: Resourcejson is {"route":{"gateway":"172.17.0.2","netmask":"255.255.255.0","network":"192.168.13.15"}}
2018/05/11 12:06:15 [DEBUG] go-nitro: Creating resource of type route
2018/05/11 12:06:15 [TRACE] go-nitro: url is http://localhost:32768/nitro/v1/config/route?idempotent=yes
2018/05/11 12:06:15 [DEBUG] go-nitro: response Status: 201 Created
2018/05/11 12:06:15 saveJSON is {"nsconfig":{}}
2018/05/11 12:06:15 [DEBUG] go-nitro: Saving config
2018/05/11 12:06:19 [DEBUG] go-nitro: response Status: 200 OK
Thanks, @chiradeep , using netscalercpx
image with given payload solves the problem.
But another issue appears as Route don't have any unique name
or id
for identification in its parameters.
While deleting we unable to delete it with the available functions in current nitro-client.
As DeleteResource(resourceType string, resourceName string)
will not be useful. So I used below one, but its kind of in-sufficient.
package main
import (
"fmt"
"github.com/chiradeep/go-nitro/config/network"
"github.com/chiradeep/go-nitro/netscaler"
)
func main() {
client, _ := netscaler.NewNitroClientFromEnv()
route := network.Route{
Network: "192.168.15.0",
Netmask: "255.255.255.0",
Gateway: "172.17.0.2",
}
// adding route
result, err := client.AddResource(netscaler.Route.Type(), "awsRoute", &route)
if err == nil {
client.SaveConfig()
}
fmt.Println(result)
// deleting route
var argsBundle = []string{"192.168.15.0", "255.255.255.0", "172.17.0.2"}
err2 := client.DeleteResourceWithArgs(netscaler.Route.Type(), "192.168.15.0", argsBundle)
if err2 != nil {
fmt.Println(err2)
}
}
2018/05/14 17:57:23 [TRACE] go-nitro: Resourcejson is {"route":{"gateway":"172.17.0.2","netmask":"255.255.255.0","network":"192.168.15.0"}}
2018/05/14 17:57:23 [DEBUG] go-nitro: Creating resource of type route
2018/05/14 17:57:23 [TRACE] go-nitro: url is http://172.17.0.2/nitro/v1/config/route?idempotent=yes
2018/05/14 17:57:23 [DEBUG] go-nitro: response Status: 201 Created
2018/05/14 17:57:23 saveJSON is {"nsconfig":{}}
2018/05/14 17:57:23 [DEBUG] go-nitro: Saving config
2018/05/14 17:57:23 [DEBUG] go-nitro: response Status: 200 OK
awsRoute
2018/05/14 17:57:23 [DEBUG] go-nitro: listing resource of type route , name: 192.168.15.0
2018/05/14 17:57:23 [DEBUG] go-nitro: response Status: 400 Bad Request
2018/05/14 17:57:23 [INFO] go-nitro: read: error = { "errorcode": 1095, "message": "Required argument missing [netmask, network]", "severity": "ERROR" }
2018/05/14 17:57:23 [INFO] go-nitro: Resource 192.168.15.0 already deleted
Fixed by 1aaf4aad6
Using Nitro-ide for local testing.
route.go
But when we use same values using REST API, route is getting created perfectly. (find below method)
http://192.168.13.20/nitro/v1/config/route
Actual result -
Expected result -