localdisk.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 qcloud
  15. import (
  16. "context"
  17. "time"
  18. api "yunion.io/x/cloudmux/pkg/apis/compute"
  19. "yunion.io/x/cloudmux/pkg/cloudprovider"
  20. "yunion.io/x/cloudmux/pkg/multicloud"
  21. )
  22. type SLocalDisk struct {
  23. multicloud.SDisk
  24. QcloudTags
  25. storage *SLocalStorage
  26. DiskId string
  27. DiskSize float32
  28. DisktType string
  29. DiskUsage string
  30. imageId string
  31. }
  32. func (self *SLocalDisk) GetSysTags() map[string]string {
  33. data := map[string]string{}
  34. data["hypervisor"] = api.HYPERVISOR_QCLOUD
  35. return data
  36. }
  37. func (self *SLocalDisk) CreateISnapshot(ctx context.Context, name, desc string) (cloudprovider.ICloudSnapshot, error) {
  38. return nil, cloudprovider.ErrNotSupported
  39. }
  40. func (self *SLocalDisk) Delete(ctx context.Context) error {
  41. return nil
  42. }
  43. func (self *SLocalDisk) GetBillingType() string {
  44. return ""
  45. }
  46. func (self *SLocalDisk) GetFsFormat() string {
  47. return ""
  48. }
  49. func (self *SLocalDisk) GetIsNonPersistent() bool {
  50. return false
  51. }
  52. func (self *SLocalDisk) GetDriver() string {
  53. return "scsi"
  54. }
  55. func (self *SLocalDisk) GetCacheMode() string {
  56. return "none"
  57. }
  58. func (self *SLocalDisk) GetMountpoint() string {
  59. return ""
  60. }
  61. func (self *SLocalDisk) GetDiskFormat() string {
  62. return "vhd"
  63. }
  64. func (self *SLocalDisk) GetDiskSizeMB() int {
  65. return int(self.DiskSize) * 1024
  66. }
  67. func (self *SLocalDisk) GetIsAutoDelete() bool {
  68. return true
  69. }
  70. func (self *SLocalDisk) GetCreatedAt() time.Time {
  71. return time.Time{}
  72. }
  73. func (self *SLocalDisk) GetExpiredAt() time.Time {
  74. return time.Time{}
  75. }
  76. func (self *SLocalDisk) GetDiskType() string {
  77. switch self.DiskUsage {
  78. case "SYSTEM_DISK":
  79. return api.DISK_TYPE_SYS
  80. case "DATA_DISK":
  81. return api.DISK_TYPE_DATA
  82. default:
  83. return api.DISK_TYPE_DATA
  84. }
  85. }
  86. func (self *SLocalDisk) Refresh() error {
  87. return nil
  88. }
  89. func (self *SLocalDisk) Reset(ctx context.Context, snapshotId string) (string, error) {
  90. return "", cloudprovider.ErrNotSupported
  91. }
  92. func (self *SLocalDisk) GetTemplateId() string {
  93. return self.imageId
  94. }
  95. func (self *SLocalDisk) GetStatus() string {
  96. return api.DISK_READY
  97. }
  98. func (self *SLocalDisk) GetName() string {
  99. return self.DiskId
  100. }
  101. func (self *SLocalDisk) GetId() string {
  102. return self.DiskId
  103. }
  104. func (self *SLocalDisk) GetGlobalId() string {
  105. return self.DiskId
  106. }
  107. func (self *SLocalDisk) IsEmulated() bool {
  108. return false
  109. }
  110. func (self *SLocalDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
  111. return nil, nil
  112. }
  113. func (self *SLocalDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
  114. return nil, nil
  115. }
  116. func (self *SLocalDisk) GetIStorage() (cloudprovider.ICloudStorage, error) {
  117. return self.storage, nil
  118. }
  119. func (self *SLocalDisk) Resize(ctx context.Context, size int64) error {
  120. return cloudprovider.ErrNotSupported
  121. }
  122. func (disk *SLocalDisk) GetAccessPath() string {
  123. return ""
  124. }
  125. func (self *SLocalDisk) Rebuild(ctx context.Context) error {
  126. // TODO
  127. return cloudprovider.ErrNotSupported
  128. }
  129. func (disk *SLocalDisk) GetProjectId() string {
  130. return ""
  131. }