mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #13299 from ioito/hotfix/qx-nutanix-net-vlan-id
fix(region): nutanix duplicate vlan id
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -145,16 +146,26 @@ func (self *SRegion) CreateVpc(opts *cloudprovider.VpcCreateOptions) (*SVpc, err
|
||||
}
|
||||
|
||||
}
|
||||
vpcs, err := self.GetVpcs()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetVpcs")
|
||||
}
|
||||
vlanId := -1
|
||||
for i := range vpcs {
|
||||
if vpcs[i].VlanID == vlanId+1 {
|
||||
vlanId = vpcs[i].VlanID
|
||||
}
|
||||
}
|
||||
params := map[string]interface{}{
|
||||
"name": opts.NAME,
|
||||
"annotation": opts.Desc,
|
||||
"ip_config": ipConfig,
|
||||
"vlan_id": 0,
|
||||
"vlan_id": vlanId + 1,
|
||||
}
|
||||
ret := struct {
|
||||
NetworkUUID string
|
||||
}{}
|
||||
err := self.post("networks", jsonutils.Marshal(params), &ret)
|
||||
err = self.post("networks", jsonutils.Marshal(params), &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user