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/4.2 to 947e9e9
Date Wed, 17 Jul 2013 00:55:00 GMT
Updated Branches:
  refs/heads/4.2 882982605 -> 947e9e902


CLOUDSTACK-3570:Vmware - Template downloads are getting re-initiated
every time management server is restarted.


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

Branch: refs/heads/4.2
Commit: 947e9e9020a8438c15f6f96bd1a8c6d0b4ffe727
Parents: 8829826
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Jul 16 17:54:17 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Jul 16 17:54:46 2013 -0700

----------------------------------------------------------------------
 .../cloud/storage/template/VmdkProcessor.java   | 81 ++++++++++----------
 1 file changed, 40 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/947e9e90/core/src/com/cloud/storage/template/VmdkProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/VmdkProcessor.java b/core/src/com/cloud/storage/template/VmdkProcessor.java
index e074041..43650c6 100644
--- a/core/src/com/cloud/storage/template/VmdkProcessor.java
+++ b/core/src/com/cloud/storage/template/VmdkProcessor.java
@@ -24,9 +24,6 @@ import javax.naming.ConfigurationException;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
 import org.apache.log4j.Logger;
 
 import com.cloud.exception.InternalErrorException;
@@ -40,27 +37,29 @@ public class VmdkProcessor extends AdapterBase implements Processor {
     private static final Logger s_logger = Logger.getLogger(VmdkProcessor.class);
 
     StorageLayer _storage;
-	
+
     @Override
     public FormatInfo process(String templatePath, ImageFormat format, String templateName)
throws InternalErrorException {
         if (format != null) {
-        	if(s_logger.isInfoEnabled())
-        		s_logger.info("We currently don't handle conversion from " + format + " to VMDK.");
+            if(s_logger.isInfoEnabled()) {
+                s_logger.info("We currently don't handle conversion from " + format + " to
VMDK.");
+            }
             return null;
         }
-        
+
         s_logger.info("Template processing. templatePath: " + templatePath + ", templateName:
" + templateName);
         String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.OVA.getFileExtension();
         if (!_storage.exists(templateFilePath)) {
-        	if(s_logger.isInfoEnabled())
-        		s_logger.info("Unable to find the vmware template file: " + templateFilePath);
+            if(s_logger.isInfoEnabled()) {
+                s_logger.info("Unable to find the vmware template file: " + templateFilePath);
+            }
             return null;
         }
-        
+
         s_logger.info("Template processing - untar OVA package. templatePath: " + templatePath
+ ", templateName: " + templateName);
-        String templateFileFullPath = templatePath + templateName + "." + ImageFormat.OVA.getFileExtension();
+        String templateFileFullPath = templatePath + File.separator + templateName + "."
+ ImageFormat.OVA.getFileExtension();
         File templateFile = new File(templateFileFullPath);
-        
+
         Script command = new Script("tar", 0, s_logger);
         command.add("--no-same-owner");
         command.add("-xf", templateFileFullPath);
@@ -68,9 +67,9 @@ public class VmdkProcessor extends AdapterBase implements Processor {
         String result = command.execute();
         if (result != null) {
             s_logger.info("failed to untar OVA package due to " + result + ". templatePath:
" + templatePath + ", templateName: " + templateName);
-        	return null;
+            return null;
         }
-        
+
         FormatInfo info = new FormatInfo();
         info.format = ImageFormat.OVA;
         info.filename = templateName + "." + ImageFormat.OVA.getFileExtension();
@@ -84,42 +83,42 @@ public class VmdkProcessor extends AdapterBase implements Processor {
 
     public long getTemplateVirtualSize(String templatePath, String templateName) throws InternalErrorException
{
         // get the virtual size from the OVF file meta data
-    	long virtualSize=0;
+        long virtualSize=0;
         String templateFileFullPath = templatePath.endsWith(File.separator) ? templatePath
: templatePath + File.separator;
-    	templateFileFullPath += templateName.endsWith(ImageFormat.OVA.getFileExtension()) ?
templateName : templateName + "." + ImageFormat.OVA.getFileExtension();
+        templateFileFullPath += templateName.endsWith(ImageFormat.OVA.getFileExtension())
? templateName : templateName + "." + ImageFormat.OVA.getFileExtension();
         String ovfFileName = getOVFFilePath(templateFileFullPath);
         if(ovfFileName == null) {
-            String msg = "Unable to locate OVF file in template package directory: " + templatePath;

+            String msg = "Unable to locate OVF file in template package directory: " + templatePath;
             s_logger.error(msg);
             throw new InternalErrorException(msg);
         }
         try {
             Document ovfDoc = null;
-        	ovfDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(ovfFileName));
-        	Element disk  = (Element) ovfDoc.getElementsByTagName("Disk").item(0);
-        	virtualSize = Long.parseLong(disk.getAttribute("ovf:capacity"));
-        	String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits");
-        	if ((virtualSize != 0) && (allocationUnits != null)) {
-        		long units = 1;
-        		if (allocationUnits.equalsIgnoreCase("KB") || allocationUnits.equalsIgnoreCase("KiloBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^10")) {
-        			units = 1024;
-        		} else if (allocationUnits.equalsIgnoreCase("MB") || allocationUnits.equalsIgnoreCase("MegaBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^20")) {
-        			units = 1024 * 1024;
-        		} else if (allocationUnits.equalsIgnoreCase("GB") || allocationUnits.equalsIgnoreCase("GigaBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^30")) {
-        			units = 1024 * 1024 * 1024;
-        		}
-        		virtualSize = virtualSize * units;
-        	} else {
-        		throw new InternalErrorException("Failed to read capacity and capacityAllocationUnits
from the OVF file: " + ovfFileName);
-        	}
-        	return virtualSize;
+            ovfDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
File(ovfFileName));
+            Element disk  = (Element) ovfDoc.getElementsByTagName("Disk").item(0);
+            virtualSize = Long.parseLong(disk.getAttribute("ovf:capacity"));
+            String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits");
+            if ((virtualSize != 0) && (allocationUnits != null)) {
+                long units = 1;
+                if (allocationUnits.equalsIgnoreCase("KB") || allocationUnits.equalsIgnoreCase("KiloBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^10")) {
+                    units = 1024;
+                } else if (allocationUnits.equalsIgnoreCase("MB") || allocationUnits.equalsIgnoreCase("MegaBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^20")) {
+                    units = 1024 * 1024;
+                } else if (allocationUnits.equalsIgnoreCase("GB") || allocationUnits.equalsIgnoreCase("GigaBytes")
|| allocationUnits.equalsIgnoreCase("byte * 2^30")) {
+                    units = 1024 * 1024 * 1024;
+                }
+                virtualSize = virtualSize * units;
+            } else {
+                throw new InternalErrorException("Failed to read capacity and capacityAllocationUnits
from the OVF file: " + ovfFileName);
+            }
+            return virtualSize;
         } catch (Exception e) {
-        	String msg = "Unable to parse OVF XML document to get the virtual disk size due
to"+e;
-        	s_logger.error(msg);
-        	throw new InternalErrorException(msg);
+            String msg = "Unable to parse OVF XML document to get the virtual disk size due
to"+e;
+            s_logger.error(msg);
+            throw new InternalErrorException(msg);
         }
     }
-    
+
     private String getOVFFilePath(String srcOVAFileName) {
         File file = new File(srcOVAFileName);
         assert(_storage != null);
@@ -141,7 +140,7 @@ public class VmdkProcessor extends AdapterBase implements Processor {
         if (_storage == null) {
             throw new ConfigurationException("Unable to get storage implementation");
         }
-    	
-    	return true;
+
+        return true;
     }
 }


Mime
View raw message