From 5efaba6dd1e049a5497b7b10fd65d4f1c1ee4ce8 Mon Sep 17 00:00:00 2001 From: Julien Brochet Date: Mon, 17 Jun 2019 16:10:22 +0200 Subject: [PATCH] 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