fix(region): fix #18397 esxi vm set tags

This commit is contained in:
ioito
2023-10-26 11:39:58 +08:00
parent aeff5ea923
commit 503f1db671
4 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -83,7 +83,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.20231026030746-e2af815a522c
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231026033713-0e4480cdfc28
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
+2 -2
View File
@@ -1179,8 +1179,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.20231026030746-e2af815a522c h1:nTOzLhTp3X9PXYYAQCi/50GVCNkqtcuL/9XiEyvdJ/4=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231026030746-e2af815a522c/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231026033713-0e4480cdfc28 h1:ilXUtLYpjxwkY6bCO8sFwg7owx9ylk358tuhIiGwJzg=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231026033713-0e4480cdfc28/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
+1 -1
View File
@@ -1438,7 +1438,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.20231026030746-e2af815a522c
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231026033713-0e4480cdfc28
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+9
View File
@@ -33,6 +33,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/util/billing"
"yunion.io/x/pkg/util/imagetools"
"yunion.io/x/pkg/util/netutils"
@@ -112,6 +113,10 @@ func (svm *SVirtualMachine) GetSecurityGroupIds() ([]string, error) {
}
func (svm *SVirtualMachine) GetTags() (map[string]string, error) {
// not support tags
if gotypes.IsNil(svm.manager.client.ServiceContent.CustomFieldsManager) {
return nil, cloudprovider.ErrNotSupported
}
ret := map[int32]string{}
for _, val := range svm.object.Entity().ExtensibleManagedObject.AvailableField {
ret[val.Key] = val.Name
@@ -139,6 +144,10 @@ func (svm *SVirtualMachine) GetTags() (map[string]string, error) {
}
func (svm *SVirtualMachine) SetTags(tags map[string]string, replace bool) error {
// not support tags
if gotypes.IsNil(svm.manager.client.ServiceContent.CustomFieldsManager) {
return cloudprovider.ErrNotSupported
}
oldTags, err := svm.GetTags()
if err != nil {
return errors.Wrapf(err, "GetTags")