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>
This commit is contained in:
Rajani Karuturi 2017-02-23 06:04:34 +05:30
commit f3d38be808

View File

@ -1585,19 +1585,28 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
String line = null; String line = null;
String uniqName = null; String uniqName = null;
Long size = null; Long size = null;
Long physicalSize = null;
String name = null; String name = null;
while ((line = brf.readLine()) != null) { while ((line = brf.readLine()) != null) {
if (line.startsWith("uniquename=")) { if (line.startsWith("uniquename=")) {
uniqName = line.split("=")[1]; uniqName = line.split("=")[1];
} else if (line.startsWith("size=")) { } else if (line.startsWith("size=")) {
physicalSize = Long.parseLong(line.split("=")[1]);
} else if (line.startsWith("virtualsize=")){
size = Long.parseLong(line.split("=")[1]); size = Long.parseLong(line.split("=")[1]);
} else if (line.startsWith("filename=")) { } else if (line.startsWith("filename=")) {
name = line.split("=")[1]; name = line.split("=")[1];
} }
} }
//fallback
if (size == null) {
size = physicalSize;
}
tempFile.delete(); tempFile.delete();
if (uniqName != null) { if (uniqName != null) {
TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, size, true, false); TemplateProp prop = new TemplateProp(uniqName, container + File.separator + name, size, physicalSize, true, false);
tmpltInfos.put(uniqName, prop); tmpltInfos.put(uniqName, prop);
} }
} catch (IOException ex) } catch (IOException ex)
@ -1615,7 +1624,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
} }
} }
return tmpltInfos; return tmpltInfos;
} }
Map<String, TemplateProp> s3ListTemplate(S3TO s3) { Map<String, TemplateProp> s3ListTemplate(S3TO s3) {