Sorry...obvious issue, but wanted to point out here from my previous e-mail:
"The problem is in the needMoveVolume method in the VolumeApiServiceImpl method." I meant VolumeApiServiceImpl class...not method, of course. :) On Mon, Mar 10, 2014 at 10:38 PM, Mike Tutkowski < mike.tutkow...@solidfire.com> wrote: > Hi, > > I noticed a minor problem trying to attach a volume that is at the cluster > scope to a VM whose root disk is at the zone scope IF the VM is in the > stopped state (this works fine when the VM is in the running state). > > The problem is in the needMoveVolume method in the VolumeApiServiceImpl > method. > > When the VM is in the Stopped state, if you try to get the host ID of the > VM, it will come back as null. (code below) > > if (storeForRootStoreScope.getScopeType() != > storeForDataStoreScope.getScopeType()) { > > 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; > > } > > } 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; > > } > > } > > throw new CloudRuntimeException("Can't move volume between > scope: " + storeForDataStoreScope.getScopeType() + " and " + > storeForRootStoreScope.getScopeType()); > > } > My question is the following: Do you think it's acceptable to query for > the last host ID if the host ID is null in this situation? (code below) > > if (storeForRootStoreScope.getScopeType() != > storeForDataStoreScope.getScopeType()) { > > 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) { > > hostId = _vmInstanceDao > .findById(rootVolumeOfVm.getInstanceId()).getLastHostId(); > > } > > > > if (hostId != null) { > > HostVO host = _hostDao.findById(hostId); > > vmClusterId = host.getClusterId(); > > } > > } > > if(storeForDataStoreScope.getScopeId().equals(vmClusterId)) { > > return false; > > } > > } 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; > > } > > } > > throw new CloudRuntimeException("Can't move volume between > scope: " + storeForDataStoreScope.getScopeType() + " and " + > storeForRootStoreScope.getScopeType()); > > } > I believe this solves the problem for this one case, but it wouldn't solve > the case where the VM was created in the Stopped state, it's root disk is > at the zone scope, and we want to attach a data disk that is at the cluster > scope to the VM. > > In this situation, there will not be a last host ID. > > Thoughts? > > Thanks! > > -- > *Mike Tutkowski* > *Senior CloudStack Developer, SolidFire Inc.* > e: mike.tutkow...@solidfire.com > o: 303.746.7302 > Advancing the way the world uses the > cloud<http://solidfire.com/solution/overview/?video=play> > *(tm)* > -- *Mike Tutkowski* *Senior CloudStack Developer, SolidFire Inc.* e: mike.tutkow...@solidfire.com o: 303.746.7302 Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play> *(tm)*