cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject git commit: updated refs/heads/master to e59420c
Date Fri, 03 Jan 2014 11:40:07 GMT
Updated Branches:
  refs/heads/master 77878299f -> e59420c51


CLOUDSTACK-5691: Fix for attaching an uploaded volume to instance running
on hyperv. There were multiple issues here. Upload volume was actually
failing because the post download check for vhd on the cifs share was
unsuccessful. Also the agent code wasn't parsing the volume path correctly.
Fixed it too.


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

Branch: refs/heads/master
Commit: e59420c5146387977530b4720e6ec7dd7a83703c
Parents: 7787829
Author: Devdeep Singh <devdeep@gmail.com>
Authored: Fri Jan 3 16:43:21 2014 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Fri Jan 3 16:55:28 2014 +0530

----------------------------------------------------------------------
 .../HypervResource/CloudStackTypes.cs           |  9 ++++++--
 scripts/storage/secondary/createvolume.sh       | 23 +++++++++++++++-----
 server/src/com/cloud/api/ApiDBUtils.java        | 15 +++++++++++--
 .../cloud/api/query/dao/VolumeJoinDaoImpl.java  |  4 ++--
 4 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e59420c5/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
index f8ca49e..020f761 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
@@ -173,7 +173,12 @@ namespace HypervResource
                     {
                         fileName += @"\" + this.path;
                     }
-                    fileName = Utils.NormalizePath(fileName + @"\" + this.name);
+
+                    fileName = Utils.NormalizePath(fileName);
+                    if (Directory.Exists(fileName))
+                    {
+                        fileName = Utils.NormalizePath(fileName + @"\" + this.name);
+                    }
                 }
                 else
                 {
@@ -182,7 +187,7 @@ namespace HypervResource
                     throw new InvalidDataException(errMsg);
                 }
 
-                if (this.format != null)
+                if (!Path.HasExtension(fileName) && this.format != null)
                 {
                     fileName = fileName + "." + this.format.ToLowerInvariant();
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e59420c5/scripts/storage/secondary/createvolume.sh
----------------------------------------------------------------------
diff --git a/scripts/storage/secondary/createvolume.sh b/scripts/storage/secondary/createvolume.sh
index f11df1d..8cbccc6 100755
--- a/scripts/storage/secondary/createvolume.sh
+++ b/scripts/storage/secondary/createvolume.sh
@@ -111,6 +111,14 @@ uncompress() {
   return 0
 }
 
+isCifs() {
+   #TO:DO incase of multiple zone where cifs and nfs exists,
+   #then check if the template file is from cifs using df -P filename
+   #Currently only cifs is supported in hyperv zone.
+   mount | grep "type cifs" > /dev/null
+   echo $?
+}
+
 create_from_file() {
   local tmpltfs=$1
   local tmpltimg=$2
@@ -196,12 +204,15 @@ rollback_if_needed $tmpltfs $? "tar archives not supported\n"
 
 if [ ${tmpltname%.vhd} != ${tmpltname} ]
 then
-  if  which  vhd-util &>/dev/null
-  then 
-    vhd-util check -n ${tmpltimg2} > /dev/null
-    rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
-    vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null
-    rollback_if_needed $tmpltfs $? "vhd remove $tmpltimg2 hidden failed\n"
+  if [ isCifs -ne 0 ] ;
+  then
+    if  which  vhd-util &>/dev/null
+    then 
+      vhd-util check -n ${tmpltimg2} > /dev/null
+      rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
+      vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null
+      rollback_if_needed $tmpltfs $? "vhd remove $tmpltimg2 hidden failed\n"
+    fi
   fi
 fi
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e59420c5/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 8c59ce6..3bdb2e6 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1054,8 +1054,19 @@ public class ApiDBUtils {
         return s_volumeDao.getHypervisorType(volumeId);
     }
 
-    public static HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {
-        return s_storageMgr.getHypervisorTypeFromFormat(format);
+    public static HypervisorType getHypervisorTypeFromFormat(long dcId, ImageFormat format){
+        HypervisorType type = s_storageMgr.getHypervisorTypeFromFormat(format);
+        if (format == ImageFormat.VHD) {
+            // Xenserver and Hyperv both support vhd format. Additionally hyperv is only
supported
+            // in a dc/zone if there aren't any other hypervisor types present in the zone).
If the
+            // format type is VHD check is any xenserver clusters are present. If not, we
assume it
+            // is a hyperv zone and update the type.
+            List<ClusterVO> xenClusters = s_clusterDao.listByDcHyType(dcId, HypervisorType.XenServer.toString());
+            if (xenClusters.isEmpty()) {
+                type = HypervisorType.Hyperv;
+            }
+        }
+        return type;
     }
 
     public static List<UserStatisticsVO> listUserStatsBy(Long accountId) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e59420c5/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index a8631f7..3604883 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -111,7 +111,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO,
Long> implem
             volResponse.setCreated(volume.getCreatedOnStore());
 
             if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
-                volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
+                volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(),
volume.getFormat()).toString());
             if (volume.getDownloadState() != Status.DOWNLOADED) {
                 String volumeStatus = "Processing";
                 if (volume.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS)
{
@@ -175,7 +175,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO,
Long> implem
                 if (volume.getHypervisorType() != null) {
                     volResponse.setHypervisor(volume.getHypervisorType().toString());
                 } else {
-                    volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
+                    volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(),
volume.getFormat()).toString());
                 }
             }
             Long poolId = volume.getPoolId();


Mime
View raw message