mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
77878299fb
commit
e59420c514
@ -173,7 +173,12 @@ namespace HypervResource
|
|||||||
{
|
{
|
||||||
fileName += @"\" + this.path;
|
fileName += @"\" + this.path;
|
||||||
}
|
}
|
||||||
fileName = Utils.NormalizePath(fileName + @"\" + this.name);
|
|
||||||
|
fileName = Utils.NormalizePath(fileName);
|
||||||
|
if (Directory.Exists(fileName))
|
||||||
|
{
|
||||||
|
fileName = Utils.NormalizePath(fileName + @"\" + this.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -182,7 +187,7 @@ namespace HypervResource
|
|||||||
throw new InvalidDataException(errMsg);
|
throw new InvalidDataException(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.format != null)
|
if (!Path.HasExtension(fileName) && this.format != null)
|
||||||
{
|
{
|
||||||
fileName = fileName + "." + this.format.ToLowerInvariant();
|
fileName = fileName + "." + this.format.ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,14 @@ uncompress() {
|
|||||||
return 0
|
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() {
|
create_from_file() {
|
||||||
local tmpltfs=$1
|
local tmpltfs=$1
|
||||||
local tmpltimg=$2
|
local tmpltimg=$2
|
||||||
@ -196,12 +204,15 @@ rollback_if_needed $tmpltfs $? "tar archives not supported\n"
|
|||||||
|
|
||||||
if [ ${tmpltname%.vhd} != ${tmpltname} ]
|
if [ ${tmpltname%.vhd} != ${tmpltname} ]
|
||||||
then
|
then
|
||||||
if which vhd-util &>/dev/null
|
if [ isCifs -ne 0 ] ;
|
||||||
then
|
then
|
||||||
vhd-util check -n ${tmpltimg2} > /dev/null
|
if which vhd-util &>/dev/null
|
||||||
rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
|
then
|
||||||
vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null
|
vhd-util check -n ${tmpltimg2} > /dev/null
|
||||||
rollback_if_needed $tmpltfs $? "vhd remove $tmpltimg2 hidden failed\n"
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -1054,8 +1054,19 @@ public class ApiDBUtils {
|
|||||||
return s_volumeDao.getHypervisorType(volumeId);
|
return s_volumeDao.getHypervisorType(volumeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {
|
public static HypervisorType getHypervisorTypeFromFormat(long dcId, ImageFormat format){
|
||||||
return s_storageMgr.getHypervisorTypeFromFormat(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) {
|
public static List<UserStatisticsVO> listUserStatsBy(Long accountId) {
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
|
|||||||
volResponse.setCreated(volume.getCreatedOnStore());
|
volResponse.setCreated(volume.getCreatedOnStore());
|
||||||
|
|
||||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
|
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) {
|
if (volume.getDownloadState() != Status.DOWNLOADED) {
|
||||||
String volumeStatus = "Processing";
|
String volumeStatus = "Processing";
|
||||||
if (volume.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
|
if (volume.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
|
||||||
@ -175,7 +175,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
|
|||||||
if (volume.getHypervisorType() != null) {
|
if (volume.getHypervisorType() != null) {
|
||||||
volResponse.setHypervisor(volume.getHypervisorType().toString());
|
volResponse.setHypervisor(volume.getHypervisorType().toString());
|
||||||
} else {
|
} else {
|
||||||
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
|
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long poolId = volume.getPoolId();
|
Long poolId = volume.getPoolId();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user