Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize VMC NSX version to 3.0.0 #531

Merged
merged 3 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients)
clients.PolicyEnforcementPoint = policyEnforcementPoint
clients.PolicyGlobalManager = policyGlobalManager

if len(vmcAccessToken) > 0 {
// Special treatment for VMC since MP API is not available there
initNSXVersionVMC(*clients)
}
return nil
}

Expand Down
30 changes: 30 additions & 0 deletions nsxt/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
api "github.com/vmware/go-vmware-nsxt"
"github.com/vmware/go-vmware-nsxt/common"
"github.com/vmware/go-vmware-nsxt/manager"

"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/search"
)

var adminStateValues = []string{"UP", "DOWN"}
Expand Down Expand Up @@ -530,6 +532,34 @@ func initNSXVersion(nsxClient *api.APIClient) error {
return err
}

func initNSXVersionVMC(clients interface{}) {
// TODO: find a ireliable way to retrieve NSX version on VMC
// For now, we need to determine whether the deployment is 3.0.0 and up, or below
// For this purpose, we fire indicator search API (introduced in 3.0.0)
nsxVersion = "3.0.0"

connector := getPolicyConnector(clients)
client := search.NewDefaultQueryClient(connector)
var cursor *string
query := "resource_type:dummy"
_, err := client.List(query, cursor, nil, nil, nil, nil)
if err == nil {
// we are 3.0.0 and above
log.Printf("[INFO] Assuming NSX version >= 3.0.0 in VMC environment")
return
}

if isNotFoundError(err) {
// search API not supported
log.Printf("[INFO] Assuming NSX version < 3.0.0 in VMC environment")
nsxVersion = "2.5.0"
return
}

// Connectivity error - alert the user
log.Printf("[ERROR] Failed to determine NSX version in VMC environment: %s", err)
}

func nsxVersionLower(ver string) bool {

requestedVersion, err1 := version.NewVersion(ver)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading