fix(region): add guest description (#16279)

This commit is contained in:
gouqi11
2023-03-23 21:35:26 +08:00
committed by GitHub
parent 3ea8667707
commit ee18e530ba
18 changed files with 120 additions and 63 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.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
+2 -2
View File
@@ -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=
+4
View File
@@ -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()
+4
View File
@@ -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()
+1 -1
View File
@@ -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
+1
View File
@@ -31,6 +31,7 @@ type ICloudResource interface {
GetName() string
GetGlobalId() string
GetCreatedAt() time.Time
GetDescription() string
GetStatus() string
+52 -48
View File
@@ -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
+5
View File
@@ -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{}
}
@@ -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
}
@@ -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()
}
@@ -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
}
@@ -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
}
+4
View File
@@ -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()
}
+4
View File
@@ -42,3 +42,7 @@ func (r *SResourceBase) GetGlobalId() string {
func (r *SResourceBase) GetName() string {
return r.Name
}
func (r *SResourceBase) GetDescription() string {
return ""
}
+4
View File
@@ -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
}
+12 -8
View File
@@ -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
}
+4
View File
@@ -32,6 +32,10 @@ type SResourceBase struct {
ProjectId string
}
func (self *SResourceBase) GetDescription() string {
return ""
}
func (self *SResourceBase) GetId() string {
return self.Id
}
+7 -3
View File
@@ -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 ""
}