Merge pull request #7755 from aerialls/proxmox-api

fix(promox): update proxmox-api-go dependency
This commit is contained in:
Adrien Delorme 2019-06-17 16:29:12 +02:00 committed by GitHub
commit 022b559c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 11 deletions

View File

@ -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")

2
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

View File

@ -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
}

View File

@ -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,

2
vendor/modules.txt vendored
View File

@ -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