mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): nutanix image and vpc vlan id
This commit is contained in:
@@ -207,7 +207,7 @@ func (self *SRegion) CreateImage(storageId string, opts *cloudprovider.SImageCre
|
||||
return nil, errors.Wrapf(err, "upload")
|
||||
}
|
||||
resp.Unmarshal(&ret)
|
||||
err = cloudprovider.Wait(time.Second*5, time.Minute*10, func() (bool, error) {
|
||||
err = cloudprovider.Wait(time.Second*10, time.Hour*2, func() (bool, error) {
|
||||
task, err := self.GetTask(ret.TaskUUID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -147,10 +148,16 @@ func (self *SInstance) CreateDisk(ctx context.Context, opts *cloudprovider.Guest
|
||||
if !utils.IsInStringArray(driver, []string{"ide", "scsi", "pci", "sata"}) {
|
||||
driver = "scsi"
|
||||
}
|
||||
idx := -1
|
||||
idx, ids := -1, []int{}
|
||||
for _, disk := range self.VMDiskInfo {
|
||||
if disk.DiskAddress.DeviceBus == driver && disk.DiskAddress.DeviceIndex > idx && disk.DiskAddress.DeviceIndex == idx+1 {
|
||||
idx = disk.DiskAddress.DeviceIndex
|
||||
if disk.DiskAddress.DeviceBus == driver {
|
||||
ids = append(ids, disk.DiskAddress.DeviceIndex)
|
||||
}
|
||||
}
|
||||
sort.Ints(ids)
|
||||
for _, id := range ids {
|
||||
if id == idx+1 {
|
||||
idx = id
|
||||
}
|
||||
}
|
||||
params := map[string]interface{}{
|
||||
@@ -365,7 +372,11 @@ func (self *SInstance) StartVM(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (self *SInstance) StopVM(ctx context.Context, opts *cloudprovider.ServerStopOptions) error {
|
||||
return self.host.zone.region.SetInstancePowerState(self.UUID, "acpi_shutdown")
|
||||
act := "acpi_shutdown"
|
||||
if opts.IsForce {
|
||||
act = "off"
|
||||
}
|
||||
return self.host.zone.region.SetInstancePowerState(self.UUID, act)
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateUserData(userData string) error {
|
||||
|
||||
@@ -17,6 +17,7 @@ package nutanix
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -150,10 +151,14 @@ func (self *SRegion) CreateVpc(opts *cloudprovider.VpcCreateOptions) (*SVpc, err
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetVpcs")
|
||||
}
|
||||
vlanId := -1
|
||||
vlanId, vlanIds := -1, []int{}
|
||||
for i := range vpcs {
|
||||
if vpcs[i].VlanID == vlanId+1 {
|
||||
vlanId = vpcs[i].VlanID
|
||||
vlanIds = append(vlanIds, vpcs[i].VlanID)
|
||||
}
|
||||
sort.Ints(vlanIds)
|
||||
for _, vlan := range vlanIds {
|
||||
if vlan == vlanId+1 {
|
||||
vlanId = vlan
|
||||
}
|
||||
}
|
||||
params := map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user