mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #4701 from tb365/bugfix/tb-bugfix-0107
Bugfix/tb bugfix 0107
This commit is contained in:
@@ -1262,6 +1262,8 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred
|
||||
startIp = iprange.StartIp().StepUp()
|
||||
endIp = iprange.EndIp().StepDown()
|
||||
input.GuestIpMask = int64(prefix.MaskLen)
|
||||
// 根据掩码得到合法的GuestIpPrefix
|
||||
input.GuestIpPrefix = prefix.String()
|
||||
} else {
|
||||
startIp, err = netutils.NewIPV4Addr(input.GuestIpStart)
|
||||
if err != nil {
|
||||
|
||||
@@ -1125,6 +1125,7 @@ func (self *SServerSku) PerformDisable(ctx context.Context, userCred mcclient.To
|
||||
|
||||
func (self *SServerSku) syncWithCloudSku(ctx context.Context, userCred mcclient.TokenCredential, extSku SServerSku) error {
|
||||
_, err := db.Update(self, func() error {
|
||||
self.ZoneId = extSku.ZoneId
|
||||
self.PrepaidStatus = extSku.PrepaidStatus
|
||||
self.PostpaidStatus = extSku.PostpaidStatus
|
||||
return nil
|
||||
|
||||
@@ -115,9 +115,9 @@ func (self *SNetwork) GetIpMask() int8 {
|
||||
|
||||
func (self *SNetwork) GetGateway() string {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CIDR)
|
||||
endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255
|
||||
endIp = endIp.StepDown() // 254
|
||||
return endIp.String()
|
||||
startIp := pref.Address.NetAddr(pref.MaskLen) // 0
|
||||
startIp = startIp.StepUp() // 1
|
||||
return startIp.String()
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetServerType() string {
|
||||
|
||||
@@ -200,7 +200,12 @@ func (self *SElasticcache) GetArchType() string {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetNodeType() string {
|
||||
return ""
|
||||
// single(单副本) | double(双副本)
|
||||
if strings.Contains(self.ResourceSpecCode, "single") {
|
||||
return "single"
|
||||
} else {
|
||||
return "double"
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetEngine() string {
|
||||
|
||||
@@ -122,9 +122,9 @@ func (self *SNetwork) GetIpMask() int8 {
|
||||
|
||||
func (self *SNetwork) GetGateway() string {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CIDR)
|
||||
endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255
|
||||
endIp = endIp.StepDown() // 254
|
||||
return endIp.String()
|
||||
startIp := pref.Address.NetAddr(pref.MaskLen) // 0
|
||||
startIp = startIp.StepUp() // 1
|
||||
return startIp.String()
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetServerType() string {
|
||||
|
||||
@@ -16,11 +16,12 @@ package huawei
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
@@ -160,22 +161,13 @@ func (self *SWire) getNetworkById(networkId string) *SNetwork {
|
||||
}
|
||||
|
||||
func getDefaultGateWay(cidr string) (string, error) {
|
||||
ip, _, err := net.ParseCIDR(cidr)
|
||||
pref, err := netutils.NewIPV4Prefix(cidr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "getDefaultGateWay.NewIPV4Prefix")
|
||||
}
|
||||
|
||||
ipv4 := ip.To4()
|
||||
if ipv4 == nil || len(ip.String()) == net.IPv6len {
|
||||
return "", fmt.Errorf("ipv6 is not supported currently")
|
||||
}
|
||||
|
||||
if ipv4[3] != 0 {
|
||||
return "", fmt.Errorf("the last byte of ip address must be zero. e.g 192.168.0.0/16")
|
||||
}
|
||||
|
||||
ipv4[3] = 1
|
||||
return ipv4.String(), nil
|
||||
startIp := pref.Address.NetAddr(pref.MaskLen) // 0
|
||||
startIp = startIp.StepUp() // 1
|
||||
return startIp.String(), nil
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-vpc/zh-cn_topic_0020090590.html
|
||||
|
||||
Reference in New Issue
Block a user