From ab52c4f87ee17c5a9e860e8ce65844b59d9c1ab6 Mon Sep 17 00:00:00 2001 From: Julien Brochet Date: Fri, 14 Jun 2019 20:24:50 +0200 Subject: [PATCH 1/2] fix(promox): update proxmox-api-go dependency --- builder/proxmox/step_start_vm.go | 4 ++-- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/proxmox/step_start_vm.go b/builder/proxmox/step_start_vm.go index a7521b14b..551174ea1 100644 --- a/builder/proxmox/step_start_vm.go +++ b/builder/proxmox/step_start_vm.go @@ -21,9 +21,9 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist client := state.Get("proxmoxClient").(*proxmox.Client) c := state.Get("config").(*Config) - agent := "1" + agent := 1 if c.Agent == false { - agent = "0" + agent = 0 } ui.Say("Creating VM") diff --git a/go.mod b/go.mod index 8d35249dd..460d1e7af 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4 // indirect github.com/ChrisTrenkamp/goxpath v0.0.0-20170625215350-4fe035839290 github.com/NaverCloudPlatform/ncloud-sdk-go v0.0.0-20180110055012-c2e73f942591 - github.com/Telmate/proxmox-api-go v0.0.0-20190410200643-f08824d5082d + github.com/Telmate/proxmox-api-go v0.0.0-20190614181158-26cd147831a4 github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af // indirect github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f diff --git a/go.sum b/go.sum index 776cc1a18..04acf6538 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Telmate/proxmox-api-go v0.0.0-20190410200643-f08824d5082d h1:igrCnHheXb+lZ1bW9Ths8JZZIjh9D4Vi/49JqiHE+cI= github.com/Telmate/proxmox-api-go v0.0.0-20190410200643-f08824d5082d/go.mod h1:OGWyIMJ87/k/GCz8CGiWB2HOXsOVDM6Lpe/nFPkC4IQ= +github.com/Telmate/proxmox-api-go v0.0.0-20190614181158-26cd147831a4 h1:o//09WenT9BNcQypCYfOBfRe5gtLUvUfTPq0xQqPMEI= +github.com/Telmate/proxmox-api-go v0.0.0-20190614181158-26cd147831a4/go.mod h1:OGWyIMJ87/k/GCz8CGiWB2HOXsOVDM6Lpe/nFPkC4IQ= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= From 5efaba6dd1e049a5497b7b10fd65d4f1c1ee4ce8 Mon Sep 17 00:00:00 2001 From: Julien Brochet Date: Mon, 17 Jun 2019 16:10:22 +0200 Subject: [PATCH 2/2] fix(proxmox): update vendor folder with latest Proxmox dependency --- .../Telmate/proxmox-api-go/proxmox/client.go | 2 ++ .../proxmox-api-go/proxmox/config_qemu.go | 26 ++++++++++++++----- vendor/modules.txt | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/vendor/github.com/Telmate/proxmox-api-go/proxmox/client.go b/vendor/github.com/Telmate/proxmox-api-go/proxmox/client.go index 50f2d9e09..75ebf1a8a 100644 --- a/vendor/github.com/Telmate/proxmox-api-go/proxmox/client.go +++ b/vendor/github.com/Telmate/proxmox-api-go/proxmox/client.go @@ -497,6 +497,8 @@ func (c *Client) GetNextID(currentID int) (nextID int, err error) { } } nextID, err = strconv.Atoi(data["data"].(string)) + } else if strings.HasPrefix(err.Error(), "400 ") { + return c.GetNextID(currentID + 1) } return } diff --git a/vendor/github.com/Telmate/proxmox-api-go/proxmox/config_qemu.go b/vendor/github.com/Telmate/proxmox-api-go/proxmox/config_qemu.go index 7c0ffd897..f0ee911b5 100644 --- a/vendor/github.com/Telmate/proxmox-api-go/proxmox/config_qemu.go +++ b/vendor/github.com/Telmate/proxmox-api-go/proxmox/config_qemu.go @@ -26,7 +26,7 @@ type ConfigQemu struct { Name string `json:"name"` Description string `json:"desc"` Onboot bool `json:"onboot"` - Agent string `json:"agent"` + Agent int `json:"agent"` Memory int `json:"memory"` QemuOs string `json:"os"` QemuCores int `json:"cores"` @@ -251,9 +251,16 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e if _, isSet := vmConfig["onboot"]; isSet { onboot = Itob(int(vmConfig["onboot"].(float64))) } - agent := "1" + + agent := 0 if _, isSet := vmConfig["agent"]; isSet { - agent = vmConfig["agent"].(string) + switch vmConfig["agent"].(type) { + case float64: + agent = int(vmConfig["agent"].(float64)) + case string: + agent, _ = strconv.Atoi(vmConfig["agent"].(string)) + } + } ostype := "other" if _, isSet := vmConfig["ostype"]; isSet { @@ -299,6 +306,9 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e if _, isSet := vmConfig["searchdomain"]; isSet { config.Searchdomain = vmConfig["searchdomain"].(string) } + if _, isSet := vmConfig["nameserver"]; isSet { + config.Nameserver = vmConfig["nameserver"].(string) + } if _, isSet := vmConfig["sshkeys"]; isSet { config.Sshkeys, _ = url.PathUnescape(vmConfig["sshkeys"].(string)) } @@ -330,6 +340,7 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e // diskConfMap := QemuDevice{ + "id": diskID, "type": diskType, "storage": storageName, "file": fileName, @@ -345,11 +356,10 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e } // Add networks. - nicNameRe := regexp.MustCompile(`net\d+`) nicNames := []string{} for k, _ := range vmConfig { - if nicName := nicNameRe.FindStringSubmatch(k); len(nicName) > 0 { + if nicName := rxNicName.FindStringSubmatch(k); len(nicName) > 0 { nicNames = append(nicNames, nicName[0]) } } @@ -358,13 +368,13 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e nicConfStr := vmConfig[nicName] nicConfList := strings.Split(nicConfStr.(string), ",") - // id := rxDeviceID.FindStringSubmatch(nicName) nicID, _ := strconv.Atoi(id[0]) model, macaddr := ParseSubConf(nicConfList[0], "=") // Add model and MAC address. nicConfMap := QemuDevice{ + "id": nicID, "model": model, "macaddr": macaddr, } @@ -441,7 +451,7 @@ func RemoveSshForwardUsernet(vmr *VmRef, client *Client) (err error) { func MaxVmId(client *Client) (max int, err error) { resp, err := client.GetVmList() vms := resp["data"].([]interface{}) - max = 0 + max = 100 for vmii := range vms { vm := vms[vmii].(map[string]interface{}) vmid := int(vm["vmid"].(float64)) @@ -524,6 +534,7 @@ func (c ConfigQemu) CreateQemuNetworksParams(vmID int, params map[string]interfa // For backward compatibility. if len(c.QemuNetworks) == 0 && len(c.QemuNicModel) > 0 { deprecatedStyleMap := QemuDevice{ + "id": 0, "model": c.QemuNicModel, "bridge": c.QemuBrige, "macaddr": c.QemuMacAddr, @@ -602,6 +613,7 @@ func (c ConfigQemu) CreateQemuDisksParams( } } deprecatedStyleMap := QemuDevice{ + "id": 0, "type": dType, "storage": c.Storage, "size": c.DiskSize, diff --git a/vendor/modules.txt b/vendor/modules.txt index 35aa98200..490ebdb6b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -49,7 +49,7 @@ github.com/NaverCloudPlatform/ncloud-sdk-go/sdk github.com/NaverCloudPlatform/ncloud-sdk-go/common github.com/NaverCloudPlatform/ncloud-sdk-go/request github.com/NaverCloudPlatform/ncloud-sdk-go/oauth -# github.com/Telmate/proxmox-api-go v0.0.0-20190410200643-f08824d5082d +# github.com/Telmate/proxmox-api-go v0.0.0-20190614181158-26cd147831a4 github.com/Telmate/proxmox-api-go/proxmox # github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors