Skip to content

Commit

Permalink
1.2.2 fix guest_update power, boot_disk_type defaults, README, window…
Browse files Browse the repository at this point in the history
…s support

Former-commit-id: fe94efa7dbce651fc97bd24bbc209035cefb650a
  • Loading branch information
josenk committed Dec 3, 2018
1 parent 698ce17 commit 35853c2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Known issues with vmware_esxi

Version History
---------------
* 1.2.2 fix guest_update power, boot_disk_type defaults, README, windows support
* 1.2.1 Fix ssh connection retries.
* 1.2.0 Add support for notes (annotation)
* 1.1.1 Fix, unable to provision ova sources. go fmt.
Expand Down
14 changes: 13 additions & 1 deletion esxi/guest-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
)
Expand All @@ -19,6 +20,7 @@ func guestCREATE(c *Config, guest_name string, disk_store string,

var memsize, numvcpus, virthwver int
var boot_disk_vmdkPATH, remote_cmd, vmid, stdout, vmx_contents string
var osShellCmd, osShellCmdOpt string
var out bytes.Buffer
var err error
err = nil
Expand Down Expand Up @@ -196,7 +198,17 @@ func guestCREATE(c *Config, guest_name string, disk_store string,

ovf_cmd := fmt.Sprintf("ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false "+
"-dm=%s --name='%s' --overwrite -ds='%s' %s '%s' '%s'", boot_disk_type, guest_name, disk_store, net_param, src_path, dst_path)
cmd := exec.Command("/bin/bash", "-c", ovf_cmd)

if runtime.GOOS == "windows" {
osShellCmd = "C:\\Windows\\System32\\cmd.exe"
osShellCmdOpt = "/c"
ovf_cmd = strings.Replace(ovf_cmd, "'", "", -1)
} else {
osShellCmd = "/bin/bash"
osShellCmdOpt = "-c"
}

cmd := exec.Command(osShellCmd, osShellCmdOpt, ovf_cmd)

log.Println("[guestCREATE] ovf_cmd: " + ovf_cmd)

Expand Down
11 changes: 7 additions & 4 deletions esxi/guest_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func resourceGUESTUpdate(d *schema.ResourceData, m interface{}) error {
guest_shutdown_timeout := d.Get("guest_shutdown_timeout").(int)
notes := d.Get("notes").(string)
lanAdaptersCount := d.Get("network_interfaces.#").(int)
power := d.Get("power").(string)

if lanAdaptersCount > 3 {
lanAdaptersCount = 3
Expand Down Expand Up @@ -96,10 +97,12 @@ func resourceGUESTUpdate(d *schema.ResourceData, m interface{}) error {
}

// power on
_, err = guestPowerOn(c, vmid)
if err != nil {
fmt.Println("Failed to power on.")
return errors.New("Failed to power on.")
if power == "on" {
_, err = guestPowerOn(c, vmid)
if err != nil {
fmt.Println("Failed to power on.")
return errors.New("Failed to power on.")
}
}

return err
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.2.1
v1.2.2

0 comments on commit 35853c2

Please sign in to comment.