Repository: vmware/govmomi
Pull request #3358 (2024-02-08 19:00:04)

Add "AggregatedSnapshotCapacityInMb" to cnstype
## Description

Add "AggregatedSnapshotCapacityInMb" in  "CnsBlockBackingDetails" struct.

## Type of change

Please mark options that are relevant:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to
  not work as expected)
- [ ] This change requires a documentation update
- [ ] Build related change

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.

Run unit test, and can see this new field is available in the QueryVolume result.

 client_test.go:244: Successfully Queried Volumes. queryResult: &types.CnsQueryResult{
            Volumes: []types.CnsVolume{
                {
                    VolumeId: types.CnsVolumeId{
                        Id: "1aea2f18-d51c-4c67-a793-3c03d587100a",
                    },
                    DatastoreUrl:    "ds:///vmfs/volumes/65b980ec-15046ef0-c7e0-0200aec77050/",
                    Name:            "pvc-901e87eb-c2bd-11e9-806f-005056a0c9a0",
                    VolumeType:      "BLOCK",   
                    StoragePolicyId: "",
                    Metadata:        types.CnsVolumeMetadata{
                        ContainerCluster: types.CnsContainerCluster{
                            ClusterType:         "KUBERNETES",
                            ClusterId:           "demo-cluster-id",
                            VSphereUser:         "Administrator@vsphere.local",
                            ClusterFlavor:       "VANILLA",
                            ClusterDistribution: "OpenShift",
                        },
                        EntityMetadata:        nil,
                        ContainerClusterArray: []types.CnsContainerCluster{
                            {
                                ClusterType:         "KUBERNETES",
                                ClusterId:           "demo-cluster-id",
                                VSphereUser:         "Administrator@vsphere.local",
                                ClusterFlavor:       "VANILLA",
                                ClusterDistribution: "OpenShift",
                            },
                        },
                    },
                    BackingObjectDetails: &types.CnsBlockBackingDetails{
                        CnsBackingObjectDetails: types.CnsBackingObjectDetails{
                            CapacityInMb: 5120,
                        },
                        BackingDiskId:                  "1aea2f18-d51c-4c67-a793-3c03d587100a",
                        BackingDiskUrlPath:             "",
                        BackingDiskObjectId:            "",
                        AggregatedSnapshotCapacityInMb: 0,
                    },
                    ComplianceStatus:             "",
                    DatastoreAccessibilityStatus: "accessible",
                    HealthStatus:                 "green",
                },
            },


## Checklist:

- [ ] My code follows the `CONTRIBUTION` [guidelines] of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

[guidelines]: https://github.com/vmware/govmomi/blob/main/CONTRIBUTING.md



Patch:
diff --git a/.github/workflows/govmomi-go-lint.yaml b/.github/workflows/govmomi-go-lint.yaml
index 4935cef8..391e103a 100644
--- a/.github/workflows/govmomi-go-lint.yaml
+++ b/.github/workflows/govmomi-go-lint.yaml
@@ -80,7 +80,7 @@ jobs:
           echo "${TEMP_PATH}" >> "$GITHUB_PATH"
 
       - id: boilerplate_txt
-        uses: andstor/file-existence-action@v3
+        uses: andstor/file-existence-action@v2
         with:
           files: ./hack/boilerplate/boilerplate.${{ matrix.extension }}.txt
 
diff --git a/.github/workflows/govmomi-release.yaml b/.github/workflows/govmomi-release.yaml
index a6b6b056..764111ae 100644
--- a/.github/workflows/govmomi-release.yaml
+++ b/.github/workflows/govmomi-release.yaml
@@ -176,7 +176,7 @@ jobs:
 
       - name: Create Pull Request
         id: cpr
-        uses: peter-evans/create-pull-request@v6
+        uses: peter-evans/create-pull-request@v5
         with:
           commit-message: "Update CHANGELOG for ${{ inputs.tag }}"
           delete-branch: true
diff --git a/.github/workflows/issue-greeting.yaml b/.github/workflows/issue-greeting.yaml
index 0af54855..26dbd2ad 100644
--- a/.github/workflows/issue-greeting.yaml
+++ b/.github/workflows/issue-greeting.yaml
@@ -41,7 +41,7 @@ jobs:
             author: ${{ github.actor }}
 
       - name: Create comment
-        uses: peter-evans/create-or-update-comment@v4
+        uses: peter-evans/create-or-update-comment@v3
         with:
           issue-number: ${{ github.event.issue.number }}
           body: ${{ steps.template.outputs.result }}
diff --git a/cns/types/types.go b/cns/types/types.go
index b796f2a1..db184b0b 100644
--- a/cns/types/types.go
+++ b/cns/types/types.go
@@ -392,9 +392,10 @@ func init() {
 type CnsBlockBackingDetails struct {
 	CnsBackingObjectDetails
 
-	BackingDiskId       string `xml:"backingDiskId,omitempty"`
-	BackingDiskUrlPath  string `xml:"backingDiskUrlPath,omitempty"`
-	BackingDiskObjectId string `xml:"backingDiskObjectId,omitempty"`
+	BackingDiskId                  string `xml:"backingDiskId,omitempty"`
+	BackingDiskUrlPath             string `xml:"backingDiskUrlPath,omitempty"`
+	BackingDiskObjectId            string `xml:"backingDiskObjectId,omitempty"`
+	AggregatedSnapshotCapacityInMb int64  `xml:"aggregatedSnapshotCapacityInMb,omitempty"`
 }
 
 func init() {
diff --git a/go.mod b/go.mod
index 2d238981..9749e97b 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
 	github.com/a8m/tree v0.0.0-20210115125333-10a5fd5b637d
 	github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02
 	github.com/google/go-cmp v0.6.0
-	github.com/google/uuid v1.6.0
+	github.com/google/uuid v1.5.0
 	github.com/rasky/go-xdr v0.0.0-20170217172119-4930550ba2e2
 	github.com/stretchr/testify v1.8.4
 	github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728
diff --git a/go.sum b/go.sum
index cf2c8cfa..e9274a00 100644
--- a/go.sum
+++ b/go.sum
@@ -8,8 +8,8 @@ github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02 h1:tR3jsKPiO/mb6ntzk/
 github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02/go.mod h1:7NQ3kWOx2cZOSjtcveTa5nqupVr2s6/83sG+rTlI7uA=
 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
-github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
+github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
 github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
diff --git a/simulator/virtual_machine.go b/simulator/virtual_machine.go
index c619fa20..98af0865 100644
--- a/simulator/virtual_machine.go
+++ b/simulator/virtual_machine.go
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2017-2024 VMware, Inc. All Rights Reserved.
+Copyright (c) 2017-2023 VMware, Inc. All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -545,13 +545,7 @@ func validateGuestID(id string) types.BaseMethodFault {
 	return &types.InvalidArgument{InvalidProperty: "configSpec.guestId"}
 }
 
-func (vm *VirtualMachine) configure(ctx *Context, spec *types.VirtualMachineConfigSpec) (result types.BaseMethodFault) {
-	defer func() {
-		if result == nil {
-			vm.updateLastModifiedAndChangeVersion(ctx)
-		}
-	}()
-
+func (vm *VirtualMachine) configure(ctx *Context, spec *types.VirtualMachineConfigSpec) types.BaseMethodFault {
 	vm.apply(spec)
 
 	if spec.MemoryAllocation != nil {
@@ -2644,19 +2638,3 @@ func changeTrackingSupported(spec *types.VirtualMachineConfigSpec) bool {
 	}
 	return false
 }
-
-func (vm *VirtualMachine) updateLastModifiedAndChangeVersion(ctx *Context) {
-	modified := time.Now()
-	ctx.Map.Update(vm, []types.PropertyChange{
-		{
-			Name: "config.changeVersion",
-			Val:  fmt.Sprintf("%d", modified.UnixNano()),
-			Op:   types.PropertyChangeOpAssign,
-		},
-		{
-			Name: "config.modified",
-			Val:  modified,
-			Op:   types.PropertyChangeOpAssign,
-		},
-	})
-}
diff --git a/vim25/mo/retrieve.go b/vim25/mo/retrieve.go
index 96be376f..0ddf78eb 100644
--- a/vim25/mo/retrieve.go
+++ b/vim25/mo/retrieve.go
@@ -77,11 +77,7 @@ func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
 	for _, p := range changes {
 		rv, ok := t.props[p.Name]
 		if !ok {
-			// For now, skip unknown properties allowing PC updates to be triggered
-			// for partial updates (e.g. extensionList["my.extension"]).
-			// Ultimately we should support partial updates by assigning the value
-			// reflectively in assignValue.
-			continue
+			panic(p.Name + " not found")
 		}
 
 		assignValue(v, rv, reflect.ValueOf(p.Val))


Test patch:
diff --git a/simulator/virtual_machine_test.go b/simulator/virtual_machine_test.go
index 43b782d2..d6b86896 100644
--- a/simulator/virtual_machine_test.go
+++ b/simulator/virtual_machine_test.go
@@ -1,11 +1,11 @@
 /*
-Copyright (c) 2017-2024 VMware, Inc. All Rights Reserved.
+Copyright (c) 2017 VMware, Inc. All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0
+    http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
@@ -2183,56 +2183,3 @@ func TestApplyExtraConfig(t *testing.T) {
 		applyAndAssertExtraConfigValue(ctx, vm, "", true)
 	})
 }
-
-func TestLastModifiedAndChangeVersionAreUpdated(t *testing.T) {
-	Test(func(ctx context.Context, c *vim25.Client) {
-		vm := object.NewVirtualMachine(c, Map.Any("VirtualMachine").Reference())
-		var vmMo mo.VirtualMachine
-		if err := vm.Properties(
-			ctx,
-			vm.Reference(),
-			[]string{"config.modified", "config.changeVersion"},
-			&vmMo); err != nil {
-
-			t.Fatalf("failed to fetch initial vm props: %v", err)
-		}
-
-		oldModified := vmMo.Config.Modified
-		oldChangeVersion := vmMo.Config.ChangeVersion
-
-		tsk, err := vm.Reconfigure(ctx, types.VirtualMachineConfigSpec{
-			ExtraConfig: []types.BaseOptionValue{
-				&types.OptionValue{
-					Key:   "hello",
-					Value: "world",
-				},
-			},
-		})
-		if err != nil {
-			t.Fatalf("failed to call reconfigure api: %v", err)
-		}
-		if err := tsk.WaitEx(ctx); err != nil {
-			t.Fatalf("failed to reconfigure: %v", err)
-		}
-
-		if err := vm.Properties(
-			ctx,
-			vm.Reference(),
-			[]string{"config.modified", "config.changeVersion"},
-			&vmMo); err != nil {
-
-			t.Fatalf("failed to fetch vm props after reconfigure: %v", err)
-		}
-
-		newModified := vmMo.Config.Modified
-		newChangeVersion := vmMo.Config.ChangeVersion
-
-		if a, e := newModified, oldModified; a == e {
-			t.Errorf("config.modified was not updated: %v", a)
-		}
-
-		if a, e := newChangeVersion, oldChangeVersion; a == e {
-			t.Errorf("config.changeVersion was not updated: %v", a)
-		}
-	})
-}