Skip to content

Commit

Permalink
Merge pull request #1101 from vmware/cluster-ip-err
Browse files Browse the repository at this point in the history
Add NSX version check to cluster IP resource
  • Loading branch information
annakhm authored Feb 9, 2024
2 parents 691b55b + 4841af7 commit 31bac2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions nsxt/policy_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func logAPIError(message string, err error) error {
if vapiError, ok := err.(errors.ServiceUnavailable); ok {
return logVapiErrorData(message, vapiError.Messages, vapiError.ErrorType, vapiError.Data)
}
if vapiError, ok := err.(errors.ConcurrentChange); ok {
return logVapiErrorData(message, vapiError.Messages, vapiError.ErrorType, vapiError.Data)
}

return err
}
Expand Down
18 changes: 13 additions & 5 deletions nsxt/resource_nsxt_cluster_virtual_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func setClusterVirtualIP(d *schema.ResourceData, m interface{}) error {
} else {
forceStr = nsxModel.ClusterVirtualIpProperties_FORCE_FALSE
}
_, err := client.Setvirtualip(&forceStr, &ipv6Address, &ipAddress)
var err error
if nsxVersionHigherOrEqual("4.0.0") {
_, err = client.Setvirtualip(&forceStr, &ipv6Address, &ipAddress)
} else {
// IPv6 not supported
_, err = client.Setvirtualip(nil, nil, &ipAddress)
}
if err != nil {
log.Printf("[WARNING] Failed to set virtual ip: %v", err)
return err
Expand Down Expand Up @@ -132,10 +138,12 @@ func resourceNsxtClusterVirualIPDelete(d *schema.ResourceData, m interface{}) er
log.Printf("[WARNING] Failed to clear virtual ip: %v", err)
return handleDeleteError("ClusterVirtualIP", id, err)
}
_, err = client.Clearvirtualip6()
if err != nil {
log.Printf("[WARNING] Failed to clear virtual ipv6 ip: %v", err)
return handleDeleteError("ClusterVirtualIP", id, err)
if nsxVersionHigherOrEqual("4.0.0") {
_, err = client.Clearvirtualip6()
if err != nil {
log.Printf("[WARNING] Failed to clear virtual ipv6 ip: %v", err)
return handleDeleteError("ClusterVirtualIP", id, err)
}
}
return nil
}
4 changes: 2 additions & 2 deletions website/docs/r/cluster_virtual_ip.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ resource "nsxt_cluster_virtual_ip" "test" {

The following arguments are supported:

* `force` - (Optional) A flag to determine if need to ignore duplicate address detection and DNS lookup validation check. Value can be `true` or `false`. Default value is `false`.
* `force` - (Optional) A flag to determine if need to ignore duplicate address detection and DNS lookup validation check. Value can be `true` or `false`. Default value is `false`. This argument is supported for NSX 4.0.0 and above.
* `ip_address` - (Optional) Virtual IP Address of the cluster. Must be in the same subnet as the manager nodes. Default value is `0.0.0.0`.
* `ipv6_address` - (Optional) Virtual IPv6 Address of the cluster. To set ipv6 virtual IP address, IPv6 interface needs to be configured on manager nodes. Default value is `::`.
* `ipv6_address` - (Optional) Virtual IPv6 Address of the cluster. To set ipv6 virtual IP address, IPv6 interface needs to be configured on manager nodes. Default value is `::`. This argument is supported for NSX 4.0.0 and above.

## Importing

Expand Down

0 comments on commit 31bac2a

Please sign in to comment.