feat(bingocloud):changed some abilities of bingocloud

This commit is contained in:
李锐
2023-01-17 18:26:59 +08:00
parent 9654b2c2c4
commit e52651b41f
2 changed files with 50 additions and 5 deletions
+46
View File
@@ -15,10 +15,16 @@
package guestdrivers
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/util/billing"
"yunion.io/x/pkg/util/rbacscope"
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
@@ -34,6 +40,14 @@ func init() {
models.RegisterGuestDriver(&driver)
}
func (self *SBingoCloudGuestDriver) DoScheduleCPUFilter() bool { return false }
func (self *SBingoCloudGuestDriver) DoScheduleMemoryFilter() bool { return false }
func (self *SBingoCloudGuestDriver) DoScheduleSKUFilter() bool { return false }
func (self *SBingoCloudGuestDriver) DoScheduleStorageFilter() bool { return false }
func (self *SBingoCloudGuestDriver) GetHypervisor() string {
return api.HYPERVISOR_BINGO_CLOUD
}
@@ -73,6 +87,38 @@ func (self *SBingoCloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacSco
return keys
}
func (self *SBingoCloudGuestDriver) GetDeployStatus() ([]string, error) {
return []string{api.VM_READY, api.VM_RUNNING}, nil
}
func (self *SBingoCloudGuestDriver) GetDefaultSysDiskBackend() string {
return ""
}
func (self *SBingoCloudGuestDriver) GetGuestInitialStateAfterCreate() string {
return api.VM_RUNNING
}
func (self *SBingoCloudGuestDriver) GetGuestInitialStateAfterRebuild() string {
return api.VM_READY
}
func (self *SBingoCloudGuestDriver) IsSupportedBillingCycle(bc billing.SBillingCycle) bool {
return false
}
func (self *SBingoCloudGuestDriver) RemoteDeployGuestSyncHost(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, host *models.SHost, iVM cloudprovider.ICloudVM) (cloudprovider.ICloudHost, error) {
if hostId := iVM.GetIHostId(); len(hostId) > 0 {
nh, err := db.FetchByExternalIdAndManagerId(models.HostManager, hostId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
return q.Equals("manager_id", host.ManagerId)
})
if err != nil {
log.Warningf("failed to found new hostId(%s) for ivm %s(%s) error: %v", hostId, guest.Name, guest.Id, err)
} else if nh.GetId() != guest.HostId {
guest.OnScheduleToHost(ctx, userCred, nh.GetId())
host = nh.(*models.SHost)
}
}
return host.GetIHost(ctx)
}
+4 -5
View File
@@ -16,7 +16,6 @@ package regiondrivers
import (
"context"
"fmt"
"strings"
"yunion.io/x/cloudmux/pkg/cloudprovider"
@@ -46,7 +45,7 @@ func (self *SBingoCloudRegionDriver) IsAllowSecurityGroupNameRepeat() bool {
func (self *SBingoCloudRegionDriver) GenerateSecurityGroupName(name string) string {
if strings.ToLower(name) == "default" {
return "DefaultGroup"
return "default"
}
return name
}
@@ -56,13 +55,13 @@ func (self *SBingoCloudRegionDriver) IsSecurityGroupBelongVpc() bool {
}
func (self *SBingoCloudRegionDriver) GetDefaultSecurityGroupInRule() cloudprovider.SecurityRule {
return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("in:deny any")}
return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("in:allow any")}
}
func (self *SBingoCloudRegionDriver) GetDefaultSecurityGroupOutRule() cloudprovider.SecurityRule {
return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("out:deny any")}
return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("out:allow any")}
}
func (self *SBingoCloudRegionDriver) ValidateCreateSnapshotData(ctx context.Context, userCred mcclient.TokenCredential, disk *models.SDisk, storage *models.SStorage, input *api.SnapshotCreateInput) error {
return fmt.Errorf("%s does not support creating snapshot", self.GetProvider())
return nil
}