Merge branch 'master' into scrape_doc_to_builder_struct_config

This commit is contained in:
Adrien Delorme 2019-06-19 11:21:06 +02:00 committed by GitHub
commit 4c1abf828c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 130 additions and 17 deletions

View File

@ -28,14 +28,14 @@ release: install-build-deps test releasebin package ## Build a release build
bin: install-build-deps ## Build debug/test build bin: install-build-deps ## Build debug/test build
@echo "WARN: 'make bin' is for debug / test builds only. Use 'make release' for release builds." @echo "WARN: 'make bin' is for debug / test builds only. Use 'make release' for release builds."
@GO111MODULE=off sh -c "$(CURDIR)/scripts/build.sh" @GO111MODULE=auto sh -c "$(CURDIR)/scripts/build.sh"
releasebin: install-build-deps releasebin: install-build-deps
@grep 'const VersionPrerelease = "dev"' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \ @grep 'const VersionPrerelease = "dev"' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
echo "ERROR: You must remove prerelease tags from version/version.go prior to release."; \ echo "ERROR: You must remove prerelease tags from version/version.go prior to release."; \
exit 1; \ exit 1; \
fi fi
@GO111MODULE=off sh -c "$(CURDIR)/scripts/build.sh" @GO111MODULE=auto sh -c "$(CURDIR)/scripts/build.sh"
package: package:
$(if $(VERSION),,@echo 'VERSION= needed to release; Use make package skip compilation'; exit 1) $(if $(VERSION),,@echo 'VERSION= needed to release; Use make package skip compilation'; exit 1)

View File

@ -73,6 +73,8 @@ type Driver interface {
DeleteVirtualSwitch(string) error DeleteVirtualSwitch(string) error
CheckVMName(string) error
CreateVirtualMachine(string, string, string, int64, int64, int64, string, uint, bool, bool, string) error CreateVirtualMachine(string, string, string, int64, int64, int64, string, uint, bool, bool, string) error
AddVirtualMachineHardDrive(string, string, string, int64, int64, string) error AddVirtualMachineHardDrive(string, string, string, int64, int64, string) error

View File

@ -110,6 +110,9 @@ type DriverMock struct {
DeleteVirtualSwitch_SwitchName string DeleteVirtualSwitch_SwitchName string
DeleteVirtualSwitch_Err error DeleteVirtualSwitch_Err error
CheckVMName_Called bool
CheckVMName_Err error
CreateVirtualSwitch_Called bool CreateVirtualSwitch_Called bool
CreateVirtualSwitch_SwitchName string CreateVirtualSwitch_SwitchName string
CreateVirtualSwitch_SwitchType string CreateVirtualSwitch_SwitchType string
@ -421,6 +424,11 @@ func (d *DriverMock) AddVirtualMachineHardDrive(vmName string, vhdFile string, v
return d.AddVirtualMachineHardDrive_Err return d.AddVirtualMachineHardDrive_Err
} }
func (d *DriverMock) CheckVMName(vmName string) error {
d.CheckVMName_Called = true
return d.CheckVMName_Err
}
func (d *DriverMock) CreateVirtualMachine(vmName string, path string, harddrivePath string, func (d *DriverMock) CreateVirtualMachine(vmName string, path string, harddrivePath string,
ram int64, diskSize int64, diskBlockSize int64, switchName string, generation uint, ram int64, diskSize int64, diskBlockSize int64, switchName string, generation uint,
diffDisks bool, fixedVHD bool, version string) error { diffDisks bool, fixedVHD bool, version string) error {

View File

@ -186,6 +186,10 @@ func (d *HypervPS4Driver) AddVirtualMachineHardDrive(vmName string, vhdFile stri
diskBlockSize, controllerType) diskBlockSize, controllerType)
} }
func (d *HypervPS4Driver) CheckVMName(vmName string) error {
return hyperv.CheckVMName(vmName)
}
func (d *HypervPS4Driver) CreateVirtualMachine(vmName string, path string, harddrivePath string, ram int64, func (d *HypervPS4Driver) CreateVirtualMachine(vmName string, path string, harddrivePath string, ram int64,
diskSize int64, diskBlockSize int64, switchName string, generation uint, diffDisks bool, diskSize int64, diskBlockSize int64, switchName string, generation uint, diffDisks bool,
fixedVHD bool, version string) error { fixedVHD bool, version string) error {

View File

@ -48,6 +48,14 @@ func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis
path = v.(string) path = v.(string)
} }
err := driver.CheckVMName(s.VMName)
if err != nil {
s.KeepRegistered = true
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
// Determine if we even have an existing virtual harddrive to attach // Determine if we even have an existing virtual harddrive to attach
harddrivePath := "" harddrivePath := ""
if harddrivePathRaw, ok := state.GetOk("iso_path"); ok { if harddrivePathRaw, ok := state.GetOk("iso_path"); ok {
@ -66,7 +74,7 @@ func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis
diskSize := int64(s.DiskSize) * 1024 * 1024 diskSize := int64(s.DiskSize) * 1024 * 1024
diskBlockSize := int64(s.DiskBlockSize) * 1024 * 1024 diskBlockSize := int64(s.DiskBlockSize) * 1024 * 1024
err := driver.CreateVirtualMachine(s.VMName, path, harddrivePath, ramSize, diskSize, diskBlockSize, err = driver.CreateVirtualMachine(s.VMName, path, harddrivePath, ramSize, diskSize, diskBlockSize,
s.SwitchName, s.Generation, s.DifferencingDisk, s.FixedVHD, s.Version) s.SwitchName, s.Generation, s.DifferencingDisk, s.FixedVHD, s.Version)
if err != nil { if err != nil {
err := fmt.Errorf("Error creating virtual machine: %s", err) err := fmt.Errorf("Error creating virtual machine: %s", err)

View File

@ -0,0 +1,58 @@
package common
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer/helper/multistep"
)
func TestStepCreateVM_impl(t *testing.T) {
var _ multistep.Step = new(StepCreateVM)
}
func TestStepCreateVM(t *testing.T) {
state := testState(t)
step := new(StepCreateVM)
step.VMName = "test-VM-Name"
driver := state.Get("driver").(*DriverMock)
// Test the run
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
t.Fatalf("Bad action: %v", action)
}
if _, ok := state.GetOk("error"); ok {
t.Fatal("Should NOT have error")
}
// Test the driver
if !driver.CheckVMName_Called {
t.Fatal("Should have called CheckVMName")
}
}
func TestStepCreateVM_CheckVMNameErr(t *testing.T) {
state := testState(t)
step := new(StepCreateVM)
step.VMName = "test-VM-Name"
driver := state.Get("driver").(*DriverMock)
driver.CheckVMName_Err = fmt.Errorf("A virtual machine with the name is already" +
" defined in Hyper-V. To avoid a name collision, please set your " +
"vm_name to a unique value")
// Test the run
if action := step.Run(context.Background(), state); action != multistep.ActionHalt {
t.Fatalf("Bad action: %v", action)
}
if _, ok := state.GetOk("error"); !ok {
t.Fatal("Should have error")
}
// Test the driver
if !driver.CheckVMName_Called {
t.Fatal("Should have called CheckVMName")
}
}

View File

@ -21,9 +21,9 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
client := state.Get("proxmoxClient").(*proxmox.Client) client := state.Get("proxmoxClient").(*proxmox.Client)
c := state.Get("config").(*Config) c := state.Get("config").(*Config)
agent := "1" agent := 1
if c.Agent == false { if c.Agent == false {
agent = "0" agent = 0
} }
ui.Say("Creating VM") ui.Say("Creating VM")

View File

@ -283,10 +283,23 @@ Hyper-V\New-VM -Name "{{ .VMName }}" -Path "{{ .Path }}" -MemoryStartupBytes {{
return final, nil return final, nil
} }
func CheckVMName(vmName string) error {
// Check that no vm with the same name is registered, to prevent
// namespace collisions
var gs powershell.PowerShellCmd
getVMCmd := fmt.Sprintf(`Hyper-V\Get-VM -Name "%s"`, vmName)
if err := gs.Run(getVMCmd); err == nil {
return fmt.Errorf("A virtual machine with the name %s is already"+
" defined in Hyper-V. To avoid a name collision, please set your "+
"vm_name to a unique value", vmName)
}
return nil
}
func CreateVirtualMachine(vmName string, path string, harddrivePath string, ram int64, func CreateVirtualMachine(vmName string, path string, harddrivePath string, ram int64,
diskSize int64, diskBlockSize int64, switchName string, generation uint, diskSize int64, diskBlockSize int64, switchName string, generation uint,
diffDisks bool, fixedVHD bool, version string) error { diffDisks bool, fixedVHD bool, version string) error {
opts := scriptOptions{ opts := scriptOptions{
Version: version, Version: version,
VMName: vmName, VMName: vmName,

3
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/ChrisTrenkamp/goxpath v0.0.0-20170625215350-4fe035839290 github.com/ChrisTrenkamp/goxpath v0.0.0-20170625215350-4fe035839290
github.com/NaverCloudPlatform/ncloud-sdk-go v0.0.0-20180110055012-c2e73f942591 github.com/NaverCloudPlatform/ncloud-sdk-go v0.0.0-20180110055012-c2e73f942591
github.com/PuerkitoBio/goquery v1.5.0 // indirect github.com/PuerkitoBio/goquery v1.5.0 // indirect
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/abdullin/seq v0.0.0-20160510034733-d5467c17e7af // indirect
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f
@ -84,6 +84,7 @@ require (
github.com/mitchellh/go-fs v0.0.0-20180402234041-7b48fa161ea7 github.com/mitchellh/go-fs v0.0.0-20180402234041-7b48fa161ea7
github.com/mitchellh/go-homedir v1.0.0 github.com/mitchellh/go-homedir v1.0.0
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed
github.com/mitchellh/gox v1.0.1 // indirect
github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/iochan v1.0.0
github.com/mitchellh/mapstructure v0.0.0-20180111000720-b4575eea38cc github.com/mitchellh/mapstructure v0.0.0-20180111000720-b4575eea38cc
github.com/mitchellh/panicwrap v0.0.0-20170106182340-fce601fe5557 github.com/mitchellh/panicwrap v0.0.0-20170106182340-fce601fe5557

5
go.sum
View File

@ -27,6 +27,8 @@ github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
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 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-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 h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14=
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw=
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e h1:/8wOj52pewmIX/8d5eVO3t7Rr3astkBI/ruyg4WNqRo= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e h1:/8wOj52pewmIX/8d5eVO3t7Rr3astkBI/ruyg4WNqRo=
@ -187,6 +189,7 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0=
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
@ -280,6 +283,8 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed h1:FI2NIv6fpef6BQl2u3IZX/Cj20tfypRF4yd+uaHOMtI= github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed h1:FI2NIv6fpef6BQl2u3IZX/Cj20tfypRF4yd+uaHOMtI=
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed/go.mod h1:3rdaFaCv4AyBgu5ALFM0+tSuHrBh6v692nyQe3ikrq0= github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed/go.mod h1:3rdaFaCv4AyBgu5ALFM0+tSuHrBh6v692nyQe3ikrq0=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=

View File

@ -144,7 +144,7 @@ IFS="${OLDIFS}"
# Copy our OS/Arch to the bin/ directory # Copy our OS/Arch to the bin/ directory
echo "==> Copying binaries for this platform..." echo "==> Copying binaries for this platform..."
DEV_PLATFORM="./pkg/${XC_OS}_${XC_ARCH}" DEV_PLATFORM="./pkg/$(go env GOOS)_$(go env GOARCH)"
for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do
cp -v ${F} bin/ cp -v ${F} bin/
cp -v ${F} "${MAIN_GOPATH}/bin/" cp -v ${F} "${MAIN_GOPATH}/bin/"

View File

@ -497,6 +497,8 @@ func (c *Client) GetNextID(currentID int) (nextID int, err error) {
} }
} }
nextID, err = strconv.Atoi(data["data"].(string)) nextID, err = strconv.Atoi(data["data"].(string))
} else if strings.HasPrefix(err.Error(), "400 ") {
return c.GetNextID(currentID + 1)
} }
return return
} }

View File

@ -26,7 +26,7 @@ type ConfigQemu struct {
Name string `json:"name"` Name string `json:"name"`
Description string `json:"desc"` Description string `json:"desc"`
Onboot bool `json:"onboot"` Onboot bool `json:"onboot"`
Agent string `json:"agent"` Agent int `json:"agent"`
Memory int `json:"memory"` Memory int `json:"memory"`
QemuOs string `json:"os"` QemuOs string `json:"os"`
QemuCores int `json:"cores"` QemuCores int `json:"cores"`
@ -251,9 +251,16 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
if _, isSet := vmConfig["onboot"]; isSet { if _, isSet := vmConfig["onboot"]; isSet {
onboot = Itob(int(vmConfig["onboot"].(float64))) onboot = Itob(int(vmConfig["onboot"].(float64)))
} }
agent := "1"
agent := 0
if _, isSet := vmConfig["agent"]; isSet { 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" ostype := "other"
if _, isSet := vmConfig["ostype"]; isSet { if _, isSet := vmConfig["ostype"]; isSet {
@ -299,6 +306,9 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
if _, isSet := vmConfig["searchdomain"]; isSet { if _, isSet := vmConfig["searchdomain"]; isSet {
config.Searchdomain = vmConfig["searchdomain"].(string) config.Searchdomain = vmConfig["searchdomain"].(string)
} }
if _, isSet := vmConfig["nameserver"]; isSet {
config.Nameserver = vmConfig["nameserver"].(string)
}
if _, isSet := vmConfig["sshkeys"]; isSet { if _, isSet := vmConfig["sshkeys"]; isSet {
config.Sshkeys, _ = url.PathUnescape(vmConfig["sshkeys"].(string)) config.Sshkeys, _ = url.PathUnescape(vmConfig["sshkeys"].(string))
} }
@ -330,6 +340,7 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
// //
diskConfMap := QemuDevice{ diskConfMap := QemuDevice{
"id": diskID,
"type": diskType, "type": diskType,
"storage": storageName, "storage": storageName,
"file": fileName, "file": fileName,
@ -345,11 +356,10 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
} }
// Add networks. // Add networks.
nicNameRe := regexp.MustCompile(`net\d+`)
nicNames := []string{} nicNames := []string{}
for k, _ := range vmConfig { 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]) nicNames = append(nicNames, nicName[0])
} }
} }
@ -358,13 +368,13 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
nicConfStr := vmConfig[nicName] nicConfStr := vmConfig[nicName]
nicConfList := strings.Split(nicConfStr.(string), ",") nicConfList := strings.Split(nicConfStr.(string), ",")
//
id := rxDeviceID.FindStringSubmatch(nicName) id := rxDeviceID.FindStringSubmatch(nicName)
nicID, _ := strconv.Atoi(id[0]) nicID, _ := strconv.Atoi(id[0])
model, macaddr := ParseSubConf(nicConfList[0], "=") model, macaddr := ParseSubConf(nicConfList[0], "=")
// Add model and MAC address. // Add model and MAC address.
nicConfMap := QemuDevice{ nicConfMap := QemuDevice{
"id": nicID,
"model": model, "model": model,
"macaddr": macaddr, "macaddr": macaddr,
} }
@ -441,7 +451,7 @@ func RemoveSshForwardUsernet(vmr *VmRef, client *Client) (err error) {
func MaxVmId(client *Client) (max int, err error) { func MaxVmId(client *Client) (max int, err error) {
resp, err := client.GetVmList() resp, err := client.GetVmList()
vms := resp["data"].([]interface{}) vms := resp["data"].([]interface{})
max = 0 max = 100
for vmii := range vms { for vmii := range vms {
vm := vms[vmii].(map[string]interface{}) vm := vms[vmii].(map[string]interface{})
vmid := int(vm["vmid"].(float64)) vmid := int(vm["vmid"].(float64))
@ -524,6 +534,7 @@ func (c ConfigQemu) CreateQemuNetworksParams(vmID int, params map[string]interfa
// For backward compatibility. // For backward compatibility.
if len(c.QemuNetworks) == 0 && len(c.QemuNicModel) > 0 { if len(c.QemuNetworks) == 0 && len(c.QemuNicModel) > 0 {
deprecatedStyleMap := QemuDevice{ deprecatedStyleMap := QemuDevice{
"id": 0,
"model": c.QemuNicModel, "model": c.QemuNicModel,
"bridge": c.QemuBrige, "bridge": c.QemuBrige,
"macaddr": c.QemuMacAddr, "macaddr": c.QemuMacAddr,
@ -602,6 +613,7 @@ func (c ConfigQemu) CreateQemuDisksParams(
} }
} }
deprecatedStyleMap := QemuDevice{ deprecatedStyleMap := QemuDevice{
"id": 0,
"type": dType, "type": dType,
"storage": c.Storage, "storage": c.Storage,
"size": c.DiskSize, "size": c.DiskSize,

2
vendor/modules.txt vendored
View File

@ -51,7 +51,7 @@ github.com/NaverCloudPlatform/ncloud-sdk-go/request
github.com/NaverCloudPlatform/ncloud-sdk-go/oauth github.com/NaverCloudPlatform/ncloud-sdk-go/oauth
# github.com/PuerkitoBio/goquery v1.5.0 # github.com/PuerkitoBio/goquery v1.5.0
github.com/PuerkitoBio/goquery github.com/PuerkitoBio/goquery
# 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/Telmate/proxmox-api-go/proxmox
# github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e # github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e
github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors