Skip to content

Commit

Permalink
v1.8.2, Fix, Disk Stores containing spaces for bare-metal builds
Browse files Browse the repository at this point in the history
  • Loading branch information
josenk committed May 29, 2021
1 parent 6ca18a7 commit 0432505
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Terraform Provider

Requirements
------------
- [Terraform](https://www.terraform.io/downloads.html) 0.10.1+
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x+
- [Go](https://golang.org/doc/install) 1.11+ (to build the provider plugin)
- [ovftool](https://www.vmware.com/support/developer/ovf/) from VMware. NOTE: ovftool installer for windows doesn't put ovftool.exe in your path. You will need to manually set your path.
- You MUST enable ssh access on your ESXi hypervisor.
Expand Down Expand Up @@ -271,11 +271,17 @@ Known issues with vmware_esxi
* Using an incorrect password could lockout your account using default esxi pam settings.
* Don't set guest_startup_timeout or guest_shutdown_timeout to 0 (zero). It's valid, however it will be changed to default values by terraform.

Donations
---------
I work very hard to produce a stable, well documented product. I appreciate any payments or donations for my efforts.
* Bitcoin: 1Kt89337143SzLjSddkRDVEMBRUWoKQhqy
* paypal: josenk at jintegrate.co


Version History
---------------
* 1.8.1 Fix, multimachine create on Windows.
* 1.8.2 Fix, Disk Stores containing spaces for bare-metal builds.
* 1.8.1 Fix, multimachine create on Windows.
* 1.8.0 Add support for vswitch and portgroup resources.
* 1.7.2 Correctly set numvcpu when using clone_from_vm that doesn't have a numvcpu key set.
* 1.7.1 Bump release to include support for Terraform 0.13
Expand Down
14 changes: 7 additions & 7 deletions esxi/guest-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func guestCREATE(c *Config, guest_name string, disk_store string,
} else if src_path == "none" {

// check if path already exists.
fullPATH := fmt.Sprintf("\"/vmfs/volumes/%s/%s\"", disk_store, guest_name)
fullPATH := fmt.Sprintf("/vmfs/volumes/%s/%s", disk_store, guest_name)
boot_disk_vmdkPATH = fmt.Sprintf("\"/vmfs/volumes/%s/%s/%s.vmdk\"", disk_store, guest_name, guest_name)

remote_cmd = fmt.Sprintf("ls -d %s", boot_disk_vmdkPATH)
Expand All @@ -81,10 +81,10 @@ func guestCREATE(c *Config, guest_name string, disk_store string,
return "", fmt.Errorf("Guest may already exists. vmdkPATH:%s\n", boot_disk_vmdkPATH)
}

remote_cmd = fmt.Sprintf("ls -d %s", fullPATH)
remote_cmd = fmt.Sprintf("ls -d \"%s\"", fullPATH)
stdout, _ = runRemoteSshCommand(esxiConnInfo, remote_cmd, "check if guest path already exists.")
if strings.Contains(stdout, "No such file or directory") == true {
remote_cmd = fmt.Sprintf("mkdir %s", fullPATH)
remote_cmd = fmt.Sprintf("mkdir \"%s\"", fullPATH)
stdout, err = runRemoteSshCommand(esxiConnInfo, remote_cmd, "create guest path")
if err != nil {
log.Printf("[guestCREATE] Failed to create guest path. fullPATH:%s\n", fullPATH)
Expand Down Expand Up @@ -163,14 +163,14 @@ func guestCREATE(c *Config, guest_name string, disk_store string,

dst_vmx_file := fmt.Sprintf("%s/%s.vmx", fullPATH, guest_name)

remote_cmd = fmt.Sprintf("echo \"%s\" >%s", vmx_contents, dst_vmx_file)
remote_cmd = fmt.Sprintf("echo \"%s\" >\"%s\"", vmx_contents, dst_vmx_file)
vmx_contents, err = runRemoteSshCommand(esxiConnInfo, 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)
_, err = runRemoteSshCommand(esxiConnInfo, remote_cmd, "vmkfstools (make boot disk)")
if err != nil {
remote_cmd = fmt.Sprintf("rm -fr %s", fullPATH)
remote_cmd = fmt.Sprintf("rm -fr \"%s\"", fullPATH)
stdout, _ = runRemoteSshCommand(esxiConnInfo, remote_cmd, "cleanup guest path because of failed events")
log.Printf("[guestCREATE] Failed to vmkfstools (make boot disk):%s\n", err.Error())
return "", fmt.Errorf("Failed to vmkfstools (make boot disk):%s\n", err.Error())
Expand All @@ -182,11 +182,11 @@ func guestCREATE(c *Config, guest_name string, disk_store string,
log.Printf("[guestCREATE] Failed to use Resource Pool ID:%s\n", poolID)
return "", fmt.Errorf("Failed to use Resource Pool ID:%s\n", poolID)
}
remote_cmd = fmt.Sprintf("vim-cmd solo/registervm %s %s %s", dst_vmx_file, guest_name, poolID)
remote_cmd = fmt.Sprintf("vim-cmd solo/registervm \"%s\" %s %s", dst_vmx_file, guest_name, poolID)
_, err = runRemoteSshCommand(esxiConnInfo, remote_cmd, "solo/registervm")
if err != nil {
log.Printf("[guestCREATE] Failed to register guest:%s\n", err.Error())
remote_cmd = fmt.Sprintf("rm -fr %s", fullPATH)
remote_cmd = fmt.Sprintf("rm -fr \"%s\"", fullPATH)
stdout, _ = runRemoteSshCommand(esxiConnInfo, remote_cmd, "cleanup guest path because of failed events")
return "", fmt.Errorf("Failed to register guest:%s\n", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.8.1
v1.8.2

0 comments on commit 0432505

Please sign in to comment.