Skip to content

Commit

Permalink
refactor: update esx5 to esxi
Browse files Browse the repository at this point in the history
Updates references to "ESX5" to "ESXi".

Sets `remote_type` of `esxi` as preferred and `esx5` as deprecated.

Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
  • Loading branch information
tenthirtyam committed Aug 9, 2024
1 parent 3059905 commit f38fa0a
Show file tree
Hide file tree
Showing 24 changed files with 365 additions and 332 deletions.
74 changes: 41 additions & 33 deletions .web-docs/components/builder/iso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ JSON Example:
the guest operating system. Allowed values are `darwin` (macOS), `linux`,
and `windows`. Default is empty and no version will be uploaded.

- `tools_upload_path` (string) - The path in the virtual machine to upload the VMware Tools. This only
takes effect if `tools_upload_flavor` is non-empty. This is a
[configuration template](/packer/docs/templates/legacy_json_templates/engine)
that has a single valid variable, `Flavor`, which will be the value of
`tools_upload_flavor` when the upload path is set to `{{.Flavor}}.iso`.
- `tools_upload_path` (string) - The path in the VM to upload the VMware tools. This only takes effect if
`tools_upload_flavor` is non-empty. This is a [configuration
template](/packer/docs/templates/legacy_json_templates/engine) that has a
single valid variable: `Flavor`, which will be the value of
`tools_upload_flavor`. By default the upload path is set to
`{{.Flavor}}.iso`.

~> **Note:** This setting is not used when `remote_type` is `esx5`.
~> **Note:** This setting is not used when `remote_type` is `esxi` or `esx5`.

- `tools_source_path` (string) - The local path on your machine to the VMware Tools ISO file.

Expand Down Expand Up @@ -723,44 +724,51 @@ wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg

<!-- Code generated from the comments of the DriverConfig struct in builder/vmware/common/driver_config.go; DO NOT EDIT MANUALLY -->

- `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is
/Applications/VMware Fusion.app but this setting allows you to
customize this.
- `fusion_app_path` (string) - The installation path of the VMware Fusion application. Defaults to
`/Applications/VMware Fusion.app`

~> **Note:** This is only required if you are using VMware Fusion as a
local desktop hypervisor and have installed it in a non-default location.

- `remote_type` (string) - The type of remote machine that will be used to
build this VM rather than a local desktop product. The only value accepted
for this currently is esx5. If this is not set, a desktop product will
be used. By default, this is not set.
- `remote_type` (string) - The type of remote hypervisor that will be used. If set, the remote
hypervisor will be used for the build. If not set, a local desktop
hypervisor (VMware Fusion or VMware Workstation) will be used.
Available options include `esxi` and `esx5` for VMware ESXi.

~> **Note:** Use of `esxi` is recommended; `esx5` is deprecated.

- `remote_datastore` (string) - The path to the datastore where the VM will be stored
on the ESXi machine.
- `remote_datastore` (string) - The datastore on the remote hypervisor where the virtual machine will be
stored.

- `remote_cache_datastore` (string) - The path to the datastore where supporting files
will be stored during the build on the remote machine.
- `remote_cache_datastore` (string) - The datastore attached to the remote hypervisor to use for the build.
Supporting files such as ISOs and floppies are cached in this datastore
during the build. Defaults to `datastore1`.

- `remote_cache_directory` (string) - The path where the ISO and/or floppy files will
be stored during the build on the remote machine. The path is relative to
the remote_cache_datastore on the remote machine.
- `remote_cache_directory` (string) - The directory path on the remote cache datastore to use for the build.
Supporting files such as ISOs and floppies are cached in this directory,
relative to the `remote_cache_datastore`, during the build. Defaults to
`packer_cache`.

- `cleanup_remote_cache` (bool) - When set to true, Packer will cleanup the cache folder where the ISO file is stored during the build on the remote machine.
By default, this is set to false.
- `cleanup_remote_cache` (bool) - Remove items added to the remote cache after the build is complete.
Defaults to `false`.

- `remote_host` (string) - The host of the remote machine used for access.
This is only required if remote_type is enabled.
- `remote_host` (string) - The fully qualified domain name or IP address of the remote hypervisor
where the virtual machine is created.

~> **Note:** Required if `remote_type` is set.

- `remote_port` (int) - The SSH port of the remote machine
- `remote_port` (int) - The SSH port of the remote hypervisor. Defaults to `22`.

- `remote_username` (string) - The SSH username used to access the remote machine.
- `remote_username` (string) - The SSH username for access to the remote hypervisor. Defaults to `root`.

- `remote_password` (string) - The SSH password for access to the remote machine.
- `remote_password` (string) - The SSH password for access to the remote hypervisor.

- `remote_private_key_file` (string) - The SSH key for access to the remote machine.
- `remote_private_key_file` (string) - The SSH key for access to the remote hypervisor.

- `skip_validate_credentials` (bool) - When Packer is preparing to run a
remote hypervisor build, and export is not disable, by default it runs a no-op
ovftool command to make sure that the remote_username and remote_password
given are valid. If you set this flag to true, Packer will skip this
validation. Default: false.
- `skip_validate_credentials` (bool) - Skip the validation of the credentials for access to the remote
hypervisor. By default, export is enabled and the plugin will validate
the credentials ('remote_username' and 'remote_password'), for use by
VMware OVF Tool, before starting the build. Defaults to `false`.

<!-- End of code generated from the comments of the DriverConfig struct in builder/vmware/common/driver_config.go; -->

Expand Down
74 changes: 41 additions & 33 deletions .web-docs/components/builder/vmx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ JSON Example:
the guest operating system. Allowed values are `darwin` (macOS), `linux`,
and `windows`. Default is empty and no version will be uploaded.

- `tools_upload_path` (string) - The path in the virtual machine to upload the VMware Tools. This only
takes effect if `tools_upload_flavor` is non-empty. This is a
[configuration template](/packer/docs/templates/legacy_json_templates/engine)
that has a single valid variable, `Flavor`, which will be the value of
`tools_upload_flavor` when the upload path is set to `{{.Flavor}}.iso`.
- `tools_upload_path` (string) - The path in the VM to upload the VMware tools. This only takes effect if
`tools_upload_flavor` is non-empty. This is a [configuration
template](/packer/docs/templates/legacy_json_templates/engine) that has a
single valid variable: `Flavor`, which will be the value of
`tools_upload_flavor`. By default the upload path is set to
`{{.Flavor}}.iso`.

~> **Note:** This setting is not used when `remote_type` is `esx5`.
~> **Note:** This setting is not used when `remote_type` is `esxi` or `esx5`.

- `tools_source_path` (string) - The local path on your machine to the VMware Tools ISO file.

Expand Down Expand Up @@ -495,44 +496,51 @@ wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg

<!-- Code generated from the comments of the DriverConfig struct in builder/vmware/common/driver_config.go; DO NOT EDIT MANUALLY -->

- `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is
/Applications/VMware Fusion.app but this setting allows you to
customize this.
- `fusion_app_path` (string) - The installation path of the VMware Fusion application. Defaults to
`/Applications/VMware Fusion.app`

~> **Note:** This is only required if you are using VMware Fusion as a
local desktop hypervisor and have installed it in a non-default location.

- `remote_type` (string) - The type of remote machine that will be used to
build this VM rather than a local desktop product. The only value accepted
for this currently is esx5. If this is not set, a desktop product will
be used. By default, this is not set.
- `remote_type` (string) - The type of remote hypervisor that will be used. If set, the remote
hypervisor will be used for the build. If not set, a local desktop
hypervisor (VMware Fusion or VMware Workstation) will be used.
Available options include `esxi` and `esx5` for VMware ESXi.

~> **Note:** Use of `esxi` is recommended; `esx5` is deprecated.

- `remote_datastore` (string) - The path to the datastore where the VM will be stored
on the ESXi machine.
- `remote_datastore` (string) - The datastore on the remote hypervisor where the virtual machine will be
stored.

- `remote_cache_datastore` (string) - The path to the datastore where supporting files
will be stored during the build on the remote machine.
- `remote_cache_datastore` (string) - The datastore attached to the remote hypervisor to use for the build.
Supporting files such as ISOs and floppies are cached in this datastore
during the build. Defaults to `datastore1`.

- `remote_cache_directory` (string) - The path where the ISO and/or floppy files will
be stored during the build on the remote machine. The path is relative to
the remote_cache_datastore on the remote machine.
- `remote_cache_directory` (string) - The directory path on the remote cache datastore to use for the build.
Supporting files such as ISOs and floppies are cached in this directory,
relative to the `remote_cache_datastore`, during the build. Defaults to
`packer_cache`.

- `cleanup_remote_cache` (bool) - When set to true, Packer will cleanup the cache folder where the ISO file is stored during the build on the remote machine.
By default, this is set to false.
- `cleanup_remote_cache` (bool) - Remove items added to the remote cache after the build is complete.
Defaults to `false`.

- `remote_host` (string) - The host of the remote machine used for access.
This is only required if remote_type is enabled.
- `remote_host` (string) - The fully qualified domain name or IP address of the remote hypervisor
where the virtual machine is created.

~> **Note:** Required if `remote_type` is set.

- `remote_port` (int) - The SSH port of the remote machine
- `remote_port` (int) - The SSH port of the remote hypervisor. Defaults to `22`.

- `remote_username` (string) - The SSH username used to access the remote machine.
- `remote_username` (string) - The SSH username for access to the remote hypervisor. Defaults to `root`.

- `remote_password` (string) - The SSH password for access to the remote machine.
- `remote_password` (string) - The SSH password for access to the remote hypervisor.

- `remote_private_key_file` (string) - The SSH key for access to the remote machine.
- `remote_private_key_file` (string) - The SSH key for access to the remote hypervisor.

- `skip_validate_credentials` (bool) - When Packer is preparing to run a
remote hypervisor build, and export is not disable, by default it runs a no-op
ovftool command to make sure that the remote_username and remote_password
given are valid. If you set this flag to true, Packer will skip this
validation. Default: false.
- `skip_validate_credentials` (bool) - Skip the validation of the credentials for access to the remote
hypervisor. By default, export is enabled and the plugin will validate
the credentials ('remote_username' and 'remote_password'), for use by
VMware OVF Tool, before starting the build. Defaults to `false`.

<!-- End of code generated from the comments of the DriverConfig struct in builder/vmware/common/driver_config.go; -->

Expand Down
4 changes: 2 additions & 2 deletions builder/vmware/common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func NewDriver(dconfig *DriverConfig, config *SSHConfig, vmName string) (Driver,
var drivers []Driver

if dconfig.RemoteType != "" {
esx5Driver, err := NewESX5Driver(dconfig, config, vmName)
esxiDriver, err := NewEsxiDriver(dconfig, config, vmName)
if err != nil {
return nil, err
}
drivers = []Driver{esx5Driver}
drivers = []Driver{esxiDriver}

} else {
switch runtime.GOOS {
Expand Down
70 changes: 38 additions & 32 deletions builder/vmware/common/driver_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,51 @@ import (
)

type DriverConfig struct {
// Path to "VMware Fusion.app". By default this is
// /Applications/VMware Fusion.app but this setting allows you to
// customize this.
// The installation path of the VMware Fusion application. Defaults to
// `/Applications/VMware Fusion.app`
//
// ~> **Note:** This is only required if you are using VMware Fusion as a
// local desktop hypervisor and have installed it in a non-default location.
FusionAppPath string `mapstructure:"fusion_app_path" required:"false"`
// The type of remote machine that will be used to
// build this VM rather than a local desktop product. The only value accepted
// for this currently is esx5. If this is not set, a desktop product will
// be used. By default, this is not set.
// The type of remote hypervisor that will be used. If set, the remote
// hypervisor will be used for the build. If not set, a local desktop
// hypervisor (VMware Fusion or VMware Workstation) will be used.
// Available options include `esxi` and `esx5` for VMware ESXi.
//
// ~> **Note:** Use of `esxi` is recommended; `esx5` is deprecated.
RemoteType string `mapstructure:"remote_type" required:"false"`
// The path to the datastore where the VM will be stored
// on the ESXi machine.
// The datastore on the remote hypervisor where the virtual machine will be
// stored.
RemoteDatastore string `mapstructure:"remote_datastore" required:"false"`
// The path to the datastore where supporting files
// will be stored during the build on the remote machine.
// The datastore attached to the remote hypervisor to use for the build.
// Supporting files such as ISOs and floppies are cached in this datastore
// during the build. Defaults to `datastore1`.
RemoteCacheDatastore string `mapstructure:"remote_cache_datastore" required:"false"`
// The path where the ISO and/or floppy files will
// be stored during the build on the remote machine. The path is relative to
// the remote_cache_datastore on the remote machine.
// The directory path on the remote cache datastore to use for the build.
// Supporting files such as ISOs and floppies are cached in this directory,
// relative to the `remote_cache_datastore`, during the build. Defaults to
// `packer_cache`.
RemoteCacheDirectory string `mapstructure:"remote_cache_directory" required:"false"`
// When set to true, Packer will cleanup the cache folder where the ISO file is stored during the build on the remote machine.
// By default, this is set to false.
// Remove items added to the remote cache after the build is complete.
// Defaults to `false`.
CleanUpRemoteCache bool `mapstructure:"cleanup_remote_cache" required:"false"`
// The host of the remote machine used for access.
// This is only required if remote_type is enabled.
// The fully qualified domain name or IP address of the remote hypervisor
// where the virtual machine is created.
//
// ~> **Note:** Required if `remote_type` is set.
RemoteHost string `mapstructure:"remote_host" required:"false"`
// The SSH port of the remote machine
// The SSH port of the remote hypervisor. Defaults to `22`.
RemotePort int `mapstructure:"remote_port" required:"false"`
// The SSH username used to access the remote machine.
// The SSH username for access to the remote hypervisor. Defaults to `root`.
RemoteUser string `mapstructure:"remote_username" required:"false"`
// The SSH password for access to the remote machine.
// The SSH password for access to the remote hypervisor.
RemotePassword string `mapstructure:"remote_password" required:"false"`
// The SSH key for access to the remote machine.
// The SSH key for access to the remote hypervisor.
RemotePrivateKey string `mapstructure:"remote_private_key_file" required:"false"`
// When Packer is preparing to run a
// remote hypervisor build, and export is not disable, by default it runs a no-op
// ovftool command to make sure that the remote_username and remote_password
// given are valid. If you set this flag to true, Packer will skip this
// validation. Default: false.
// Skip the validation of the credentials for access to the remote
// hypervisor. By default, export is enabled and the plugin will validate
// the credentials ('remote_username' and 'remote_password'), for use by
// VMware OVF Tool, before starting the build. Defaults to `false`.
SkipValidateCredentials bool `mapstructure:"skip_validate_credentials" required:"false"`
}

Expand Down Expand Up @@ -82,12 +89,12 @@ func (c *DriverConfig) Prepare(ctx *interpolate.Context) []error {
if c.RemoteType != "" {
if c.RemoteHost == "" {
errs = append(errs,
fmt.Errorf("remote_host must be specified"))
fmt.Errorf("'remote_host' must be specified"))
}

if c.RemoteType != "esx5" {
if c.RemoteType != "esxi" && c.RemoteType != "esx5" {
errs = append(errs,
fmt.Errorf("only 'esx5' value is accepted for remote_type"))
fmt.Errorf("only 'esxi' and 'esx5' values are accepted for 'remote_type'"))
}
}

Expand All @@ -100,8 +107,7 @@ func (c *DriverConfig) Validate(SkipExport bool) error {
}

if c.RemoteType != "" && c.RemotePassword == "" {
return fmt.Errorf("exporting the vm from esxi with ovftool requires " +
"that you set a value for remote_password")
return fmt.Errorf("export requires 'remote_password' to be set")
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions builder/vmware/common/driver_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func TestDriverConfigPrepare(t *testing.T) {
RemoteHost: "host",
},
expectedConfig: nil,
errs: []error{fmt.Errorf("only 'esx5' value is accepted for remote_type")},
errs: []error{fmt.Errorf("only 'esxi' and 'esx5' values are accepted for 'remote_type'")},
},
{
name: "Remote host not set",
config: &DriverConfig{
RemoteType: "esx5",
RemoteType: "esxi",
},
expectedConfig: nil,
errs: []error{fmt.Errorf("remote_host must be specified")},
errs: []error{fmt.Errorf("'remote_host' must be specified")},
},
}

Expand Down
Loading

0 comments on commit f38fa0a

Please sign in to comment.