mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: add qcloud get tags and remove unused interface
This commit is contained in:
@@ -38,7 +38,6 @@ type ICloudResource interface {
|
||||
Refresh() error
|
||||
|
||||
IsEmulated() bool
|
||||
// GetMetadata() *jsonutils.JSONDict
|
||||
|
||||
GetSysTags() map[string]string
|
||||
GetTags() (map[string]string, error)
|
||||
|
||||
@@ -74,26 +74,6 @@ type SDisk struct {
|
||||
ZoneId string
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
// The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_ALIYUN), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
data := map[string]string{}
|
||||
data["price_key"] = priceKey
|
||||
data["hypervisor"] = api.HYPERVISOR_ALIYUN
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
@@ -83,23 +83,6 @@ func (self *SImage) GetMinRamSizeMb() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if len(self.Architecture) > 0 {
|
||||
data.Add(jsonutils.NewString(self.Architecture), "os_arch")
|
||||
}
|
||||
if len(self.OSType) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsType()), "os_name")
|
||||
}
|
||||
if len(self.Platform) > 0 {
|
||||
data.Add(jsonutils.NewString(self.Platform), "os_distribution")
|
||||
}
|
||||
if len(self.OSName) > 0 {
|
||||
data.Add(jsonutils.NewString(self.OSName), "os_version")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
|
||||
@@ -181,34 +181,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return self.SecurityGroupIds.SecurityGroupId, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
|
||||
optimized := "optimized"
|
||||
if !self.IoOptimized {
|
||||
optimized = "none"
|
||||
}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s::%s::%s", self.RegionId, self.InstanceType, self.InstanceNetworkType, self.OSType, optimized)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
_, tags, err := self.fetchTags()
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
data.Update(jsonutils.Marshal(tags))
|
||||
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
if len(self.ImageId) > 0 {
|
||||
if image, err := self.host.zone.region.GetImage(self.ImageId); err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s", self.ImageId, self.GetName())
|
||||
} else if meta := image.GetMetadata(); meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
|
||||
|
||||
@@ -90,17 +90,6 @@ func (self *SSecurityGroup) GetVpcId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := jsonutils.NewDict()
|
||||
for _, value := range self.Tags.Tag {
|
||||
data.Add(jsonutils.NewString(value.TagValue), value.TagKey)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
tags := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
|
||||
@@ -778,20 +778,6 @@ func (region *SRegion) RenewDBInstance(instanceId string, bc billing.SBillingCyc
|
||||
return err
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
tags, err := rds.region.ListResourceTags(APSARA_PRODUCT_RDS, "INSTANCE", []string{rds.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]rds.region.FetchResourceTags("slb", "instance", []string{rds.GetId()})`, err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, ok := tags[rds.GetId()]; !ok {
|
||||
return nil
|
||||
}
|
||||
data.Update(jsonutils.Marshal(tags[rds.GetId()]))
|
||||
return data
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := rds.region.ListResourceTags("rds", "INSTANCE", []string{rds.GetId()})
|
||||
if err != nil {
|
||||
|
||||
@@ -75,28 +75,6 @@ type SDisk struct {
|
||||
ZoneId string
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
// The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_APSARA), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
data["price_key"] = priceKey
|
||||
data["hypervisor"] = api.HYPERVISOR_APSARA
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
@@ -923,20 +923,6 @@ func (self *SElasticcache) GetICloudElasticcacheBackup(backupId string) (cloudpr
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
tags, err := instance.region.ListResourceTags(APSARA_PRODUCT_KVSTORE, "INSTANCE", []string{instance.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]instance.region.FetchResourceTags("kvs", "instance", []string{instance.GetId()})`, err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, ok := tags[instance.GetId()]; !ok {
|
||||
return nil
|
||||
}
|
||||
data.Update(jsonutils.Marshal(tags[instance.GetId()]))
|
||||
return data
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) GetTags() (map[string]string, error) {
|
||||
tags, err := instance.region.ListResourceTags("kvs", "INSTANCE", []string{instance.GetId()})
|
||||
if err != nil {
|
||||
|
||||
@@ -83,23 +83,6 @@ func (self *SImage) GetMinRamSizeMb() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if len(self.Architecture) > 0 {
|
||||
data.Add(jsonutils.NewString(self.Architecture), "os_arch")
|
||||
}
|
||||
if len(self.OSType) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsType()), "os_name")
|
||||
}
|
||||
if len(self.Platform) > 0 {
|
||||
data.Add(jsonutils.NewString(self.Platform), "os_distribution")
|
||||
}
|
||||
if len(self.OSName) > 0 {
|
||||
data.Add(jsonutils.NewString(self.OSName), "os_version")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
|
||||
@@ -222,34 +222,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return self.SecurityGroupIds.SecurityGroupId, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
|
||||
optimized := "optimized"
|
||||
if !self.IoOptimized {
|
||||
optimized = "none"
|
||||
}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s::%s::%s", self.RegionId, self.InstanceType, self.InstanceNetworkType, self.OSType, optimized)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
tags, err := self.host.zone.region.fetchTags("instance", self.InstanceId)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
data.Update(tags)
|
||||
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
if len(self.ImageId) > 0 {
|
||||
if image, err := self.host.zone.region.GetImage(self.ImageId); err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s", self.ImageId, self.GetName())
|
||||
} else if meta := image.GetMetadata(); meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
|
||||
|
||||
@@ -102,20 +102,6 @@ func (lb *SLoadbalancer) GetStatus() string {
|
||||
return api.LB_STATUS_DISABLED
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
tags, err := lb.region.ListResourceTags(APSARA_PRODUCT_SLB, "instance", []string{lb.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]lb.region.FetchResourceTags("slb", "instance", []string{lb.GetId()})`, err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, ok := tags[lb.GetId()]; !ok {
|
||||
return nil
|
||||
}
|
||||
data.Update(jsonutils.Marshal(tags[lb.GetId()]))
|
||||
return data
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetTags() (map[string]string, error) {
|
||||
tags, err := lb.region.ListResourceTags("slb", "instance", []string{lb.GetId()})
|
||||
if err != nil {
|
||||
|
||||
@@ -90,17 +90,6 @@ func (self *SSecurityGroup) GetVpcId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := jsonutils.NewDict()
|
||||
for _, value := range self.Tags.Tag {
|
||||
data.Add(jsonutils.NewString(value.TagValue), value.TagKey)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
tags := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
|
||||
@@ -124,19 +124,6 @@ func (self *SDisk) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_AWS), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_AWS
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetBillingType() string {
|
||||
// todo: implement me
|
||||
return billing.BILLING_TYPE_POSTPAID
|
||||
|
||||
@@ -273,23 +273,6 @@ func (self *SImage) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if len(self.Architecture) > 0 {
|
||||
data.Add(jsonutils.NewString(self.Architecture), "os_arch")
|
||||
}
|
||||
if len(self.OSType) > 0 {
|
||||
data.Add(jsonutils.NewString(self.OSType), "os_name")
|
||||
}
|
||||
if len(self.OSDist) > 0 {
|
||||
data.Add(jsonutils.NewString(self.OSDist), "os_distribution")
|
||||
}
|
||||
if len(self.OSVersion) > 0 {
|
||||
data.Add(jsonutils.NewString(self.OSVersion), "os_version")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
|
||||
@@ -210,50 +210,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return self.SecurityGroupIds.SecurityGroupId, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
// todo: add price_key here
|
||||
// 格式 :regionId::instanceType::osName::os_license::preInstall::tenancy::usageType
|
||||
// 举例 : cn-northwest-1::c3.2xlarge::linux::NA::NA::shared::boxusage
|
||||
// 注意:除了空用大写NA.其他一律用小写格式
|
||||
priceKey := fmt.Sprintf("%s::%s::%s::NA::NA::shared::boxusage", self.RegionId, self.InstanceType, strings.ToLower(self.OSType))
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
ec2Client, err := self.host.zone.region.getEc2Client()
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
tags, err := FetchTags(ec2Client, self.InstanceId)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
} else {
|
||||
data.Update(tags)
|
||||
}
|
||||
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
|
||||
if strings.Contains(strings.ToLower(self.OSType), "window") {
|
||||
if loginKey, err := self.host.zone.region.getPasswordData(self.GetId()); err == nil {
|
||||
data.Add(jsonutils.NewString(loginKey), "login_key")
|
||||
}
|
||||
}
|
||||
|
||||
// no need to sync image metadata
|
||||
/*
|
||||
if len(self.ImageId) > 0 {
|
||||
image, err := self.host.zone.region.GetImage(self.ImageId)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s zone %s", self.ImageId, self.GetId(), self.ZoneId)
|
||||
} else {
|
||||
meta := image.GetMetadata()
|
||||
if meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s::NA::NA::shared::boxusage", self.RegionId, self.InstanceType, strings.ToLower(self.OSType))
|
||||
|
||||
@@ -113,32 +113,6 @@ func (self *SElb) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElb) GetMetadata() *jsonutils.JSONDict {
|
||||
metadata := jsonutils.NewDict()
|
||||
metadata.Add(jsonutils.NewString(self.Type), "loadbalance_type")
|
||||
|
||||
attrs, err := self.region.getElbAttributesById(self.GetId())
|
||||
if err != nil {
|
||||
log.Errorf("SElb GetMetadata %s", err)
|
||||
return metadata
|
||||
}
|
||||
|
||||
for k, v := range attrs {
|
||||
metadata.Add(jsonutils.NewString(v), k)
|
||||
}
|
||||
|
||||
tags, err := self.region.FetchElbTags(self.LoadBalancerArn)
|
||||
if err != nil {
|
||||
log.Errorf("self.region.FetchElbTags() %s", err)
|
||||
return metadata
|
||||
}
|
||||
for k, v := range tags {
|
||||
metadata.Add(jsonutils.NewString(v), k)
|
||||
}
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
func (self *SElb) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["loadbalance_type"] = self.Type
|
||||
|
||||
@@ -18,8 +18,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
@@ -68,10 +66,6 @@ func (self *SElbBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElbBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SElbBackend) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -104,15 +104,6 @@ func (self *SElbBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElbBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
metadata := jsonutils.NewDict()
|
||||
metadata.Add(jsonutils.NewInt(self.Port), "port")
|
||||
metadata.Add(jsonutils.NewString(self.TargetType), "target_type")
|
||||
metadata.Add(jsonutils.NewString(strings.ToLower(self.HealthCheckProtocol)), "health_check_protocol")
|
||||
metadata.Add(jsonutils.NewInt(int64(self.HealthCheckIntervalSeconds)), "health_check_interval")
|
||||
return metadata
|
||||
}
|
||||
|
||||
func (self *SElbBackendGroup) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["port"] = strconv.FormatInt(self.Port, 10)
|
||||
|
||||
@@ -81,10 +81,6 @@ func (self *SElbCertificate) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElbCertificate) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SElbCertificate) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -92,10 +92,6 @@ func (self *SElbListener) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElbListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SElbListener) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -116,10 +116,6 @@ func (self *SElbListenerRule) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElbListenerRule) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SElbListenerRule) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -86,27 +86,6 @@ func (self *SNetwork) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
routes, _ := self.wire.vpc.region.GetRouteTablesByNetworkId(self.GetId())
|
||||
if len(routes) == 0 {
|
||||
routes, _ = self.wire.vpc.region.GetRouteTables(self.VpcId, true)
|
||||
}
|
||||
|
||||
support_eip := false
|
||||
if len(routes) >= 1 {
|
||||
for i := range routes[0].Routes {
|
||||
route := routes[0].Routes[i]
|
||||
if route.GetNextHopType() == api.Next_HOP_TYPE_INTERNET {
|
||||
support_eip = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
meta.Set("support_eip", jsonutils.NewBool(support_eip))
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
routes, _ := self.wire.vpc.region.GetRouteTablesByNetworkId(self.GetId())
|
||||
|
||||
@@ -102,26 +102,12 @@ func (self *SSecurityGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := jsonutils.NewDict()
|
||||
for _, value := range self.Tags.Tag {
|
||||
data.Add(jsonutils.NewString(value.TagValue), value.TagKey)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetSysTags() map[string]string {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil
|
||||
}
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
data := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
data[value.TagKey] = value.TagValue
|
||||
}
|
||||
return data
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
billing_api "yunion.io/x/onecloud/pkg/apis/billing"
|
||||
@@ -53,18 +52,6 @@ type SClassicDisk struct {
|
||||
Properties ClassicProperties
|
||||
}
|
||||
|
||||
func (self *SClassicDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_AZURE), "hypervisor")
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SClassicDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_AZURE
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SClassicDisk) CreateISnapshot(ctx context.Context, name, desc string) (cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
@@ -155,14 +155,6 @@ func (self *SClassicInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return secgroupIds, nil
|
||||
}
|
||||
|
||||
func (self *SClassicInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
priceKey := fmt.Sprintf("%s::%s", self.Properties.HardwareProfile.Size, self.host.zone.region.Name)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SClassicInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
priceKey := fmt.Sprintf("%s::%s", self.Properties.HardwareProfile.Size, self.host.zone.region.Name)
|
||||
|
||||
@@ -120,14 +120,6 @@ func (self *SClassicSecurityGroup) GetVpcId() string {
|
||||
return "classic"
|
||||
}
|
||||
|
||||
func (self *SClassicSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
if len(self.Tags) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := jsonutils.Marshal(self.Tags).(*jsonutils.JSONDict)
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SClassicSecurityGroup) GetTags() (map[string]string, error) {
|
||||
return self.Tags, nil
|
||||
}
|
||||
|
||||
@@ -103,15 +103,6 @@ func (self *SImage) GetMinRamSizeMb() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
osType := string(self.Properties.StorageProfile.OsDisk.OsType)
|
||||
if len(osType) > 0 {
|
||||
data.Add(jsonutils.NewString(osType), "os_name")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
osType := string(self.Properties.StorageProfile.OsDisk.OsType)
|
||||
|
||||
@@ -226,29 +226,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return secgroupIds, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
tags := jsonutils.NewDict()
|
||||
for k, v := range self.Tags {
|
||||
tags.Set(k, jsonutils.NewString(v))
|
||||
}
|
||||
data.Update(tags)
|
||||
if osDistribution := self.Properties.StorageProfile.ImageReference.Publisher; len(osDistribution) > 0 {
|
||||
data.Add(jsonutils.NewString(osDistribution), "os_distribution")
|
||||
}
|
||||
if loginAccount := self.Properties.OsProfile.AdminUsername; len(loginAccount) > 0 {
|
||||
data.Add(jsonutils.NewString(loginAccount), "login_account")
|
||||
}
|
||||
if loginKey := self.Properties.OsProfile.AdminPassword; len(loginKey) > 0 {
|
||||
data.Add(jsonutils.NewString(loginKey), "login_key")
|
||||
}
|
||||
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
priceKey := fmt.Sprintf("%s::%s", self.Properties.HardwareProfile.VMSize, self.host.zone.region.Name)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
if osDistribution := self.Properties.StorageProfile.ImageReference.Publisher; len(osDistribution) > 0 {
|
||||
|
||||
@@ -78,14 +78,6 @@ type SSecurityGroup struct {
|
||||
Tags map[string]string
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
if len(self.Tags) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := jsonutils.Marshal(self.Tags).(*jsonutils.JSONDict)
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
return self.Tags, nil
|
||||
}
|
||||
|
||||
@@ -186,13 +186,6 @@ func (self *SDisk) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_CTYUN), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_CTYUN
|
||||
|
||||
@@ -86,23 +86,6 @@ func (self *SImage) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if self.OSBit > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsArch()), "os_arch")
|
||||
}
|
||||
if len(self.OSType) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsType()), "os_name")
|
||||
}
|
||||
if len(self.Platform) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsDist()), "os_distribution")
|
||||
}
|
||||
|
||||
data.Add(jsonutils.NewString(self.GetOsVersion()), "os_version")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
if self.OSBit > 0 {
|
||||
|
||||
@@ -181,26 +181,6 @@ func (self *SInstance) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
lowerOs := self.GetOSType()
|
||||
if strings.HasPrefix(lowerOs, "win") {
|
||||
lowerOs = "win"
|
||||
}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.host.zone.region.GetId(), self.GetInstanceType(), lowerOs)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
|
||||
image, _ := self.GetImage()
|
||||
if image != nil {
|
||||
if meta := image.GetMetadata(); meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
lowerOs := self.GetOSType()
|
||||
|
||||
@@ -135,10 +135,6 @@ func (self *SSecurityGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -97,27 +97,6 @@ func (self *SVirtualMachine) GetSecurityGroupIds() ([]string, error) {
|
||||
return []string{}, cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SVirtualMachine) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
meta.Set("datacenter", jsonutils.NewString(self.GetDatacenterPathString()))
|
||||
rp, _ := self.getResourcePool()
|
||||
if rp != nil {
|
||||
rpPath := rp.GetPath()
|
||||
rpOffset := -1
|
||||
for i := range rpPath {
|
||||
if rpPath[i] == "Resources" {
|
||||
if i > 0 {
|
||||
meta.Set("cluster", jsonutils.NewString(rpPath[i-1]))
|
||||
rpOffset = i
|
||||
}
|
||||
} else if rpOffset >= 0 && i > rpOffset {
|
||||
meta.Set(fmt.Sprintf("pool%d", i-rpOffset-1), jsonutils.NewString(rpPath[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SVirtualMachine) GetSysTags() map[string]string {
|
||||
meta := map[string]string{}
|
||||
meta["datacenter"] = self.GetDatacenterPathString()
|
||||
|
||||
@@ -184,21 +184,6 @@ func (self *SDisk) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
// todo: add price key
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_HUAWEI), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_HUAWEI
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) getResourceDetails() *SResourceDetail {
|
||||
if self.details != nil {
|
||||
return self.details
|
||||
|
||||
@@ -204,23 +204,6 @@ func (self *SImage) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if len(self.OSBit) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsArch()), "os_arch")
|
||||
}
|
||||
if len(self.OSType) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsType()), "os_name")
|
||||
}
|
||||
if len(self.Platform) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsDist()), "os_distribution")
|
||||
}
|
||||
if len(self.OSVersion) > 0 {
|
||||
data.Add(jsonutils.NewString(self.GetOsVersion()), "os_version")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
if len(self.OSBit) > 0 {
|
||||
|
||||
@@ -253,26 +253,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return self.host.zone.region.GetInstanceSecrityGroupIds(self.GetId())
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
// cn-north-1::et2.2xlarge.16::win
|
||||
lowerOs := self.GetOSType()
|
||||
if strings.HasPrefix(lowerOs, "win") {
|
||||
lowerOs = "win"
|
||||
}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s", self.host.zone.region.GetId(), self.GetInstanceType(), lowerOs)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
if len(self.Metadata.MeteringImageID) > 0 {
|
||||
if image, err := self.host.zone.region.GetImage(self.Metadata.MeteringImageID); err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s zone %s", self.Metadata.MeteringImageID, self.GetId(), self.OSEXTAZAvailabilityZone)
|
||||
} else if meta := image.GetMetadata(); meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// cn-north-1::et2.2xlarge.16::win
|
||||
|
||||
@@ -127,12 +127,6 @@ func (self *SLoadbalancer) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetProjectId() string {
|
||||
return self.ProjectID
|
||||
}
|
||||
|
||||
@@ -124,11 +124,6 @@ func (self *SSecurityGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
if self.Description == self.VpcID {
|
||||
return ""
|
||||
|
||||
@@ -120,19 +120,6 @@ type SDisk struct {
|
||||
VolumeType string
|
||||
}
|
||||
|
||||
func (disk *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_OPENSTACK), "hypervisor")
|
||||
return data
|
||||
}
|
||||
|
||||
func (disk *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_OPENSTACK
|
||||
return data
|
||||
}
|
||||
|
||||
func (region *SRegion) GetDisks() ([]SDisk, error) {
|
||||
disks := []SDisk{}
|
||||
resource := "/volumes/detail"
|
||||
|
||||
@@ -84,28 +84,6 @@ func (v SDiskSet) Less(i, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
// // The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
|
||||
// priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
// data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_QCLOUD), "hypervisor")
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
|
||||
// // The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
|
||||
// priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
|
||||
// data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
data["hypervisor"] = api.HYPERVISOR_QCLOUD
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
@@ -241,25 +241,6 @@ func (self *SElasticcache) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
tags, err := self.region.FetchResourceTags("redis", "instance", []string{self.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]self.region.FetchResourceTags("cdb", "instanceId", []string{self.GetId()})`, err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, ok := tags[self.GetId()]; !ok {
|
||||
return meta
|
||||
}
|
||||
resourceTag := tags[self.GetId()]
|
||||
if resourceTag != nil {
|
||||
for k, v := range *resourceTag {
|
||||
meta.Add(jsonutils.NewString(v), k)
|
||||
}
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetTags() (map[string]string, error) {
|
||||
tags, err := self.region.FetchResourceTags("redis", "instance", []string{self.GetId()})
|
||||
if err != nil {
|
||||
|
||||
@@ -166,32 +166,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return self.SecurityGroupIds, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
if self.image == nil {
|
||||
image, err := self.host.zone.region.GetImage(self.ImageId)
|
||||
if err == nil {
|
||||
self.image = image
|
||||
}
|
||||
}
|
||||
|
||||
if self.image != nil {
|
||||
data.Add(jsonutils.NewString(self.image.OsName), "os_distribution")
|
||||
}
|
||||
|
||||
priceKey := fmt.Sprintf("%s::%s", self.host.zone.Zone, self.InstanceType)
|
||||
data.Add(jsonutils.NewString(priceKey), "price_key")
|
||||
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
|
||||
tags, _ := self.getCloudMetadata()
|
||||
for k, v := range tags {
|
||||
data.Add(jsonutils.NewString(v), k)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
if self.image == nil {
|
||||
|
||||
@@ -272,27 +272,22 @@ func (self *SLoadbalancer) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
meta.Add(jsonutils.NewInt(int64(self.Forward)), "Forward")
|
||||
meta.Add(jsonutils.NewInt(self.OpenBGP), "OpenBGP")
|
||||
meta.Add(jsonutils.NewString(self.Domain), "Domain")
|
||||
meta.Add(jsonutils.NewInt(self.ProjectID), "ProjectID")
|
||||
func (self *SLoadbalancer) GetTags() (map[string]string, error) {
|
||||
tags, err := self.region.FetchResourceTags("clb", "clb", []string{self.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]self.region.FetchResourceTags("clb", "clb", []string{self.GetId()})`, err.Error())
|
||||
return nil
|
||||
return nil, errors.Wrapf(err, "FetchResourceTags")
|
||||
}
|
||||
ret := map[string]string{}
|
||||
if _, ok := tags[self.GetId()]; !ok {
|
||||
return meta
|
||||
return ret, nil
|
||||
}
|
||||
resourceTag := tags[self.GetId()]
|
||||
if resourceTag != nil {
|
||||
for k, v := range *resourceTag {
|
||||
meta.Add(jsonutils.NewString(v), k)
|
||||
ret[k] = v
|
||||
}
|
||||
}
|
||||
return meta
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetSysTags() map[string]string {
|
||||
|
||||
@@ -18,8 +18,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -35,12 +33,6 @@ type SLocalDisk struct {
|
||||
DiskUsage string
|
||||
}
|
||||
|
||||
func (self *SLocalDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_QCLOUD), "hypervisor")
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SLocalDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_QCLOUD
|
||||
|
||||
@@ -897,25 +897,6 @@ func (self *SMySQLInstance) CreateIBackup(opts *cloudprovider.SDBInstanceBackupC
|
||||
return self.region.CreateMySQLBackup(self.InstanceId, tables)
|
||||
}
|
||||
|
||||
func (self *SMySQLInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
meta := jsonutils.NewDict()
|
||||
tags, err := self.region.FetchResourceTags("cdb", "instanceId", []string{self.GetId()})
|
||||
if err != nil {
|
||||
log.Errorf(`[err:%s]self.region.FetchResourceTags("cdb", "instanceId", []string{self.GetId()})`, err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, ok := tags[self.GetId()]; !ok {
|
||||
return meta
|
||||
}
|
||||
resourceTag := tags[self.GetId()]
|
||||
if resourceTag != nil {
|
||||
for k, v := range *resourceTag {
|
||||
meta.Add(jsonutils.NewString(v), k)
|
||||
}
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SMySQLInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := self.region.FetchResourceTags("cdb", "instanceId", []string{self.GetId()})
|
||||
if err != nil {
|
||||
|
||||
@@ -115,14 +115,6 @@ func (self *SDisk) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
// todo: add price key
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_UCLOUD), "hypervisor")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_UCLOUD
|
||||
|
||||
@@ -92,24 +92,6 @@ func (self *SImage) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
imageInfo := imagetools.NormalizeImageInfo(self.ImageName, "", "", "", "")
|
||||
data := jsonutils.NewDict()
|
||||
if len(imageInfo.OsArch) > 0 {
|
||||
data.Add(jsonutils.NewString(imageInfo.OsArch), "os_arch")
|
||||
}
|
||||
if len(imageInfo.OsType) > 0 {
|
||||
data.Add(jsonutils.NewString(imageInfo.OsType), "os_name")
|
||||
}
|
||||
if len(imageInfo.OsDistro) > 0 {
|
||||
data.Add(jsonutils.NewString(imageInfo.OsDistro), "os_distribution")
|
||||
}
|
||||
if len(imageInfo.OsVersion) > 0 {
|
||||
data.Add(jsonutils.NewString(imageInfo.OsVersion), "os_version")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
imageInfo := imagetools.NormalizeImageInfo(self.ImageName, "", "", "", "")
|
||||
data := map[string]string{}
|
||||
|
||||
@@ -182,21 +182,6 @@ func (self *SInstance) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
// todo: add price key here
|
||||
data.Add(jsonutils.NewString(self.host.zone.GetGlobalId()), "zone_ext_id")
|
||||
if len(self.BasicImageID) > 0 {
|
||||
if image, err := self.host.zone.region.GetImage(self.BasicImageID); err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s", self.BasicImageID, self.GetName())
|
||||
} else if meta := image.GetMetadata(); meta != nil {
|
||||
data.Update(meta)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// todo: add price key here
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
package ucloud
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
@@ -57,10 +55,6 @@ func (self *SProject) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SProject) GetMetadata() *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (self *SUcloudClient) FetchProjects() ([]SProject, error) {
|
||||
params := NewUcloudParams()
|
||||
projects := make([]SProject, 0)
|
||||
|
||||
@@ -91,11 +91,6 @@ func (self *SSecurityGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
return self.Remark
|
||||
}
|
||||
|
||||
@@ -135,13 +135,6 @@ func (region *SRegion) GetDisks(storageId string, diskIds []string, diskType str
|
||||
return disks, region.client.listAll("volumes", params, &disks)
|
||||
}
|
||||
|
||||
func (disk *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
data.Add(jsonutils.NewString(api.HYPERVISOR_ZSTACK), "hypervisor")
|
||||
return data
|
||||
}
|
||||
|
||||
func (disk *SDisk) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["hypervisor"] = api.HYPERVISOR_ZSTACK
|
||||
|
||||
@@ -74,11 +74,6 @@ func (image *SImage) GetMinRamSizeMb() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (image *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
return data
|
||||
}
|
||||
|
||||
func (image *SImage) GetId() string {
|
||||
return image.UUID
|
||||
}
|
||||
|
||||
@@ -107,12 +107,6 @@ func (instance *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func (instance *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (instance *SInstance) GetIHost() cloudprovider.ICloudHost {
|
||||
return instance.host
|
||||
}
|
||||
|
||||
@@ -86,11 +86,6 @@ func (self *SSecurityGroup) GetVpcId() string {
|
||||
return api.NORMAL_VPC_ID
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
data := jsonutils.NewDict()
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.UUID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user