mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 12:32:55 +08:00
fix(region): aws tag sync
This commit is contained in:
@@ -84,7 +84,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523061656-13cfa7fc15bd
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523113658-0669df73bac9
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230428104347-7c2fdff8e8e7
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1185,8 +1185,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523061656-13cfa7fc15bd h1:gAt+8sC+OlIGZWBjRDBnpVxZiSG85zEK1tBLlEaB9Ko=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523061656-13cfa7fc15bd/go.mod h1:crMeQeaNaZefTXfXbQkoj5SStggqkSNVABHtYBFjM3Y=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523113658-0669df73bac9 h1:3BB/EC6dSg+xP7VFTEZNAODp/oWZ7oX4DtSU4JRQDLk=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523113658-0669df73bac9/go.mod h1:crMeQeaNaZefTXfXbQkoj5SStggqkSNVABHtYBFjM3Y=
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII=
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
Vendored
+1
-1
@@ -1457,7 +1457,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523061656-13cfa7fc15bd
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230523113658-0669df73bac9
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+2
@@ -636,6 +636,7 @@ func (self *SRegion) AddRdsTagsToResource(arn string, tags map[string]string) er
|
||||
for k, v := range tags {
|
||||
params[fmt.Sprintf("Tags.member.%d.Key", i)] = k
|
||||
params[fmt.Sprintf("Tags.member.%d.Value", i)] = v
|
||||
i++
|
||||
}
|
||||
return self.rdsRequest("AddTagsToResource", params, nil)
|
||||
}
|
||||
@@ -650,6 +651,7 @@ func (self *SRegion) RemoveRdsTagsFromResource(arn string, tags map[string]strin
|
||||
i := 1
|
||||
for k := range tags {
|
||||
params[fmt.Sprintf("TagKeys.member.%d", i)] = k
|
||||
i++
|
||||
}
|
||||
return self.rdsRequest("RemoveTagsFromResource", params, nil)
|
||||
}
|
||||
|
||||
+2
@@ -478,6 +478,7 @@ func (self *SElasticache) SetTags(tags map[string]string, replace bool) error {
|
||||
i := 1
|
||||
for k := range tags {
|
||||
params[fmt.Sprintf("TagKeys.member.%d", i)] = k
|
||||
i++
|
||||
}
|
||||
return self.region.redisRequest("RemoveTagsFromResource", params, nil)
|
||||
}
|
||||
@@ -489,6 +490,7 @@ func (self *SElasticache) SetTags(tags map[string]string, replace bool) error {
|
||||
for k, v := range tags {
|
||||
params[fmt.Sprintf("Tags.member.%d.Key", i)] = k
|
||||
params[fmt.Sprintf("Tags.member.%d.Value", i)] = v
|
||||
i++
|
||||
}
|
||||
return self.region.redisRequest("AddTagsToResource", params, nil)
|
||||
}
|
||||
|
||||
+9
-12
@@ -208,10 +208,6 @@ func (self *SInstance) Refresh() error {
|
||||
return jsonutils.Update(self, new)
|
||||
}
|
||||
|
||||
func (self *SInstance) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SInstance) GetInstanceType() string {
|
||||
return self.InstanceType
|
||||
}
|
||||
@@ -225,7 +221,7 @@ func (self *SInstance) GetTags() (map[string]string, error) {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
return map[string]string{}
|
||||
return self.TagSpec.GetSysTags()
|
||||
}
|
||||
|
||||
func (self *SInstance) GetBillingType() string {
|
||||
@@ -1284,16 +1280,17 @@ func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "FetchTags(self.host.zone.region.ec2Client, %s)", self.InstanceId)
|
||||
}
|
||||
oldTags := map[string]string{}
|
||||
err = oldTagsJson.Unmarshal(oldTags)
|
||||
_oldTags := TagSpec{}
|
||||
err = oldTagsJson.Unmarshal(&_oldTags.Tags)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "(%s).Unmarshal(oldTags)", oldTagsJson.String())
|
||||
}
|
||||
oldTags, err := _oldTags.GetTags()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetTags")
|
||||
}
|
||||
addTags := map[string]string{}
|
||||
for k, v := range tags {
|
||||
if strings.HasPrefix(k, "aws:") {
|
||||
return errors.Wrap(cloudprovider.ErrNotSupported, "The aws: prefix is reserved for AWS use")
|
||||
}
|
||||
if _, ok := oldTags[k]; !ok {
|
||||
addTags[k] = v
|
||||
} else {
|
||||
@@ -1315,12 +1312,12 @@ func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
Arn := self.GetArn()
|
||||
err = self.host.zone.region.UntagResources([]string{Arn}, delTags)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "self.host.zone.region.UntagResources([]string{%s}, %s)", Arn, jsonutils.Marshal(delTags).String())
|
||||
return errors.Wrapf(err, "UntagResources")
|
||||
}
|
||||
delete(addTags, "Name")
|
||||
err = self.host.zone.region.TagResources([]string{Arn}, addTags)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "self.host.zone.region.TagResources([]string{%s}, %s)", Arn, jsonutils.Marshal(addTags).String())
|
||||
return errors.Wrapf(err, "TagResources")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+14
@@ -80,11 +80,25 @@ func (self *TagSpec) GetTags() (map[string]string, error) {
|
||||
if k == "Name" || k == "Description" {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(k, "aws:") {
|
||||
continue
|
||||
}
|
||||
ret[k] = v
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *TagSpec) GetSysTags() map[string]string {
|
||||
ret := map[string]string{}
|
||||
for k, v := range self.Tags {
|
||||
if !strings.HasPrefix(k, "aws:") {
|
||||
continue
|
||||
}
|
||||
ret[k] = v
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (self *TagSpec) SetNameTag(v string) {
|
||||
self.SetTag("Name", v)
|
||||
}
|
||||
|
||||
+3
-1
@@ -232,10 +232,12 @@ func (disk *SDisk) GetStatus() string {
|
||||
return api.DISK_DETACHING
|
||||
case DISK_STATUS_EXTENDING:
|
||||
return api.DISK_RESIZING
|
||||
case DISK_STATUS_RETYPING, DISK_STATUS_AVAILABLE, DISK_STATUS_RESERVED, DISK_STATUS_IN_USE, DISK_STATUS_MAINTENANCE, DISK_STATUS_AWAITING_TRANSFER, DISK_STATUS_BACKING_UP, DISK_STATUS_RESTORING_BACKUP, DISK_STATUS_UPLOADING:
|
||||
case DISK_STATUS_RETYPING, DISK_STATUS_AVAILABLE, DISK_STATUS_IN_USE, DISK_STATUS_MAINTENANCE, DISK_STATUS_AWAITING_TRANSFER, DISK_STATUS_BACKING_UP, DISK_STATUS_RESTORING_BACKUP, DISK_STATUS_UPLOADING:
|
||||
return api.DISK_READY
|
||||
case DISK_STATUS_DELETING:
|
||||
return api.DISK_DEALLOC
|
||||
case DISK_STATUS_RESERVED:
|
||||
return api.DISK_RESET
|
||||
case DISK_STATUS_ERROR:
|
||||
return api.DISK_ALLOC_FAILED
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user