mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 01:36:11 +08:00
update vendor & bugfix
This commit is contained in:
5
Gopkg.lock
generated
5
Gopkg.lock
generated
@@ -1676,7 +1676,7 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:6277045f9c9a63d84e1aa48c7ad3c1f42ea6523bc54ea92e772d541c78e37404"
|
||||
digest = "1:37d4e9b3030c077522fc5669b497a25ce53429da77d5e592226658e57cc604bb"
|
||||
name = "yunion.io/x/pkg"
|
||||
packages = [
|
||||
"gotypes",
|
||||
@@ -1710,7 +1710,7 @@
|
||||
"utils",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "e2e42205d868c26829b9322b40cdc48f24fed379"
|
||||
revision = "5fbe7b39e5f599aa49f6f597d57da460d93c26ff"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -1826,6 +1826,7 @@
|
||||
"golang.org/x/net/ipv4",
|
||||
"golang.org/x/sys/unix",
|
||||
"gopkg.in/gin-gonic/gin.v1",
|
||||
"gopkg.in/yaml.v2",
|
||||
"k8s.io/api/core/v1",
|
||||
"k8s.io/apimachinery/pkg/api/errors",
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
|
||||
@@ -270,6 +270,14 @@ func (self *SDisk) GetMountpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMountServerId() string {
|
||||
if len(self.Attachments) > 0 {
|
||||
return self.Attachments[0].ServerID
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) GetAccessPath() string {
|
||||
return ""
|
||||
}
|
||||
@@ -325,8 +333,55 @@ func (self *SDisk) Resize(ctx context.Context, newSizeMB int64) error {
|
||||
return self.storage.zone.region.resizeDisk(self.GetId(), sizeGb)
|
||||
}
|
||||
|
||||
func (self *SDisk) Detach() error {
|
||||
err := self.storage.zone.region.DetachDisk(self.GetMountServerId(), self.GetId())
|
||||
if err != nil {
|
||||
log.Debugf("detach server %s disk %s failed: %s", self.GetMountServerId(), self.GetId(), err)
|
||||
return err
|
||||
}
|
||||
|
||||
return cloudprovider.WaitStatus(self, models.DISK_READY, 5*time.Second, 60*time.Second)
|
||||
}
|
||||
|
||||
func (self *SDisk) Attach(device string) error {
|
||||
err := self.storage.zone.region.AttachDisk(self.GetMountServerId(), self.GetId(), device)
|
||||
if err != nil {
|
||||
log.Debugf("attach server %s disk %s failed: %s", self.GetMountServerId(), self.GetId(), err)
|
||||
return err
|
||||
}
|
||||
|
||||
return cloudprovider.WaitStatus(self, models.DISK_READY, 5*time.Second, 60*time.Second)
|
||||
}
|
||||
|
||||
// 在线卸载磁盘 https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0036046828.html
|
||||
// 对于挂载在系统盘盘位(也就是“/dev/sda”或“/dev/vda”挂载点)上的磁盘,当前仅支持离线卸载
|
||||
func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error) {
|
||||
return self.storage.zone.region.resetDisk(self.GetId(), snapshotId)
|
||||
mountpoint := self.GetMountpoint()
|
||||
if mountpoint == "/dev/sda" || mountpoint == "/dev/vda" {
|
||||
err := self.Detach()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
diskId, err := self.storage.zone.region.resetDisk(self.GetId(), snapshotId)
|
||||
if err != nil {
|
||||
return diskId, err
|
||||
}
|
||||
|
||||
err = cloudprovider.WaitStatus(self, models.DISK_READY, 5*time.Second, 300*time.Second)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if mountpoint == "/dev/sda" || mountpoint == "/dev/vda" {
|
||||
err := self.Attach(mountpoint)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return diskId, nil
|
||||
}
|
||||
|
||||
// 华为云不支持重置
|
||||
|
||||
@@ -105,7 +105,7 @@ func (self *SRegion) GetOrderResources(orderId string, resource_ids []string, on
|
||||
queries["only_main_resource"] = "1"
|
||||
}
|
||||
|
||||
err = DoList(self.ecsClient.Orders.GetPeriodResourceList, queries, &resources)
|
||||
err = doListAll(self.ecsClient.Orders.GetPeriodResourceList, queries, &resources)
|
||||
return resources, err
|
||||
}
|
||||
|
||||
|
||||
@@ -338,6 +338,8 @@ func (self *SRegion) SyncSecurityGroup(secgroupId string, vpcId string, name str
|
||||
secgroupId = extID
|
||||
}
|
||||
|
||||
// 华为云默认deny。不需要显式指定
|
||||
rules = SecurityRuleSetToAllowSet(rules)
|
||||
return secgroupId, self.syncSecgroupRules(secgroupId, rules)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ https://support.huaweicloud.com/usermanual-vpc/zh-cn_topic_0073379079.html
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sort"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/secrules"
|
||||
)
|
||||
@@ -68,6 +70,33 @@ func compatibleSecurityGroupRule(r SecurityGroupRule) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 将安全组规则全部转换为等价的allow规则
|
||||
func SecurityRuleSetToAllowSet(srs secrules.SecurityRuleSet) secrules.SecurityRuleSet {
|
||||
inRuleSet := secrules.SecurityRuleSet{}
|
||||
outRuleSet := secrules.SecurityRuleSet{}
|
||||
|
||||
for _, rule := range srs {
|
||||
if rule.Direction == secrules.SecurityRuleIngress {
|
||||
inRuleSet = append(inRuleSet, rule)
|
||||
}
|
||||
|
||||
if rule.Direction == secrules.SecurityRuleEgress {
|
||||
outRuleSet = append(outRuleSet, rule)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(inRuleSet)
|
||||
sort.Sort(outRuleSet)
|
||||
|
||||
inRuleSet = inRuleSet.AllowList()
|
||||
outRuleSet = outRuleSet.AllowList()
|
||||
|
||||
ret := secrules.SecurityRuleSet{}
|
||||
ret = append(ret, inRuleSet...)
|
||||
ret = append(ret, outRuleSet...)
|
||||
return ret
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.ID
|
||||
}
|
||||
|
||||
6
vendor/yunion.io/x/pkg/util/regutils/regutils.go
generated
vendored
6
vendor/yunion.io/x/pkg/util/regutils/regutils.go
generated
vendored
@@ -27,6 +27,7 @@ var FULLISO_TIME_REG *regexp.Regexp
|
||||
var COMPACT_TIME_REG *regexp.Regexp
|
||||
var MYSQL_TIME_REG *regexp.Regexp
|
||||
var NORMAL_TIME_REG *regexp.Regexp
|
||||
var FULLNORMAL_TIME_REG *regexp.Regexp
|
||||
var RFC2882_TIME_REG *regexp.Regexp
|
||||
var EMAIL_REG *regexp.Regexp
|
||||
var CHINA_MOBILE_REG *regexp.Regexp
|
||||
@@ -56,6 +57,7 @@ func init() {
|
||||
COMPACT_TIME_REG = regexp.MustCompile(`^\d{14}$`)
|
||||
MYSQL_TIME_REG = regexp.MustCompile(`^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$`)
|
||||
NORMAL_TIME_REG = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$`)
|
||||
FULLNORMAL_TIME_REG = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}$`)
|
||||
RFC2882_TIME_REG = regexp.MustCompile(`[A-Z][a-z]{2}, [0-9]{1,2} [A-Z][a-z]{2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3}`)
|
||||
EMAIL_REG = regexp.MustCompile(`^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$`)
|
||||
CHINA_MOBILE_REG = regexp.MustCompile(`^1[0-9-]{10}$`)
|
||||
@@ -171,6 +173,10 @@ func MatchNormalTime(str string) bool {
|
||||
return NORMAL_TIME_REG.MatchString(str)
|
||||
}
|
||||
|
||||
func MatchFullNormalTime(str string) bool {
|
||||
return FULLNORMAL_TIME_REG.MatchString(str)
|
||||
}
|
||||
|
||||
func MatchRFC2882Time(str string) bool {
|
||||
return RFC2882_TIME_REG.MatchString(str)
|
||||
}
|
||||
|
||||
7
vendor/yunion.io/x/pkg/util/timeutils/timeutils.go
generated
vendored
7
vendor/yunion.io/x/pkg/util/timeutils/timeutils.go
generated
vendored
@@ -26,6 +26,7 @@ const (
|
||||
FullIsoTimeFormat = "2006-01-02T15:04:05.000000Z"
|
||||
MysqlTimeFormat = "2006-01-02 15:04:05"
|
||||
NormalTimeFormat = "2006-01-02T15:04:05"
|
||||
FullNormalTimeFormat = "2006-01-02T15:04:05.000000"
|
||||
CompactTimeFormat = "20060102150405"
|
||||
DateFormat = "2006-01-02"
|
||||
ShortDateFormat = "20060102"
|
||||
@@ -84,6 +85,10 @@ func ParseNormalTime(str string) (time.Time, error) {
|
||||
return time.Parse(NormalTimeFormat, str)
|
||||
}
|
||||
|
||||
func ParseFullNormalTime(str string) (time.Time, error) {
|
||||
return time.Parse(FullNormalTimeFormat, str)
|
||||
}
|
||||
|
||||
func ParseCompactTime(str string) (time.Time, error) {
|
||||
return time.Parse(CompactTimeFormat, str)
|
||||
}
|
||||
@@ -111,6 +116,8 @@ func ParseTimeStr(str string) (time.Time, error) {
|
||||
return ParseMysqlTime(str)
|
||||
} else if regutils.MatchNormalTime(str) {
|
||||
return ParseNormalTime(str)
|
||||
} else if regutils.MatchFullNormalTime(str) {
|
||||
return ParseFullNormalTime(str)
|
||||
} else if regutils.MatchRFC2882Time(str) {
|
||||
return ParseRFC2882Time(str)
|
||||
} else if regutils.MatchCompactTime(str) {
|
||||
|
||||
Reference in New Issue
Block a user