Skip to content

ovf: Support non-file backed disks, deployment configs, and vApp property qualifiers#3971

Open
akutz wants to merge 8 commits intovmware:mainfrom
akutz:feature/indicate-file-backed-disk-from-ovf
Open

ovf: Support non-file backed disks, deployment configs, and vApp property qualifiers#3971
akutz wants to merge 8 commits intovmware:mainfrom
akutz:feature/indicate-file-backed-disk-from-ovf

Conversation

@akutz
Copy link
Member

@akutz akutz commented Feb 27, 2026

Description

This PR extends the ovf package’s OVF→ConfigSpec behavior in three areas: file-backed vs empty disks, OVF property types/qualifiers per DSP0243, and explicit deployment configuration selection.

1. File-backed disks in OVF→ConfigSpec

  • Behavior: Treat OVF disks that have ovf:fileRef as file-backed and all others as capacity-only (empty) in the generated ConfigSpec.
  • Implementation:
    • Build a fileRefs map from Envelope.References and pass it through toHardware into toVirtualDisk.
    • For disks with a DiskSection fileRef, set backing FileName from path.Base(File.Href); empty disks keep an empty backing name.
    • Set FileOperation to Create for empty disks and to empty string for file-backed disks (existing file).
  • Tests/fixtures: fixtures/mixed-disks.ovf (one file-backed, one empty), plus tests for backing FileName, FileOperation, and file-backed disk name from path.Base(File.Href).

2. Parse OVF property qualifiers per DSP0243

  • OVF→vApp type mapping (DSP0243 Table 6): Map uint8/sint8/…/sint64int, Stringstring, Booleanboolean, real32/real64real. Honor ovf:password so string becomes password.
  • Qualifiers (DSP0243 9.5.1 Table 7): Parse ovf:qualifiers: MinLen, MaxLen, ValueMap for string; ValueMap for integer types.
  • VAppPropertyInfo.Type: Build from base type and qualifiers (e.g. MinLen(1),MaxLen(65535)string(1..65535), ValueMap → string["a","b"] or int(min..max)).
  • Usage: Use the computed type in toVAppConfig for property Info.Type and in parseVAppConfigValue so qualifier-derived constraints are applied.
  • Tests: Qualifier-derived types and root_pwd Type "password" when ovf:password="true".

3. Explicit deployment configuration

  • API: Add DeploymentConfiguration to ToConfigSpecOptions to select which deployment option (DeploymentOptionSection) to use; if empty, use the default or the first configuration.
  • Resolution: New resolveDeploymentConfiguration() resolves by name and validates against the envelope’s DeploymentOptionSection.
  • Behavior: Only elements (e.g. VirtualHardware Item, ProductSection Property) that match the selected configuration or have no configuration are included.
  • Tests/fixtures: Deployment config selection (including invalid name), OVF property types → vAppPropertyInfo.Type, and file-ref path in disk backing. Fixtures: deployment-configs.ovf, property-types.ovf, file-ref-path.ovf.

Closes: #(issue-number) NA

How Has This Been Tested?

go test -v ./ovf

Guidelines

Please read and follow the CONTRIBUTION guidelines of this project.

@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch 2 times, most recently from 6d109f8 to ab1a238 Compare March 5, 2026 17:52
akutz added 2 commits March 5, 2026 13:52
Distinguish OVF disks that are backed by a file (ovf:fileRef) from
capacity-only (empty) disks in the generated ConfigSpec.

Implementation (configspec.go):
- Build a fileRefs map from Envelope.References and pass it through
  toHardware into toVirtualDisk.
- For disks with a DiskSection fileRef, set backing FileName from
  path.Base(File.Href) so file-backed disks get a non-empty name;
  empty disks keep an empty backing name.
- Build DeviceChange explicitly: for VirtualDisks, set FileOperation
  to Create for empty disks and to empty string for file-backed disks
  (existing file).

Tests and fixtures:
- Add fixtures/mixed-disks.ovf (one file-backed disk, one empty) and
  test "Mixed file-backed and empty disks" for backing FileName and
  FileOperation.
- Add test "File-backed disk name from path.Base(File.Href)" using
  fixtures/file-ref-path.ovf.
- In "Large" test, assert file-backed disk has non-empty FileName and
  empty disk has empty FileName.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
- Add OVF-to-vApp type mapping
  (DSP0243 Table 6 → vim.vApp.PropertyInfo):
  uint8/sint8/.../sint64 → int, String → string, Boolean → boolean,
  real32/real64 → real. Honor ovf:password for string → password.
- Parse ovf:qualifiers per DSP0243 9.5.1 Table 7: MinLen, MaxLen,
  ValueMap for string; ValueMap for integer types.
- Build VAppPropertyInfo.Type from base type and qualifiers (e.g.
  MinLen(1),MaxLen(65535) → string(1..65535), ValueMap → string["a","b"]
  or int(min..max)).
- Use computed type in toVAppConfig for both the property Info.Type and
  for parseVAppConfigValue so qualifier-derived constraints are applied.
- Add tests for qualifier-derived types and expect root_pwd Type
  "password" when ovf:password="true".

Signed-off-by: akutz <andrew.kutz@broadcom.com>
@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from ab1a238 to 6cab4c9 Compare March 5, 2026 22:20
@akutz akutz changed the title Mark non-empty disks from OVF ovf: Support non-file backed disks, deployment configs, and vApp property qualifiers Mar 5, 2026
@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from 6cab4c9 to 2e797ce Compare March 5, 2026 22:27
Copy link
Contributor

@lubronzhan lubronzhan left a comment

Choose a reason for hiding this comment

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

LGTM

@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from 2e797ce to e13f3be Compare March 6, 2026 16:54
Add DeploymentConfiguration to ToConfigSpecOptions to select which
deployment option (DeploymentOptionSection) to use; default or first
if empty. Resolve by name with resolveDeploymentConfiguration().

Add tests for deployment config selection, OVF property types to
vAppPropertyInfo.Type, and file-ref path in disk backing.

Add fixtures: deployment-configs.ovf, property-types.ovf,
file-ref-path.ovf.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from e13f3be to 9d8ceb0 Compare March 6, 2026 16:56
akutz added 4 commits March 6, 2026 11:37
This patch fixes the vAppPropertyInfo types for strings with min/max
qualifiers.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
This patch adds support for specifying OVF disk capacity via an OVF
property as well as handles possible invalid property key names.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
This patch supports OVF product categories.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
This patch adds OVF testing based on an uber OVF.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from a6f8527 to aa91758 Compare March 6, 2026 17:37
This patch adds support for vSphere-specific OVF property qualifiers.

Signed-off-by: akutz <andrew.kutz@broadcom.com>
@akutz akutz force-pushed the feature/indicate-file-backed-disk-from-ovf branch from 711396e to 76edb74 Compare March 6, 2026 18:20
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