diff --git a/go.mod b/go.mod index e30749a79e..d3cd1bc824 100644 --- a/go.mod +++ b/go.mod @@ -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.20230323054147-6e2b259a89f2 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230323062012-21f8a2ca0add yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd yunion.io/x/log v1.0.0 diff --git a/go.sum b/go.sum index 8065762f72..07c6e3c210 100644 --- a/go.sum +++ b/go.sum @@ -1164,8 +1164,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.20230323054147-6e2b259a89f2 h1:vqU3NZvfTPFKnj8ycGqH4CbC5q7y6GpCDMpVQjFjU8w= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230323054147-6e2b259a89f2/go.mod h1:sWqblYRhQCO63xeKdxdAT3wczCCY8Mc+TDa3WD/a5Kg= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230323062012-21f8a2ca0add h1:w0kPDxDar0F0p9fWSBoqTCsBojhFrRzxsiJYiGO3bLY= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230323062012-21f8a2ca0add/go.mod h1:sWqblYRhQCO63xeKdxdAT3wczCCY8Mc+TDa3WD/a5Kg= 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= diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index f3243e60f4..8644a7bb6d 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -2911,6 +2911,9 @@ func (self *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.Token self.Hypervisor = extVM.GetHypervisor() + if len(self.Description) == 0 { + self.Description = extVM.GetDescription() + } self.IsEmulated = extVM.IsEmulated() if provider.GetFactory().IsSupportPrepaidResources() && !recycle { @@ -2973,6 +2976,7 @@ func (manager *SGuestManager) newCloudVM(ctx context.Context, userCred mcclient. guest.Hostname = pinyinutils.Text2Pinyin(extVM.GetHostname()) guest.InternetMaxBandwidthOut = extVM.GetInternetMaxBandwidthOut() guest.Throughput = extVM.GetThroughput() + guest.Description = extVM.GetDescription() guest.IsEmulated = extVM.IsEmulated() diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index bd48a99a97..219981e00c 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -537,6 +537,9 @@ func (self *SVpc) SyncWithCloudVpc(ctx context.Context, userCred mcclient.TokenC self.IsEmulated = extVPC.IsEmulated() self.ExternalAccessMode = extVPC.GetExternalAccessMode() + if len(self.Description) == 0 { + self.Description = extVPC.GetDescription() + } if createdAt := extVPC.GetCreatedAt(); !createdAt.IsZero() { self.CreatedAt = createdAt } @@ -574,6 +577,7 @@ func (manager *SVpcManager) newFromCloudVpc(ctx context.Context, userCred mcclie vpc.SetModelManager(manager, &vpc) vpc.Status = extVPC.GetStatus() + vpc.Description = extVPC.GetDescription() vpc.ExternalId = extVPC.GetGlobalId() vpc.IsDefault = extVPC.GetIsDefault() vpc.CidrBlock = extVPC.GetCidrBlock() diff --git a/vendor/modules.txt b/vendor/modules.txt index 57c860ee4a..dfcd21d6ab 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1442,7 +1442,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.20230323054147-6e2b259a89f2 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230323062012-21f8a2ca0add ## explicit; go 1.18 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go index c46f3e6a9f..b9ee7c3a66 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go @@ -31,6 +31,7 @@ type ICloudResource interface { GetName() string GetGlobalId() string GetCreatedAt() time.Time + GetDescription() string GetStatus() string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/instance_type.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/instance_type.go index 54b58f8719..05a5737b0e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/instance_type.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/instance_type.go @@ -43,146 +43,150 @@ type SInstanceType struct { Description string } -func (self *SInstanceType) GetCreatedAt() time.Time { +func (insType *SInstanceType) GetCreatedAt() time.Time { return time.Time{} } -func (self *SInstanceType) GetId() string { - return self.InstanceType +func (insType *SInstanceType) GetId() string { + return insType.InstanceType } -func (self *SInstanceType) GetName() string { - return self.InstanceType +func (insType *SInstanceType) GetName() string { + return insType.InstanceType } -func (self *SInstanceType) GetGlobalId() string { - return self.InstanceType -} - -func (self *SInstanceType) GetStatus() string { +func (insType *SInstanceType) GetDescription() string { return "" } -func (self *SInstanceType) Refresh() error { +func (insType *SInstanceType) GetGlobalId() string { + return insType.InstanceType +} + +func (insType *SInstanceType) GetStatus() string { + return "" +} + +func (insType *SInstanceType) Refresh() error { return nil } -func (self *SInstanceType) IsEmulated() bool { +func (insType *SInstanceType) IsEmulated() bool { return false } -func (self *SInstanceType) GetSysTags() map[string]string { +func (insType *SInstanceType) GetSysTags() map[string]string { return nil } -func (self *SInstanceType) GetTags() (map[string]string, error) { +func (insType *SInstanceType) GetTags() (map[string]string, error) { return nil, nil } -func (self *SInstanceType) SetTags(tags map[string]string, replace bool) error { +func (insType *SInstanceType) SetTags(tags map[string]string, replace bool) error { return nil } -func (self *SInstanceType) GetInstanceTypeFamily() string { - return strings.Split(self.InstanceType, ".")[0] +func (insType *SInstanceType) GetInstanceTypeFamily() string { + return strings.Split(insType.InstanceType, ".")[0] } -func (self *SInstanceType) GetInstanceTypeCategory() string { - return getInstanceCategory(self.GetInstanceTypeFamily()) +func (insType *SInstanceType) GetInstanceTypeCategory() string { + return getInstanceCategory(insType.GetInstanceTypeFamily()) } -func (self *SInstanceType) GetPrepaidStatus() string { +func (insType *SInstanceType) GetPrepaidStatus() string { return "available" } -func (self *SInstanceType) GetPostpaidStatus() string { +func (insType *SInstanceType) GetPostpaidStatus() string { return "available" } // https://support.huaweicloud.com/productdesc-ecs/ecs_01_0066.html // https://support.huaweicloud.com/ecs_faq/ecs_faq_0105.html -func (self *SInstanceType) GetCpuArch() string { +func (insType *SInstanceType) GetCpuArch() string { return apis.OS_ARCH_X86 } -func (self *SInstanceType) GetCpuCoreCount() int { - return self.Cpu +func (insType *SInstanceType) GetCpuCoreCount() int { + return insType.Cpu } -func (self *SInstanceType) GetMemorySizeMB() int { - return self.Ram +func (insType *SInstanceType) GetMemorySizeMB() int { + return insType.Ram } -func (self *SInstanceType) GetOsName() string { +func (insType *SInstanceType) GetOsName() string { return "" } -func (self *SInstanceType) GetSysDiskResizable() bool { +func (insType *SInstanceType) GetSysDiskResizable() bool { return false } -func (self *SInstanceType) GetSysDiskType() string { +func (insType *SInstanceType) GetSysDiskType() string { return "" } -func (self *SInstanceType) GetSysDiskMinSizeGB() int { +func (insType *SInstanceType) GetSysDiskMinSizeGB() int { return 0 } -func (self *SInstanceType) GetSysDiskMaxSizeGB() int { +func (insType *SInstanceType) GetSysDiskMaxSizeGB() int { return 0 } -func (self *SInstanceType) GetAttachedDiskType() string { +func (insType *SInstanceType) GetAttachedDiskType() string { return "" } -func (self *SInstanceType) GetAttachedDiskSizeGB() int { +func (insType *SInstanceType) GetAttachedDiskSizeGB() int { return 0 } -func (self *SInstanceType) GetAttachedDiskCount() int { +func (insType *SInstanceType) GetAttachedDiskCount() int { return 0 } -func (self *SInstanceType) GetDataDiskTypes() string { +func (insType *SInstanceType) GetDataDiskTypes() string { return "" } -func (self *SInstanceType) GetDataDiskMaxCount() int { +func (insType *SInstanceType) GetDataDiskMaxCount() int { return 0 } -func (self *SInstanceType) GetNicType() string { +func (insType *SInstanceType) GetNicType() string { return "" } -func (self *SInstanceType) GetNicMaxCount() int { +func (insType *SInstanceType) GetNicMaxCount() int { return 0 } -func (self *SInstanceType) GetGpuAttachable() bool { +func (insType *SInstanceType) GetGpuAttachable() bool { return false } -func (self *SInstanceType) GetGpuSpec() string { +func (insType *SInstanceType) GetGpuSpec() string { return "" } -func (self *SInstanceType) GetGpuCount() int { +func (insType *SInstanceType) GetGpuCount() int { return 0 } -func (self *SInstanceType) GetGpuMaxCount() int { +func (insType *SInstanceType) GetGpuMaxCount() int { return 0 } -func (self *SInstanceType) Delete() error { +func (insType *SInstanceType) Delete() error { return nil } -func (self *SRegion) GetInstanceTypes() ([]SInstanceType, error) { - resp, err := self.invoke("DescribeInstanceTypes", nil) +func (insType *SRegion) GetInstanceTypes() ([]SInstanceType, error) { + resp, err := insType.invoke("DescribeInstanceTypes", nil) if err != nil { return nil, err } @@ -195,14 +199,14 @@ func (self *SRegion) GetInstanceTypes() ([]SInstanceType, error) { return result.InstanceTypeInfo, err } -func (self *SRegion) GetISkus() ([]cloudprovider.ICloudSku, error) { - instanceTypes, err := self.GetInstanceTypes() +func (insType *SRegion) GetISkus() ([]cloudprovider.ICloudSku, error) { + instanceTypes, err := insType.GetInstanceTypes() if err != nil { return nil, err } iskus := make([]cloudprovider.ICloudSku, len(instanceTypes)) for i := 0; i < len(instanceTypes); i++ { - instanceTypes[i].region = self + instanceTypes[i].region = insType iskus[i] = &instanceTypes[i] } return iskus, nil diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go index 4838b47c1c..7182e9d96b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go @@ -764,6 +764,11 @@ func (self *SVirtualMachine) GetCreatedAt() time.Time { } } +func (self *SVirtualMachine) GetDescription() string { + moVM := self.getVirtualMachine() + return moVM.Config.Annotation +} + func (self *SVirtualMachine) GetExpiredAt() time.Time { return time.Time{} } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backend.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backend.go index d192be8d81..6e17974438 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backend.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backend.go @@ -54,6 +54,10 @@ func (self *SLoadbalancerBackend) GetGlobalId() string { return self.GetId() } +func (self *SLoadbalancerBackend) GetDescription() string { + return "" +} + func (self *SLoadbalancerBackend) GetStatus() string { return api.LB_STATUS_ENABLED } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backendgroup.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backendgroup.go index 9a9e1ee0e5..4f85ac1e5f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backendgroup.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_backendgroup.go @@ -42,6 +42,10 @@ func (self *SLoadBalancerBackendGroup) GetName() string { return self.Name } +func (self *SLoadBalancerBackendGroup) GetDescription() string { + return "" +} + func (self *SLoadBalancerBackendGroup) GetGlobalId() string { return self.backendService.GetGlobalId() } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listener.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listener.go index 005cc20ebf..1f9058f5a0 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listener.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listener.go @@ -59,6 +59,9 @@ func (self *SLoadbalancerListener) GetStatus() string { return api.LB_STATUS_ENABLED } +func (self *SLoadbalancerListener) GetDescription() string { + return "" +} func (self *SLoadbalancerListener) Refresh() error { return nil } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listenerrule.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listenerrule.go index c3ece7d926..4306b82d42 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listenerrule.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/loadbalancer_listenerrule.go @@ -49,6 +49,10 @@ func (self *SLoadbalancerListenerRule) GetGlobalId() string { return self.GetId() } +func (self *SLoadbalancerListenerRule) GetDescription() string { + return "" +} + func (self *SLoadbalancerListenerRule) GetStatus() string { return api.LB_STATUS_ENABLED } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go index d7efd2d9ee..b55cc8432c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go @@ -41,6 +41,10 @@ func (self *SNetwork) GetId() string { return self.wire.vpc.GetId() } +func (self *SNetwork) GetDescription() string { + return "" +} + func (self *SNetwork) GetGlobalId() string { return self.wire.vpc.GetGlobalId() } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/resourcebase.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/resourcebase.go index 64acf4d2d2..6c4f4e6ae1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/resourcebase.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/resourcebase.go @@ -42,3 +42,7 @@ func (r *SResourceBase) GetGlobalId() string { func (r *SResourceBase) GetName() string { return r.Name } + +func (r *SResourceBase) GetDescription() string { + return "" +} diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go index 9cf69d576e..57b3509b0b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go @@ -80,6 +80,10 @@ func (self *SInstance) GetThroughput() int { return self.Throughput } +func (self *SInstance) GetDescription() string { + return "" +} + func (self *SInstance) GetSerialOutput(port int) (string, error) { return "", cloudprovider.ErrNotSupported } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/projects.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/projects.go index 0b88d62f18..fccb3271d6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/projects.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/projects.go @@ -27,22 +27,26 @@ type SProject struct { Name string } -func (self *SProject) GetGlobalId() string { - return self.Id +func (project *SProject) GetGlobalId() string { + return project.Id } -func (self *SProject) GetId() string { - return self.Id +func (project *SProject) GetId() string { + return project.Id } -func (self *SProject) GetName() string { - return self.Name +func (project *SProject) GetName() string { + return project.Name } -func (self *SProject) Refresh() error { +func (project *SProject) Refresh() error { return nil } -func (self *SProject) GetStatus() string { +func (project *SProject) GetDescription() string { + return "" +} + +func (project *SProject) GetStatus() string { return api.EXTERNAL_PROJECT_STATUS_AVAILABLE } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/resource.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/resource.go index ff8adc58bb..c790406ab9 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/resource.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/resource.go @@ -32,6 +32,10 @@ type SResourceBase struct { ProjectId string } +func (self *SResourceBase) GetDescription() string { + return "" +} + func (self *SResourceBase) GetId() string { return self.Id } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/resource_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/resource_base.go index 06878f51c6..83384692bd 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/resource_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/resource_base.go @@ -19,14 +19,18 @@ import "time" type SResourceBase struct { } -func (self *SResourceBase) IsEmulated() bool { +func (resource *SResourceBase) IsEmulated() bool { return false } -func (self *SResourceBase) Refresh() error { +func (resource *SResourceBase) Refresh() error { return nil } -func (self *SResourceBase) GetCreatedAt() time.Time { +func (resource *SResourceBase) GetCreatedAt() time.Time { return time.Time{} } + +func (resource *SResourceBase) GetDescription() string { + return "" +}