fix: sync cloud snapshot size

This commit is contained in:
ioito
2019-08-10 16:27:38 +08:00
parent c60913e34c
commit e3ee3c54cb
11 changed files with 19 additions and 18 deletions
+1 -1
View File
@@ -386,7 +386,7 @@ type ICloudDisk interface {
type ICloudSnapshot interface {
IVirtualResource
GetSize() int32
GetSizeMb() int32
GetDiskId() string
GetDiskType() string
Delete() error
+2 -1
View File
@@ -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
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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)
}