Skip to content

Commit

Permalink
v1.6.4 Fix default IP dection. Fix Disk Stores containing spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
josenk committed Mar 6, 2020
1 parent 7ab909a commit 4ae1327
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Known issues with vmware_esxi

Version History
---------------
* 1.6.4 Fix default IP dection. Fix Disk Stores containing spaces.
* 1.6.3 Mask username/password in debug logs. Set default, disk.EnableUUID = true.
* 1.6.2 Fix Defaults for guest_startup_timeout and guest_shutdown_timeout. Fix IP address detection type2 to always run regardless of guest_startup_timeout value.
* 1.6.1 Fix some minor refresh bugs, allow http(s) ovf sources.
Expand Down
2 changes: 1 addition & 1 deletion esxi/guest-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func guestCREATE(c *Config, guest_name string, disk_store string,
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)
remote_cmd = fmt.Sprintf("vmkfstools -c %sG -d %s \"%s/%s.vmdk\"", boot_disk_size, boot_disk_type, fullPATH, guest_name)
_, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "vmkfstools (make boot disk)")
if err != nil {
remote_cmd = fmt.Sprintf("rm -fr %s", fullPATH)
Expand Down
4 changes: 2 additions & 2 deletions esxi/guest_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func guestGetIpAddress(c *Config, vmid string, guest_startup_timeout int) string
uptime = 0
for uptime < guest_startup_timeout {
// Primary method to get IP
remote_cmd = fmt.Sprintf("vim-cmd vmsvc/get.guest %s 2>/dev/null |grep -A 5 'deviceConfigId = 4000' |tail -1|grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]).){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'", vmid)
remote_cmd = fmt.Sprintf("vim-cmd vmsvc/get.guest %s 2>/dev/null |sed '1!G;h;$!d' |awk '/deviceConfigId = 4000/,/ipAddress/' |grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' |tail -1", vmid)
stdout, _ = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "get ip_address method 1")
ip_address = stdout
if ip_address != "" {
Expand All @@ -493,7 +493,7 @@ func guestGetIpAddress(c *Config, vmid string, guest_startup_timeout int) string
//
// Alternate method to get IP
//
remote_cmd = fmt.Sprintf("vim-cmd vmsvc/get.guest %s 2>/dev/null | grep -m 1 '^ ipAddress = ' | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]).){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'", vmid)
remote_cmd = fmt.Sprintf("vim-cmd vmsvc/get.guest %s 2>/dev/null | grep -m 1 '^ ipAddress = ' | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'", vmid)
stdout, _ = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "get ip_address method 2")
ip_address2 = stdout
if ip_address2 != "" {
Expand Down
2 changes: 1 addition & 1 deletion esxi/virtual-disk_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func resourceVIRTUALDISKDelete(d *schema.ResourceData, m interface{}) error {
virtual_disk_dir := d.Get("virtual_disk_dir").(string)

// Destroy virtual disk.
remote_cmd = fmt.Sprintf("/bin/vmkfstools -U %s", virtdisk_id)
remote_cmd = fmt.Sprintf("/bin/vmkfstools -U \"%s\"", virtdisk_id)
stdout, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "destroy virtual disk")
if err != nil {
if strings.Contains(err.Error(), "Process exited with status 255") == true {
Expand Down
10 changes: 5 additions & 5 deletions esxi/virtual-disk_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func diskStoreValidate(c *Config, disk_store string) error {
//
// Check if Disk Store already exists
//
remote_cmd = fmt.Sprintf("esxcli storage filesystem list | grep '/vmfs/volumes/.*[VMFS|NFS]' | awk '{print $2}'")
remote_cmd = fmt.Sprintf("esxcli storage filesystem list | grep '/vmfs/volumes/.*[VMFS|NFS]' |awk '{for(i=2;i<=NF-5;++i)printf $i\" \" ; printf \"\\n\"}'")
stdout, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Get list of disk stores")
if err != nil {
return fmt.Errorf("Unable to get list of disk stores: %s\n", err)
Expand All @@ -32,7 +32,7 @@ func diskStoreValidate(c *Config, disk_store string) error {
remote_cmd = fmt.Sprintf("esxcli storage filesystem rescan")
_, _ = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Refresh filesystems")

remote_cmd = fmt.Sprintf("esxcli storage filesystem list | grep '/vmfs/volumes/.*[VMFS|NFS]' | awk '{print $2}'")
remote_cmd = fmt.Sprintf("esxcli storage filesystem list | grep '/vmfs/volumes/.*[VMFS|NFS]' |awk '{for(i=2;i<=NF-5;++i)printf $i\" \" ; printf \"\\n\"}'")
stdout, err = runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Get list of disk stores")
if err != nil {
return fmt.Errorf("Unable to get list of disk stores: %s\n", err)
Expand Down Expand Up @@ -175,13 +175,13 @@ func virtualDiskREAD(c *Config, virtdisk_id string) (string, string, string, int
virtual_disk_size = int(flatSizei64 / 1024 / 1024 / 1024)

// Determine virtual disk type (only works if Guest is powered off)
remote_cmd = fmt.Sprintf("vmkfstools -t0 %s |grep -q 'VMFS Z- LVID:' && echo true", virtdisk_id)
remote_cmd = fmt.Sprintf("vmkfstools -t0 \"%s\" |grep -q 'VMFS Z- LVID:' && echo true", virtdisk_id)
isZeroedThick, _ := runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Get disk type. Is zeroedthick.")

remote_cmd = fmt.Sprintf("vmkfstools -t0 %s |grep -q 'VMFS -- LVID:' && echo true", virtdisk_id)
remote_cmd = fmt.Sprintf("vmkfstools -t0 \"%s\" |grep -q 'VMFS -- LVID:' && echo true", virtdisk_id)
isEagerZeroedThick, _ := runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Get disk type. Is eagerzeroedthick.")

remote_cmd = fmt.Sprintf("vmkfstools -t0 %s |grep -q 'NOMP -- :' && echo true", virtdisk_id)
remote_cmd = fmt.Sprintf("vmkfstools -t0 \"%s\" |grep -q 'NOMP -- :' && echo true", virtdisk_id)
isThin, _ := runRemoteSshCommand(esxiSSHinfo, remote_cmd, "Get disk type. Is thin.")

if isThin == "true" {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.6.3
v1.6.4

0 comments on commit 4ae1327

Please sign in to comment.