vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.32k stars 913 forks source link

[WIP]Add new "UsedCapacityInMb" in struct "CnsBlockBackingDetails" #3345

Closed lipingxue closed 9 months ago

lipingxue commented 10 months ago

Description

This change add new field "UsedCapacityInMb" in struct "CnsBlockBackingDetails". This field is s the rolled up used capacity of the FCD and its snapshots. Closes: #(issue-number)

Type of change

Please mark options that are relevant:

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.

unit test passed and in the QueryVolume API output. Field "UsedCapacityInMb" exists in struct "CnsBlockBackingDetails".

bash-3.2$ pwd                       
/Users/lipingx/go/src/github.com/lipingxue/govmomi/cns
bash-3.2$ go test -v      
...

client_test.go:244: Successfully Queried Volumes. queryResult: &types.CnsQueryResult{
            Volumes: []types.CnsVolume{
                {
                    VolumeId: types.CnsVolumeId{
                        Id: "2c4d86f3-3f6c-406f-8a5b-45e9ba37dcca",
                    },
                    DatastoreUrl:    "ds:///vmfs/volumes/vsan:52680136b8cf925d-47750bb646138963/",
                    Name:            "pvc-901e87eb-c2bd-11e9-806f-005056a0c9a0",
                    VolumeType:      "BLOCK",
                    StoragePolicyId: "aa6d5a82-1c88-45da-85d3-3d74b91a5bad",
                    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:       "2c4d86f3-3f6c-406f-8a5b-45e9ba37dcca",
                        BackingDiskUrlPath:  "",
                        BackingDiskObjectId: "46a2b165-b28f-220a-a17d-02007609a56a",
                        UsedCapacityInMb:    -1,
                    },
                    ComplianceStatus:             "compliant",
                    DatastoreAccessibilityStatus: "accessible",
                    HealthStatus:                 "green",
                },
            },

Checklist:

divyenpatel commented 10 months ago

@lipingxue in your testing result why UsedCapacityInMb is -1?

UsedCapacityInMb:    -1,
lipingxue commented 9 months ago

@lipingxue in your testing result why UsedCapacityInMb is -1?

UsedCapacityInMb:    -1,

"-1" means CNS cannot determine the value of this field. See the following from VMODL definition. I have confirmed with Yang that this field is not always set.

  This is the rolled up allocated space of the FCD's snapshots.
 Set to -1 if unknown.
lipingxue commented 9 months ago

Per offline discussion, Field "UsedCapacityInMb" should not be used by CNS and should not added to cns type. Close this MR.

lipingxue commented 9 months ago

/close