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

api: GetVirtualDiskInfoByUUID for getting capacity/size info #3482

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

akutz
Copy link
Member

@akutz akutz commented Jul 3, 2024

Description

This patch introduces the helper function GetVirtualDiskInfoByUUID for getting the capacity and size information for a virtual disk with a provided UUID.

Closes: NA

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • 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?

  • Ran go test which produces almost 100% code coverage (working with @dougm to figure out how to spoof the error in the property collector) (thanks @dougm!):

    $ go test -v -count 1 -run 'TestGetVirtualDiskInfoByUUID' ./vmdk
    === RUN   TestGetVirtualDiskInfoByUUID
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/diskUUID_is_empty
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/no_matching_disks
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskFlatVer2BackingInfo
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskSeSparseBackingInfo
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskRawDiskMappingVer1BackingInfo
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskSparseVer2BackingInfo
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskRawDiskVer2BackingInfo
    === RUN   TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_multiple_chain_entries
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties/ctx_is_nil
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties/client_is_nil
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties/failed_to_retrieve_properties
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties/fetchProperties_is_false_but_cached_properties_are_missing
    === RUN   TestGetVirtualDiskInfoByUUID/fetch_properties/fetchProperties_is_true_and_cached_properties_are_stale
    --- PASS: TestGetVirtualDiskInfoByUUID (0.41s)
        --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/diskUUID_is_empty (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/no_matching_disks (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskFlatVer2BackingInfo (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskSeSparseBackingInfo (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskRawDiskMappingVer1BackingInfo (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskSparseVer2BackingInfo (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_VirtualDiskRawDiskVer2BackingInfo (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/w_cached_properties/one_disk_w_multiple_chain_entries (0.00s)
        --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties (0.41s)
            --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties/ctx_is_nil (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties/client_is_nil (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties/failed_to_retrieve_properties (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties/fetchProperties_is_false_but_cached_properties_are_missing (0.00s)
            --- PASS: TestGetVirtualDiskInfoByUUID/fetch_properties/fetchProperties_is_true_and_cached_properties_are_stale (0.00s)
    PASS
    ok  	github.com/vmware/govmomi/vmdk	0.713s
image image image

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

This patch introduces the helper function GetVirtualDiskInfoByUUID for
getting the capacity and size information for a virtual disk with a
provided UUID.
@akutz akutz force-pushed the feature/disk-info branch from 9edd0e5 to 2d16e19 Compare July 3, 2024 19:59
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @akutz

@akutz akutz merged commit 39d3e4d into vmware:main Jul 5, 2024
11 checks passed
@akutz akutz deleted the feature/disk-info branch July 5, 2024 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants