mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
fix: sync cloud snapshot size
This commit is contained in:
@@ -386,7 +386,7 @@ type ICloudDisk interface {
|
||||
type ICloudSnapshot interface {
|
||||
IVirtualResource
|
||||
|
||||
GetSize() int32
|
||||
GetSizeMb() int32
|
||||
GetDiskId() string
|
||||
GetDiskType() string
|
||||
Delete() error
|
||||
|
||||
@@ -658,6 +658,7 @@ func (self *SSnapshot) SyncWithCloudSnapshot(ctx context.Context, userCred mccli
|
||||
// self.Name = ext.GetName()
|
||||
self.Status = ext.GetStatus()
|
||||
self.DiskType = ext.GetDiskType()
|
||||
self.Size = int(ext.GetSizeMb())
|
||||
|
||||
self.CloudregionId = region.Id
|
||||
return nil
|
||||
@@ -694,7 +695,7 @@ func (manager *SSnapshotManager) newFromCloudSnapshot(ctx context.Context, userC
|
||||
}
|
||||
|
||||
snapshot.DiskType = extSnapshot.GetDiskType()
|
||||
snapshot.Size = int(extSnapshot.GetSize()) * 1024
|
||||
snapshot.Size = int(extSnapshot.GetSizeMb())
|
||||
snapshot.ManagerId = provider.Id
|
||||
snapshot.CloudregionId = region.Id
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ func (self *SSnapshot) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.SourceDiskSize
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.SourceDiskSize * 1024
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -99,8 +99,8 @@ func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.SourceDiskSize
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.SourceDiskSize * 1024
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -64,7 +64,7 @@ func (self *SClassicSnapshot) Delete() error {
|
||||
return self.region.DeleteClassicSnapshot(self.GetId())
|
||||
}
|
||||
|
||||
func (self *SClassicSnapshot) GetSize() int32 {
|
||||
func (self *SClassicSnapshot) GetSizeMb() int32 {
|
||||
return self.sizeMB
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ func (self *SSnapshot) Delete() error {
|
||||
return self.region.DeleteSnapshot(self.ID)
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.Properties.DiskSizeGB
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.Properties.DiskSizeGB * 1024
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteSnapshot(snapshotId string) error {
|
||||
|
||||
@@ -112,8 +112,8 @@ func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.Size
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.Size * 1024
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -119,8 +119,8 @@ func (snapshot *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (snapshot *SSnapshot) GetSize() int32 {
|
||||
return snapshot.Size
|
||||
func (snapshot *SSnapshot) GetSizeMb() int32 {
|
||||
return snapshot.Size * 1024
|
||||
}
|
||||
|
||||
func (snapshot *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -173,8 +173,8 @@ func (self *SSnapshot) GetRegionId() string {
|
||||
return self.region.GetId()
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.DiskSize
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.DiskSize * 1024
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -102,8 +102,8 @@ func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetSize() int32 {
|
||||
return self.SizeGB
|
||||
func (self *SSnapshot) GetSizeMb() int32 {
|
||||
return self.SizeGB * 1024
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDiskId() string {
|
||||
|
||||
@@ -55,7 +55,7 @@ func (snapshot *SSnapshot) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (snapshot *SSnapshot) GetSize() int32 {
|
||||
func (snapshot *SSnapshot) GetSizeMb() int32 {
|
||||
return int32(snapshot.Size / 1024 / 1024)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user