qingcloud.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/cloudmux/pkg/cloudprovider"
  17. "yunion.io/x/pkg/util/billing"
  18. "yunion.io/x/pkg/util/rbacscope"
  19. api "yunion.io/x/onecloud/pkg/apis/compute"
  20. "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
  21. "yunion.io/x/onecloud/pkg/compute/models"
  22. "yunion.io/x/onecloud/pkg/mcclient"
  23. )
  24. type SQingCloudGuestDriver struct {
  25. SManagedVirtualizedGuestDriver
  26. }
  27. func init() {
  28. driver := SQingCloudGuestDriver{}
  29. models.RegisterGuestDriver(&driver)
  30. }
  31. func (self *SQingCloudGuestDriver) GetHypervisor() string {
  32. return api.HYPERVISOR_QINGCLOUD
  33. }
  34. func (self *SQingCloudGuestDriver) GetProvider() string {
  35. return api.CLOUD_PROVIDER_QINGCLOUD
  36. }
  37. func (self *SQingCloudGuestDriver) GetDefaultSysDiskBackend() string {
  38. return ""
  39. }
  40. func (self *SQingCloudGuestDriver) GetMinimalSysDiskSizeGb() int {
  41. return 20
  42. }
  43. func (self *SQingCloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
  44. keys := models.SComputeResourceKeys{}
  45. keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
  46. keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD
  47. keys.Provider = api.CLOUD_PROVIDER_QINGCLOUD
  48. keys.Brand = api.CLOUD_PROVIDER_QINGCLOUD
  49. keys.Hypervisor = api.HYPERVISOR_QINGCLOUD
  50. return keys
  51. }
  52. func (self *SQingCloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
  53. return cloudprovider.SInstanceCapability{
  54. Hypervisor: self.GetHypervisor(),
  55. Provider: self.GetProvider(),
  56. DefaultAccount: cloudprovider.SDefaultAccount{
  57. Linux: cloudprovider.SOsDefaultAccount{
  58. DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
  59. Changeable: false,
  60. },
  61. Windows: cloudprovider.SOsDefaultAccount{
  62. DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
  63. Changeable: false,
  64. },
  65. },
  66. }
  67. }
  68. func (self *SQingCloudGuestDriver) GetGuestInitialStateAfterCreate() string {
  69. return api.VM_READY
  70. }
  71. func (self *SQingCloudGuestDriver) GetGuestInitialStateAfterRebuild() string {
  72. return api.VM_READY
  73. }
  74. func (self *SQingCloudGuestDriver) AllowReconfigGuest() bool {
  75. return true
  76. }
  77. func (self *SQingCloudGuestDriver) IsSupportedBillingCycle(bc billing.SBillingCycle) bool {
  78. return false
  79. }
  80. func (self *SQingCloudGuestDriver) IsSupportPublicipToEip() bool {
  81. return false
  82. }
  83. func (self *SQingCloudGuestDriver) IsSupportSetAutoRenew() bool {
  84. return false
  85. }