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

govc: add -b flag to volume.ls #3662

Merged
merged 2 commits into from
Dec 24, 2024
Merged

govc: add -b flag to volume.ls #3662

merged 2 commits into from
Dec 24, 2024

Conversation

dougm
Copy link
Member

@dougm dougm commented Dec 24, 2024

cns: add json tags

PR #3007 added camelCase json tags for generated types
PR #3247 added camelCase json tags for govc commands

This change does the same for cns/types.

Testing of the -b flag has been done manually for now, as we still don't have a govc volume.create command.
A volume's backing file can already being seen using -json:

% govc volume.ls -json a24b36ff-c407-46ef-b068-a9620145a0cb | jq -r .volume[].backingObjectDetails.backingDiskPath
[sharedVmfs-0] fcd/861ed49f57e549c3a5ea25780c13fdf7.vmdk

With the -b flag, backing is included in the friendly output and also uses QueryVolumeInfo to verify the backing file exists, for example:

% govc volume.ls -b
0b9d71d2-2236-4d67-96e7-89a46292e430	pvc-c3b456c7-01d8-4576-b3eb-6c1b0833fcea	[sharedVmfs-0] fcd/f10e825975bb4b079cba05ca8da86116.vmdk
a24b36ff-c407-46ef-b068-a9620145a0cb	pvc-6584bf4c-fe95-4451-bb45-6d4a5b03b88a	Failed to retrieve the vstorage object for fcd id a24b36ff-c407-46ef-b068-a9620145a0cb
e777a2db-84b9-4a7b-a967-fde885b61592	pvc-01ba5707-6333-49e9-b8e3-abe3654ff2e6	[sharedVmfs-0] fcd/4a601cd0caef43a39fe886e2794dbab9.vmdk

The QueryVolumeInfo task result can also be output as Go code, example with fault:

// govc volume.ls -b -dump a24b36ff-c407-46ef-b068-a9620145a0cb
[]types.BaseCnsVolumeOperationResult{
    &types.CnsQueryVolumeInfoResult{
        CnsVolumeOperationResult: types.CnsVolumeOperationResult{
            VolumeId: types.CnsVolumeId{},
            Fault:    &types.LocalizedMethodFault{
                Fault: types.CnsFault{
                    BaseMethodFault: nil,
                    Reason:          "Failed to retrieve the vstorage object for fcd id a24b36ff-c407-46ef-b068-a9620145a0cb",
                },
                LocalizedMessage: "CnsFault error: Failed to retrieve the vstorage object for fcd id a24b36ff-c407-46ef-b068-a9620145a0cb",
            },
        },
        VolumeInfo: nil,
    },
}

Example when found:

// govc volume.ls -b -dump 0b9d71d2-2236-4d67-96e7-89a46292e430
[]types.BaseCnsVolumeOperationResult{
    &types.CnsQueryVolumeInfoResult{
        CnsVolumeOperationResult: types.CnsVolumeOperationResult{},
        VolumeInfo:               &types.CnsBlockVolumeInfo{
            CnsVolumeInfo:  types.CnsVolumeInfo{},
            VStorageObject: types.VStorageObject{
                Config: types.VStorageObjectConfigInfo{
                    BaseConfigInfo: types.BaseConfigInfo{
                        Id: types.ID{
                            Id: "0b9d71d2-2236-4d67-96e7-89a46292e430",
                        },
                        Name:                        "pvc-c3b456c7-01d8-4576-b3eb-6c1b0833fcea",
                        CreateTime:                  time.Now(),
                        KeepAfterDeleteVm:           types.NewBool(true),
                        RelocationDisabled:          types.NewBool(false),
                        NativeSnapshotSupported:     types.NewBool(false),
                        ChangedBlockTrackingEnabled: types.NewBool(false),
                        Backing:                     &types.BaseConfigInfoDiskFileBackingInfo{
                            BaseConfigInfoFileBackingInfo: types.BaseConfigInfoFileBackingInfo{
                                BaseConfigInfoBackingInfo: types.BaseConfigInfoBackingInfo{
                                    Datastore: types.ManagedObjectReference{Type:"Datastore", Value:"datastore-42", ServerGUID:""},
                                },
                                FilePath:        "[sharedVmfs-0] fcd/f10e825975bb4b079cba05ca8da86116.vmdk",
                                BackingObjectId: "",
                                Parent:          nil,
                                DeltaSizeInMB:   0,
                                KeyId:           (*types.CryptoKeyId)(nil),
                            },
                            ProvisioningType: "thin",
                        },
                        Metadata: nil,
                        Vclock:   (*types.VslmVClockInfo)(nil),
                        Iofilter: nil,
                    },
                    DescriptorVersion: 5,
                    CapacityInMB:      100,
                    ConsumptionType:   []string{"disk"},
                    ConsumerId:        []types.ID{
                        {
                            Id: "6bf965f5-0348-4687-beca-8c89a0624168",
                        },
                    },
                },
            },
        },
    },
}

PR vmware#3007 added camelCase json tags for generated types
PR vmware#3247 added camelCase json tags for govc commands

This change does the same for cns/types.

Signed-off-by: Doug MacEachern <[email protected]>
Signed-off-by: Doug MacEachern <[email protected]>
@dougm dougm merged commit eff7c95 into vmware:main Dec 24, 2024
11 checks passed
@dougm dougm deleted the volume-backing branch December 24, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants