diff --git a/.changes/v2.15.0/434-features.md b/.changes/v2.15.0/434-features.md new file mode 100644 index 000000000..df64d4374 --- /dev/null +++ b/.changes/v2.15.0/434-features.md @@ -0,0 +1 @@ +* Add environment variable `GOVCD_API_VERSION` so API version can be set manually [GH-434] diff --git a/.changes/v2.15.0/434-improvements.md b/.changes/v2.15.0/434-improvements.md new file mode 100644 index 000000000..edf9a5cef --- /dev/null +++ b/.changes/v2.15.0/434-improvements.md @@ -0,0 +1 @@ +* Bump Default API Version to V35.0 [GH-434] diff --git a/TESTING.md b/TESTING.md index 0c3f31e19..65b133a6c 100644 --- a/TESTING.md +++ b/TESTING.md @@ -342,6 +342,8 @@ While running tests, the following environment variables can be used: * `VCD_TOKEN` : specifies the authorization token to use instead of username/password (Use `./scripts/get_token.sh` to retrieve one) * `GOVCD_KEEP_TEST_OBJECTS` will skip deletion of objects created during tests. +* `GOVCD_API_VERSION` allows to select the API version to use. This must be used **for testing purposes only** as the SDK + has been tested to use certain version of the API. Using this environment variable may lead to unexpected failures. When both the environment variable and the command line option are possible, the environment variable gets evaluated first. diff --git a/govcd/api_vcd.go b/govcd/api_vcd.go index 7bc70cb41..971638747 100644 --- a/govcd/api_vcd.go +++ b/govcd/api_vcd.go @@ -7,8 +7,10 @@ package govcd import ( "crypto/tls" "fmt" + semver "github.com/hashicorp/go-version" "net/http" "net/url" + "os" "strings" "time" @@ -102,10 +104,22 @@ func (vcdClient *VCDClient) vcdCloudApiAuthorize(user, pass, org string) (*http. // NewVCDClient initializes VMware vCloud Director client with reasonable defaults. // It accepts functions of type VCDClientOption for adjusting defaults. func NewVCDClient(vcdEndpoint url.URL, insecure bool, options ...VCDClientOption) *VCDClient { + minVcdApiVersion := "35.0" // supported by 10.2+ + userDefinedApiVersion := os.Getenv("GOVCD_API_VERSION") + if userDefinedApiVersion != "" { + _, err := semver.NewVersion(userDefinedApiVersion) + if err != nil { + // We do not have error in return of this function signature. + // To avoid breaking API the only thing we can do is panic. + panic(fmt.Sprintf("unable to initialize VCD client from environment variable GOVCD_API_VERSION. Version '%s' is not valid: %s", userDefinedApiVersion, err)) + } + minVcdApiVersion = userDefinedApiVersion + } + // Setting defaults vcdClient := &VCDClient{ Client: Client{ - APIVersion: "33.0", // supported by 10.0+ + APIVersion: minVcdApiVersion, // supported by 10.2+ // UserAgent cannot embed exact version by default because this is source code and is supposed to be used by programs, // but any client can customize or disable it at all using WithHttpUserAgent() configuration options function. UserAgent: "go-vcloud-director", @@ -130,7 +144,7 @@ func NewVCDClient(vcdEndpoint url.URL, insecure bool, options ...VCDClientOption if err != nil { // We do not have error in return of this function signature. // To avoid breaking API the only thing we can do is panic. - panic(fmt.Sprintf("unable to initialize vCD client: %s", err)) + panic(fmt.Sprintf("unable to initialize VCD client: %s", err)) } } return vcdClient diff --git a/govcd/api_vcd_test.go b/govcd/api_vcd_test.go index f6732c3e4..7c357d8a2 100644 --- a/govcd/api_vcd_test.go +++ b/govcd/api_vcd_test.go @@ -618,7 +618,8 @@ func (vcd *TestVCD) SetUpSuite(check *C) { // creates a new VApp for vapp tests if !skipVappCreation && config.VCD.Network.Net1 != "" && config.VCD.StorageProfile.SP1 != "" && config.VCD.Catalog.Name != "" && config.VCD.Catalog.CatalogItem != "" { - vcd.vapp, err = vcd.createTestVapp(TestSetUpSuite) + // deployVappForTest replaces the old createTestVapp() because it was using bad implemented method vdc.ComposeVApp + vcd.vapp, err = deployVappForTest(vcd, TestSetUpSuite) // If no vApp is created, we skip all vApp tests if err != nil { fmt.Printf("%s\n", err) @@ -1611,69 +1612,6 @@ func TestVCDClient_Authenticate(t *testing.T) { } } -func (vcd *TestVCD) createTestVapp(name string) (*VApp, error) { - // ========================= issue#252 ================================== - // TODO: To be enabled when issue#252 is resolved. - // Allows re-using a pre-created vApp - // existingVapp, err := vcd.vdc.GetVAppByName(name, false) - // if err == nil { - // fmt.Printf("vApp %s already exists. Skipping creation\n",name) - // return existingVapp, nil - // } - // ====================================================================== - // Populate OrgVDCNetwork - var networks []*types.OrgVDCNetwork - net, err := vcd.vdc.GetOrgVdcNetworkByName(vcd.config.VCD.Network.Net1, false) - if err != nil { - return nil, fmt.Errorf("error finding network : %s, err: %s", vcd.config.VCD.Network.Net1, err) - } - networks = append(networks, net.OrgVDCNetwork) - // Populate Catalog - cat, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false) - if err != nil || cat == nil { - return nil, fmt.Errorf("error finding catalog : %s", err) - } - // Populate Catalog Item - catitem, err := cat.GetCatalogItemByName(vcd.config.VCD.Catalog.CatalogItem, false) - if err != nil { - return nil, fmt.Errorf("error finding catalog item : %s", err) - } - // Get VAppTemplate - vAppTemplate, err := catitem.GetVAppTemplate() - if err != nil { - return nil, fmt.Errorf("error finding vapptemplate : %s", err) - } - // Get StorageProfileReference - storageProfileRef, err := vcd.vdc.FindStorageProfileReference(vcd.config.VCD.StorageProfile.SP1) - if err != nil { - return nil, fmt.Errorf("error finding storage profile: %s", err) - } - // Compose VApp - task, err := vcd.vdc.ComposeVApp(networks, vAppTemplate, storageProfileRef, name, "description", true) - if err != nil { - return nil, fmt.Errorf("error composing vapp: %s", err) - } - // After a successful creation, the entity is added to the cleanup list. - // If something fails after this point, the entity will be removed - AddToCleanupList(name, "vapp", "", "createTestVapp") - err = task.WaitTaskCompletion() - if err != nil { - return nil, fmt.Errorf("error composing vapp: %s", err) - } - // Get VApp - vapp, err := vcd.vdc.GetVAppByName(name, true) - if err != nil { - return nil, fmt.Errorf("error getting vapp: %s", err) - } - - err = vapp.BlockWhileStatus("UNRESOLVED", vapp.client.MaxRetryTimeout) - if err != nil { - return nil, fmt.Errorf("error waiting for created test vApp to have working state: %s", err) - } - - return vapp, err -} - func Test_splitParent(t *testing.T) { type args struct { parent string diff --git a/govcd/common_test.go b/govcd/common_test.go index 5cf610812..9b344744b 100644 --- a/govcd/common_test.go +++ b/govcd/common_test.go @@ -1,5 +1,5 @@ -//go:build api || auth || functional || catalog || vapp || gateway || network || org || query || extnetwork || task || vm || vdc || system || disk || lb || lbAppRule || lbAppProfile || lbServerPool || lbServiceMonitor || lbVirtualServer || user || role || nsxv || nsxt || openapi || affinity || search || ALL -// +build api auth functional catalog vapp gateway network org query extnetwork task vm vdc system disk lb lbAppRule lbAppProfile lbServerPool lbServiceMonitor lbVirtualServer user role nsxv nsxt openapi affinity search ALL +//go:build api || auth || functional || catalog || vapp || gateway || network || org || query || extnetwork || task || vm || vdc || system || disk || lb || lbAppRule || lbAppProfile || lbServerPool || lbServiceMonitor || lbVirtualServer || user || role || nsxv || nsxt || openapi || affinity || search || alb || certificate || vdcGroup || metadata || ALL +// +build api auth functional catalog vapp gateway network org query extnetwork task vm vdc system disk lb lbAppRule lbAppProfile lbServerPool lbServiceMonitor lbVirtualServer user role nsxv nsxt openapi affinity search alb certificate vdcGroup metadata ALL /* * Copyright 2021 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. @@ -261,15 +261,14 @@ func isTcpPortOpen(host, port string, timeout int) bool { } -// moved from vapp_test.go -func createVappForTest(vcd *TestVCD, vappName string) (*VApp, error) { +// deployVappForTest aims to replace createVappForTest +func deployVappForTest(vcd *TestVCD, vappName string) (*VApp, error) { // Populate OrgVDCNetwork - var networks []*types.OrgVDCNetwork net, err := vcd.vdc.GetOrgVdcNetworkByName(vcd.config.VCD.Network.Net1, false) if err != nil { return nil, fmt.Errorf("error finding network : %s", err) } - networks = append(networks, net.OrgVDCNetwork) + // Populate Catalog cat, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false) if err != nil || cat == nil { @@ -290,22 +289,45 @@ func createVappForTest(vcd *TestVCD, vappName string) (*VApp, error) { if err != nil { return nil, fmt.Errorf("error finding storage profile: %s", err) } - // Compose VApp - task, err := vcd.vdc.ComposeVApp(networks, vAppTemplate, storageProfileRef, vappName, "description", true) + + // Create empty vApp + vapp, err := vcd.vdc.CreateRawVApp(vappName, "description") if err != nil { - return nil, fmt.Errorf("error composing vapp: %s", err) + return nil, fmt.Errorf("error creating vapp: %s", err) } + // After a successful creation, the entity is added to the cleanup list. // If something fails after this point, the entity will be removed AddToCleanupList(vappName, "vapp", "", "createTestVapp") - err = task.WaitTaskCompletion() + + // Create vApp networking + vAppNetworkConfig, err := vapp.AddOrgNetwork(&VappNetworkSettings{}, net.OrgVDCNetwork, false) + if err != nil { + return nil, fmt.Errorf("error creating vApp network. %s", err) + } + + // Create VM with only one NIC connected to vapp_net + networkConnectionSection := &types.NetworkConnectionSection{ + PrimaryNetworkConnectionIndex: 0, + } + + netConn := &types.NetworkConnection{ + Network: vAppNetworkConfig.NetworkConfig[0].NetworkName, + IsConnected: true, + NetworkConnectionIndex: 0, + IPAddressAllocationMode: types.IPAllocationModePool, + } + + networkConnectionSection.NetworkConnection = append(networkConnectionSection.NetworkConnection, netConn) + + task, err := vapp.AddNewVMWithStorageProfile("test_vm", vAppTemplate, networkConnectionSection, &storageProfileRef, true) if err != nil { - return nil, fmt.Errorf("error composing vapp: %s", err) + return nil, fmt.Errorf("error creating the VM: %s", err) } - // Get VApp - vapp, err := vcd.vdc.GetVAppByName(vappName, true) + + err = task.WaitTaskCompletion() if err != nil { - return nil, fmt.Errorf("error getting vapp: %s", err) + return nil, fmt.Errorf("error while waiting for the VM to be created %s", err) } err = vapp.BlockWhileStatus("UNRESOLVED", vapp.client.MaxRetryTimeout) diff --git a/govcd/nsxt_firewall_group_security_group_test.go b/govcd/nsxt_firewall_group_security_group_test.go index bed52d545..9ceb4f521 100644 --- a/govcd/nsxt_firewall_group_security_group_test.go +++ b/govcd/nsxt_firewall_group_security_group_test.go @@ -171,7 +171,9 @@ func createNsxtRoutedNetwork(check *C, vcd *TestVCD, vdc *Vdc, edgeGatewayId str orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName() + "routed-net", Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeRouted, diff --git a/govcd/openapi_org_network_dhcp.go b/govcd/openapi_org_network_dhcp.go index a059d1fd1..f2caa7d9a 100644 --- a/govcd/openapi_org_network_dhcp.go +++ b/govcd/openapi_org_network_dhcp.go @@ -73,6 +73,18 @@ func (vdc *Vdc) UpdateOpenApiOrgVdcNetworkDhcp(orgNetworkId string, orgVdcNetwor client: vdc.client, } + // From v35.0 onwards, if orgVdcNetworkDhcpConfig.LeaseTime or orgVdcNetworkDhcpConfig.Mode are not explicitly + // passed, the API doesn't use any defaults returning an error. Previous API versions were setting + // LeaseTime to 86400 seconds and Mode to EDGE if these values were not supplied. These two conditional + // address the situation. + if orgVdcNetworkDhcpConfig.LeaseTime == nil { + orgVdcNetworkDhcpConfig.LeaseTime = takeIntAddress(86400) + } + + if len(orgVdcNetworkDhcpConfig.Mode) == 0 { + orgVdcNetworkDhcpConfig.Mode = "EDGE" + } + err = vdc.client.OpenApiPutItem(minimumApiVersion, urlRef, nil, orgVdcNetworkDhcpConfig, orgNetDhcpResponse.OpenApiOrgVdcNetworkDhcp, nil) if err != nil { return nil, fmt.Errorf("error updating Org VDC network DHCP configuration: %s", err) diff --git a/govcd/openapi_org_network_test.go b/govcd/openapi_org_network_test.go index c54d23afd..1f02b6db0 100644 --- a/govcd/openapi_org_network_test.go +++ b/govcd/openapi_org_network_test.go @@ -21,7 +21,9 @@ func (vcd *TestVCD) Test_NsxtOrgVdcNetworkIsolated(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeIsolated, Subnets: types.OrgVdcNetworkSubnets{ @@ -65,7 +67,9 @@ func (vcd *TestVCD) Test_NsxtOrgVdcNetworkRouted(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeRouted, @@ -130,7 +134,9 @@ func (vcd *TestVCD) Test_NsxtOrgVdcNetworkImported(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.nsxtVdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeOpaque, // BackingNetworkId contains NSX-T logical switch ID for Imported networks @@ -170,7 +176,9 @@ func (vcd *TestVCD) Test_NsxvOrgVdcNetworkIsolated(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeIsolated, Subnets: types.OrgVdcNetworkSubnets{ @@ -213,7 +221,9 @@ func (vcd *TestVCD) Test_NsxvOrgVdcNetworkRouted(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeRouted, @@ -275,7 +285,9 @@ func (vcd *TestVCD) Test_NsxvOrgVdcNetworkDirect(check *C) { orgVdcNetworkConfig := &types.OpenApiOrgVdcNetwork{ Name: check.TestName(), Description: check.TestName() + "-description", - OrgVdc: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, + + // On v35.0 orgVdc is not supported anymore. Using ownerRef instead. + OwnerRef: &types.OpenApiReference{ID: vcd.vdc.Vdc.ID}, NetworkType: types.OrgVdcNetworkTypeDirect, ParentNetwork: &types.OpenApiReference{ID: externalNetwork.ExternalNetwork.ID}, diff --git a/govcd/vapp_network_test.go b/govcd/vapp_network_test.go index f6678f633..d3766da46 100644 --- a/govcd/vapp_network_test.go +++ b/govcd/vapp_network_test.go @@ -84,7 +84,7 @@ func (vcd *TestVCD) Test_UpdateNetworkFirewallRules(check *C) { func (vcd *TestVCD) prepareVappWithVappNetwork(check *C, vappName, orgVdcNetworkName string) (*VApp, string, *types.NetworkConfigSection, error) { fmt.Printf("Running: %s\n", check.TestName()) - vapp, err := createVappForTest(vcd, vappName) + vapp, err := deployVappForTest(vcd, vappName) check.Assert(err, IsNil) check.Assert(vapp, NotNil) diff --git a/govcd/vapp_test.go b/govcd/vapp_test.go index d40a044ae..8ddffaf4a 100644 --- a/govcd/vapp_test.go +++ b/govcd/vapp_test.go @@ -456,7 +456,7 @@ func (vcd *TestVCD) Test_AddNewVMNilNIC(check *C) { vapptemplate, err := catitem.GetVAppTemplate() check.Assert(err, IsNil) - vapp, err := createVappForTest(vcd, "Test_AddNewVMNilNIC") + vapp, err := deployVappForTest(vcd, "Test_AddNewVMNilNIC") check.Assert(err, IsNil) check.Assert(vapp, NotNil) task, err := vapp.AddNewVM(check.TestName(), vapptemplate, nil, true) @@ -511,7 +511,7 @@ func (vcd *TestVCD) Test_AddNewVMMultiNIC(check *C) { vapptemplate, err := catitem.GetVAppTemplate() check.Assert(err, IsNil) - vapp, err := createVappForTest(vcd, "Test_AddNewVMMultiNIC") + vapp, err := deployVappForTest(vcd, "Test_AddNewVMMultiNIC") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -751,7 +751,7 @@ func (vcd *TestVCD) Test_GetVM(check *C) { func (vcd *TestVCD) Test_AddAndRemoveIsolatedVappNetwork(check *C) { fmt.Printf("Running: %s\n", check.TestName()) - vapp, err := createVappForTest(vcd, "Test_AddAndRemoveIsolatedVappNetwork") + vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveIsolatedVappNetwork") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -838,7 +838,7 @@ func (vcd *TestVCD) Test_AddAndRemoveNatVappNetwork(check *C) { check.Skip("Skipping test because no network was given") } - vapp, err := createVappForTest(vcd, "Test_AddAndRemoveNatVappNetwork") + vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveNatVappNetwork") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -935,7 +935,7 @@ func (vcd *TestVCD) Test_UpdateVappNetwork(check *C) { check.Skip("Skipping test because no network was given") } - vapp, err := createVappForTest(vcd, "Test_UpdateVappNetwork") + vapp, err := deployVappForTest(vcd, "Test_UpdateVappNetwork") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1094,7 +1094,7 @@ func (vcd *TestVCD) Test_UpdateVappNetwork(check *C) { func (vcd *TestVCD) Test_AddAndRemoveVappNetworkWithMinimumValues(check *C) { fmt.Printf("Running: %s\n", check.TestName()) - vapp, err := createVappForTest(vcd, "Test_AddAndRemoveVappNetworkWithMinimumValues") + vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveVappNetworkWithMinimumValues") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1164,7 +1164,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetworkWithMinimumValues(check *C) { check.Skip("Skipping test because no network was given") } - vapp, err := createVappForTest(vcd, "Test_AddAndRemoveOrgVappNetworkWithMinimumValues") + vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveOrgVappNetworkWithMinimumValues") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1198,7 +1198,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetworkWithMinimumValues(check *C) { check.Assert(networkFound.Configuration.ParentNetwork.Name, Equals, vcd.config.VCD.Network.Net1) - err = vcd.vapp.Refresh() + err = vapp.Refresh() check.Assert(err, IsNil) vappNetworkConfig, err = vapp.RemoveNetwork(vcd.config.VCD.Network.Net1) check.Assert(err, IsNil) @@ -1226,7 +1226,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetwork(check *C) { check.Skip("Skipping test because no network was given") } - vapp, err := createVappForTest(vcd, "Test_AddAndRemoveOrgVappNetwork") + vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveOrgVappNetwork") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1289,7 +1289,7 @@ func (vcd *TestVCD) Test_UpdateOrgVappNetwork(check *C) { check.Skip("Skipping test because no network was given") } - vapp, err := createVappForTest(vcd, "Test_UpdateOrgVappNetwork") + vapp, err := deployVappForTest(vcd, "Test_UpdateOrgVappNetwork") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1420,7 +1420,7 @@ func (vcd *TestVCD) Test_AddNewVMFromMultiVmTemplate(check *C) { returnedVappTemplate, err := catalog.GetVappTemplateByHref(vmInTemplateRecord.HREF) check.Assert(err, IsNil) - vapp, err := createVappForTest(vcd, "Test_AddNewVMFromMultiVmTemplate") + vapp, err := deployVappForTest(vcd, "Test_AddNewVMFromMultiVmTemplate") check.Assert(err, IsNil) check.Assert(vapp, NotNil) task, err := vapp.AddNewVM(check.TestName(), *returnedVappTemplate, nil, true) @@ -1469,7 +1469,7 @@ func (vcd *TestVCD) Test_AddNewVMWithComputeCapacity(check *C) { vapptemplate, err := catitem.GetVAppTemplate() check.Assert(err, IsNil) - vapp, err := createVappForTest(vcd, "Test_AddNewVMWithComputeCapacity") + vapp, err := deployVappForTest(vcd, "Test_AddNewVMWithComputeCapacity") check.Assert(err, IsNil) check.Assert(vapp, NotNil) diff --git a/govcd/vm_dhcp_test.go b/govcd/vm_dhcp_test.go index 7d662a721..7e510fd45 100644 --- a/govcd/vm_dhcp_test.go +++ b/govcd/vm_dhcp_test.go @@ -29,7 +29,7 @@ func (vcd *TestVCD) Test_VMGetDhcpAddress(check *C) { } // Construct new VM for test - vapp, err := vcd.createTestVapp("GetDhcpAddress") + vapp, err := deployVappForTest(vcd, "GetDhcpAddress") check.Assert(err, IsNil) vmType, _ := vcd.findFirstVm(*vapp) vm := &VM{ diff --git a/govcd/vm_test.go b/govcd/vm_test.go index a685f2dac..cd120cf6e 100644 --- a/govcd/vm_test.go +++ b/govcd/vm_test.go @@ -1221,7 +1221,7 @@ func (vcd *TestVCD) Test_AddNewEmptyVMMultiNIC(check *C) { check.Skip("skipping test because no vApp is found") } - vapp, err := createVappForTest(vcd, "Test_AddNewEmptyVMMultiNIC") + vapp, err := deployVappForTest(vcd, "Test_AddNewEmptyVMMultiNIC") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1455,7 +1455,7 @@ func (vcd *TestVCD) Test_UpdateVmCpuAndMemoryHotAdd(check *C) { } func (vcd *TestVCD) Test_AddNewEmptyVMWithVmComputePolicyAndUpdate(check *C) { - vapp, err := createVappForTest(vcd, "Test_AddNewEmptyVMWithVmComputePolicy") + vapp, err := deployVappForTest(vcd, "Test_AddNewEmptyVMWithVmComputePolicy") check.Assert(err, IsNil) check.Assert(vapp, NotNil) @@ -1609,7 +1609,7 @@ func (vcd *TestVCD) Test_VMUpdateStorageProfile(check *C) { check.Skip("Skipping test because both storage profiles have to be configured") } - vapp, err := createVappForTest(vcd, "Test_VMUpdateStorageProfile") + vapp, err := deployVappForTest(vcd, "Test_VMUpdateStorageProfile") check.Assert(err, IsNil) check.Assert(vapp, NotNil) diff --git a/samples/openapi/main.go b/samples/openapi/main.go index b5e8b49e3..b1c8d560b 100644 --- a/samples/openapi/main.go +++ b/samples/openapi/main.go @@ -58,8 +58,8 @@ func main() { os.Exit(3) } - if vcdCli.Client.APIVCDMaxVersionIs("< 33.0") { - fmt.Println("This example requires VCD API to support at least version 33.0 (VCD 10.0) to use '1.0.0/auditTrail' endpoint") + if vcdCli.Client.APIVCDMaxVersionIs("< 35.0") { + fmt.Println("This example requires VCD API to support at least version 35.0 (VCD 10.2) to use '1.0.0/auditTrail' endpoint") os.Exit(4) } @@ -87,7 +87,7 @@ func openAPIGetRawJsonAuditTrail(vcdClient *govcd.VCDClient) { queryParams.Add("filter", "timestamp=gt="+filterTime) allResponses := []json.RawMessage{{}} - err = vcdClient.Client.OpenApiGetAllItems("33.0", urlRef, queryParams, &allResponses, nil) + err = vcdClient.Client.OpenApiGetAllItems("35.0", urlRef, queryParams, &allResponses, nil) if err != nil { panic(err) } @@ -145,7 +145,7 @@ func openAPIGetStructAuditTrail(vcdClient *govcd.VCDClient) { filterTime := time.Now().Add(-12 * time.Hour).Format(types.FiqlQueryTimestampFormat) queryParams.Add("filter", "timestamp=gt="+filterTime) - err = vcdClient.Client.OpenApiGetAllItems("33.0", urlRef, queryParams, &response, nil) + err = vcdClient.Client.OpenApiGetAllItems("35.0", urlRef, queryParams, &response, nil) if err != nil { panic(err) } diff --git a/test-resources/golden/TestSamlAdfsAuthenticate_RESP_api_versions.golden b/test-resources/golden/TestSamlAdfsAuthenticate_RESP_api_versions.golden index 2f6ecedbf..260db6a42 100644 --- a/test-resources/golden/TestSamlAdfsAuthenticate_RESP_api_versions.golden +++ b/test-resources/golden/TestSamlAdfsAuthenticate_RESP_api_versions.golden @@ -56,6 +56,14 @@ 33.0 https://192.168.1.109/api/sessions + + 34.0 + https://192.168.1.109/api/sessions + + + 35.0 + https://192.168.1.109/api/sessions + 5.5 https://192.168.1.109/api/sessions