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