diff --git a/Dockerfile b/Dockerfile index 91ced3c6..d4c6fd53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,8 @@ RUN wget -P / https://releases.hashicorp.com/terraform/1.9.8/terraform_1.9.8_lin RUN wget -P / https://releases.hashicorp.com/terraform/1.9.8/terraform_1.9.8_linux_arm64.zip RUN unzip /terraform_1.9.8_linux_amd64.zip -d /linux/amd64 RUN unzip /terraform_1.9.8_linux_arm64.zip -d /linux/arm64 -RUN wget -P / https://github.com/vmware/govmomi/releases/download/v0.37.1/govc_Linux_x86_64.tar.gz -RUN wget -P / https://github.com/vmware/govmomi/releases/download/v0.37.1/govc_Linux_arm64.tar.gz +RUN wget -P / https://github.com/vmware/govmomi/releases/download/v0.52.0/govc_Linux_x86_64.tar.gz +RUN wget -P / https://github.com/vmware/govmomi/releases/download/v0.52.0/govc_Linux_arm64.tar.gz RUN tar -xzf /govc_Linux_x86_64.tar.gz -C /linux/amd64 RUN tar -xzf /govc_Linux_arm64.tar.gz -C /linux/arm64 RUN mkdir -p /root/go/src/px-deploy diff --git a/vsphere.go b/vsphere.go index 88cf8644..d8be50b2 100644 --- a/vsphere.go +++ b/vsphere.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "regexp" "strconv" "strings" @@ -722,6 +723,15 @@ func vsphere_init() { vsphere_template_dir := path.Dir(config.Vsphere_Template) vsphere_template_base := path.Base(config.Vsphere_Template) + path_json_opts := filepath.Join(os.TempDir(), "options.json") + json_opts := []byte(fmt.Sprintf("{\"NetworkMapping\":[{\"Name\": \"VM Network (Standard)\",\"Network\": \"%s\"}]}", config.Vsphere_Network)) + + err := os.WriteFile(path_json_opts, json_opts, 0644) + if err != nil { + fmt.Println(Red + "ERROR writing import options file" + Reset) + return + } + govc_opts = append(govc_opts, fmt.Sprintf("GOVC_URL=%s", config.Vsphere_Host)) govc_opts = append(govc_opts, fmt.Sprintf("GOVC_INSECURE=1")) govc_opts = append(govc_opts, fmt.Sprintf("GOVC_RESOURCE_POOL=%s", config.Vsphere_Resource_Pool)) @@ -734,12 +744,12 @@ func vsphere_init() { govc_opts = append(govc_opts, fmt.Sprintf("GOVC_FOLDER=%s", vsphere_template_dir)) } fmt.Printf("Importing new template to VM %s_tmp\n (source %stemplate.ova)\n", config.Vsphere_Template, config.Vsphere_Repo) - cmd := exec.Command("govc", "import.ova", "-name="+vsphere_template_base+"_tmp", config.Vsphere_Repo+"template.ova") + cmd := exec.Command("govc", "import.ova", "-options="+path_json_opts, "-name="+vsphere_template_base+"_tmp", config.Vsphere_Repo+"template.ova") cmd.Env = os.Environ() cmd.Env = append(cmd.Env, govc_opts...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - err := cmd.Run() + err = cmd.Run() if err != nil { fmt.Println(Red + "ERROR importing px-deploy base template" + Reset) return