mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
refact(region): resource tags
This commit is contained in:
@@ -39,10 +39,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
SYSTEM_ADMIN_PREFIX = "__sys_"
|
||||
SYS_TAG_PREFIX = "__"
|
||||
CLOUD_TAG_PREFIX = "ext:"
|
||||
USER_TAG_PREFIX = "user:"
|
||||
SYSTEM_ADMIN_PREFIX = "__sys_"
|
||||
SYS_TAG_PREFIX = "__"
|
||||
CLOUD_TAG_PREFIX = "ext:"
|
||||
USER_TAG_PREFIX = "user:"
|
||||
SYS_CLOUD_TAG_PREFIX = "sys:"
|
||||
|
||||
// TAG_DELETE_RANGE_USER = "user"
|
||||
// TAG_DELETE_RANGE_CLOUD = CLOUD_TAG_PREFIX // "cloud"
|
||||
@@ -568,6 +569,8 @@ func (manager *SMetadataManager) SetAll(ctx context.Context, obj IModel, store m
|
||||
q = q.Like("key", USER_TAG_PREFIX+"%")
|
||||
case CLOUD_TAG_PREFIX:
|
||||
q = q.Like("key", CLOUD_TAG_PREFIX+"%")
|
||||
case SYS_CLOUD_TAG_PREFIX:
|
||||
q = q.Like("key", SYS_CLOUD_TAG_PREFIX+"%")
|
||||
}
|
||||
q = q.Filter(sqlchemy.NOT(sqlchemy.In(q.Field("key"), keys)))
|
||||
if err := FetchModelObjects(manager, q, &records); err != nil {
|
||||
|
||||
@@ -293,6 +293,14 @@ func (model *SStandaloneAnonResourceBase) SetCloudMetadataAll(ctx context.Contex
|
||||
return nil
|
||||
}
|
||||
|
||||
func (model *SStandaloneAnonResourceBase) SetSysCloudMetadataAll(ctx context.Context, dictstore map[string]interface{}, userCred mcclient.TokenCredential) error {
|
||||
err := Metadata.SetAll(ctx, model, dictstore, userCred, SYS_CLOUD_TAG_PREFIX)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "SetAll")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (model *SStandaloneAnonResourceBase) RemoveMetadata(ctx context.Context, key string, userCred mcclient.TokenCredential) error {
|
||||
err := Metadata.SetValue(ctx, model, key, "", userCred)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
package cloudprovider
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
)
|
||||
|
||||
type SFakeOnPremiseRegion struct {
|
||||
}
|
||||
|
||||
@@ -53,10 +49,18 @@ func (region *SFakeOnPremiseRegion) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (region *SFakeOnPremiseRegion) GetMetadata() *jsonutils.JSONDict {
|
||||
func (region *SFakeOnPremiseRegion) GetSysTags() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (region *SFakeOnPremiseRegion) GetTags() (map[string]string, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (region *SFakeOnPremiseRegion) SetTags(tags map[string]string, replace bool) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (region *SFakeOnPremiseRegion) GetGeographicInfo() SGeographicInfo {
|
||||
return SGeographicInfo{}
|
||||
}
|
||||
|
||||
@@ -271,8 +271,6 @@ type ICloudBucket interface {
|
||||
SetPolicy(policy SBucketPolicyStatementInput) error
|
||||
DeletePolicy(id []string) ([]SBucketPolicyStatement, error)
|
||||
|
||||
GetTags() (map[string]string, error)
|
||||
SetTags(tags map[string]string) error
|
||||
DeleteTags() error
|
||||
|
||||
ListMultipartUploads() ([]SBucketMultipartUploads, error)
|
||||
@@ -861,7 +859,7 @@ func SetBucketMetadata(ibucket ICloudBucket, tags map[string]string, replace boo
|
||||
return errors.Wrap(err, "b.DeleteTags()")
|
||||
}
|
||||
} else {
|
||||
err := ibucket.SetTags(newTags)
|
||||
err := ibucket.SetTags(newTags, true)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "b.setTags(%s)", jsonutils.Marshal(newTags).String())
|
||||
}
|
||||
|
||||
@@ -38,7 +38,11 @@ type ICloudResource interface {
|
||||
Refresh() error
|
||||
|
||||
IsEmulated() bool
|
||||
GetMetadata() *jsonutils.JSONDict
|
||||
// GetMetadata() *jsonutils.JSONDict
|
||||
|
||||
GetSysTags() map[string]string
|
||||
GetTags() (map[string]string, error)
|
||||
SetTags(tags map[string]string, replace bool) error
|
||||
}
|
||||
|
||||
type IVirtualResource interface {
|
||||
@@ -325,8 +329,6 @@ type ICloudVM interface {
|
||||
|
||||
GetError() error
|
||||
|
||||
SetMetadata(tags map[string]string, replace bool) error
|
||||
|
||||
CreateInstanceSnapshot(ctx context.Context, name string, desc string) (ICloudInstanceSnapshot, error)
|
||||
GetInstanceSnapshot(idStr string) (ICloudInstanceSnapshot, error)
|
||||
GetInstanceSnapshots() ([]ICloudInstanceSnapshot, error)
|
||||
@@ -604,8 +606,6 @@ type ICloudLoadbalancer interface {
|
||||
|
||||
CreateILoadBalancerListener(ctx context.Context, listener *SLoadbalancerListener) (ICloudLoadbalancerListener, error)
|
||||
GetILoadBalancerListenerById(listenerId string) (ICloudLoadbalancerListener, error)
|
||||
|
||||
SetMetadata(tags map[string]string, replace bool) error
|
||||
}
|
||||
|
||||
type ICloudLoadbalancerListener interface {
|
||||
@@ -879,8 +879,6 @@ type ICloudDBInstance interface {
|
||||
RecoveryFromBackup(conf *SDBInstanceRecoveryConfig) error
|
||||
|
||||
Delete() error
|
||||
|
||||
SetMetadata(tags map[string]string, replace bool) error
|
||||
}
|
||||
|
||||
type ICloudDBInstanceParameter interface {
|
||||
@@ -991,7 +989,6 @@ type ICloudElasticcache interface {
|
||||
UpdateBackupPolicy(config SCloudElasticCacheBackupPolicyUpdateInput) error
|
||||
Renew(bc billing.SBillingCycle) error
|
||||
|
||||
SetMetadata(tags map[string]string, replace bool) error
|
||||
UpdateSecurityGroups(secgroupIds []string) error
|
||||
}
|
||||
|
||||
|
||||
@@ -1271,11 +1271,12 @@ func (self *SManagedVirtualizedGuestDriver) RequestRemoteUpdate(ctx context.Cont
|
||||
if err != nil {
|
||||
log.Errorf("GetAllUserMetadata fail %s", err)
|
||||
} else {
|
||||
err := iVM.SetMetadata(tags, replaceTags)
|
||||
err := iVM.SetTags(tags, replaceTags)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "iVM.SetMetadata")
|
||||
}
|
||||
// sync back cloud metadata
|
||||
iVM.Refresh()
|
||||
err = models.SyncVirtualResourceMetadata(ctx, userCred, guest, iVM)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "syncVirtualResourceMetadata")
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
billing_api "yunion.io/x/onecloud/pkg/apis/billing"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
@@ -97,15 +98,15 @@ func fetchIVMinfo(desc cloudprovider.SManagedVMCreateConfig, iVM cloudprovider.I
|
||||
dinfo.FsFromat = idisks[i].GetFsFormat()
|
||||
dinfo.ExpiredAt = idisks[i].GetExpiredAt()
|
||||
dinfo.StorageExternalId = idisks[i].GetIStorageId()
|
||||
if metaData := idisks[i].GetMetadata(); metaData != nil {
|
||||
diskSysTags := idisks[i].GetSysTags()
|
||||
diskTags, _ := idisks[i].GetTags()
|
||||
if diskSysTags != nil || diskTags != nil {
|
||||
dinfo.Metadata = make(map[string]string, 0)
|
||||
metadata := map[string]string{}
|
||||
if err := metaData.Unmarshal(&metadata); err != nil {
|
||||
log.Errorf("Get disk %s metadata info error: %v", idisks[i].GetName(), err)
|
||||
} else {
|
||||
for k, v := range metadata {
|
||||
dinfo.Metadata["ext:"+k] = v
|
||||
}
|
||||
for k, v := range diskSysTags {
|
||||
dinfo.Metadata[db.SYS_CLOUD_TAG_PREFIX+k] = v
|
||||
}
|
||||
for k, v := range diskTags {
|
||||
dinfo.Metadata[db.CLOUD_TAG_PREFIX+k] = v
|
||||
}
|
||||
}
|
||||
diskInfo[i] = dinfo
|
||||
@@ -114,13 +115,14 @@ func fetchIVMinfo(desc cloudprovider.SManagedVMCreateConfig, iVM cloudprovider.I
|
||||
}
|
||||
|
||||
data.Add(jsonutils.NewString(iVM.GetGlobalId()), "uuid")
|
||||
metadata := map[string]string{}
|
||||
if _metadata := iVM.GetMetadata(); _metadata != nil {
|
||||
_metadata.Unmarshal(&metadata)
|
||||
}
|
||||
sysTags := iVM.GetSysTags()
|
||||
tags, _ := iVM.GetTags()
|
||||
metadataDict := jsonutils.NewDict()
|
||||
for k, v := range metadata {
|
||||
metadataDict.Add(jsonutils.NewString(v), "ext:"+k)
|
||||
for k, v := range sysTags {
|
||||
metadataDict.Add(jsonutils.NewString(v), db.SYS_CLOUD_TAG_PREFIX+k)
|
||||
}
|
||||
for k, v := range tags {
|
||||
metadataDict.Add(jsonutils.NewString(v), db.CLOUD_TAG_PREFIX+k)
|
||||
}
|
||||
data.Add(metadataDict, "metadata")
|
||||
|
||||
|
||||
@@ -3206,7 +3206,7 @@ func (manager *SGuestManager) getUserMetadata(data jsonutils.JSONObject) (map[st
|
||||
}
|
||||
dictStore := map[string]interface{}{}
|
||||
for k, v := range metadata {
|
||||
dictStore["user:"+k], _ = v.GetString()
|
||||
dictStore[db.USER_TAG_PREFIX+k], _ = v.GetString()
|
||||
}
|
||||
return dictStore, nil
|
||||
}
|
||||
|
||||
@@ -359,15 +359,21 @@ func (lbbg *SAwsCachedLbbg) SyncWithCloudLoadbalancerBackendgroup(ctx context.Co
|
||||
|
||||
diff, err := db.UpdateWithLock(ctx, lbbg, func() error {
|
||||
lbbg.Status = extLoadbalancerBackendgroup.GetStatus()
|
||||
metadata := extLoadbalancerBackendgroup.GetMetadata()
|
||||
if port, _ := metadata.Int("port"); port > 0 {
|
||||
lbbg.Port = int(port)
|
||||
metadata := extLoadbalancerBackendgroup.GetSysTags()
|
||||
if port, ok := metadata["port"]; ok {
|
||||
portNum, err := strconv.Atoi(port)
|
||||
if err == nil {
|
||||
lbbg.Port = portNum
|
||||
}
|
||||
}
|
||||
if protocol, _ := metadata.GetString("health_check_protocol"); len(protocol) > 0 {
|
||||
if protocol, ok := metadata["health_check_protocol"]; ok {
|
||||
lbbg.HealthCheckProtocol = protocol
|
||||
}
|
||||
if interval, _ := metadata.Int("health_check_interval"); interval > 0 {
|
||||
lbbg.HealthCheckInterval = int(interval)
|
||||
if interval, ok := metadata["health_check_interval"]; ok {
|
||||
intervalNum, err := strconv.Atoi(interval)
|
||||
if err == nil {
|
||||
lbbg.HealthCheckInterval = intervalNum
|
||||
}
|
||||
}
|
||||
if newLocalLbbg != nil {
|
||||
lbbg.BackendGroupId = newLocalLbbg.GetId()
|
||||
@@ -399,21 +405,27 @@ func (man *SAwsCachedLbbgManager) newFromCloudLoadbalancerBackendgroup(ctx conte
|
||||
lbbg.ExternalId = extLoadbalancerBackendgroup.GetGlobalId()
|
||||
lbbg.ProtocolType = extLoadbalancerBackendgroup.GetProtocolType()
|
||||
|
||||
metadata := extLoadbalancerBackendgroup.GetMetadata()
|
||||
if t, _ := metadata.GetString("target_type"); len(t) > 0 {
|
||||
metadata := extLoadbalancerBackendgroup.GetSysTags()
|
||||
if t, ok := metadata["target_type"]; ok {
|
||||
lbbg.TargetType = t
|
||||
}
|
||||
|
||||
if p, _ := metadata.Int("port"); p > 0 {
|
||||
lbbg.Port = int(p)
|
||||
if p, ok := metadata["port"]; ok {
|
||||
portNum, err := strconv.Atoi(p)
|
||||
if err == nil {
|
||||
lbbg.Port = portNum
|
||||
}
|
||||
}
|
||||
|
||||
if protocol, _ := metadata.GetString("health_check_protocol"); len(protocol) > 0 {
|
||||
if protocol, ok := metadata["health_check_protocol"]; ok {
|
||||
lbbg.HealthCheckProtocol = protocol
|
||||
}
|
||||
|
||||
if interval, _ := metadata.Int("health_check_interval"); interval > 0 {
|
||||
lbbg.HealthCheckInterval = int(interval)
|
||||
if interval, ok := metadata["health_check_interval"]; ok {
|
||||
intervalNum, err := strconv.Atoi(interval)
|
||||
if err == nil {
|
||||
lbbg.HealthCheckInterval = intervalNum
|
||||
}
|
||||
}
|
||||
newName, err := db.GenerateName(man, syncOwnerId, LocalLbbg.GetName())
|
||||
if err != nil {
|
||||
|
||||
@@ -986,8 +986,8 @@ func (man *SLoadbalancerManager) newFromCloudLoadbalancer(ctx context.Context, u
|
||||
}
|
||||
}
|
||||
|
||||
if extLb.GetMetadata() != nil {
|
||||
lb.LBInfo = extLb.GetMetadata()
|
||||
if extLb.GetSysTags() != nil {
|
||||
lb.LBInfo = jsonutils.Marshal(extLb.GetSysTags())
|
||||
}
|
||||
|
||||
if err := man.TableSpec().Insert(ctx, &lb); err != nil {
|
||||
@@ -1150,8 +1150,8 @@ func (lb *SLoadbalancer) SyncWithCloudLoadbalancer(ctx context.Context, userCred
|
||||
lb.ManagerId = provider.Id
|
||||
lbNetworkIds := getExtLbNetworkIds(extLb, lb.ManagerId)
|
||||
lb.NetworkId = strings.Join(lbNetworkIds, ",")
|
||||
if extLb.GetMetadata() != nil {
|
||||
lb.LBInfo = extLb.GetMetadata()
|
||||
if extLb.GetSysTags() != nil {
|
||||
lb.LBInfo = jsonutils.Marshal(extLb.GetSysTags())
|
||||
}
|
||||
syncVirtualResourceMetadata(ctx, userCred, lb, extLb)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -26,58 +27,55 @@ import (
|
||||
|
||||
type IMetadataSetter interface {
|
||||
SetCloudMetadataAll(ctx context.Context, meta map[string]interface{}, userCred mcclient.TokenCredential) error
|
||||
SetSysCloudMetadataAll(ctx context.Context, meta map[string]interface{}, userCred mcclient.TokenCredential) error
|
||||
Keyword() string
|
||||
GetName() string
|
||||
GetCloudproviderId() string
|
||||
}
|
||||
|
||||
func syncMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IMetadataSetter, remote cloudprovider.ICloudResource) error {
|
||||
metaData := remote.GetMetadata()
|
||||
if metaData != nil {
|
||||
meta := make(map[string]interface{}, 0)
|
||||
err := metaData.Unmarshal(meta)
|
||||
if err != nil {
|
||||
log.Errorf("Get VM Metadata error: %v", err)
|
||||
return err
|
||||
}
|
||||
sysTags := remote.GetSysTags()
|
||||
sysStore := make(map[string]interface{}, 0)
|
||||
for key, value := range sysTags {
|
||||
sysStore[db.SYS_CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
model.SetSysCloudMetadataAll(ctx, sysStore, userCred)
|
||||
|
||||
tags, err := remote.GetTags()
|
||||
if err == nil || errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
store := make(map[string]interface{}, 0)
|
||||
for key, value := range meta {
|
||||
for key, value := range tags {
|
||||
store[db.CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
// model.SetMetadata(ctx, "ext:"+key, value, userCred)
|
||||
// replace all ext keys
|
||||
model.SetCloudMetadataAll(ctx, store, userCred)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func syncVirtualResourceMetadata(ctx context.Context, userCred mcclient.TokenCredential, model IMetadataSetter, remote cloudprovider.IVirtualResource) error {
|
||||
metaData := remote.GetMetadata()
|
||||
store := make(map[string]interface{}, 0)
|
||||
if metaData != nil {
|
||||
meta := make(map[string]interface{}, 0)
|
||||
err := metaData.Unmarshal(meta)
|
||||
if err != nil {
|
||||
log.Errorf("Get VM Metadata error: %v", err)
|
||||
return err
|
||||
}
|
||||
for key, value := range meta {
|
||||
store[db.CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
|
||||
sysTags := remote.GetSysTags()
|
||||
sysStore := make(map[string]interface{}, 0)
|
||||
for key, value := range sysTags {
|
||||
sysStore[db.SYS_CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
|
||||
extProjectId := remote.GetProjectId()
|
||||
if len(extProjectId) > 0 {
|
||||
extProject, err := ExternalProjectManager.GetProject(extProjectId, model.GetCloudproviderId())
|
||||
if err != nil {
|
||||
log.Errorf("sync project metadata for %s %s error: %v", model.Keyword(), model.GetName(), err)
|
||||
} else {
|
||||
store[db.CLOUD_TAG_PREFIX+"project"] = extProject.Name
|
||||
sysStore[db.SYS_CLOUD_TAG_PREFIX+"project"] = extProject.Name
|
||||
}
|
||||
}
|
||||
|
||||
if len(store) > 0 {
|
||||
model.SetSysCloudMetadataAll(ctx, sysStore, userCred)
|
||||
|
||||
tags, err := remote.GetTags()
|
||||
if err == nil || errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
store := make(map[string]interface{}, 0)
|
||||
for key, value := range tags {
|
||||
store[db.CLOUD_TAG_PREFIX+key] = value
|
||||
}
|
||||
model.SetCloudMetadataAll(ctx, store, userCred)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -335,11 +335,12 @@ func (self *SManagedVirtualizationRegionDriver) RequestRemoteUpdateLoadbalancer(
|
||||
if err != nil {
|
||||
log.Errorf("GetAllUserMetadata fail %s", err)
|
||||
} else {
|
||||
err := iLoadbalancer.SetMetadata(tags, replaceTags)
|
||||
err := iLoadbalancer.SetTags(tags, replaceTags)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "iLoadbalancer.SetMetadata")
|
||||
}
|
||||
// sync back cloud metadata
|
||||
iLoadbalancer.Refresh()
|
||||
err = models.SyncVirtualResourceMetadata(ctx, userCred, lb, iLoadbalancer)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "syncVirtualResourceMetadata")
|
||||
@@ -2729,11 +2730,12 @@ func (self *SManagedVirtualizationRegionDriver) RequestRemoteUpdateDBInstance(ct
|
||||
if err != nil {
|
||||
log.Errorf("GetAllUserMetadata fail %s", err)
|
||||
} else {
|
||||
err := iRds.SetMetadata(tags, replaceTags)
|
||||
err := iRds.SetTags(tags, replaceTags)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "iRds.SetMetadata")
|
||||
}
|
||||
// sync back cloud metadata
|
||||
iRds.Refresh()
|
||||
err = models.SyncVirtualResourceMetadata(ctx, userCred, instance, iRds)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "syncVirtualResourceMetadata")
|
||||
@@ -3127,11 +3129,12 @@ func (self *SManagedVirtualizationRegionDriver) RequestRemoteUpdateElasticcache(
|
||||
if err != nil {
|
||||
log.Errorf("GetAllUserMetadata fail %s", err)
|
||||
} else {
|
||||
err := iElasticcache.SetMetadata(tags, replaceTags)
|
||||
err := iElasticcache.SetTags(tags, replaceTags)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "iElasticcache.SetMetadata")
|
||||
}
|
||||
// sync back cloud metadata
|
||||
iElasticcache.Refresh()
|
||||
err = models.SyncVirtualResourceMetadata(ctx, userCred, elasticcache, iElasticcache)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "syncVirtualResourceMetadata")
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -1261,19 +1262,23 @@ func (self *SQcloudRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx c
|
||||
}
|
||||
|
||||
func (self *SQcloudRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
meta := remoteLoadbalancer.GetMetadata()
|
||||
meta := remoteLoadbalancer.GetSysTags()
|
||||
if meta == nil {
|
||||
return fmt.Errorf("")
|
||||
|
||||
}
|
||||
|
||||
// 经典型负载均衡只有一个后端服务器组,全局共享
|
||||
if forward, _ := meta.Int("Forward"); forward == 1 {
|
||||
models.SyncQcloudLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
return nil
|
||||
} else {
|
||||
return self.SManagedVirtualizationRegionDriver.RequestPullLoadbalancerBackendGroup(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
|
||||
if forward, ok := meta["Forward"]; ok {
|
||||
forwardNum, err := strconv.Atoi(forward)
|
||||
if err == nil && forwardNum == 1 {
|
||||
models.SyncQcloudLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return self.SManagedVirtualizationRegionDriver.RequestPullLoadbalancerBackendGroup(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
}
|
||||
|
||||
func (self *SQcloudRegionDriver) RequestPreSnapshotPolicyApply(ctx context.Context, userCred mcclient.
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/util/reflectutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
)
|
||||
|
||||
// Int returns a pointer to int type with the same value as the argument. This
|
||||
@@ -286,14 +288,14 @@ func (opts *BaseListOptions) Params() (*jsonutils.JSONDict, error) {
|
||||
tagIdx++
|
||||
}
|
||||
for _, tag := range opts.UserTags {
|
||||
err = opts.addTag("user:", tag, tagIdx, params)
|
||||
err = opts.addTag(db.USER_TAG_PREFIX, tag, tagIdx, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tagIdx++
|
||||
}
|
||||
for _, tag := range opts.CloudTags {
|
||||
err = opts.addTag("ext:", tag, tagIdx, params)
|
||||
err = opts.addTag(db.CLOUD_TAG_PREFIX, tag, tagIdx, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -736,7 +736,10 @@ func (b *SBucket) GetTags() (map[string]string, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (b *SBucket) SetTags(tags map[string]string) error {
|
||||
func (b *SBucket) SetTags(tags map[string]string, replace bool) error {
|
||||
if !replace {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
osscli, err := b.region.GetOssClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetOssClient")
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SCenRouteEntries struct {
|
||||
@@ -56,6 +57,7 @@ type Conflict struct {
|
||||
}
|
||||
|
||||
type SCenRouteEntry struct {
|
||||
multicloud.SResourceBase
|
||||
ChildInstance *SCenChildInstance
|
||||
NextHopInstanceID string `json:"NextHopInstanceId,omitempty"`
|
||||
Status string `json:"Status"`
|
||||
@@ -172,10 +174,6 @@ func (self *SCenRouteEntry) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SCenRouteEntry) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SCenRouteEntry) GetCidr() string {
|
||||
return self.DestinationCidrBlock
|
||||
}
|
||||
|
||||
@@ -861,6 +861,17 @@ func (rds *SDBInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (rds *SDBInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := rds.region.ListResourceTags("rds", "INSTANCE", []string{rds.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, `rds.region.ListResourceTags`)
|
||||
}
|
||||
if _, ok := tags[rds.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[rds.GetId()], nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return rds.region.SetResourceTags("rds", "INSTANCE", []string{rds.GetId()}, tags, replace)
|
||||
}
|
||||
|
||||
@@ -86,6 +86,14 @@ func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
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
|
||||
|
||||
@@ -147,10 +147,6 @@ func (self *SEipAddress) IsEmulated() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetIpAddr() string {
|
||||
return self.IpAddress
|
||||
}
|
||||
|
||||
@@ -939,7 +939,18 @@ func (instance *SElasticcache) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (instance *SElasticcache) GetTags() (map[string]string, error) {
|
||||
tags, err := instance.region.ListResourceTags("kvs", "INSTANCE", []string{instance.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "instance.region.ListResourceTags")
|
||||
}
|
||||
if _, ok := tags[instance.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[instance.GetId()], nil
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) SetTags(tags map[string]string, replace bool) error {
|
||||
return instance.region.SetResourceTags("kvs", "INSTANCE", []string{instance.GetId()}, tags, replace)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,6 @@ type SHost struct {
|
||||
zone *SZone
|
||||
}
|
||||
|
||||
func (self *SHost) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHost) GetIWires() ([]cloudprovider.ICloudWire, error) {
|
||||
return self.zone.GetIWires()
|
||||
}
|
||||
|
||||
@@ -98,6 +98,15 @@ func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
data["os_name"] = self.GetOsType()
|
||||
data["os_distribution"] = self.Platform
|
||||
data["os_version"] = self.OSName
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetId() string {
|
||||
return self.ImageId
|
||||
}
|
||||
|
||||
@@ -250,6 +250,42 @@ func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// 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["price_key"] = priceKey
|
||||
data["zone_ext_id"] = self.host.zone.GetGlobalId()
|
||||
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 {
|
||||
imageSysTags := image.GetSysTags()
|
||||
for k, v := range imageSysTags {
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := self.host.zone.region.fetchTags("instance", self.InstanceId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "self.host.zone.region.fetchTags")
|
||||
}
|
||||
data := map[string]string{}
|
||||
err = tags.Unmarshal(&data)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "tags.Unmarshal")
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIHost() cloudprovider.ICloudHost {
|
||||
return self.host
|
||||
}
|
||||
@@ -1087,7 +1123,7 @@ func (self *SInstance) SetAutoRenew(autoRenew bool) error {
|
||||
return self.host.zone.region.SetInstanceAutoRenew(self.InstanceId, autoRenew)
|
||||
}
|
||||
|
||||
func (self *SInstance) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return self.host.zone.region.SetResourceTags("ecs", "instance", []string{self.InstanceId}, tags, replace)
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,17 @@ func (lb *SLoadbalancer) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetTags() (map[string]string, error) {
|
||||
tags, err := lb.region.ListResourceTags("slb", "instance", []string{lb.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "lb.region.ListResourceTags")
|
||||
}
|
||||
if _, ok := tags[lb.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[lb.GetId()], nil
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetAddress() string {
|
||||
return lb.Address
|
||||
}
|
||||
@@ -412,7 +423,7 @@ func (lb *SLoadbalancer) GetProjectId() string {
|
||||
return lb.ResourceGroupId
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (lb *SLoadbalancer) SetTags(tags map[string]string, replace bool) error {
|
||||
return lb.region.SetResourceTags("slb", "instance", []string{lb.LoadBalancerId}, tags, replace)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type AclEntrys struct {
|
||||
@@ -31,6 +32,7 @@ type AclEntry struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerAcl struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
AclId string
|
||||
@@ -59,10 +61,6 @@ func (acl *SLoadbalancerAcl) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -48,10 +50,6 @@ func (backend *SLoadbalancerBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type Rule struct {
|
||||
@@ -50,6 +51,7 @@ type AssociatedObjects struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
VServerGroupId string
|
||||
@@ -105,10 +107,6 @@ func (backendgroup *SLoadbalancerBackendGroup) GetType() string {
|
||||
return api.LB_BACKENDGROUP_TYPE_NORMAL
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerDefaultBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerDefaultBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -46,10 +48,6 @@ func (backend *SLoadbalancerDefaultBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerDefaultBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
}
|
||||
|
||||
@@ -76,10 +78,6 @@ func (backendgroup *SLoadbalancerDefaultBackendGroup) GetType() string {
|
||||
return api.LB_BACKENDGROUP_TYPE_DEFAULT
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerHTTPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -102,10 +104,6 @@ func (listerner *SLoadbalancerHTTPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerHTTPSListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -97,10 +99,6 @@ func (listerner *SLoadbalancerHTTPSListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerListenerRule struct {
|
||||
multicloud.SResourceBase
|
||||
httpListener *SLoadbalancerHTTPListener
|
||||
httpsListener *SLoadbalancerHTTPSListener
|
||||
|
||||
@@ -52,10 +54,6 @@ func (lbr *SLoadbalancerListenerRule) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (lbr *SLoadbalancerListenerRule) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListenerRule) IsDefault() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerMasterSlaveBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerMasterSlaveBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -50,10 +50,6 @@ func (backend *SLoadbalancerMasterSlaveBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerMasterSlaveBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
MasterSlaveServerGroupId string
|
||||
@@ -67,10 +69,6 @@ func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SubjectAlternativeNames struct {
|
||||
@@ -27,6 +27,7 @@ type SubjectAlternativeNames struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerServerCertificate struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
ServerCertificateId string // 服务器证书ID。
|
||||
@@ -69,10 +70,6 @@ func (certificate *SLoadbalancerServerCertificate) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerTCPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -82,10 +84,6 @@ func (listerner *SLoadbalancerTCPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetEgressMbps() int {
|
||||
if listerner.Bandwidth < 1 {
|
||||
return 0
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerUDPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -82,10 +84,6 @@ func (listerner *SLoadbalancerUDPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetEgressMbps() int {
|
||||
if listerner.Bandwidth < 1 {
|
||||
return 0
|
||||
|
||||
@@ -69,10 +69,6 @@ func (self *SRegion) GetClient() *SAliyunClient {
|
||||
return self.client
|
||||
}
|
||||
|
||||
func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) getSdkClient() (*sdk.Client, error) {
|
||||
if self.sdkClient == nil {
|
||||
cli, err := self.client.getSdkClient(self.RegionId)
|
||||
|
||||
@@ -19,11 +19,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
// {"CreationTime":"2017-03-19T13:37:40Z","RouteEntrys":{"RouteEntry":[{"DestinationCidrBlock":"172.31.32.0/20","InstanceId":"","NextHopType":"local","NextHops":{"NextHop":[]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","Status":"Available","Type":"System"},{"DestinationCidrBlock":"100.64.0.0/10","InstanceId":"","NextHopType":"service","NextHops":{"NextHop":[]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","Status":"Available","Type":"System"}]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","RouteTableType":"System","VRouterId":"vrt-j6c00qrol733dg36iq4qj"}
|
||||
@@ -33,6 +33,7 @@ type SNextHops struct {
|
||||
}
|
||||
|
||||
type SRouteEntry struct {
|
||||
multicloud.SResourceBase
|
||||
routeTable *SRouteTable
|
||||
|
||||
RouteTableId string
|
||||
@@ -69,10 +70,6 @@ func (route *SRouteEntry) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (route *SRouteEntry) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Custom:自定义路由。 System:系统路由。
|
||||
func (route *SRouteEntry) GetType() string {
|
||||
return route.Type
|
||||
@@ -116,6 +113,7 @@ type SRouteEntrys struct {
|
||||
}
|
||||
|
||||
type SRouteTable struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
vpc *SVpc
|
||||
routes []cloudprovider.ICloudRoute
|
||||
@@ -163,10 +161,6 @@ func (self *SRouteTable) GetName() string {
|
||||
return self.RouteTableName
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetRegionId() string {
|
||||
return self.region.RegionId
|
||||
}
|
||||
|
||||
@@ -101,6 +101,17 @@ func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
tags := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
tags[value.TagKey] = value.TagValue
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.SecurityGroupId
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SnapshotStatusType string
|
||||
@@ -38,6 +39,7 @@ const (
|
||||
)
|
||||
|
||||
type SSnapshot struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
Progress string
|
||||
@@ -136,10 +138,6 @@ func (self *SSnapshot) Delete() error {
|
||||
return self.region.DeleteSnapshot(self.SnapshotId)
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetSnapshots(instanceId string, diskId string, snapshotName string, snapshotIds []string, offset int, limit int) ([]SSnapshot, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SSnapshotPolicyType string
|
||||
@@ -34,6 +35,7 @@ const (
|
||||
)
|
||||
|
||||
type SSnapshotPolicy struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
AutoSnapshotPolicyName string
|
||||
@@ -78,10 +80,6 @@ func (self *SSnapshotPolicy) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetGlobalId() string {
|
||||
return self.AutoSnapshotPolicyId
|
||||
}
|
||||
|
||||
@@ -37,17 +37,15 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SStorage struct {
|
||||
multicloud.SResourceBase
|
||||
zone *SZone
|
||||
storageType string
|
||||
}
|
||||
|
||||
func (self *SStorage) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetId() string {
|
||||
return fmt.Sprintf("%s-%s-%s", self.zone.region.client.cpcfg.Id, self.zone.GetId(), self.storageType)
|
||||
}
|
||||
|
||||
@@ -33,17 +33,15 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
"yunion.io/x/onecloud/pkg/util/qemuimg"
|
||||
)
|
||||
|
||||
type SStoragecache struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.region.client.cpcfg.Id, self.region.GetId())
|
||||
}
|
||||
|
||||
@@ -64,10 +64,6 @@ type SVpc struct {
|
||||
VpcName string
|
||||
}
|
||||
|
||||
func (self *SVpc) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SVpc) GetId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
@@ -41,6 +42,7 @@ type SCloudResources struct {
|
||||
}
|
||||
|
||||
type SVSwitch struct {
|
||||
multicloud.SResourceBase
|
||||
wire *SWire
|
||||
|
||||
AvailableIpAddressCount int
|
||||
@@ -61,10 +63,6 @@ type SVSwitch struct {
|
||||
RouteTable SRouteTable
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetId() string {
|
||||
return self.VSwitchId
|
||||
}
|
||||
|
||||
@@ -17,23 +17,20 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SWire struct {
|
||||
multicloud.SResourceBase
|
||||
zone *SZone
|
||||
vpc *SVpc
|
||||
|
||||
inetworks []cloudprovider.ICloudNetwork
|
||||
}
|
||||
|
||||
func (self *SWire) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SWire) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.vpc.GetId(), self.zone.GetId())
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type TChargeType string
|
||||
@@ -108,6 +108,7 @@ type SDedicatedHostTypes struct {
|
||||
}
|
||||
|
||||
type SZone struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
iwires []cloudprovider.ICloudWire
|
||||
@@ -131,10 +132,6 @@ type SZone struct {
|
||||
AvailableDedicatedHostTypes SDedicatedHostTypes
|
||||
}
|
||||
|
||||
func (self *SZone) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SZone) GetId() string {
|
||||
return self.ZoneId
|
||||
}
|
||||
|
||||
@@ -792,6 +792,17 @@ func (rds *SDBInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (rds *SDBInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := rds.region.ListResourceTags("rds", "INSTANCE", []string{rds.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "rds.region.ListResourceTags")
|
||||
}
|
||||
if _, ok := tags[rds.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[rds.GetId()], nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return rds.region.SetResourceTags("rds", "INSTANCE", []string{rds.GetId()}, tags, replace)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type STags struct {
|
||||
}
|
||||
|
||||
type SDisk struct {
|
||||
multicloud.SResourceBase
|
||||
storage *SStorage
|
||||
multicloud.SDisk
|
||||
|
||||
@@ -86,6 +87,16 @@ func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
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
|
||||
|
||||
@@ -137,10 +137,6 @@ func (self *SEipAddress) IsEmulated() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetIpAddr() string {
|
||||
return self.IpAddress
|
||||
}
|
||||
|
||||
@@ -937,7 +937,18 @@ func (instance *SElasticcache) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (instance *SElasticcache) GetTags() (map[string]string, error) {
|
||||
tags, err := instance.region.ListResourceTags("kvs", "INSTANCE", []string{instance.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "instance.region.ListResourceTags")
|
||||
}
|
||||
if _, ok := tags[instance.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[instance.GetId()], nil
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) SetTags(tags map[string]string, replace bool) error {
|
||||
return instance.region.SetResourceTags(APSARA_PRODUCT_KVSTORE, "INSTANCE", []string{instance.GetId()}, tags, replace)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,6 @@ type SHost struct {
|
||||
zone *SZone
|
||||
}
|
||||
|
||||
func (self *SHost) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHost) GetIWires() ([]cloudprovider.ICloudWire, error) {
|
||||
return self.zone.GetIWires()
|
||||
}
|
||||
|
||||
@@ -98,6 +98,15 @@ func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
data["os_name"] = self.GetOsType()
|
||||
data["os_distribution"] = self.Platform
|
||||
data["os_version"] = self.OSName
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetId() string {
|
||||
return self.ImageId
|
||||
}
|
||||
|
||||
@@ -250,6 +250,42 @@ func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// 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["price_key"] = priceKey
|
||||
data["zone_ext_id"] = self.host.zone.GetGlobalId()
|
||||
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 {
|
||||
imageSysTags := image.GetSysTags()
|
||||
for k, v := range imageSysTags {
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := self.host.zone.region.fetchTags("instance", self.InstanceId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "self.host.zone.region.fetchTags")
|
||||
}
|
||||
data := map[string]string{}
|
||||
err = tags.Unmarshal(&data)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "tags.Unmarshal")
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIHost() cloudprovider.ICloudHost {
|
||||
return self.host
|
||||
}
|
||||
@@ -1084,6 +1120,6 @@ func (self *SInstance) SetAutoRenew(autoRenew bool) error {
|
||||
return self.host.zone.region.SetInstanceAutoRenew(self.InstanceId, autoRenew)
|
||||
}
|
||||
|
||||
func (self *SInstance) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return self.host.zone.region.SetResourceTags("ecs", "instance", []string{self.InstanceId}, tags, replace)
|
||||
}
|
||||
|
||||
@@ -116,6 +116,17 @@ func (lb *SLoadbalancer) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetTags() (map[string]string, error) {
|
||||
tags, err := lb.region.ListResourceTags("slb", "instance", []string{lb.GetId()})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "lb.region.ListResourceTags")
|
||||
}
|
||||
if _, ok := tags[lb.GetId()]; !ok {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return *tags[lb.GetId()], nil
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetAddress() string {
|
||||
return lb.Address
|
||||
}
|
||||
@@ -411,6 +422,6 @@ func (lb *SLoadbalancer) GetProjectId() string {
|
||||
return lb.ResourceGroupId
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (lb *SLoadbalancer) SetTags(tags map[string]string, replace bool) error {
|
||||
return lb.region.SetResourceTags("slb", "instance", []string{lb.LoadBalancerId}, tags, replace)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type AclEntrys struct {
|
||||
@@ -31,6 +32,7 @@ type AclEntry struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerAcl struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
AclId string
|
||||
@@ -59,10 +61,6 @@ func (acl *SLoadbalancerAcl) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -48,10 +50,6 @@ func (backend *SLoadbalancerBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type Rule struct {
|
||||
@@ -50,6 +51,7 @@ type AssociatedObjects struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
VServerGroupId string
|
||||
@@ -105,10 +107,6 @@ func (backendgroup *SLoadbalancerBackendGroup) GetType() string {
|
||||
return api.LB_BACKENDGROUP_TYPE_NORMAL
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerDefaultBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerDefaultBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -46,10 +48,6 @@ func (backend *SLoadbalancerDefaultBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerDefaultBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
}
|
||||
|
||||
@@ -76,10 +78,6 @@ func (backendgroup *SLoadbalancerDefaultBackendGroup) GetType() string {
|
||||
return api.LB_BACKENDGROUP_TYPE_DEFAULT
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerHTTPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -102,10 +104,6 @@ func (listerner *SLoadbalancerHTTPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerHTTPSListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -97,10 +99,6 @@ func (listerner *SLoadbalancerHTTPSListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerListenerRule struct {
|
||||
multicloud.SResourceBase
|
||||
httpListener *SLoadbalancerHTTPListener
|
||||
httpsListener *SLoadbalancerHTTPSListener
|
||||
|
||||
@@ -52,10 +54,6 @@ func (lbr *SLoadbalancerListenerRule) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (lbr *SLoadbalancerListenerRule) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListenerRule) IsDefault() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerMasterSlaveBackend struct {
|
||||
multicloud.SResourceBase
|
||||
lbbg *SLoadbalancerMasterSlaveBackendGroup
|
||||
|
||||
ServerId string
|
||||
@@ -50,10 +50,6 @@ func (backend *SLoadbalancerMasterSlaveBackend) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerMasterSlaveBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
MasterSlaveServerGroupId string
|
||||
@@ -67,10 +69,6 @@ func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetStatus() string {
|
||||
return api.LB_STATUS_ENABLED
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SubjectAlternativeNames struct {
|
||||
@@ -27,6 +27,7 @@ type SubjectAlternativeNames struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerServerCertificate struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
ServerCertificateId string // 服务器证书ID。
|
||||
@@ -69,10 +70,6 @@ func (certificate *SLoadbalancerServerCertificate) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerTCPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -82,10 +84,6 @@ func (listerner *SLoadbalancerTCPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetEgressMbps() int {
|
||||
if listerner.Bandwidth < 1 {
|
||||
return 0
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerUDPListener struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
@@ -82,10 +84,6 @@ func (listerner *SLoadbalancerUDPListener) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetEgressMbps() int {
|
||||
if listerner.Bandwidth < 1 {
|
||||
return 0
|
||||
|
||||
@@ -68,10 +68,6 @@ func (self *SRegion) GetClient() *SApsaraClient {
|
||||
return self.client
|
||||
}
|
||||
|
||||
func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) getSdkClient() (*sdk.Client, error) {
|
||||
if self.sdkClient == nil {
|
||||
cli, err := sdk.NewClientWithAccessKey(self.RegionId, self.client.accessKey, self.client.accessSecret)
|
||||
|
||||
@@ -19,10 +19,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
// {"CreationTime":"2017-03-19T13:37:40Z","RouteEntrys":{"RouteEntry":[{"DestinationCidrBlock":"172.31.32.0/20","InstanceId":"","NextHopType":"local","NextHops":{"NextHop":[]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","Status":"Available","Type":"System"},{"DestinationCidrBlock":"100.64.0.0/10","InstanceId":"","NextHopType":"service","NextHops":{"NextHop":[]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","Status":"Available","Type":"System"}]},"RouteTableId":"vtb-j6c60lectdi80rk5xz43g","RouteTableType":"System","VRouterId":"vrt-j6c00qrol733dg36iq4qj"}
|
||||
@@ -32,6 +32,7 @@ type SNextHops struct {
|
||||
}
|
||||
|
||||
type SRouteEntry struct {
|
||||
multicloud.SResourceBase
|
||||
routeTable *SRouteTable
|
||||
|
||||
RouteTableId string
|
||||
@@ -68,10 +69,6 @@ func (route *SRouteEntry) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (route *SRouteEntry) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Custom:自定义路由。 System:系统路由。
|
||||
func (route *SRouteEntry) GetType() string {
|
||||
return route.Type
|
||||
@@ -94,6 +91,7 @@ type SRouteEntrys struct {
|
||||
}
|
||||
|
||||
type SRouteTable struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
vpc *SVpc
|
||||
routes []cloudprovider.ICloudRoute
|
||||
@@ -141,10 +139,6 @@ func (self *SRouteTable) GetName() string {
|
||||
return self.RouteTableName
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetRegionId() string {
|
||||
return self.region.RegionId
|
||||
}
|
||||
|
||||
@@ -101,6 +101,17 @@ func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
tags := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
tags[value.TagKey] = value.TagValue
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.SecurityGroupId
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SnapshotStatusType string
|
||||
@@ -38,6 +39,7 @@ const (
|
||||
)
|
||||
|
||||
type SSnapshot struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
Progress string
|
||||
@@ -136,10 +138,6 @@ func (self *SSnapshot) Delete() error {
|
||||
return self.region.DeleteSnapshot(self.SnapshotId)
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetSnapshots(instanceId string, diskId string, snapshotName string, snapshotIds []string, offset int, limit int) ([]SSnapshot, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SSnapshotPolicyType string
|
||||
@@ -34,6 +35,7 @@ const (
|
||||
)
|
||||
|
||||
type SSnapshotPolicy struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
AutoSnapshotPolicyName string
|
||||
@@ -78,10 +80,6 @@ func (self *SSnapshotPolicy) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetGlobalId() string {
|
||||
return self.AutoSnapshotPolicyId
|
||||
}
|
||||
|
||||
@@ -37,17 +37,15 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SStorage struct {
|
||||
multicloud.SResourceBase
|
||||
zone *SZone
|
||||
storageType string
|
||||
}
|
||||
|
||||
func (self *SStorage) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetId() string {
|
||||
return fmt.Sprintf("%s-%s-%s", self.zone.region.client.cpcfg.Id, self.zone.GetId(), self.storageType)
|
||||
}
|
||||
|
||||
@@ -33,19 +33,17 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
"yunion.io/x/onecloud/pkg/util/qemuimg"
|
||||
)
|
||||
|
||||
type SStoragecache struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
iimages []cloudprovider.ICloudImage
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.region.client.cpcfg.Id, self.region.GetId())
|
||||
}
|
||||
|
||||
@@ -63,10 +63,6 @@ type SVpc struct {
|
||||
VpcName string
|
||||
}
|
||||
|
||||
func (self *SVpc) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SVpc) GetId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
@@ -41,6 +42,7 @@ type SCloudResources struct {
|
||||
}
|
||||
|
||||
type SVSwitch struct {
|
||||
multicloud.SResourceBase
|
||||
wire *SWire
|
||||
|
||||
AvailableIpAddressCount int
|
||||
@@ -61,10 +63,6 @@ type SVSwitch struct {
|
||||
RouteTable SRouteTable
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetId() string {
|
||||
return self.VSwitchId
|
||||
}
|
||||
|
||||
@@ -17,23 +17,20 @@ package apsara
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SWire struct {
|
||||
multicloud.SResourceBase
|
||||
zone *SZone
|
||||
vpc *SVpc
|
||||
|
||||
inetworks []cloudprovider.ICloudNetwork
|
||||
}
|
||||
|
||||
func (self *SWire) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SWire) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.vpc.GetId(), self.zone.GetId())
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ package apsara
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type TChargeType string
|
||||
@@ -107,6 +107,7 @@ type SDedicatedHostTypes struct {
|
||||
}
|
||||
|
||||
type SZone struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
iwires []cloudprovider.ICloudWire
|
||||
@@ -130,10 +131,6 @@ type SZone struct {
|
||||
AvailableDedicatedHostTypes SDedicatedHostTypes
|
||||
}
|
||||
|
||||
func (self *SZone) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SZone) GetId() string {
|
||||
return self.ZoneId
|
||||
}
|
||||
|
||||
@@ -704,7 +704,10 @@ func (b *SBucket) GetTags() (map[string]string, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (b *SBucket) SetTags(tags map[string]string) error {
|
||||
func (b *SBucket) SetTags(tags map[string]string, replace bool) error {
|
||||
if !replace {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
s3cli, err := b.region.GetS3Client()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetS3Client")
|
||||
|
||||
@@ -131,6 +131,12 @@ func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
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
|
||||
|
||||
@@ -97,10 +97,6 @@ func (self *SEipAddress) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetIpAddr() string {
|
||||
return self.IpAddress
|
||||
}
|
||||
|
||||
@@ -54,10 +54,6 @@ func (self *SHost) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SHost) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHost) GetIVMs() ([]cloudprovider.ICloudVM, error) {
|
||||
vms := make([]SInstance, 0)
|
||||
vms, _, err := self.zone.region.GetInstances(self.zone.ZoneId, nil, len(vms), 50)
|
||||
|
||||
@@ -60,6 +60,7 @@ var (
|
||||
)
|
||||
|
||||
type ImageImportTask struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
ImageId string
|
||||
@@ -148,10 +149,6 @@ func (self *ImageImportTask) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *ImageImportTask) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ImageImportTask) GetStatus() string {
|
||||
self.Refresh()
|
||||
if self.Status == "completed" {
|
||||
@@ -274,6 +271,15 @@ func (self *SImage) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["os_arch"] = self.Architecture
|
||||
data["os_name"] = self.OSType
|
||||
data["os_distribution"] = self.OSDist
|
||||
data["os_version"] = self.OSVersion
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SImage) Delete(ctx context.Context) error {
|
||||
// todo: implement me
|
||||
return self.storageCache.region.DeleteImage(self.ImageId)
|
||||
|
||||
@@ -240,6 +240,41 @@ func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
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))
|
||||
data["price_key"] = priceKey
|
||||
data["zone_ext_id"] = self.host.zone.GetGlobalId()
|
||||
if strings.Contains(strings.ToLower(self.OSType), "window") {
|
||||
if loginKey, err := self.host.zone.region.getPasswordData(self.GetId()); err == nil {
|
||||
data["login_key"] = loginKey
|
||||
}
|
||||
}
|
||||
// Name tag
|
||||
tags, err := FetchTags(self.host.zone.region.ec2Client, self.InstanceId)
|
||||
if err == nil {
|
||||
name, err := tags.GetString("Name")
|
||||
if err == nil {
|
||||
data["Name"] = name
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := FetchTags(self.host.zone.region.ec2Client, self.InstanceId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "FetchTags(self.host.zone.region.ec2Client, self.InstanceId)")
|
||||
}
|
||||
data := map[string]string{}
|
||||
err = tags.Unmarshal(&data)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "tags.Unmarshal")
|
||||
}
|
||||
delete(data, "Name")
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetBillingType() string {
|
||||
// todo: implement me
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
@@ -1169,7 +1204,8 @@ func (self *SInstance) GetError() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
delete(tags, "Name")
|
||||
oldTagsJson, err := FetchTags(self.host.zone.region.ec2Client, self.InstanceId)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "FetchTags(self.host.zone.region.ec2Client, %s)", self.InstanceId)
|
||||
|
||||
@@ -3,12 +3,12 @@ package aws
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SInternetGateway struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
Attachments []InternetGatewayAttachment `json:"Attachments"`
|
||||
@@ -45,7 +45,3 @@ func (i *SInternetGateway) Refresh() error {
|
||||
func (i *SInternetGateway) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *SInternetGateway) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -37,6 +38,7 @@ https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/Welcome.htm
|
||||
*/
|
||||
|
||||
type SElb struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
Type string `json:"Type"`
|
||||
@@ -137,6 +139,29 @@ func (self *SElb) GetMetadata() *jsonutils.JSONDict {
|
||||
return metadata
|
||||
}
|
||||
|
||||
func (self *SElb) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["loadbalance_type"] = self.Type
|
||||
attrs, err := self.region.getElbAttributesById(self.GetId())
|
||||
if err != nil {
|
||||
log.Errorf("SElb GetSysTags %s", err)
|
||||
return data
|
||||
}
|
||||
|
||||
for k, v := range attrs {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SElb) GetTags() (map[string]string, error) {
|
||||
tags, err := self.region.FetchElbTags(self.LoadBalancerArn)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "self.region.FetchElbTags")
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (self *SElb) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
@@ -479,7 +504,7 @@ func (self *SRegion) CreateElbBackendgroup(group *cloudprovider.SLoadbalancerBac
|
||||
return nil, fmt.Errorf("CreateElbBackendgroup error: %#v", backendgroups)
|
||||
}
|
||||
|
||||
func (self *SElb) SetMetadata(tags map[string]string, replace bool) error {
|
||||
func (self *SElb) SetTags(tags map[string]string, replace bool) error {
|
||||
oldTags, err := self.region.FetchElbTags(self.LoadBalancerArn)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "self.region.FetchElbTags(%s)", self.LoadBalancerArn)
|
||||
|
||||
@@ -21,9 +21,11 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SElbBackend struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
group *SElbBackendGroup
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SElbBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
lb *SElb
|
||||
|
||||
@@ -109,6 +111,15 @@ func (self *SElbBackendGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return metadata
|
||||
}
|
||||
|
||||
func (self *SElbBackendGroup) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
data["port"] = strconv.FormatInt(self.Port, 10)
|
||||
data["target_type"] = self.TargetType
|
||||
data["health_check_protocol"] = strings.ToLower(self.HealthCheckProtocol)
|
||||
data["health_check_interval"] = strconv.Itoa(self.HealthCheckIntervalSeconds)
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SElbBackendGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -29,9 +29,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SElbCertificate struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
cert *x509.Certificate
|
||||
|
||||
|
||||
@@ -30,9 +30,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SElbListener struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
lb *SElb
|
||||
group *SElbBackendGroup
|
||||
|
||||
@@ -28,9 +28,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SElbListenerRule struct {
|
||||
multicloud.SResourceBase
|
||||
listener *SElbListener
|
||||
region *SRegion
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -27,10 +28,12 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
multicloud.SResourceBase
|
||||
wire *SWire
|
||||
|
||||
AvailableIpAddressCount int
|
||||
@@ -103,6 +106,26 @@ func (self *SNetwork) GetMetadata() *jsonutils.JSONDict {
|
||||
return meta
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
data["support_eip"] = strconv.FormatBool(support_eip)
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIWire() cloudprovider.ICloudWire {
|
||||
return self.wire
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import (
|
||||
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
@@ -437,10 +436,6 @@ func (self *SRegion) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetGeographicInfo() cloudprovider.SGeographicInfo {
|
||||
if info, ok := LatitudeAndLongitude[self.RegionId]; ok {
|
||||
return info
|
||||
|
||||
@@ -17,12 +17,12 @@ package aws
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SRoute struct {
|
||||
multicloud.SResourceBase
|
||||
routetable *SRouteTable
|
||||
|
||||
DestinationCIDRBlock string `json:"DestinationCidrBlock"`
|
||||
@@ -65,10 +65,6 @@ func (self *SRoute) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SRoute) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRoute) GetType() string {
|
||||
switch self.Origin {
|
||||
case "CreateRouteTable":
|
||||
|
||||
@@ -25,9 +25,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SRouteTable struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
vpc *SVpc
|
||||
|
||||
@@ -81,10 +83,6 @@ func (self *SRouteTable) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRouteTable) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -113,6 +113,17 @@ func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetSysTags() map[string]string {
|
||||
if len(self.Tags.Tag) == 0 {
|
||||
return nil
|
||||
}
|
||||
data := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
data[value.TagKey] = value.TagValue
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
return self.Description
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SnapshotStatusType string
|
||||
@@ -36,6 +37,7 @@ const (
|
||||
)
|
||||
|
||||
type SSnapshot struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
|
||||
Progress string
|
||||
@@ -95,10 +97,6 @@ func (self *SSnapshot) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.SourceDiskSize * 1024
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SStorage struct {
|
||||
multicloud.SResourceBase
|
||||
zone *SZone
|
||||
storageType string
|
||||
}
|
||||
@@ -53,10 +55,6 @@ func (self *SStorage) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.zone.region.getStoragecache()
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user