-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Overview
Extend the vsphere-clone builder to support using local OVF and OVA files as clone sources, in addition to the current support for standard virtual machine templates. Local OVF/OVA support enables users to clone virtual machines directly from OVF/OVA files stored on the local file system where Packer is running.
Requirements
Requirement 1
User Story: As a user of the Packer plugin for vSphere, I want to clone virtual machines from local OVF files stored on my file system, so that I can use OVF templates directly.
Acceptance Criteria
- WHEN a user specifies a local OVF file path as the clone source THEN the system SHALL successfully read and clone from that OVF file.
- WHEN a local OVF source is specified THEN the system SHALL support both absolute and relative file paths.
- WHEN a local OVF file path uses relative paths THEN the system SHALL resolve them relative to the configuration file location.
- IF a local OVF file is not accessible or does not exist THEN the
Prepare()method SHALL return an error early with a clear message indicating the file path and access issue.
Requirement 2
User Story: As a user of the Packer plugin for vSphere, I want to clone virtual machines from local OVA files stored on my file system, so that I can use single-file OVA templates locally.
Acceptance Criteria
- WHEN a user specifies a local OVA file path as the clone source THEN the system SHALL successfully read and clone from that OVA file.
- WHEN a local OVA file is specified THEN the system SHALL handle the single-file OVA format appropriately.
- IF an OVA file is corrupted or invalid THEN the
Prepare()method SHALL return an error early with a clear message about file integrity issues.
Requirement 3
User Story: As a user of the Packer plugin for vSphere, I want the local OVF/OVA source configuration to be intuitive and consistent with other source specification patterns, so that I can easily configure local sources.
Acceptance Criteria
-
WHEN configuring a local OVF/OVA source THEN the user SHALL be able to specify it using a
local_sourcefield with a direct string path value.HCL Examples:
# Absolute path to OVF file source "vsphere-clone" "example" { local_source = "/home/user/templates/linux-ubuntu-24.04-lts.ovf" } # Relative path to OVA file (relative to config file) source "vsphere-clone" "example" { local_source = "./templates/linux-ubuntu-24.04-lts.ova" } # Using variables for file paths variable "template_path" { type = string } source "vsphere-clone" "example" { local_source = var.template_path } # Using environment variables in path source "vsphere-clone" "example" { local_source = "${env("TEMPLATE_DIR")}/linux-ubuntu-24.04-lts.ovf" } # Windows path example source "vsphere-clone" "example" { local_source = "C:\\Templates\\linux-ubuntu-24.04-lts.ova" } # Invalid: Cannot use multiple source types source "vsphere-clone" "example" { template = "linux-ubuntu-24.04-lts" local_source = "./templates/linux-ubuntu-24.04-lts.ovf" # ERROR }
-
WHEN both
templatefield andlocal_sourcefield are specified THEN thePrepare()method SHALL return an error message "cannot specify both 'template' and 'local_source' - choose one source type". -
WHEN multiple source types are specified THEN the
Prepare()method SHALL validate mutual exclusivity among all source types. -
WHEN designing the local source configuration THEN it SHALL use a simple string field for ease of use and consistency with similar Packer patterns.
Requirement 4
User Story: As a user of the Packer plugin for vSphere, I want flexible file path handling for local OVF/OVA sources, so that I can organize my templates in various directory structures and reference them easily.
Acceptance Criteria
- WHEN using absolute file paths THEN the system SHALL access files directly using the provided absolute path.
- WHEN using relative file paths THEN the system SHALL resolve them relative to the directory containing the configuration file.
- WHEN file paths contain environment variables THEN the system SHALL expand environment variables before accessing the file.
- WHEN file paths contain variables THEN the system SHALL interpolate variables before accessing the file.
- WHEN file paths contain special characters or spaces THEN the system SHALL handle them correctly across different operating systems.
- WHEN accessing files on different operating systems THEN the system SHALL handle path separators appropriately (forward slash on Unix-like systems, backslash on Windows).
Requirement 5
User Story: As a user of the Packer plugin for vSphere, I want comprehensive error handling and validation for local OVF/OVA operations, so that I can troubleshoot issues effectively when local files are not accessible or invalid.
Acceptance Criteria
- WHEN a local OVF/OVA file does not exist THEN the
Prepare()method SHALL return an error early with a clear message indicating the file path and that the file was not found. - WHEN a local OVF/OVA file exists but is not readable THEN the
Prepare()method SHALL return an error early with a clear message about file permissions or access issues. - WHEN a local OVF/OVA file is corrupted or has invalid format THEN the
Prepare()method SHALL perform basic validation and return an error early with specific messages about what validation checks failed. - WHEN local OVF/OVA operations succeed THEN the system SHALL log successful file reading and cloning progress with file size information.
- WHEN file path resolution fails THEN the
Prepare()method SHALL return an error early with clear messages about path resolution issues.
Requirement 6
User Story: As a user of the Packer plugin for vSphere, I want support for vApp properties and OVF-specific configurations when cloning from local OVF/OVA sources, so that I can fully utilize OVF template capabilities.
Acceptance Criteria
- WHEN a local OVF source defines vApp properties THEN the system SHALL support configuration of those properties through the existing vApp configuration block.
- WHEN an OVF file requires specific clone parameters THEN the system SHALL handle those parameters appropriately during cloning.
- WHEN OVF clone options are available THEN the system SHALL support configuration of clone options such as network mapping and storage policies.
- IF required OVF clone parameters are missing THEN the system SHALL provide clear error messages about which parameters are required.
Requirement 7
User Story: As a user of the Packer plugin for vSphere, I want backward compatibility with existing vsphere-clone configurations, so that the current template pattern continues to work without modification when local OVF/OVA support is added.
Acceptance Criteria
- WHEN existing configurations use the
templatefield with standard virtual machine templates THEN they SHALL continue to work without changes. - WHEN new local source fields are added THEN they SHALL not affect existing template-based configurations.
- WHEN the plugin loads existing configurations THEN no breaking changes SHALL be introduced to the configuration schema.
- WHEN documentation is updated THEN it SHALL clearly explain all available source types.
Requirement 8
User Story: As a user of the Packer plugin for vSphere, I want the local OVF/OVA cloning to use vSphere's native APIs without requiring external tools, so that I don't need to install and manage additional dependencies.
Acceptance Criteria
- WHEN cloning from local OVF/OVA files THEN the system SHALL use vSphere's native OVF deployment APIs through the
govmomilibrary. - WHEN the system processes OVF/OVA files THEN it SHALL NOT require any external tools (e.g., VMware OVFTool) to be installed.
- WHEN OVF cloning is performed THEN the system SHALL leverage the existing vSphere API client connection used by other
vsphere-cloneoperations. - IF vSphere's native OVF APIs cannot handle a specific OVF/OVA file THEN the system SHALL provide a clear error message about the incompatibility.
Requirement 9
User Story: As a user of the Packer plugin for vSphere, I want reliable handling of local OVA/OVF files during cloning, so that the process works consistently regardless of file size.
Acceptance Criteria
- WHEN local file operations are performed THEN the system SHALL validate basic file accessibility and format before attempting cloning to vSphere.
- WHEN OVF/OVA cloning is in progress THEN the system SHALL provide basic status logging consistent with other
vsphere-cloneoperations. - IF local file processing or cloning fails THEN the system SHALL provide clear error messages about the failure and cleanup any partial operations.