Skip to content

Commit f3d38be

Browse files
committed
Merge pull request #1770 from syed/tmpl-virt-size
CLOUDSTACK-9628: Fix Template Size in Swift as Secondary StorageCloudstack incorrectly uses the physical size as the size of the template. Ideally, the size should refelct the virtual size. This PR fixes that issue. * pr/1770: CLOUDSTACK-9628: Use correct virtualsize with Swift as secondary storage Signed-off-by: Rajani Karuturi <rajani.karuturi@accelerite.com>
2 parents e860249 + 79f4177 commit f3d38be

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,19 +1585,28 @@ Map<String, TemplateProp> swiftListTemplate(SwiftTO swift) {
15851585
String line = null;
15861586
String uniqName = null;
15871587
Long size = null;
1588+
Long physicalSize = null;
15881589
String name = null;
15891590
while ((line = brf.readLine()) != null) {
15901591
if (line.startsWith("uniquename=")) {
15911592
uniqName = line.split("=")[1];
15921593
} else if (line.startsWith("size=")) {
1594+
physicalSize = Long.parseLong(line.split("=")[1]);
1595+
} else if (line.startsWith("virtualsize=")){
15931596
size = Long.parseLong(line.split("=")[1]);
15941597
} else if (line.startsWith("filename=")) {
15951598
name = line.split("=")[1];
15961599
}
15971600
}
1601+
1602+
//fallback
1603+
if (size == null) {
1604+
size = physicalSize;
1605+
}
1606+
15981607
tempFile.delete();
15991608
if (uniqName != null) {
1600-
TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, size, true, false);
1609+
TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, physicalSize, true, false);
16011610
tmpltInfos.put(uniqName, prop);
16021611
}
16031612
} catch (IOException ex)
@@ -1615,7 +1624,6 @@ Map<String, TemplateProp> swiftListTemplate(SwiftTO swift) {
16151624
}
16161625
}
16171626
return tmpltInfos;
1618-
16191627
}
16201628

16211629
Map<String, TemplateProp> s3ListTemplate(S3TO s3) {

0 commit comments

Comments
 (0)