Repository: cloudstack Updated Branches: refs/heads/master aa7ae1b91 -> 866cc4114
CLOUDSTACK-8417 : [Hyper-V] Added support for smb share path in Hyper-V settings virtual disk path this closes #197 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c3558100 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c3558100 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c3558100 Branch: refs/heads/master Commit: c355810034b592d4cf27039b6bd0548f29774c40 Parents: aa7ae1b Author: Anshul Gangwar <anshul.gang...@citrix.com> Authored: Thu Apr 2 14:33:01 2015 +0530 Committer: Rajesh Battala <rajesh.batt...@citrix.com> Committed: Thu Apr 30 14:41:50 2015 +0530 ---------------------------------------------------------------------- .../HypervResource/HypervResourceController.cs | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3558100/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs index 1afa977..5af37a9 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs @@ -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); + } + } } }