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