remotefile.go 2.4 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/cloudmux/pkg/cloudprovider"
  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/compute/options"
  22. "yunion.io/x/onecloud/pkg/mcclient"
  23. )
  24. type SRemoteFileGuestDriver struct {
  25. SManagedVirtualizedGuestDriver
  26. }
  27. func init() {
  28. driver := SRemoteFileGuestDriver{}
  29. models.RegisterGuestDriver(&driver)
  30. }
  31. func (self *SRemoteFileGuestDriver) GetHypervisor() string {
  32. return api.HYPERVISOR_REMOTEFILE
  33. }
  34. func (self *SRemoteFileGuestDriver) GetProvider() string {
  35. return api.CLOUD_PROVIDER_REMOTEFILE
  36. }
  37. func (self *SRemoteFileGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
  38. return cloudprovider.SInstanceCapability{
  39. Hypervisor: self.GetHypervisor(),
  40. Provider: self.GetProvider(),
  41. DefaultAccount: cloudprovider.SDefaultAccount{
  42. Linux: cloudprovider.SOsDefaultAccount{
  43. DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
  44. Changeable: false,
  45. },
  46. Windows: cloudprovider.SOsDefaultAccount{
  47. DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
  48. Changeable: false,
  49. },
  50. },
  51. }
  52. }
  53. func (self *SRemoteFileGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
  54. keys := models.SComputeResourceKeys{}
  55. keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
  56. keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD
  57. keys.Provider = api.CLOUD_PROVIDER_REMOTEFILE
  58. keys.Brand = brand
  59. keys.Hypervisor = api.HYPERVISOR_REMOTEFILE
  60. return keys
  61. }
  62. func (self *SRemoteFileGuestDriver) GetDefaultSysDiskBackend() string {
  63. return api.STORAGE_LOCAL
  64. }
  65. func (self *SRemoteFileGuestDriver) GetMinimalSysDiskSizeGb() int {
  66. return options.Options.DefaultDiskSizeMB / 1024
  67. }