Convert incorrect 'vmxc' -> 'vmcx' in codebase, docs and template opts

grep -rli --exclude-dir={vendor,bin\*,\*vmware\*,\*pkg\*} vmxc . | \
xargs sed -i 's/\(vm\)\(x\)\(c\)/\1\3\2/ig'
This commit is contained in:
DanHam 2018-07-19 18:53:42 +01:00
parent 3c5d7aec74
commit da21c25791
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
7 changed files with 59 additions and 59 deletions

View File

@ -134,7 +134,7 @@ type DriverMock struct {
CreateVirtualMachine_Err error
CloneVirtualMachine_Called bool
CloneVirtualMachine_CloneFromVmxcPath string
CloneVirtualMachine_CloneFromVmcxPath string
CloneVirtualMachine_CloneFromVmName string
CloneVirtualMachine_CloneFromSnapshotName string
CloneVirtualMachine_CloneAllSnapshots bool
@ -423,11 +423,11 @@ func (d *DriverMock) CreateVirtualMachine(vmName string, path string, harddriveP
return d.CreateVirtualMachine_Err
}
func (d *DriverMock) CloneVirtualMachine(cloneFromVmxcPath string, cloneFromVmName string,
func (d *DriverMock) CloneVirtualMachine(cloneFromVmcxPath string, cloneFromVmName string,
cloneFromSnapshotName string, cloneAllSnapshots bool, vmName string, path string,
harddrivePath string, ram int64, switchName string) error {
d.CloneVirtualMachine_Called = true
d.CloneVirtualMachine_CloneFromVmxcPath = cloneFromVmxcPath
d.CloneVirtualMachine_CloneFromVmcxPath = cloneFromVmcxPath
d.CloneVirtualMachine_CloneFromVmName = cloneFromVmName
d.CloneVirtualMachine_CloneFromSnapshotName = cloneFromSnapshotName
d.CloneVirtualMachine_CloneAllSnapshots = cloneAllSnapshots

View File

@ -188,10 +188,10 @@ func (d *HypervPS4Driver) CreateVirtualMachine(vmName string, path string, hardd
generation, diffDisks, fixedVHD)
}
func (d *HypervPS4Driver) CloneVirtualMachine(cloneFromVmxcPath string, cloneFromVmName string,
func (d *HypervPS4Driver) CloneVirtualMachine(cloneFromVmcxPath string, cloneFromVmName string,
cloneFromSnapshotName string, cloneAllSnapshots bool, vmName string, path string, harddrivePath string,
ram int64, switchName string) error {
return hyperv.CloneVirtualMachine(cloneFromVmxcPath, cloneFromVmName, cloneFromSnapshotName,
return hyperv.CloneVirtualMachine(cloneFromVmcxPath, cloneFromVmName, cloneFromSnapshotName,
cloneAllSnapshots, vmName, path, harddrivePath, ram, switchName)
}

View File

@ -16,7 +16,7 @@ import (
// Produces:
// VMName string - The name of the VM
type StepCloneVM struct {
CloneFromVMXCPath string
CloneFromVMCXPath string
CloneFromVMName string
CloneFromSnapshotName string
CloneAllSnapshots bool
@ -55,7 +55,7 @@ func (s *StepCloneVM) Run(_ context.Context, state multistep.StateBag) multistep
// convert the MB to bytes
ramSize := int64(s.RamSize * 1024 * 1024)
err := driver.CloneVirtualMachine(s.CloneFromVMXCPath, s.CloneFromVMName, s.CloneFromSnapshotName,
err := driver.CloneVirtualMachine(s.CloneFromVMCXPath, s.CloneFromVMName, s.CloneFromSnapshotName,
s.CloneAllSnapshots, s.VMName, path, harddrivePath, ramSize, s.SwitchName)
if err != nil {
err := fmt.Errorf("Error cloning virtual machine: %s", err)

View File

@ -62,7 +62,7 @@ type Config struct {
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
// This is the path to a directory containing an exported virtual machine.
CloneFromVMXCPath string `mapstructure:"clone_from_vmxc_path"`
CloneFromVMCXPath string `mapstructure:"clone_from_vmcx_path"`
// This is the name of the virtual machine to clone from.
CloneFromVMName string `mapstructure:"clone_from_vm_name"`
@ -158,9 +158,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b.config.Generation = 1
if b.config.CloneFromVMName == "" {
if b.config.CloneFromVMXCPath == "" {
if b.config.CloneFromVMCXPath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vm_name must be specified if "+
"clone_from_vmxc_path is not specified."))
"clone_from_vmcx_path is not specified."))
}
} else {
virtualMachineExists, err := powershell.DoesVirtualMachineExist(b.config.CloneFromVMName)
@ -207,16 +207,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
}
if b.config.CloneFromVMXCPath == "" {
if b.config.CloneFromVMCXPath == "" {
if b.config.CloneFromVMName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmxc_path be specified if "+
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmcx_path be specified if "+
"clone_from_vm_name must is not specified."))
}
} else {
if _, err := os.Stat(b.config.CloneFromVMXCPath); os.IsNotExist(err) {
if _, err := os.Stat(b.config.CloneFromVMCXPath); os.IsNotExist(err) {
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("CloneFromVMXCPath does not exist: %s", err))
errs, fmt.Errorf("CloneFromVMCXPath does not exist: %s", err))
}
}
}
@ -426,7 +426,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SwitchName: b.config.SwitchName,
},
&hypervcommon.StepCloneVM{
CloneFromVMXCPath: b.config.CloneFromVMXCPath,
CloneFromVMCXPath: b.config.CloneFromVMCXPath,
CloneFromVMName: b.config.CloneFromVMName,
CloneFromSnapshotName: b.config.CloneFromSnapshotName,
CloneAllSnapshots: b.config.CloneAllSnapshots,

View File

@ -23,7 +23,7 @@ func testConfig() map[string]interface{} {
"ssh_username": "foo",
"ram_size": 64,
"guest_additions_mode": "none",
"clone_from_vmxc_path": "generated",
"clone_from_vmcx_path": "generated",
packer.BuildNameConfigKey: "foo",
}
}
@ -40,13 +40,13 @@ func TestBuilderPrepare_Defaults(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
warns, err := b.Prepare(config)
if len(warns) > 0 {
@ -65,13 +65,13 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
// Add a random key
config["i_should_not_be_valid"] = true
@ -87,7 +87,7 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
func TestBuilderPrepare_CloneFromExistingMachineOrImportFromExportedMachineSettingsRequired(t *testing.T) {
var b Builder
config := testConfig()
delete(config, "clone_from_vmxc_path")
delete(config, "clone_from_vmcx_path")
warns, err := b.Prepare(config)
if len(warns) > 0 {
@ -102,7 +102,7 @@ func TestBuilderPrepare_ExportedMachinePathDoesNotExist(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
@ -111,7 +111,7 @@ func TestBuilderPrepare_ExportedMachinePathDoesNotExist(t *testing.T) {
//Delete the folder immediately
os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
warns, err := b.Prepare(config)
if len(warns) > 0 {
@ -126,7 +126,7 @@ func TestBuilderPrepare_ExportedMachinePathExists(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
@ -135,7 +135,7 @@ func TestBuilderPrepare_ExportedMachinePathExists(t *testing.T) {
//Only delete afterwards
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
warns, err := b.Prepare(config)
if len(warns) > 0 {
@ -146,10 +146,10 @@ func TestBuilderPrepare_ExportedMachinePathExists(t *testing.T) {
}
}
func disabled_TestBuilderPrepare_CloneFromVmSettingUsedSoNoCloneFromVmxcPathRequired(t *testing.T) {
func disabled_TestBuilderPrepare_CloneFromVmSettingUsedSoNoCloneFromVmcxPathRequired(t *testing.T) {
var b Builder
config := testConfig()
delete(config, "clone_from_vmxc_path")
delete(config, "clone_from_vmcx_path")
config["clone_from_vm_name"] = "test_machine_name_that_does_not_exist"
@ -173,13 +173,13 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
// Test bad
config["iso_checksum"] = ""
@ -211,13 +211,13 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
// Test bad
config["iso_checksum_type"] = ""
@ -275,13 +275,13 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
delete(config, "iso_url")
delete(config, "iso_urls")
@ -354,13 +354,13 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
delete(config, "floppy_files")
warns, err := b.Prepare(config)
@ -396,13 +396,13 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
config["floppy_files"] = []string{"nonexistent.bat", "nonexistent.ps1"}
b = Builder{}
@ -421,13 +421,13 @@ func TestBuilderPrepare_CommConfig(t *testing.T) {
{
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
config["communicator"] = "winrm"
config["winrm_username"] = "username"
@ -458,13 +458,13 @@ func TestBuilderPrepare_CommConfig(t *testing.T) {
{
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
config["communicator"] = "ssh"
config["ssh_username"] = "username"
@ -496,13 +496,13 @@ func TestUserVariablesInBootCommand(t *testing.T) {
var b Builder
config := testConfig()
//Create vmxc folder
//Create vmcx folder
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)
config["clone_from_vmxc_path"] = td
config["clone_from_vmcx_path"] = td
config[packer.UserVariablesConfigKey] = map[string]string{"test-variable": "test"}
config["boot_command"] = []string{"blah {{user `test-variable`}} blah"}

View File

@ -286,7 +286,7 @@ if ((Get-Command Hyper-V\Set-Vm).Parameters["AutomaticCheckpointsEnabled"]) {
return err
}
func ExportVmxcVirtualMachine(exportPath string, vmName string, snapshotName string, allSnapshots bool) error {
func ExportVmcxVirtualMachine(exportPath string, vmName string, snapshotName string, allSnapshots bool) error {
var script = `
param([string]$exportPath, [string]$vmName, [string]$snapshotName, [string]$allSnapshotsString)
@ -333,22 +333,22 @@ $result = Remove-Item -Path $WorkingPath
return err
}
func CopyVmxcVirtualMachine(exportPath string, cloneFromVmxcPath string) error {
func CopyVmcxVirtualMachine(exportPath string, cloneFromVmcxPath string) error {
var script = `
param([string]$exportPath, [string]$cloneFromVmxcPath)
if (!(Test-Path $cloneFromVmxcPath)){
throw "Clone from vmxc directory: $cloneFromVmxcPath does not exist!"
param([string]$exportPath, [string]$cloneFromVmcxPath)
if (!(Test-Path $cloneFromVmcxPath)){
throw "Clone from vmcx directory: $cloneFromVmcxPath does not exist!"
}
if (!(Test-Path $exportPath)){
New-Item -ItemType Directory -Force -Path $exportPath
}
$cloneFromVmxcPath = Join-Path $cloneFromVmxcPath '\*'
Copy-Item $cloneFromVmxcPath $exportPath -Recurse -Force
$cloneFromVmcxPath = Join-Path $cloneFromVmcxPath '\*'
Copy-Item $cloneFromVmcxPath $exportPath -Recurse -Force
`
var ps powershell.PowerShellCmd
err := ps.Run(script, exportPath, cloneFromVmxcPath)
err := ps.Run(script, exportPath, cloneFromVmcxPath)
return err
}
@ -365,7 +365,7 @@ Hyper-V\Set-VMNetworkAdapter $vmName -staticmacaddress $mac
return err
}
func ImportVmxcVirtualMachine(importPath string, vmName string, harddrivePath string,
func ImportVmcxVirtualMachine(importPath string, vmName string, harddrivePath string,
ram int64, switchName string) error {
var script = `
@ -422,24 +422,24 @@ if ($vm) {
return err
}
func CloneVirtualMachine(cloneFromVmxcPath string, cloneFromVmName string,
func CloneVirtualMachine(cloneFromVmcxPath string, cloneFromVmName string,
cloneFromSnapshotName string, cloneAllSnapshots bool, vmName string,
path string, harddrivePath string, ram int64, switchName string) error {
if cloneFromVmName != "" {
if err := ExportVmxcVirtualMachine(path, cloneFromVmName,
if err := ExportVmcxVirtualMachine(path, cloneFromVmName,
cloneFromSnapshotName, cloneAllSnapshots); err != nil {
return err
}
}
if cloneFromVmxcPath != "" {
if err := CopyVmxcVirtualMachine(path, cloneFromVmxcPath); err != nil {
if cloneFromVmcxPath != "" {
if err := CopyVmcxVirtualMachine(path, cloneFromVmcxPath); err != nil {
return err
}
}
if err := ImportVmxcVirtualMachine(path, vmName, harddrivePath, ram, switchName); err != nil {
if err := ImportVmcxVirtualMachine(path, vmName, harddrivePath, ram, switchName); err != nil {
return err
}

View File

@ -33,7 +33,7 @@ Import from folder:
``` json
{
"type": "hyperv-vmcx",
"clone_from_vmxc_path": "c:\\virtual machines\\ubuntu-12.04.5-server-amd64",
"clone_from_vmcx_path": "c:\\virtual machines\\ubuntu-12.04.5-server-amd64",
"ssh_username": "packer",
"ssh_password": "packer",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
@ -71,7 +71,7 @@ builder.
### Required for virtual machine import:
- `clone_from_vmxc_path` (string) - The path to the exported virtual machine
- `clone_from_vmcx_path` (string) - The path to the exported virtual machine
folder.
### Required for virtual machine clone: