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

Bump API version to v37.0 #609

Merged
merged 8 commits into from
Aug 22, 2023
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
3 changes: 3 additions & 0 deletions .changes/v2.22.0/609-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Bumped up minimal API version to 37.0 (drops support for VCD 10.3.x) [GH-609]
* Add struct `IopsResource` to `types.DiskSettings` (in replacement of dropped field `iops`) initially supported in API 37.0 [GH-609]
* Add field `SslEnabled` to struct `types.NsxtAlbPool` initially supported in API 37.0 [GH-609]
1 change: 1 addition & 0 deletions .changes/v2.22.0/609-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Changed `Test_AddNewVMFromMultiVmTemplate` to use preloaded vApp template [GH-609]
1 change: 1 addition & 0 deletions .changes/v2.22.0/609-removals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Removed field `iops` from `types.DiskSettings` (dropped in API version 37.0) [GH-609]
2 changes: 1 addition & 1 deletion govcd/api_vcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (vcdClient *VCDClient) vcdCloudApiAuthorize(user, pass, org string) (*http.
// NewVCDClient initializes VMware VMware Cloud 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 := "36.0" // supported by 10.3+
minVcdApiVersion := "37.0" // supported by 10.4+
userDefinedApiVersion := os.Getenv("GOVCD_API_VERSION")
if userDefinedApiVersion != "" {
_, err := semver.NewVersion(userDefinedApiVersion)
Expand Down
2 changes: 2 additions & 0 deletions govcd/nsxt_alb_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func testPoolWithCertNoPrivateKey(check *C, vcd *TestVCD, edgeGatewayId string,
CommonNameCheckEnabled: addrOf(true),
DomainNames: []string{"one", "two", "three"},
DefaultPort: addrOf(1211),
SslEnabled: addrOf(true),
}

testAlbPoolConfig(check, vcd, "CertificateWithNoPrivateKey", poolConfigWithCert, nil, client)
Expand Down Expand Up @@ -174,6 +175,7 @@ func testPoolWithCertAndPrivateKey(check *C, vcd *TestVCD, edgeGatewayId string,
Algorithm: "FASTEST_RESPONSE",
CaCertificateRefs: []types.OpenApiReference{types.OpenApiReference{ID: createdCertificate.CertificateLibrary.Id}},
DefaultPort: addrOf(1211),
SslEnabled: addrOf(true),
}

testAlbPoolConfig(check, vcd, "CertificateWithPrivateKey", poolConfigWithCertAndKey, nil, client)
Expand Down
24 changes: 14 additions & 10 deletions govcd/vapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,25 +1518,27 @@ func (vcd *TestVCD) Test_AddNewVMFromMultiVmTemplate(check *C) {
}

// Populate Catalog
catalog, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
catalog, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.NsxtBackedCatalogName, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)

uploadedItem := false
itemName := vcd.config.VCD.Catalog.CatalogItemWithMultiVms
if itemName == "" {
check.Log("Using `OvaMultiVmPath` for test. Will upload to use it.")
check.Logf("Using `OvaMultiVmPath` '%s' for test. Will upload to use it.", vcd.config.OVA.OvaMultiVmPath)
itemName = check.TestName()
uploadTask, err := catalog.UploadOvf(vcd.config.OVA.OvaMultiVmPath, itemName, "upload from test", 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, check.TestName())
uploadedItem = true
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.NsxtBackedCatalogName, check.TestName())
} else {
check.Log("Using `CatalogItemWithMultiVms` for test")
check.Logf("Using pre-loaded `CatalogItemWithMultiVms` '%s' for test", itemName)
}

vmInTemplateRecord, err := vcd.vdc.QueryVappSynchronizedVmTemplate(vcd.config.VCD.Catalog.Name, itemName, vcd.config.VCD.Catalog.VmNameInMultiVmItem)
vmInTemplateRecord, err := vcd.nsxtVdc.QueryVappSynchronizedVmTemplate(vcd.config.VCD.Catalog.NsxtBackedCatalogName, itemName, vcd.config.VCD.Catalog.VmNameInMultiVmItem)
check.Assert(err, IsNil)

// Get VAppTemplate
Expand Down Expand Up @@ -1566,12 +1568,14 @@ func (vcd *TestVCD) Test_AddNewVMFromMultiVmTemplate(check *C) {
check.Assert(err, IsNil)
check.Assert(task.Task.Status, Equals, "success")

// Remove catalog item so far other tests don't fail
catalogItem, err := catalog.GetCatalogItemByName(itemName, true)
check.Assert(err, IsNil)
// Remove uploaded catalog item
if uploadedItem {
catalogItem, err := catalog.GetCatalogItemByName(itemName, true)
check.Assert(err, IsNil)

err = catalogItem.Delete()
check.Assert(err, IsNil)
err = catalogItem.Delete()
check.Assert(err, IsNil)
}
}

// Test_AddNewVMWithComputeCapacity creates a new VM in vApp with VM using compute capacity
Expand Down
4 changes: 2 additions & 2 deletions govcd/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,8 @@ func (vm *VM) validateInternalDiskInput(diskData *types.DiskSettings, vmName, vm
return fmt.Errorf("[VM %s Id %s] disk settings size MB has to be 0 or higher", vmName, vmId)
}

if diskData.Iops != nil && *diskData.Iops < int64(0) {
return fmt.Errorf("[VM %s Id %s] disk settings iops has to be 0 or higher", vmName, vmId)
if diskData.IopsAllocation != nil && diskData.IopsAllocation.Reservation < int64(0) {
return fmt.Errorf("[VM %s Id %s] disk settings iops reservation has to be 0 or higher", vmName, vmId)
}

if diskData.ThinProvisioned == nil {
Expand Down
23 changes: 16 additions & 7 deletions govcd/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,9 @@ func (vcd *TestVCD) Test_AddInternalDisk(check *C) {
check.Assert(disk.StorageProfile.ID, Equals, storageProfile.ID)
check.Assert(disk.AdapterType, Equals, diskSettings.AdapterType)
check.Assert(*disk.ThinProvisioned, Equals, *diskSettings.ThinProvisioned)
check.Assert(*disk.Iops, Equals, *diskSettings.Iops)
check.Assert(disk.IopsAllocation, NotNil)
check.Assert(diskSettings.IopsAllocation, NotNil)
check.Assert(disk.IopsAllocation.Reservation, Equals, diskSettings.IopsAllocation.Reservation)
check.Assert(disk.SizeMb, Equals, diskSettings.SizeMb)
check.Assert(disk.UnitNumber, Equals, diskSettings.UnitNumber)
check.Assert(disk.BusNumber, Equals, diskSettings.BusNumber)
Expand Down Expand Up @@ -1038,7 +1040,6 @@ func (vcd *TestVCD) createInternalDisk(check *C, vmName string, busNumber int) (
storageProfile, err := vcd.vdc.FindStorageProfileReference(vcd.config.VCD.StorageProfile.SP1)
check.Assert(err, IsNil)
isThinProvisioned := true
iops := int64(0)
diskSettings := &types.DiskSettings{
SizeMb: 1024,
UnitNumber: 0,
Expand All @@ -1047,7 +1048,12 @@ func (vcd *TestVCD) createInternalDisk(check *C, vmName string, busNumber int) (
ThinProvisioned: &isThinProvisioned,
StorageProfile: &storageProfile,
OverrideVmDefault: true,
Iops: &iops,
IopsAllocation: &types.IopsResource{
Limit: 0,
Reservation: 0,
SharesLevel: "NORMAL",
Shares: 1000,
},
}

diskId, err := vm.AddInternalDisk(diskSettings)
Expand Down Expand Up @@ -1146,9 +1152,9 @@ func (vcd *TestVCD) Test_UpdateInternalDisk(check *C) {
// increase new disk size
vmSpecSection := vm.VM.VmSpecSection
changeDiskSettings := vm.VM.VmSpecSection.DiskSection.DiskSettings
for _, diskSettings := range changeDiskSettings {
if diskSettings.DiskId == diskId {
diskSettings.SizeMb = 2048
for _, ds := range changeDiskSettings {
if ds.DiskId == diskId {
ds.SizeMb = 2048
}
}

Expand All @@ -1167,7 +1173,10 @@ func (vcd *TestVCD) Test_UpdateInternalDisk(check *C) {
check.Assert(disk.StorageProfile.ID, Equals, storageProfile.ID)
check.Assert(disk.AdapterType, Equals, diskSettings.AdapterType)
check.Assert(*disk.ThinProvisioned, Equals, *diskSettings.ThinProvisioned)
check.Assert(*disk.Iops, Equals, *diskSettings.Iops)
check.Assert(disk.IopsAllocation, NotNil)
check.Assert(diskSettings.IopsAllocation, NotNil)
check.Assert(disk.IopsAllocation.Shares, Equals, diskSettings.IopsAllocation.Shares)
check.Assert(disk.IopsAllocation.Reservation, Equals, diskSettings.IopsAllocation.Reservation)
check.Assert(disk.SizeMb, Equals, int64(2048))
check.Assert(disk.UnitNumber, Equals, diskSettings.UnitNumber)
check.Assert(disk.BusNumber, Equals, diskSettings.BusNumber)
Expand Down
Loading