You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/01/02 15:36:12 UTC

[20/50] [abbrv] git commit: updated refs/heads/reporter to b26f3fc

CLOUDSTACK-8109. Extract Template is failing.
Fix the OVA path that is returned once an OVA is packaged using a META file.


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

Branch: refs/heads/reporter
Commit: 507d9d337d2e80f7f6e5d665708c0687c387c5fc
Parents: 0f224c8
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Oct 27 16:56:29 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Tue Dec 23 10:44:10 2014 +0530

----------------------------------------------------------------------
 .../manager/VmwareStorageManagerImpl.java       | 40 +++++++++-----------
 1 file changed, 17 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/507d9d33/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 3d6a4fb..86b1edf 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -148,37 +148,32 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
     public String createOvaForTemplate(TemplateObjectTO template) {
         DataStoreTO storeTO = template.getDataStore();
         if (!(storeTO instanceof NfsTO)) {
-            s_logger.debug("can only handle nfs storage, when create ova from volume");
+            s_logger.debug("Can only handle NFS storage, while creating OVA from template");
             return null;
         }
         NfsTO nfsStore = (NfsTO)storeTO;
         String secStorageUrl = nfsStore.getUrl();
         assert (secStorageUrl != null);
         String installPath = template.getPath();
-        String ovafileName = "";
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
         String installFullPath = secondaryMountPoint + "/" + installPath;
-
-        String templateName = installFullPath;   // should be a file ending .ova;
         try {
-            if (templateName.endsWith(".ova")) {
-                if (new File(templateName).exists()) {
-                    s_logger.debug("OVA files exists. succeed. ");
-                    return installPath;
+            if (installFullPath.endsWith(".ova")) {
+                if (new File(installFullPath).exists()) {
+                    s_logger.debug("OVA file found at: " + installFullPath);
                 } else {
-                    if (new File(templateName + ".meta").exists()) {
-                        ovafileName = getOVAFromMetafile(templateName + ".meta");
-                        s_logger.debug("OVA file in meta file is " + ovafileName);
-                        return ovafileName;
+                    if (new File(installFullPath + ".meta").exists()) {
+                        createOVAFromMetafile(installFullPath + ".meta");
                     } else {
-                        String msg = "Unable to find ova meta or ova file to prepare template (vmware)";
+                        String msg = "Unable to find OVA or OVA MetaFile to prepare template.";
                         s_logger.error(msg);
                         throw new Exception(msg);
                     }
                 }
+                return installPath;
             }
         } catch (Throwable e) {
-            s_logger.debug("Failed to create ova: " + e.toString());
+            s_logger.debug("Failed to create OVA: " + e.toString());
         }
         return null;
     }
@@ -1042,12 +1037,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
     // here we use a method to return the ovf and vmdk file names; Another way to do it:
     // create a new class, and like TemplateLocation.java and create templateOvfInfo.java to handle it;
-    private String getOVAFromMetafile(String metafileName) throws Exception {
+    private String createOVAFromMetafile(String metafileName) throws Exception {
         File ova_metafile = new File(metafileName);
         Properties props = null;
         FileInputStream strm = null;
         String ovaFileName = "";
-        s_logger.info("getOVAfromMetaFile: " + metafileName);
+        s_logger.info("Creating OVA using MetaFile: " + metafileName);
         try {
             strm = new FileInputStream(ova_metafile);
 
@@ -1088,18 +1083,17 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
             command.execute();
             s_logger.info("Package OVA for template in dir: " + exportDir + "cmd: " + command.toString());
             // to be safe, physically test existence of the target OVA file
-            if ((new File(exportDir + ovaFileName)).exists()) {
-                s_logger.info("ova file is created and ready to extract ");
-                return (ovaFileName);
+            if ((new File(exportDir + File.separator + ovaFileName)).exists()) {
+                s_logger.info("OVA file: " + ovaFileName +" is created and ready to extract.");
+                return ovaFileName;
             } else {
-                String msg = exportDir + File.separator + ovaFileName + ".ova is not created as expected";
+                String msg = exportDir + File.separator + ovaFileName + " is not created as expected";
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
         } catch (Exception e) {
-            s_logger.error("Exception in getOVAFromMetafile", e);
-            return null;
-            // Do something, re-throw the exception
+            s_logger.error("Exception while creating OVA using Metafile", e);
+            throw e;
         } finally {
             if (strm != null) {
                 try {