yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/classic_snapshot.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 azure
    16  
    17  import (
    18  	"fmt"
    19  
    20  	api "yunion.io/x/cloudmux/pkg/apis/compute"
    21  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    22  	"yunion.io/x/cloudmux/pkg/multicloud"
    23  )
    24  
    25  type SClassicSnapshot struct {
    26  	multicloud.SResourceBase
    27  	AzureTags
    28  	region *SRegion
    29  
    30  	Name     string
    31  	sizeMB   int32
    32  	diskID   string
    33  	diskName string
    34  }
    35  
    36  func (self *SClassicSnapshot) GetId() string {
    37  	return fmt.Sprintf("%s?snapshot=%s", self.diskID, self.Name)
    38  }
    39  
    40  func (self *SClassicSnapshot) GetGlobalId() string {
    41  	return self.GetId()
    42  }
    43  
    44  func (self *SClassicSnapshot) GetName() string {
    45  	return fmt.Sprintf("%s-%s", self.diskName, self.Name)
    46  }
    47  
    48  func (self *SClassicSnapshot) GetStatus() string {
    49  	return api.SNAPSHOT_READY
    50  }
    51  
    52  func (self *SClassicSnapshot) IsEmulated() bool {
    53  	return false
    54  }
    55  
    56  func (self *SRegion) CreateClassicSnapshot(diskId, snapName, desc string) (*SClassicSnapshot, error) {
    57  	return nil, cloudprovider.ErrNotImplemented
    58  }
    59  
    60  func (self *SClassicSnapshot) Delete() error {
    61  	return self.region.DeleteClassicSnapshot(self.GetId())
    62  }
    63  
    64  func (self *SClassicSnapshot) GetSizeMb() int32 {
    65  	return self.sizeMB
    66  }
    67  
    68  func (self *SRegion) DeleteClassicSnapshot(snapshotId string) error {
    69  	return cloudprovider.ErrNotImplemented
    70  }
    71  
    72  func (self *SClassicSnapshot) Refresh() error {
    73  	return nil
    74  }
    75  
    76  func (self *SClassicSnapshot) GetDiskId() string {
    77  	return self.diskID
    78  }
    79  
    80  func (self *SClassicSnapshot) GetRegionId() string {
    81  	return self.region.GetId()
    82  }
    83  
    84  func (self *SClassicSnapshot) GetDiskType() string {
    85  	return ""
    86  }
    87  
    88  func (self *SClassicSnapshot) GetProjectId() string {
    89  	return ""
    90  }