mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-31 01:35:56 +08:00
fix: add tag for databricks vm
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
|
||||
package apis
|
||||
|
||||
const (
|
||||
IS_SYSTEM = "IsSystem"
|
||||
)
|
||||
|
||||
type MetadataListInput struct {
|
||||
ModelBaseListInput
|
||||
|
||||
|
||||
@@ -113,6 +113,14 @@ func (manager *SVirtualResourceBaseManager) FilterByHiddenSystemAttributes(q *sq
|
||||
return q
|
||||
}
|
||||
|
||||
func (model *SVirtualResourceBase) SetSystemInfo(isSystem bool) error {
|
||||
_, err := Update(model, func() error {
|
||||
model.IsSystem = isSystem
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (model *SVirtualResourceBase) SetProjectInfo(ctx context.Context, userCred mcclient.TokenCredential, projectId, domainId string) error {
|
||||
_, err := Update(model, func() error {
|
||||
model.ProjectId = projectId
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -32,6 +33,11 @@ type IMetadataSetter interface {
|
||||
GetCloudproviderId() string
|
||||
}
|
||||
|
||||
type IVirtualResourceMetadataSetter interface {
|
||||
IMetadataSetter
|
||||
SetSystemInfo(isSystem bool) error
|
||||
}
|
||||
|
||||
func syncMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IMetadataSetter, remote cloudprovider.ICloudResource) error {
|
||||
sysTags := remote.GetSysTags()
|
||||
sysStore := make(map[string]interface{}, 0)
|
||||
@@ -51,10 +57,13 @@ func syncMetadata(ctx context.Context, userCred mcclient.TokenCredential, model
|
||||
return nil
|
||||
}
|
||||
|
||||
func syncVirtualResourceMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IMetadataSetter, remote cloudprovider.IVirtualResource) error {
|
||||
func syncVirtualResourceMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IVirtualResourceMetadataSetter, remote cloudprovider.IVirtualResource) error {
|
||||
sysTags := remote.GetSysTags()
|
||||
sysStore := make(map[string]interface{}, 0)
|
||||
for key, value := range sysTags {
|
||||
if key == apis.IS_SYSTEM && value == "true" {
|
||||
model.SetSystemInfo(true)
|
||||
}
|
||||
sysStore[db.SYS_CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
extProjectId := remote.GetProjectId()
|
||||
@@ -84,6 +93,6 @@ func SyncMetadata(ctx context.Context, userCred mcclient.TokenCredential, model
|
||||
return syncMetadata(ctx, userCred, model, remote)
|
||||
}
|
||||
|
||||
func SyncVirtualResourceMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IMetadataSetter, remote cloudprovider.IVirtualResource) error {
|
||||
func SyncVirtualResourceMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IVirtualResourceMetadataSetter, remote cloudprovider.IVirtualResource) error {
|
||||
return syncVirtualResourceMetadata(ctx, userCred, model, remote)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/osprofile"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
billing_api "yunion.io/x/onecloud/pkg/apis/billing"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -237,9 +238,12 @@ func (self *SInstance) GetSysTags() map[string]string {
|
||||
if loginKey := self.Properties.OsProfile.AdminPassword; len(loginKey) > 0 {
|
||||
data["login_key"] = loginKey
|
||||
}
|
||||
data["zone_ext_id"] = self.host.zone.GetGlobalId()
|
||||
priceKey := fmt.Sprintf("%s::%s", self.Properties.HardwareProfile.VMSize, self.host.zone.region.Name)
|
||||
data["price_key"] = priceKey
|
||||
for _, res := range self.Resources {
|
||||
if strings.HasSuffix(strings.ToLower(res.Id), "databricksbootstrap") {
|
||||
data[apis.IS_SYSTEM] = "true"
|
||||
break
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user