Updated Branches: refs/heads/master c5e1c4725 -> e58bef22c
CLOUDSTACK-4682: VMs are getting deployed with shared service offering and local compute offering VM deployment is fine, issue is in attach volume where all possible scenarios are not handled. The following needs to be logic of attached volume: 1. if data volume scope is zone then allow attach (this is already there) 2. if data volume scope is cluster a. if root volume scope is host, allow if both are in same cluster (already there) b. if root volume scope is zone, allow if vm and data volume in same cluster (fixed as part of this commit) 3. if data volume scope is host allow if vm and data volume in same host (fixed as part of this commit) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e58bef22 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e58bef22 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e58bef22 Branch: refs/heads/master Commit: e58bef22c161a939b52b7748c17238476bac923b Parents: c5e1c47 Author: Koushik Das <kous...@apache.org> Authored: Thu Oct 17 15:26:03 2013 +0530 Committer: Koushik Das <kous...@apache.org> Committed: Thu Oct 17 15:27:25 2013 +0530 ---------------------------------------------------------------------- .../com/cloud/storage/VolumeApiServiceImpl.java | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e58bef22/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 079f90c..2a058bf 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1545,15 +1545,25 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } if (storeForRootStoreScope.getScopeType() != storeForDataStoreScope.getScopeType()) { - if (storeForDataStoreScope.getScopeType() == ScopeType.CLUSTER && storeForRootStoreScope.getScopeType() == ScopeType.HOST) { - HostScope hs = (HostScope)storeForRootStoreScope; - if (storeForDataStoreScope.getScopeId().equals(hs.getClusterId())) { + if (storeForDataStoreScope.getScopeType() == ScopeType.CLUSTER) { + Long vmClusterId = null; + if (storeForRootStoreScope.getScopeType() == ScopeType.HOST) { + HostScope hs = (HostScope)storeForRootStoreScope; + vmClusterId = hs.getClusterId(); + } else if (storeForRootStoreScope.getScopeType() == ScopeType.ZONE) { + Long hostId = _vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId(); + if (hostId != null) { + HostVO host = _hostDao.findById(hostId); + vmClusterId = host.getClusterId(); + } + } + if (storeForDataStoreScope.getScopeId().equals(vmClusterId)) { return false; } - } - if (storeForRootStoreScope.getScopeType() == ScopeType.CLUSTER && storeForDataStoreScope.getScopeType() == ScopeType.HOST) { - HostScope hs = (HostScope)storeForDataStoreScope; - if (storeForRootStoreScope.getScopeId().equals(hs.getClusterId())) { + } else if (storeForDataStoreScope.getScopeType() == ScopeType.HOST && + (storeForRootStoreScope.getScopeType() == ScopeType.CLUSTER || storeForRootStoreScope.getScopeType() == ScopeType.ZONE)) { + Long hostId = _vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId(); + if (storeForDataStoreScope.getScopeId().equals(hostId)) { return false; } }