Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9DD9197F9 for ; Wed, 15 May 2013 20:30:09 +0000 (UTC) Received: (qmail 42846 invoked by uid 500); 15 May 2013 20:30:09 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 42819 invoked by uid 500); 15 May 2013 20:30:09 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 42809 invoked by uid 99); 15 May 2013 20:30:09 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 May 2013 20:30:09 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3AE22B62C; Wed, 15 May 2013 20:30:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: prachidamle@apache.org To: commits@cloudstack.apache.org Message-Id: <40d05384c7c74185898f53ae3b0e4044@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to ddd7cfd Date: Wed, 15 May 2013 20:30:09 +0000 (UTC) Updated Branches: refs/heads/master 9f59c618e -> ddd7cfd71 CLOUDSTACK-2519: VMs on local storage incorrectly destroyed when removing another host using deleteHost API - For DeleteHost API: Search for Volumes in READY state on the local storage of the host to find VM's in 'Running' State - For PrepareForMaintenance API: Search for Volumes not in Destroy or Expunging state to check if the Local Storage on the host is being used. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ddd7cfd7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ddd7cfd7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ddd7cfd7 Branch: refs/heads/master Commit: ddd7cfd71c45c708012d30a0b7858db9d74c90f4 Parents: 9f59c61 Author: Prachi Damle Authored: Wed May 15 12:19:33 2013 -0700 Committer: Prachi Damle Committed: Wed May 15 13:28:41 2013 -0700 ---------------------------------------------------------------------- .../src/com/cloud/storage/StorageManagerImpl.java | 28 ++++++++------ 1 files changed, 16 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ddd7cfd7/server/src/com/cloud/storage/StorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 1d4dcef..a67397e 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -423,6 +423,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C SearchCriteria.Op.EQ); volumeSB.and("removed", volumeSB.entity().getRemoved(), SearchCriteria.Op.NULL); + volumeSB.and("state", volumeSB.entity().getState(), SearchCriteria.Op.NIN); SearchBuilder activeVmSB = _vmInstanceDao .createSearchBuilder(); @@ -434,6 +435,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C SearchCriteria volumeSC = volumeSB.create(); volumeSC.setParameters("poolId", PrimaryDataStoreVO.getId()); + volumeSC.setParameters("state", Volume.State.Expunging, Volume.State.Destroy); volumeSC.setJoinParameters("activeVmSB", "state", State.Starting, State.Running, State.Stopping, State.Migrating); @@ -456,13 +458,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C VirtualMachineProfile profile = new VirtualMachineProfileImpl( vm); for (StoragePoolAllocator allocator : _storagePoolAllocators) { - + ExcludeList avoidList = new ExcludeList(); for(StoragePool pool : avoid){ avoidList.addPool(pool.getId()); } DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), pod.getId(), clusterId, hostId, null, null); - + final List poolList = allocator.allocateToPool(dskCh, profile, plan, avoidList, 1); if (poolList != null && !poolList.isEmpty()) { return (StoragePool)this.dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary); @@ -629,6 +631,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C SearchCriteria.Op.EQ); volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ); + volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ); StoragePoolSearch.join("vmVolume", volumeSearch, volumeSearch.entity() .getInstanceId(), StoragePoolSearch.entity().getId(), JoinBuilder.JoinType.INNER); @@ -651,7 +654,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C return true; } - + @Override public String getStoragePoolTags(long poolId) { return _configMgr.listToCsvTags(_storagePoolDao @@ -680,7 +683,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C return true; } - + @DB @Override public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException { @@ -694,7 +697,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid()); if(pool == null && host.getHypervisorType() == HypervisorType.VMware) { // perform run-time upgrade. In versions prior to 2.2.12, there is a bug that we don't save local datastore info (host path is empty), this will cause us - // not able to distinguish multiple local datastores that may be available on the host, to support smooth migration, we + // not able to distinguish multiple local datastores that may be available on the host, to support smooth migration, we // need to perform runtime upgrade here if(pInfo.getHostPath().length() > 0) { pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid()); @@ -714,13 +717,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C params.put("details", pInfo.getDetails()); params.put("uuid", pInfo.getUuid()); params.put("providerName", provider.getName()); - + store = lifeCycle.initialize(params); } else { store = (DataStore) dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); } - + HostScope scope = new HostScope(host.getId()); lifeCycle.attachHost(store, scope, pInfo); } catch (Exception e) { @@ -990,7 +993,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled; - + capacity.setCapacityState(capacityState); _capacityDao.persist(capacity); } else { @@ -1130,7 +1133,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C }finally { scanLock.unlock(); } - } + } }finally { scanLock.releaseRef(); } @@ -1462,7 +1465,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C DataStore store = dataStoreMgr.getDataStore( primaryStorage.getId(), DataStoreRole.Primary); lifeCycle.cancelMaintain(store); - + return (PrimaryDataStoreInfo) dataStoreMgr.getDataStore( primaryStorage.getId(), DataStoreRole.Primary); } @@ -1610,7 +1613,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C DataStoreRole.Primary); } - + @Override @DB @@ -1618,6 +1621,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C SearchCriteria sc = StoragePoolSearch.create(); sc.setJoinParameters("vmVolume", "volumeType", Volume.Type.ROOT); sc.setJoinParameters("vmVolume", "poolId", storagePoolId); + sc.setJoinParameters("vmVolume", "state", Volume.State.Ready); return _vmInstanceDao.search(sc, null); } @@ -1691,7 +1695,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C return secHost; } - + @Override public HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {