Skip to content

Commit

Permalink
Disable MP Resources from NSX 9.0.0 onwards
Browse files Browse the repository at this point in the history
This change removes support for NSX MP API client when the
NSX manager version is higher or equal to 9.0.0

For MP resources, with NSX >= 9.0.0:
- terraform apply, destroy, and import operations will fail with
  the following error:
  "This resource is not supported with given provider settings.
   Management Plane resources are not supported since NSX 9.0.0;
- terraform plan operations for resources already in the Terraform
  state will fail with the same error;
- all terraform operations involving MP data sources will fail
  with the same error;
- terraform plan operations for resource not yet in the Terraform
  state will succeed, but will then fail at the apply stage. This
  because Terraform won't perform a read from the backend if the
  resource is not present at all in the state.

Signed-off-by: Salvatore Orlando <[email protected]>
  • Loading branch information
salv-orlando committed Sep 25, 2024
1 parent 73aba67 commit cb5064a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,12 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return nil, err
}

initNSXVersion(getPolicyConnector(clients))
if util.NsxVersionHigherOrEqual("9.0.0") {
// Disable MP client from 9.0.0 onwards
log.Printf("[INFO]: NSX MP client disabled for NSX %s. MP resources will not be supported", util.NsxVersion)
clients.NsxtClient = nil
}
return clients, nil
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ func initNSXVersionVMC(clients interface{}) {
}

func resourceNotSupportedError() error {
if util.NsxVersionHigherOrEqual("9.0.0") {
return fmt.Errorf("This resource is not supported with given provider settings.\nManagement Plane resources are not supported since NSX 9.0.0")
}
return fmt.Errorf("This resource is not supported with given provider settings")
}

Expand Down

0 comments on commit cb5064a

Please sign in to comment.