From a2e96ff707540b6db6f16bcaa956008510d8dfc1 Mon Sep 17 00:00:00 2001 From: Jonathan Senkerik Date: Sun, 3 Nov 2019 16:00:22 -0500 Subject: [PATCH] 1.5.3, Fix introduced bug when creating a bare-metal guest. --- README.md | 2 ++ esxi/guest-create.go | 12 +++++++----- go.mod | 2 +- version | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d68fd6f..e21ac7f 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ Configuration reference Known issues with vmware_esxi ----------------------------- +* Using a local source vmx files should not have any networks configured. There is very limited network interface mapping abilities in ovf_tools for vmx files. It's best to simply clean out all network information from your vmx file. The plugin will add network configuration to the destination vm guest as required. * terraform import cannot import the guest disk type (thick, thin, etc) if the VM is powered on and cannot import the guest ip_address if it's powered off. * Only numvcpus are supported. numcores is not supported. * Doesn't support CDrom or floppy. @@ -205,6 +206,7 @@ Known issues with vmware_esxi Version History --------------- +* 1.5.3 Fix introduced bug when creating a bare-metal guest. * 1.5.2 Handle large userdata using scp. Connectivity test will retry only 3 times to help prevent account lockout. * 1.5.1 Windows Fix for special characters in esxi password. * 1.5.0 Support for Terraform 0.12, migrated examples to 0.12 format. Support to modify virtual_network & nic_type. Windows fixes. diff --git a/esxi/guest-create.go b/esxi/guest-create.go index 2179d1c..c202132 100644 --- a/esxi/guest-create.go +++ b/esxi/guest-create.go @@ -68,16 +68,16 @@ func guestCREATE(c *Config, guest_name string, disk_store string, boot_disk_vmdkPATH = fmt.Sprintf("\"/vmfs/volumes/%s/%s/%s.vmdk\"", disk_store, guest_name, guest_name) remote_cmd = fmt.Sprintf("ls -d %s", fullPATH) stdout, _ = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "check if guest path already exists.") - if stdout == fullPATH { - fmt.Printf("Error: Guest path already exists. fullPATH:%s\n", fullPATH) - return "", fmt.Errorf("Guest path already exists. fullPATH:%s\n", fullPATH) - } else { + if strings.Contains(stdout, "No such file or directory") == true { remote_cmd = fmt.Sprintf("mkdir %s", fullPATH) stdout, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "create guest path") if err != nil { log.Printf("Failed to create guest path. fullPATH:%s\n", fullPATH) return "", fmt.Errorf("Failed to create guest path. fullPATH:%s\n", fullPATH) } + } else { + fmt.Printf("Error: Guest path already exists. fullPATH:%s\n", fullPATH) + return "", fmt.Errorf("Guest path already exists. fullPATH:%s\n", fullPATH) } hasISO := false @@ -149,7 +149,9 @@ func guestCREATE(c *Config, guest_name string, disk_store string, log.Printf("[guestCREATE] New guest_name.vmx: %s\n", vmx_contents) dst_vmx_file := fmt.Sprintf("%s/%s.vmx", fullPATH, guest_name) - vmx_contents, err = writeContentToRemoteFile(esxiSSHinfo, strings.Replace(vmx_contents, "\\\"", "\"", -1), dst_vmx_file, "write guest_name.vmx file") + + remote_cmd = fmt.Sprintf("echo \"%s\" >%s", vmx_contents, dst_vmx_file) + vmx_contents, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "write guest_name.vmx file") // Create boot disk (vmdk) remote_cmd = fmt.Sprintf("vmkfstools -c %sG -d %s %s/%s.vmdk", boot_disk_size, boot_disk_type, fullPATH, guest_name) diff --git a/go.mod b/go.mod index 78cbd52..e1cd19d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module terraform-provider-esxi require ( github.com/hashicorp/terraform v0.12.2 - github.com/josenk/terraform-provider-esxi v1.5.2 + github.com/josenk/terraform-provider-esxi v1.5.3 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 diff --git a/version b/version index a503124..f1a2e63 100644 --- a/version +++ b/version @@ -1 +1 @@ -v1.5.2 +v1.5.3