mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix: add cloudprovider capabilities
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -115,6 +116,32 @@ type ICloudProvider interface {
|
||||
GetCloudRegionExternalIdPrefix() string
|
||||
|
||||
GetStorageClasses(regionId string) []string
|
||||
|
||||
GetCapabilities() []string
|
||||
}
|
||||
|
||||
func IsSupportProject(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_PROJECT, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
func IsSupportCompute(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_COMPUTE, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
func IsSupportLoadbalancer(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_LOADBALANCER, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
func IsSupportObjectstore(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_OBJECTSTORE, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
func IsSupportRds(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_RDS, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
func IsSupportElasticCache(prod ICloudProvider) bool {
|
||||
return utils.IsInStringArray(CLOUD_CAPABILITY_CACHE, prod.GetCapabilities())
|
||||
}
|
||||
|
||||
var providerTable map[string]ICloudProviderFactory
|
||||
|
||||
@@ -39,3 +39,12 @@ const (
|
||||
ErrInvalidProvider = httperrors.ErrInvalidProvider
|
||||
ErrNoBalancePermission = httperrors.ErrNoBalancePermission
|
||||
)
|
||||
|
||||
const (
|
||||
CLOUD_CAPABILITY_PROJECT = "project"
|
||||
CLOUD_CAPABILITY_COMPUTE = "compute"
|
||||
CLOUD_CAPABILITY_LOADBALANCER = "loadbalancer"
|
||||
CLOUD_CAPABILITY_OBJECTSTORE = "objectstore"
|
||||
CLOUD_CAPABILITY_RDS = "rds"
|
||||
CLOUD_CAPABILITY_CACHE = "cache"
|
||||
)
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -70,30 +71,29 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context.
|
||||
|
||||
cachedImage := scimg.GetCachedimage()
|
||||
if cachedImage == nil {
|
||||
return nil, fmt.Errorf("cached image not found???")
|
||||
return nil, errors.Wrap(httperrors.ErrImageNotFound, "cached image not found???")
|
||||
}
|
||||
|
||||
iStorageCache, err := storageCache.GetIStorageCache()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "storageCache.GetIStorageCache")
|
||||
}
|
||||
|
||||
image.ExternalId = scimg.ExternalId
|
||||
if cachedImage.ImageType == cloudprovider.CachedImageTypeCustomized {
|
||||
image.ExternalId, err = iStorageCache.UploadImage(ctx, userCred, image, isForce)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "iStorageCache.UploadImage")
|
||||
}
|
||||
} else {
|
||||
_, err = iStorageCache.GetIImageById(cachedImage.ExternalId)
|
||||
if err != nil {
|
||||
log.Errorf("remote image fetch error %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "iStorageCache.GetIImageById")
|
||||
}
|
||||
image.ExternalId = cachedImage.ExternalId
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// should record the externalId immediately
|
||||
// so the waiting goroutine could pick the new externalId
|
||||
// and avoid duplicate uploading
|
||||
|
||||
@@ -57,6 +57,9 @@ type SCapabilities struct {
|
||||
PublicNetworkCount int
|
||||
DBInstance map[string]map[string]map[string][]string //map[engine][engineVersion][category][]{storage_type}
|
||||
Specs jsonutils.JSONObject
|
||||
|
||||
StorageTypes2 map[string][]string `json:",allowempty"`
|
||||
DataStorageTypes2 map[string][]string `json:",allowempty"`
|
||||
}
|
||||
|
||||
func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, region *SCloudregion, zone *SZone) (SCapabilities, error) {
|
||||
@@ -88,8 +91,10 @@ func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, que
|
||||
getBrands(region, zone, domainId, &capa)
|
||||
// capa.Brands, capa.ComputeEngineBrands, capa.NetworkManageBrands, capa.ObjectStorageBrands = a, c, n, o
|
||||
capa.ResourceTypes = getResourceTypes(region, zone, domainId)
|
||||
capa.StorageTypes = getStorageTypes(region, zone, true, domainId)
|
||||
capa.DataStorageTypes = getStorageTypes(region, zone, false, domainId)
|
||||
capa.StorageTypes = getStorageTypes(region, zone, true, domainId, "")
|
||||
capa.DataStorageTypes = getStorageTypes(region, zone, false, domainId, "")
|
||||
capa.StorageTypes2 = getStorageTypes2(region, zone, true, domainId, capa.Hypervisors)
|
||||
capa.DataStorageTypes2 = getStorageTypes2(region, zone, false, domainId, capa.Hypervisors)
|
||||
capa.GPUModels = getGPUs(region, zone, domainId)
|
||||
capa.SchedPolicySupport = isSchedPolicySupported(region, zone)
|
||||
capa.MinNicCount = getMinNicCount(region, zone)
|
||||
@@ -379,7 +384,16 @@ func getResourceTypes(region *SCloudregion, zone *SZone, domainId string) []stri
|
||||
return resourceTypes
|
||||
}
|
||||
|
||||
func getStorageTypes(region *SCloudregion, zone *SZone, isSysDisk bool, domainId string) []string {
|
||||
func getStorageTypes2(region *SCloudregion, zone *SZone, isSysDisk bool, domainId string, hypervisors []string) map[string][]string {
|
||||
ret := make(map[string][]string)
|
||||
for _, hypervisor := range hypervisors {
|
||||
hostType := api.HYPERVISOR_HOSTTYPE[hypervisor]
|
||||
ret[hypervisor] = getStorageTypes(region, zone, isSysDisk, domainId, hostType)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func getStorageTypes(region *SCloudregion, zone *SZone, isSysDisk bool, domainId string, hostType string) []string {
|
||||
storages := StorageManager.Query().SubQuery()
|
||||
hostStorages := HoststorageManager.Query().SubQuery()
|
||||
hosts := HostManager.Query().SubQuery()
|
||||
@@ -407,6 +421,9 @@ func getStorageTypes(region *SCloudregion, zone *SZone, isSysDisk bool, domainId
|
||||
sqlchemy.IsNullOrEmpty(hosts.Field("manager_id")),
|
||||
))
|
||||
}
|
||||
if len(hostType) > 0 {
|
||||
q = q.Filter(sqlchemy.Equals(hosts.Field("host_type"), hostType))
|
||||
}
|
||||
q = q.Filter(sqlchemy.Equals(hosts.Field("resource_type"), api.HostResourceTypeShared))
|
||||
q = q.Filter(sqlchemy.IsNotEmpty(storages.Field("storage_type")))
|
||||
q = q.Filter(sqlchemy.IsNotNull(storages.Field("storage_type")))
|
||||
|
||||
@@ -995,7 +995,9 @@ func syncPublicCloudProviderInfo(
|
||||
|
||||
storageCachePairs := make([]sStoragecacheSyncPair, 0)
|
||||
|
||||
syncProjects(ctx, userCred, syncResults, driver, provider)
|
||||
if cloudprovider.IsSupportProject(driver) {
|
||||
syncProjects(ctx, userCred, syncResults, driver, provider)
|
||||
}
|
||||
|
||||
localZones, remoteZones, _ := syncRegionZones(ctx, userCred, syncResults, provider, localRegion, remoteRegion)
|
||||
|
||||
@@ -1008,45 +1010,57 @@ func syncPublicCloudProviderInfo(
|
||||
|
||||
// no need to lock public cloud region as cloud region for public cloud is readonly
|
||||
|
||||
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, remoteRegion)
|
||||
|
||||
// 需要先同步vpc,避免私有云eip找不到network
|
||||
syncRegionVPCs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
|
||||
syncRegionEips(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
// sync snapshot policies before sync disks
|
||||
syncRegionSnapshotPolicies(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
|
||||
for j := 0; j < len(localZones); j += 1 {
|
||||
|
||||
if len(syncRange.Zone) > 0 && !utils.IsInStringArray(localZones[j].Id, syncRange.Zone) {
|
||||
continue
|
||||
}
|
||||
// no need to lock zone as public cloud zone is read-only
|
||||
|
||||
newPairs := syncZoneStorages(ctx, userCred, syncResults, provider, driver, &localZones[j], remoteZones[j], syncRange, storageCachePairs)
|
||||
if len(newPairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newPairs...)
|
||||
}
|
||||
newPairs = syncZoneHosts(ctx, userCred, syncResults, provider, driver, &localZones[j], remoteZones[j], syncRange, storageCachePairs)
|
||||
if len(newPairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newPairs...)
|
||||
}
|
||||
if cloudprovider.IsSupportObjectstore(driver) {
|
||||
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, remoteRegion)
|
||||
}
|
||||
|
||||
// sync snapshots after sync disks
|
||||
syncRegionSnapshots(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
if cloudprovider.IsSupportCompute(driver) {
|
||||
// 需要先同步vpc,避免私有云eip找不到network
|
||||
syncRegionVPCs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
|
||||
syncRegionLoadbalancerAcls(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionLoadbalancerCertificates(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionLoadbalancers(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionEips(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
// sync snapshot policies before sync disks
|
||||
syncRegionSnapshotPolicies(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
|
||||
syncRegionNetworkInterfaces(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
for j := 0; j < len(localZones); j += 1 {
|
||||
|
||||
syncRegionDBInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionDBInstanceBackups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
if len(syncRange.Zone) > 0 && !utils.IsInStringArray(localZones[j].Id, syncRange.Zone) {
|
||||
continue
|
||||
}
|
||||
// no need to lock zone as public cloud zone is read-only
|
||||
|
||||
syncElasticcaches(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
newPairs := syncZoneStorages(ctx, userCred, syncResults, provider, driver, &localZones[j], remoteZones[j], syncRange, storageCachePairs)
|
||||
if len(newPairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newPairs...)
|
||||
}
|
||||
newPairs = syncZoneHosts(ctx, userCred, syncResults, provider, driver, &localZones[j], remoteZones[j], syncRange, storageCachePairs)
|
||||
if len(newPairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newPairs...)
|
||||
}
|
||||
}
|
||||
|
||||
// sync snapshots after sync disks
|
||||
syncRegionSnapshots(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
}
|
||||
|
||||
if cloudprovider.IsSupportLoadbalancer(driver) {
|
||||
syncRegionLoadbalancerAcls(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionLoadbalancerCertificates(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionLoadbalancers(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
}
|
||||
|
||||
if cloudprovider.IsSupportCompute(driver) {
|
||||
syncRegionNetworkInterfaces(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
}
|
||||
|
||||
if cloudprovider.IsSupportRds(driver) {
|
||||
syncRegionDBInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
syncRegionDBInstanceBackups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
}
|
||||
|
||||
if cloudprovider.IsSupportElasticCache(driver) {
|
||||
syncElasticcaches(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
}
|
||||
|
||||
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
|
||||
for i := range storageCachePairs {
|
||||
@@ -1074,7 +1088,9 @@ func syncOnPremiseCloudProviderInfo(
|
||||
) error {
|
||||
log.Debugf("Start sync on-premise provider %s(%s)", provider.Name, provider.Provider)
|
||||
|
||||
syncProjects(ctx, userCred, syncResults, driver, provider)
|
||||
if cloudprovider.IsSupportProject(driver) {
|
||||
syncProjects(ctx, userCred, syncResults, driver, provider)
|
||||
}
|
||||
|
||||
iregion, err := driver.GetOnPremiseIRegion()
|
||||
if err != nil {
|
||||
@@ -1084,41 +1100,45 @@ func syncOnPremiseCloudProviderInfo(
|
||||
}
|
||||
|
||||
localRegion := CloudregionManager.FetchDefaultRegion()
|
||||
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, iregion)
|
||||
|
||||
ihosts, err := iregion.GetIHosts()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetIHosts for provider %s failed %s", provider.GetName(), err)
|
||||
log.Errorf(msg)
|
||||
return err
|
||||
if cloudprovider.IsSupportObjectstore(driver) {
|
||||
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, iregion)
|
||||
}
|
||||
|
||||
localHosts, remoteHosts, result := HostManager.SyncHosts(ctx, userCred, provider, nil, ihosts)
|
||||
|
||||
syncResults.Add(HostManager, result)
|
||||
|
||||
msg := result.Result()
|
||||
notes := fmt.Sprintf("SyncHosts for provider %s result: %s", provider.Name, msg)
|
||||
log.Infof(notes)
|
||||
//if result.IsError() {
|
||||
// logSyncFailed(provider, task, msg)
|
||||
// return
|
||||
//}
|
||||
// db.OpsLog.LogEvent(provider, db.ACT_SYNC_HOST_COMPLETE, msg, userCred)
|
||||
// logclient.AddActionLog(provider, getAction(task.Params), notes, task.UserCred, true)
|
||||
|
||||
storageCachePairs := make([]sStoragecacheSyncPair, 0)
|
||||
if cloudprovider.IsSupportCompute(driver) {
|
||||
ihosts, err := iregion.GetIHosts()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetIHosts for provider %s failed %s", provider.GetName(), err)
|
||||
log.Errorf(msg)
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(localHosts); i += 1 {
|
||||
if len(syncRange.Host) > 0 && !utils.IsInStringArray(localHosts[i].Id, syncRange.Host) {
|
||||
continue
|
||||
localHosts, remoteHosts, result := HostManager.SyncHosts(ctx, userCred, provider, nil, ihosts)
|
||||
|
||||
syncResults.Add(HostManager, result)
|
||||
|
||||
msg := result.Result()
|
||||
notes := fmt.Sprintf("SyncHosts for provider %s result: %s", provider.Name, msg)
|
||||
log.Infof(notes)
|
||||
//if result.IsError() {
|
||||
// logSyncFailed(provider, task, msg)
|
||||
// return
|
||||
//}
|
||||
// db.OpsLog.LogEvent(provider, db.ACT_SYNC_HOST_COMPLETE, msg, userCred)
|
||||
// logclient.AddActionLog(provider, getAction(task.Params), notes, task.UserCred, true)
|
||||
|
||||
for i := 0; i < len(localHosts); i += 1 {
|
||||
if len(syncRange.Host) > 0 && !utils.IsInStringArray(localHosts[i].Id, syncRange.Host) {
|
||||
continue
|
||||
}
|
||||
newCachePairs := syncHostStorages(ctx, userCred, syncResults, provider, &localHosts[i], remoteHosts[i], storageCachePairs)
|
||||
if len(newCachePairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newCachePairs...)
|
||||
}
|
||||
syncHostNics(ctx, userCred, provider, &localHosts[i], remoteHosts[i])
|
||||
syncHostVMs(ctx, userCred, syncResults, provider, driver, &localHosts[i], remoteHosts[i], syncRange)
|
||||
}
|
||||
newCachePairs := syncHostStorages(ctx, userCred, syncResults, provider, &localHosts[i], remoteHosts[i], storageCachePairs)
|
||||
if len(newCachePairs) > 0 {
|
||||
storageCachePairs = append(storageCachePairs, newCachePairs...)
|
||||
}
|
||||
syncHostNics(ctx, userCred, provider, &localHosts[i], remoteHosts[i])
|
||||
syncHostVMs(ctx, userCred, syncResults, provider, driver, &localHosts[i], remoteHosts[i], syncRange)
|
||||
}
|
||||
|
||||
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
|
||||
@@ -1131,6 +1151,7 @@ func syncOnPremiseCloudProviderInfo(
|
||||
log.Infof("syncCloudImages result: %s", msg)
|
||||
// }
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -396,3 +396,15 @@ func (region *SAliyunClient) GetIProjects() ([]cloudprovider.ICloudProject, erro
|
||||
// body, err := region.ecsRequest("ListResourceGroups", params)
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (region *SAliyunClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -151,3 +151,7 @@ func (self *SAliyunProvider) GetStorageClasses(regionId string) []string {
|
||||
"Standard", "IA", "Archive",
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAliyunProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -388,3 +388,15 @@ func jsonRequest(cli *client.Client, apiName string, params map[string]string, r
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -155,3 +155,7 @@ func (self *SAwsProvider) GetStorageClasses(regionId string) []string {
|
||||
func (self *SAwsProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return self.client.GetAccessEnv() + "/"
|
||||
}
|
||||
|
||||
func (self *SAwsProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -963,3 +963,15 @@ func (self *SAzureClient) GetAccessEnv() string {
|
||||
return api.CLOUD_ACCESS_ENV_AZURE_CHINA
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAzureClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -193,3 +193,7 @@ func (self *SAzureProvider) GetStorageClasses(regionId string) []string {
|
||||
func (self *SAzureProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return self.client.GetAccessEnv() + "/"
|
||||
}
|
||||
|
||||
func (self *SAzureProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -303,3 +303,15 @@ func (self *SCtyunClient) GetCloudRegionExternalIdPrefix() string {
|
||||
return CLOUD_PROVIDER_CTYUN
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SCtyunClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -158,3 +158,7 @@ func (self *SCtyunProvider) GetStorageClasses(regionId string) []string {
|
||||
func (self *SCtyunProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return self.client.GetCloudRegionExternalIdPrefix()
|
||||
}
|
||||
|
||||
func (self *SCtyunProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -407,3 +407,15 @@ func (cli *SESXiClient) IsVCenter() bool {
|
||||
func (cli *SESXiClient) IsValid() bool {
|
||||
return cli.client.Client.Valid()
|
||||
}
|
||||
|
||||
func (cli *SESXiClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -188,3 +188,7 @@ func (self *SESXiProvider) GetIProjects() ([]cloudprovider.ICloudProject, error)
|
||||
func (self *SESXiProvider) GetStorageClasses(regionId string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SESXiProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -268,3 +268,15 @@ func (self *SGoogleClient) GetIProjects() ([]cloudprovider.ICloudProject, error)
|
||||
}
|
||||
return iprojects, nil
|
||||
}
|
||||
|
||||
func (self *SGoogleClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -184,3 +184,7 @@ func (self *SGoogleProvider) GetStorageClasses(regionId string) []string {
|
||||
"Standard", "IA", "Archive",
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SGoogleProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -414,3 +414,18 @@ func (self *SHuaweiClient) GetAccessEnv() string {
|
||||
return api.CLOUD_ACCESS_ENV_HUAWEI_GLOBAL
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SHuaweiClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
if self.isMainProject {
|
||||
caps = append(caps, cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE)
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -185,3 +185,7 @@ func (self *SHuaweiProvider) GetStorageClasses(regionId string) []string {
|
||||
"STANDARD", "WARM", "COLD",
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SHuaweiProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -946,7 +946,8 @@ func (region *SRegion) GetIBuckets() ([]cloudprovider.ICloudBucket, error) {
|
||||
}
|
||||
ret := make([]cloudprovider.ICloudBucket, 0)
|
||||
for i := range iBuckets {
|
||||
if iBuckets[i].GetLocation() == region.GetId() && region.client.isMainProject {
|
||||
// huawei OBS is shared across projects
|
||||
if iBuckets[i].GetLocation() == region.GetId() {
|
||||
ret = append(ret, iBuckets[i])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/multicloud/huawei"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -45,4 +47,10 @@ func init() {
|
||||
printList(domains, 0, 0, 0, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
shellutils.R(&RegionListOptions{}, "capabilities", "Get capabilities", func(cli *huawei.SRegion, args *RegionListOptions) error {
|
||||
capabilities := cli.GetClient().GetCapabilities()
|
||||
fmt.Println(capabilities)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, userCred mcclient.To
|
||||
s := auth.GetAdminSession(ctx, options.Options.Region, "")
|
||||
meta, reader, sizeByte, err := modules.Images.Download(s, image.ImageId, string(qemuimg.VMDK), false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "Images.Download")
|
||||
}
|
||||
log.Debugf("Images meta data %s", meta)
|
||||
|
||||
@@ -191,7 +191,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, userCred mcclient.To
|
||||
|
||||
bucket, err := self.region.GetIBucketByName(bucketName)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "GetIBucketByName")
|
||||
return "", errors.Wrapf(err, "GetIBucketByName", bucketName)
|
||||
}
|
||||
|
||||
err = cloudprovider.UploadObject(context.Background(), bucket, image.ImageId, 0, reader, sizeByte, "", "", nil, false)
|
||||
|
||||
@@ -39,4 +39,6 @@ type IBucketProvider interface {
|
||||
SetObjectAcl(bucket, key string, cannedAcl cloudprovider.TBucketACLType) error
|
||||
GetIBucketAcl(name string) (cloudprovider.TBucketACLType, error)
|
||||
SetIBucketAcl(name string, cannedAcl cloudprovider.TBucketACLType) error
|
||||
|
||||
GetCapabilities() []string
|
||||
}
|
||||
|
||||
@@ -524,3 +524,15 @@ func (cli *SObjectStoreClient) GetIBucketById(name string) (cloudprovider.ICloud
|
||||
func (cli *SObjectStoreClient) GetIBucketByName(name string) (cloudprovider.ICloudBucket, error) {
|
||||
return cli.GetIBucketById(name)
|
||||
}
|
||||
|
||||
func (self *SObjectStoreClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
// cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -152,3 +152,7 @@ func (self *SObjectStoreProvider) GetAccountId() string {
|
||||
func (self *SObjectStoreProvider) GetStorageClasses(regionId string) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func (self *SObjectStoreProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -255,3 +255,15 @@ func (cli *SOpenStackClient) GetIProjects() ([]cloudprovider.ICloudProject, erro
|
||||
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SOpenStackClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -192,3 +192,7 @@ func (self *SOpenStackProvider) GetIProjects() ([]cloudprovider.ICloudProject, e
|
||||
func (self *SOpenStackProvider) GetStorageClasses(regionId string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SOpenStackProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -189,3 +189,7 @@ func (self *SQcloudProvider) GetStorageClasses(regionId string) []string {
|
||||
"STANDARD", "STANDARD_IA", "ARCHIVE",
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SQcloudProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -748,3 +748,15 @@ func (client *SQcloudClient) GetIProjects() ([]cloudprovider.ICloudProject, erro
|
||||
}
|
||||
return iprojects, nil
|
||||
}
|
||||
|
||||
func (self *SQcloudClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -169,3 +169,7 @@ func (self *SUcloudProvider) GetStorageClasses(regionId string) []string {
|
||||
"STANDARD", "IA", "ARCHIVE",
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SUcloudProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -342,3 +342,15 @@ func (self *SUcloudClient) GetIStorageById(id string) (cloudprovider.ICloudStora
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SUcloudClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
@@ -145,3 +145,7 @@ func (self *SZStackProvider) GetIProjects() ([]cloudprovider.ICloudProject, erro
|
||||
func (self *SZStackProvider) GetStorageClasses(regionId string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SZStackProvider) GetCapabilities() []string {
|
||||
return self.client.GetCapabilities()
|
||||
}
|
||||
|
||||
@@ -433,3 +433,15 @@ func (cli *SZStackClient) GetRegions() []SRegion {
|
||||
func (cli *SZStackClient) GetIProjects() ([]cloudprovider.ICloudProject, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SZStackClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
// cloudprovider.CLOUD_CAPABILITY_PROJECT,
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_LOADBALANCER,
|
||||
// cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE,
|
||||
// cloudprovider.CLOUD_CAPABILITY_RDS,
|
||||
// cloudprovider.CLOUD_CAPABILITY_CACHE,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user