diff --git a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java index 66dde3655f0..0b1622640d0 100644 --- a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java +++ b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java @@ -79,9 +79,26 @@ public class StoragePoolResponse extends BaseResponse { @SerializedName(ApiConstants.STATE) @Param(description="the state of the storage pool") private StoragePoolStatus state; + + @SerializedName(ApiConstants.SCOPE) @Param(description="the scope of the storage pool") + private String scope; + /** + * @return the scope + */ + public String getScope() { + return scope; + } + + /** + * @param scope the scope to set + */ + public void setScope(String scope) { + this.scope = scope; + } + @Override public String getObjectId() { return this.getId(); diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreStatus.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreStatus.java deleted file mode 100644 index 2388795410c..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.subsystem.api.storage; - -public enum DataStoreStatus { - Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed; -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java index 747e2586fed..0dd55d1d325 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java @@ -51,6 +51,7 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat @Override protected List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { + s_logger.debug("ClusterScopeStoragePoolAllocator looking for storage pool"); List suitablePools = new ArrayList(); long dcId = plan.getDataCenterId(); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java index 91bc25c715d..02032ee4fbd 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java @@ -48,7 +48,7 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl @Override public List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { - + s_logger.debug("GarbageCollectingStoragePoolAllocator looking for storage pool"); if (!_storagePoolCleanupEnabled) { s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped."); return null; diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java index a8d5173cebe..7447d988a58 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java @@ -69,11 +69,12 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { List suitablePools = new ArrayList(); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); - } + s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); + if (!dskCh.useLocalStorage()) { + return suitablePools; + } + // data disk and host identified from deploying vm (attach volume case) if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) { List hostPools = _poolHostDao.listByHostId(plan.getHostId()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java index a4aa3d5cf84..7c6c946765f 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java @@ -55,6 +55,7 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator { protected List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { + s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool"); List suitablePools = new ArrayList(); HypervisorType hypervisor = dskCh.getHypersorType(); if (hypervisor != null) { diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index 3a1ba3ab8c8..613c817668e 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -1,22 +1,15 @@ - - + + 4.0.0 cloud-plugin-hypervisor-kvm Apache CloudStack Plugin - Hypervisor KVM @@ -45,29 +38,29 @@ - install - src - test - - - org.apache.maven.plugins - maven-dependency-plugin - 2.5.1 - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/dependencies - runtime - - - - - + install + src + test + + + org.apache.maven.plugins + maven-dependency-plugin + 2.5.1 + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/dependencies + runtime + + + + + org.apache.maven.plugins maven-surefire-plugin 2.14 @@ -77,6 +70,52 @@ + + maven-assembly-plugin + 2.3 + + kvm-agent + false + + agent-descriptor.xml + + + + + make-agent + package + + single + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + + package + + copy-resources + + + dist + + + target + + kvm-agent.zip + + + + + + + + diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 526107f8ae0..362e0a53e53 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -666,6 +666,9 @@ ServerResource { if (_localStoragePath == null) { _localStoragePath = "/var/lib/libvirt/images/"; } + + File storagePath = new File(_localStoragePath); + _localStoragePath = storagePath.getAbsolutePath(); _localStorageUUID = (String) params.get("local.storage.uuid"); if (_localStorageUUID == null) { diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java index b8b08598f69..51ea2126756 100644 --- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java @@ -348,6 +348,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements new String(storageHost + hostPath).getBytes()).toString(); } + List spHandles = primaryDataStoreDao .findIfDuplicatePoolsExistByUUID(uuid); if ((spHandles != null) && (spHandles.size() > 0)) { @@ -358,6 +359,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements "Another active pool with the same uuid already exists"); } + String poolName = (String) dsInfos.get("name"); parameters.setUuid(uuid); diff --git a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java index 66aecc212d8..58968df2e56 100644 --- a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java @@ -82,6 +82,7 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase _storagePoolAllocators; public List getStoragePoolAllocators() { return _storagePoolAllocators; diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index a33d524d8ea..4e410e4b41e 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -51,7 +51,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreStatus; import org.apache.cloudstack.engine.subsystem.api.storage.HostScope; import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener; import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory; @@ -381,7 +380,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C if (pools == null || pools.size() == 0 || (pools.size() == 1 && pools.get(0).getStatus() - .equals(DataStoreStatus.Maintenance))) { + .equals(StoragePoolStatus.Maintenance))) { return false; } else { return true; @@ -1000,8 +999,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C if (capacities.size() == 0) { CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity, capacityType); - CapacityState capacityState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(storagePool.getClusterId())) == AllocationState.Disabled ? + AllocationState allocationState = null; + if (storagePool.getScope() == ScopeType.ZONE) { + DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId()); + allocationState = dc.getAllocationState(); + } else { + allocationState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(storagePool.getClusterId())); + } + CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled; + capacity.setCapacityState(capacityState); _capacityDao.persist(capacity); } else { @@ -1419,9 +1426,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } } - if (!primaryStorage.getStatus().equals(DataStoreStatus.Up) + if (!primaryStorage.getStatus().equals(StoragePoolStatus.Up) && !primaryStorage.getStatus().equals( - DataStoreStatus.ErrorInMaintenance)) { + StoragePoolStatus.ErrorInMaintenance)) { throw new InvalidParameterValueException("Primary storage with id " + primaryStorageId + " is not ready for migration, as the status is:" @@ -1458,9 +1465,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C throw new InvalidParameterValueException(msg); } - if (primaryStorage.getStatus().equals(DataStoreStatus.Up) + if (primaryStorage.getStatus().equals(StoragePoolStatus.Up) || primaryStorage.getStatus().equals( - DataStoreStatus.PrepareForMaintenance)) { + StoragePoolStatus.PrepareForMaintenance)) { throw new StorageUnavailableException("Primary storage with id " + primaryStorageId + " is not ready to complete migration, as the status is:" @@ -1519,11 +1526,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // check if pool is in an inconsistent state if (pool != null && (pool.getStatus().equals( - DataStoreStatus.ErrorInMaintenance) + StoragePoolStatus.ErrorInMaintenance) || pool.getStatus() - .equals(DataStoreStatus.PrepareForMaintenance) || pool + .equals(StoragePoolStatus.PrepareForMaintenance) || pool .getStatus() - .equals(DataStoreStatus.CancelMaintenance))) { + .equals(StoragePoolStatus.CancelMaintenance))) { _storagePoolWorkDao.removePendingJobsOnMsRestart( vo.getMsid(), poolId); pool.setStatus(StoragePoolStatus.ErrorInMaintenance); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 9a4d6b047e7..c94224b264c 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -742,7 +742,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm"); + s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + " system.vm.use.local.storage: " + _useLocalStorage + + "If you want to use local storage to start ssvm, need to set system.vm.use.local.storage to true"); } } } else { diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java index 8ce118f3cbc..434430afb72 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -62,7 +62,13 @@ public class Upgrade410to420 implements DbUpgrade { upgradeVmwareLabels(conn); createPlaceHolderNics(conn); updateRemoteAccessVpn(conn); - PreparedStatement sql = null; + updateSystemVmTemplates(conn); + updateCluster_details(conn); + updatePrimaryStore(conn); + } + + private void updateSystemVmTemplates(Connection conn) { + PreparedStatement sql = null; try { sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'"); sql.executeUpdate(); @@ -76,8 +82,39 @@ public class Upgrade410to420 implements DbUpgrade { } } } - updateCluster_details(conn); - } + } + + private void updatePrimaryStore(Connection conn) { + PreparedStatement sql = null; + PreparedStatement sql2 = null; + try { + sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'"); + sql.setString(1, "ancient primary data store provider"); + sql.setString(2, "HOST"); + sql.executeUpdate(); + + sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'"); + sql2.setString(1, "ancient primary data store provider"); + sql2.setString(2, "CLUSTER"); + sql2.executeUpdate(); + } catch (SQLException e) { + throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString()); + } finally { + if (sql != null) { + try { + sql.close(); + } catch (SQLException e) { + } + } + + if (sql2 != null) { + try { + sql2.close(); + } catch (SQLException e) { + } + } + } + } //update the cluster_details table with default overcommit ratios. private void updateCluster_details(Connection conn) { diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index e333810cb06..77225b95474 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -1479,6 +1479,7 @@ CREATE VIEW `cloud`.`storage_pool_view` AS storage_pool.created, storage_pool.removed, storage_pool.capacity_bytes, + storage_pool.scope, cluster.id cluster_id, cluster.uuid cluster_uuid, cluster.name cluster_name,