CLOUDSTACK-8417 : [Hyper-V] Added support for smb share path in Hyper-V settings virtual disk path

this closes #197
This commit is contained in:
Anshul Gangwar 2015-04-02 14:33:01 +05:30 committed by Rajesh Battala
parent aa7ae1b918
commit c355810034
1 changed files with 20 additions and 9 deletions

View File

@ -974,8 +974,8 @@ namespace HypervResource
if (poolType == StoragePoolType.Filesystem)
{
GetCapacityForLocalPath(localPath, out capacityBytes, out availableBytes);
hostPath = localPath;
GetCapacityForPath(hostPath, out capacityBytes, out availableBytes);
}
else if (poolType == StoragePoolType.NetworkFilesystem ||
poolType == StoragePoolType.SMB)
@ -1943,8 +1943,8 @@ namespace HypervResource
}
else if (poolType == StoragePoolType.Filesystem)
{
hostPath = (string)cmd.localPath;;
GetCapacityForLocalPath(hostPath, out capacity, out available);
hostPath = (string)cmd.localPath;
GetCapacityForPath(hostPath, out capacity, out available);
used = capacity - available;
result = true;
}
@ -2287,8 +2287,8 @@ namespace HypervResource
// Read the localStoragePath for virtual disks from the Hyper-V configuration
// See http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/05/06/managing-the-default-virtual-machine-location-with-hyper-v.aspx
// for discussion of Hyper-V file locations paths.
string localStoragePath = wmiCallsV2.GetDefaultVirtualDiskFolder();
if (localStoragePath != null)
string virtualDiskFolderPath = wmiCallsV2.GetDefaultVirtualDiskFolder();
if (virtualDiskFolderPath != null)
{
// GUID arbitrary. Host agents deals with storage pool in terms of localStoragePath.
// We use HOST guid.
@ -2306,8 +2306,7 @@ namespace HypervResource
long capacity;
long available;
GetCapacityForLocalPath(localStoragePath, out capacity, out available);
GetCapacityForPath(virtualDiskFolderPath, out capacity, out available);
logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available);
string ipAddr = strtRouteCmd.privateIpAddress;
@ -2317,8 +2316,8 @@ namespace HypervResource
StoragePoolInfo pi = new StoragePoolInfo(
poolGuid.ToString(),
ipAddr,
localStoragePath,
localStoragePath,
virtualDiskFolderPath,
virtualDiskFolderPath,
StoragePoolType.Filesystem.ToString(),
capacity,
available);
@ -2492,5 +2491,17 @@ namespace HypervResource
capacityBytes = capacityBytes > 0 ? capacityBytes : 0;
}
}
public static void GetCapacityForPath(String hostPath, out long capacityBytes, out long availableBytes)
{
if (hostPath.Substring(0, 2) == "\\\\")
{
Utils.GetShareDetails(hostPath, out capacityBytes, out availableBytes);
}
else
{
GetCapacityForLocalPath(hostPath, out capacityBytes, out availableBytes);
}
}
}
}