From e26b330456f66e9606ac22702479be272c9cf04c Mon Sep 17 00:00:00 2001 From: Jonathan Senkerik Date: Mon, 7 Sep 2020 23:18:27 -0400 Subject: [PATCH] v1.7.2 Correctly set numvcpu when using clone_from_vm --- README.md | 5 +++-- esxi/guest_functions.go | 11 ++++++++--- examples-0.12/README.md | 2 +- examples-0.13/README.md | 2 +- go.mod | 2 ++ version | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bae650b..fb74498 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ How to install * Download and install Terraform on your local system using instructions from https://www.terraform.io/downloads.html. * Automatic install * Add the required_providers block to your terraform project. - ``` +``` terraform { required_version = ">= 0.13" required_providers { @@ -114,7 +114,7 @@ terraform { } } ``` -* Manual installation +* Manual installation (Terraform 0.11.x or 0.12.x only) * Download pre-built binaries from https://github.com/josenk/terraform-provider-esxi/releases. Place a copy of it in your path or current directory of your terraform project. @@ -256,6 +256,7 @@ Known issues with vmware_esxi Version History --------------- +* 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 * 1.7.0 Add support for esxi_hostssl (Setting the ssl port for ovftool). * 1.6.4 Fix default IP dection. Fix Disk Stores containing spaces. diff --git a/esxi/guest_functions.go b/esxi/guest_functions.go index 07e960f..384bd74 100644 --- a/esxi/guest_functions.go +++ b/esxi/guest_functions.go @@ -129,9 +129,14 @@ func updateVmx_contents(c *Config, vmid string, iscreate bool, memsize int, numv // modify numvcpus if numvcpus != 0 { - re := regexp.MustCompile("numvcpus = \".*\"") - regexReplacement = fmt.Sprintf("numvcpus = \"%d\"", numvcpus) - vmx_contents = re.ReplaceAllString(vmx_contents, regexReplacement) + if strings.Contains(vmx_contents, "numvcpus = ") { + re := regexp.MustCompile("numvcpus = \".*\"") + regexReplacement = fmt.Sprintf("numvcpus = \"%d\"", numvcpus) + vmx_contents = re.ReplaceAllString(vmx_contents, regexReplacement) + } else { + log.Printf("[updateVmx_contents] Add numvcpu: %d\n", numvcpus) + vmx_contents += fmt.Sprintf("\nnumvcpus = \"%d\"", numvcpus) + } } // modify virthwver diff --git a/examples-0.12/README.md b/examples-0.12/README.md index 090bff3..97bf308 100644 --- a/examples-0.12/README.md +++ b/examples-0.12/README.md @@ -2,5 +2,5 @@ Terraform esxi Provider ======================= -This directory hold the examples for terraform 0.12.x+ +This directory hold the examples for terraform 0.12.x ------------------------------------------------------ diff --git a/examples-0.13/README.md b/examples-0.13/README.md index 090bff3..edc666a 100644 --- a/examples-0.13/README.md +++ b/examples-0.13/README.md @@ -2,5 +2,5 @@ Terraform esxi Provider ======================= -This directory hold the examples for terraform 0.12.x+ +This directory hold the examples for terraform 0.13.x+ ------------------------------------------------------ diff --git a/go.mod b/go.mod index 1474689..943471d 100644 --- a/go.mod +++ b/go.mod @@ -6,3 +6,5 @@ require ( github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 ) + +go 1.13 diff --git a/version b/version index a97fc44..3b34d22 100644 --- a/version +++ b/version @@ -1 +1 @@ -v1.7.1 +v1.7.2