cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/object_store to 3424ac8
Date Tue, 14 May 2013 00:45:57 GMT
Updated Branches:
  refs/heads/object_store 0ce01e56d -> 3424ac86a


Fix size issue for template created from snapshot.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3424ac86
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3424ac86
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3424ac86

Branch: refs/heads/object_store
Commit: 3424ac86ad5cbf1a06f17e35bbb4fac5a8e61101
Parents: 0ce01e5
Author: Min Chen <min.chen@citrix.com>
Authored: Mon May 13 17:45:22 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Mon May 13 17:45:22 2013 -0700

----------------------------------------------------------------------
 .../cloud/storage/template/TemplateLocation.java   |   70 ++++++++-------
 .../storage/image/store/TemplateObject.java        |    1 +
 2 files changed, 38 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3424ac86/core/src/com/cloud/storage/template/TemplateLocation.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/TemplateLocation.java b/core/src/com/cloud/storage/template/TemplateLocation.java
index eb7a6ec..34626e5 100644
--- a/core/src/com/cloud/storage/template/TemplateLocation.java
+++ b/core/src/com/cloud/storage/template/TemplateLocation.java
@@ -35,17 +35,17 @@ import com.cloud.utils.NumbersUtil;
 public class TemplateLocation {
     private static final Logger s_logger = Logger.getLogger(TemplateLocation.class);
     public final static String Filename = "template.properties";
-    
+
     StorageLayer _storage;
     String _templatePath;
     boolean _isCorrupted;
     ResourceType _resourceType = ResourceType.TEMPLATE;
-    
+
     File _file;
     Properties _props;
-    
+
     ArrayList<FormatInfo> _formats;
-    
+
     public TemplateLocation(StorageLayer storage, String templatePath) {
         _storage = storage;
         _templatePath = templatePath;
@@ -63,16 +63,16 @@ public class TemplateLocation {
         }
         _isCorrupted = false;
     }
-    
+
     public boolean create(long id, boolean isPublic, String uniqueName) throws IOException
{
         boolean result = load();
         _props.setProperty("id", Long.toString(id));
         _props.setProperty("public", Boolean.toString(isPublic));
         _props.setProperty("uniquename", uniqueName);
-        
+
         return result;
     }
-    
+
     public boolean purge() {
         boolean purged = true;
         String[] files = _storage.listFiles(_templatePath);
@@ -85,10 +85,10 @@ public class TemplateLocation {
                 s_logger.debug((r ? "R" : "Unable to r") + "emove " + file);
             }
         }
-        
+
         return purged;
     }
-    
+
     public boolean load() throws IOException {
         FileInputStream strm = null;
         try {
@@ -102,7 +102,7 @@ public class TemplateLocation {
                 }
             }
         }
-        
+
         for (ImageFormat format : ImageFormat.values()) {
             String ext = _props.getProperty(format.getFileExtension());
             if (ext != null) {
@@ -115,22 +115,22 @@ public class TemplateLocation {
                 info.size = NumbersUtil.parseLong(_props.getProperty(format.getFileExtension()
+ ".size"), -1);
                 _props.setProperty("physicalSize", Long.toString(info.size));
                 info.virtualSize = NumbersUtil.parseLong(_props.getProperty(format.getFileExtension()
+ ".virtualsize"), -1);
-                _formats.add(info);               
-                
+                _formats.add(info);
+
                 if (!checkFormatValidity(info)) {
                     _isCorrupted = true;
                     s_logger.warn("Cleaning up inconsistent information for " + format);
-                } 
+                }
             }
         }
-        
+
         if (_props.getProperty("uniquename") == null || _props.getProperty("virtualsize")
== null) {
             return false;
         }
-        
+
         return (_formats.size() > 0);
     }
-    
+
     public boolean save() {
         for (FormatInfo info : _formats) {
             _props.setProperty(info.format.getFileExtension(), "true");
@@ -152,60 +152,64 @@ public class TemplateLocation {
                 } catch (IOException e) {
                 }
             }
-        }        
+        }
         return true;
     }
-    
+
     public TemplateProp getTemplateInfo() {
-        TemplateProp tmplInfo = new TemplateProp();       
+        TemplateProp tmplInfo = new TemplateProp();
         tmplInfo.id = Long.parseLong(_props.getProperty("id"));
         tmplInfo.installPath = _templatePath + File.separator + _props.getProperty("filename");
         if (_resourceType == ResourceType.VOLUME){
-        	tmplInfo.installPath = tmplInfo.installPath.substring(tmplInfo.installPath.indexOf("volumes"));

+        	tmplInfo.installPath = tmplInfo.installPath.substring(tmplInfo.installPath.indexOf("volumes"));
         }else {
         	tmplInfo.installPath = tmplInfo.installPath.substring(tmplInfo.installPath.indexOf("template"));
         }
         tmplInfo.isCorrupted = _isCorrupted;
         tmplInfo.isPublic = Boolean.parseBoolean(_props.getProperty("public"));
         tmplInfo.templateName = _props.getProperty("uniquename");
-        tmplInfo.size = Long.parseLong(_props.getProperty("virtualsize"));
-        tmplInfo.physicalSize = Long.parseLong(_props.getProperty("physicalSize"));
-        
+        if (_props.getProperty("virtualsize") != null) {
+            tmplInfo.size = Long.parseLong(_props.getProperty("virtualsize"));
+        }
+        if (_props.getProperty("physicalSize") != null) {
+            tmplInfo.physicalSize = Long.parseLong(_props.getProperty("physicalSize"));
+        }
+
         return tmplInfo;
     }
-    
-   
+
+
     public FormatInfo getFormat(ImageFormat format) {
         for (FormatInfo info : _formats) {
             if (info.format == format) {
                 return info;
             }
         }
-        
+
         return null;
     }
-    
+
     public boolean addFormat(FormatInfo newInfo) {
         deleteFormat(newInfo.format);
-        
+
         if (!checkFormatValidity(newInfo)) {
             s_logger.warn("Format is invalid ");
             return false;
         }
-        
+
         _props.setProperty("virtualsize", Long.toString(newInfo.virtualSize));
         _formats.add(newInfo);
         return true;
     }
-    
+
     public void updateVirtualSize(long virtualSize) {
         _props.setProperty("virtualsize", Long.toString(virtualSize));
     }
-    
+
     protected boolean checkFormatValidity(FormatInfo info) {
         return (info.format != null && info.size > 0 && info.virtualSize
> 0 && info.filename != null);
     }
-    
+
     protected FormatInfo deleteFormat(ImageFormat format) {
         Iterator<FormatInfo> it = _formats.iterator();
         while (it.hasNext()) {
@@ -219,7 +223,7 @@ public class TemplateLocation {
                 return info;
             }
         }
-        
+
         return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3424ac86/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index cd94704..a94716e 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -222,6 +222,7 @@ public class TemplateObject implements TemplateInfo {
         			templateStoreRef.setInstallPath(newTemplate.getPath());
         			templateStoreRef.setDownloadPercent(100);
         			templateStoreRef.setDownloadState(Status.DOWNLOADED);
+        			templateStoreRef.setSize(newTemplate.getSize());
         			templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
                     if (this.getDataStore().getRole() == DataStoreRole.Image) {
                         VMTemplateVO templateVO = this.imageDao.findById(this.getId());


Mime
View raw message