apsara.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package guestdrivers
  15. import (
  16. "yunion.io/x/pkg/util/billing"
  17. "yunion.io/x/pkg/util/rbacscope"
  18. api "yunion.io/x/onecloud/pkg/apis/compute"
  19. "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
  20. "yunion.io/x/onecloud/pkg/compute/models"
  21. "yunion.io/x/onecloud/pkg/mcclient"
  22. )
  23. type SApsaraGuestDriver struct {
  24. SAliyunGuestDriver
  25. }
  26. func init() {
  27. driver := SApsaraGuestDriver{}
  28. models.RegisterGuestDriver(&driver)
  29. }
  30. func (self *SApsaraGuestDriver) DoScheduleSKUFilter() bool { return false }
  31. func (self *SApsaraGuestDriver) GetHypervisor() string {
  32. return api.HYPERVISOR_APSARA
  33. }
  34. func (self *SApsaraGuestDriver) GetProvider() string {
  35. return api.CLOUD_PROVIDER_APSARA
  36. }
  37. func (self *SApsaraGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
  38. keys := models.SComputeResourceKeys{}
  39. keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
  40. keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD
  41. keys.Provider = api.CLOUD_PROVIDER_APSARA
  42. keys.Brand = api.CLOUD_PROVIDER_APSARA
  43. keys.Hypervisor = api.HYPERVISOR_APSARA
  44. return keys
  45. }
  46. func (self *SApsaraGuestDriver) GetGuestInitialStateAfterCreate() string {
  47. return api.VM_READY
  48. }
  49. func (self *SApsaraGuestDriver) GetGuestInitialStateAfterRebuild() string {
  50. return api.VM_READY
  51. }
  52. func (self *SApsaraGuestDriver) AllowReconfigGuest() bool {
  53. return true
  54. }
  55. func (self *SApsaraGuestDriver) IsSupportedBillingCycle(bc billing.SBillingCycle) bool {
  56. return false
  57. }
  58. func (self *SApsaraGuestDriver) IsSupportPublicipToEip() bool {
  59. return false
  60. }
  61. func (self *SApsaraGuestDriver) IsSupportSetAutoRenew() bool {
  62. return false
  63. }