Merge pull request #310 in YUNIONIO/onecloud from ~ZHOUYOUSONG/onecloud:bugfix/yousong-allow-change-bw-zero to release/2.1.0

* commit 'c96849e3343879e60925d2ab92bcfbbb6f43dff1':
  guests: allow change nic bandwidth to 0
This commit is contained in:
邱剑
2018-10-18 17:58:51 +08:00
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ func (manager *SGuestnetworkManager) newGuestNetwork(ctx context.Context, userCr
driver = "virtio"
}
gn.Driver = driver
if bwLimit > 0 {
if bwLimit >= 0 {
gn.BwLimit = bwLimit
}
+2 -2
View File
@@ -2881,8 +2881,8 @@ func (self *SGuest) PerformChangeBandwidth(ctx context.Context, userCred mcclien
return nil, httperrors.NewBadRequestError("Index Not fount or out of NIC index")
}
bandwidth, err := data.Int("bandwidth")
if err != nil || bandwidth <= 0 {
return nil, httperrors.NewBadRequestError("Bandwidth must be larger than 0")
if err != nil || bandwidth < 0 {
return nil, httperrors.NewBadRequestError("Bandwidth must be non-negative")
}
guestnic := &guestnics[index]
if guestnic.BwLimit != int(bandwidth) {