diff --git a/go.mod b/go.mod index 9fc179aa6..e21ec3f90 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/citrix/terraform-provider-citrixadc go 1.13 require ( - github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 + github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 github.com/hashicorp/terraform v0.12.20 github.com/hashicorp/terraform-plugin-sdk v1.6.0 github.com/mitchellh/mapstructure v1.1.2 diff --git a/go.sum b/go.sum index 186f568ba..84e4bf8b2 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,12 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 h1:wk2ukyd2A8hgCWemrDCq+pM71QMtn3wpxEQL4aNOH2I= github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200522165541-e35ec60a1d1b h1:Q0m3P756l2lcBEEQmm2WWMs/OXs8WtX9D2uY9X9OY6k= +github.com/chiradeep/go-nitro v0.0.0-20200522165541-e35ec60a1d1b/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200723075907-bf03b0d21306 h1:wuZCDMb2/1c5W3vSyQ1jLZbylVVIkGhW0+v53AGzQcA= +github.com/chiradeep/go-nitro v0.0.0-20200723075907-bf03b0d21306/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 h1:y8Ovob0o1JKjOvh8LwhfjQSNbFvYVHSRr0t19PqcJlY= +github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= diff --git a/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go b/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go index c02ea2025..c2675ac44 100644 --- a/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go +++ b/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go @@ -7,16 +7,16 @@ type Nsparam struct { Cipheader string `json:"cipheader,omitempty"` Cookieversion string `json:"cookieversion,omitempty"` Crportrange string `json:"crportrange,omitempty"` - Exclusivequotamaxclient int `json:"exclusivequotamaxclient,omitempty"` - Exclusivequotaspillover int `json:"exclusivequotaspillover,omitempty"` + Exclusivequotamaxclient int `json:"exclusivequotamaxclient"` // 0 is a valid value + Exclusivequotaspillover int `json:"exclusivequotaspillover"` // 0 is a valid value Ftpportrange string `json:"ftpportrange,omitempty"` - Grantquotamaxclient int `json:"grantquotamaxclient,omitempty"` - Grantquotaspillover int `json:"grantquotaspillover,omitempty"` + Grantquotamaxclient int `json:"grantquotamaxclient"` // 0 is a valid value + Grantquotaspillover int `json:"grantquotaspillover"` // 0 is a valid value Httpport interface{} `json:"httpport,omitempty"` Icaports interface{} `json:"icaports,omitempty"` Internaluserlogin string `json:"internaluserlogin,omitempty"` - Maxconn int `json:"maxconn,omitempty"` - Maxreq int `json:"maxreq,omitempty"` + Maxconn int `json:"maxconn"` // 0 is a valid value + Maxreq int `json:"maxreq"` // 0 is a valid value Mgmthttpport int `json:"mgmthttpport,omitempty"` Mgmthttpsport int `json:"mgmthttpsport,omitempty"` Pmtumin int `json:"pmtumin,omitempty"` diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/client.go b/vendor/github.com/chiradeep/go-nitro/netscaler/client.go index 24c84b3fa..1eb48b64c 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/client.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/client.go @@ -18,6 +18,7 @@ package netscaler import ( "crypto/tls" + "crypto/x509" "fmt" "net/http" "net/url" @@ -25,6 +26,7 @@ import ( "strconv" "strings" "sync" + "io/ioutil" ) //NitroParams encapsulates options to create a NitroClient @@ -35,6 +37,8 @@ type NitroParams struct { ProxiedNs string SslVerify bool Timeout int + RootCAPath string + ServerName string } //NitroClient has methods to configure the NetScaler @@ -84,7 +88,25 @@ func NewNitroClientFromParams(params NitroParams) (*NitroClient, error) { c.sessionid = "" c.timeout = params.Timeout if params.SslVerify { - c.client = &http.Client{} + if( len(params.RootCAPath) > 0 ){ + caCert, err := ioutil.ReadFile(params.RootCAPath) + if err != nil { + return nil, fmt.Errorf("Unable to read certificate file: %v", err) + } + caCertPool := x509.NewCertPool() + if ok := caCertPool.AppendCertsFromPEM(caCert); !ok { + return nil, fmt.Errorf("Could not Append CA certificate.") + } + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + RootCAs: caCertPool, + ServerName: params.ServerName, + }, + } + c.client = &http.Client{Transport: tr} + } else { + c.client = &http.Client{} + } } else { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go b/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go index 8ad707cf8..a1d26a18b 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go @@ -439,3 +439,19 @@ func (c *NitroClient) listStat(resourceType, resourceName string) ([]byte, error return c.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler) } + +func (c *NitroClient) listStatWithArgs(resourceType string, resourceName string, args []string) ([]byte, error) { + log.Println("[DEBUG] go-nitro: listing stat of type ", resourceType, ", name: ", resourceName, ", args:", args) + var url string + + if len(resourceName) > 0 { + url = c.statsURL + fmt.Sprintf("%s/%s", resourceType, resourceName) + } else { + url = c.statsURL + fmt.Sprintf("%s", resourceType) + } + strArgs := strings.Join(args, ",") + url = url + "?args=" + strArgs + log.Println("[TRACE] go-nitro: url is ", url) + + return c.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler) +} diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go b/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go index 3878a2356..3dc65296c 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go @@ -52,3 +52,31 @@ func (c *NitroClient) FindStat(resourceType string, resourceName string) (map[st return resource.(map[string]interface{}), nil } + +func (c *NitroClient) FindStatWithArgs(resourceType string, resourceName string, args []string) (map[string]interface{}, error) { + + var data map[string]interface{} + result, err := c.listStatWithArgs(resourceType, resourceName, args) + if err != nil { + log.Printf("[WARN] go-nitro: FindStatWithArgs: No %s %s found", resourceType, resourceName) + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: No resource %s of type %s found", resourceName, resourceType) + } + if err = json.Unmarshal(result, &data); err != nil { + log.Printf("[ERROR] go-nitro: FindStatWithArgs: Failed to unmarshal Netscaler Response!") + return nil, fmt.Errorf("[ERROR] go-nitro: FindStatWithArgs: Failed to unmarshal Netscaler Response:resource %s of type %s", resourceName, resourceType) + } + rsrc, ok := data[resourceType] + if !ok || rsrc == nil { + log.Printf("[WARN] go-nitro: FindStatWithArgs No %s type with name %s found", resourceType, resourceName) + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: No resource %s of type %s found", resourceName, resourceType) + } + switch result := data[resourceType].(type) { + case map[string]interface{}: + return result, nil + case []interface{}: + return result[0].(map[string]interface{}), nil + default: + log.Printf("[WARN] go-nitro: FindStatWithArgs Unable to determine type of response") + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: Unable to determine type of response") + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0ba928466..3247949cd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/bgentry/speakeasy github.com/blang/semver # github.com/bmatcuk/doublestar v1.1.5 github.com/bmatcuk/doublestar -# github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 +# github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 github.com/chiradeep/go-nitro/config/audit github.com/chiradeep/go-nitro/config/basic github.com/chiradeep/go-nitro/config/cluster