disk.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 remotefile
  15. import (
  16. "context"
  17. "fmt"
  18. api "yunion.io/x/cloudmux/pkg/apis/compute"
  19. "yunion.io/x/cloudmux/pkg/cloudprovider"
  20. "yunion.io/x/pkg/errors"
  21. )
  22. type SDisk struct {
  23. SResourceBase
  24. storage *SStorage
  25. ZoneId string
  26. StorageId string
  27. DiskFormat string
  28. DiskSizeMb int
  29. IsAutoDelete bool
  30. DiskType string
  31. FsFormat string
  32. Iops int
  33. Driver string
  34. CacheMode string
  35. Mountpoint string
  36. Preallocation string
  37. AccessPath string
  38. }
  39. func (self *SDisk) GetIStorage() (cloudprovider.ICloudStorage, error) {
  40. if self.storage == nil {
  41. return nil, fmt.Errorf("disk %s(%s) missing storage", self.Name, self.Id)
  42. }
  43. return self.storage, nil
  44. }
  45. func (self *SDisk) GetIStorageId() string {
  46. return self.StorageId
  47. }
  48. func (self *SDisk) GetDiskFormat() string {
  49. return self.DiskFormat
  50. }
  51. func (self *SDisk) GetDiskSizeMB() int {
  52. return self.DiskSizeMb
  53. }
  54. func (self *SDisk) GetIsAutoDelete() bool {
  55. return self.IsAutoDelete
  56. }
  57. func (self *SDisk) GetTemplateId() string {
  58. return ""
  59. }
  60. func (self *SDisk) GetDiskType() string {
  61. if len(self.DiskType) == 0 {
  62. return api.DISK_TYPE_DATA
  63. }
  64. return self.DiskType
  65. }
  66. func (self *SDisk) GetFsFormat() string {
  67. return self.FsFormat
  68. }
  69. func (self *SDisk) GetIsNonPersistent() bool {
  70. return false
  71. }
  72. func (self *SDisk) GetIops() int {
  73. return self.Iops
  74. }
  75. func (self *SDisk) GetDriver() string {
  76. return self.Driver
  77. }
  78. func (self *SDisk) GetCacheMode() string {
  79. return self.CacheMode
  80. }
  81. func (self *SDisk) GetMountpoint() string {
  82. return self.Mountpoint
  83. }
  84. func (self *SDisk) GetPreallocation() string {
  85. return self.Preallocation
  86. }
  87. func (self *SDisk) GetAccessPath() string {
  88. return self.AccessPath
  89. }
  90. func (self *SDisk) Delete(ctx context.Context) error {
  91. return cloudprovider.ErrNotSupported
  92. }
  93. func (self *SDisk) CreateISnapshot(ctx context.Context, name string, desc string) (cloudprovider.ICloudSnapshot, error) {
  94. return nil, cloudprovider.ErrNotSupported
  95. }
  96. func (self *SDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
  97. return nil, cloudprovider.ErrNotSupported
  98. }
  99. func (self *SDisk) Resize(ctx context.Context, newSizeMB int64) error {
  100. return cloudprovider.ErrNotSupported
  101. }
  102. func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error) {
  103. return "", cloudprovider.ErrNotSupported
  104. }
  105. func (self *SDisk) Rebuild(ctx context.Context) error {
  106. return cloudprovider.ErrNotSupported
  107. }
  108. func (disk *SDisk) SetStorage(storage SStorage) {
  109. disk.storage = &storage
  110. }
  111. func (disk *SDisk) ChangeStorage(ctx context.Context, opts *cloudprovider.ChangeStorageOptions) error {
  112. return errors.Wrapf(cloudprovider.ErrNotImplemented, "ChangeStorage")
  113. }
  114. func (disk *SDisk) GetDeviceName() string {
  115. return ""
  116. }