diff --git a/api/src/com/cloud/api/commands/ListCapacityCmd.java b/api/src/com/cloud/api/commands/ListCapacityCmd.java index 981c4b381ca..e34926ff0fe 100755 --- a/api/src/com/cloud/api/commands/ListCapacityCmd.java +++ b/api/src/com/cloud/api/commands/ListCapacityCmd.java @@ -61,9 +61,12 @@ public class ListCapacityCmd extends BaseListCmd { "* CAPACITY_TYPE_CPU = 1" + "* CAPACITY_TYPE_STORAGE = 2" + "* CAPACITY_TYPE_STORAGE_ALLOCATED = 3" + - "* CAPACITY_TYPE_PUBLIC_IP = 4" + + "* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4" + "* CAPACITY_TYPE_PRIVATE_IP = 5" + - "* CAPACITY_TYPE_SECONDARY_STORAGE = 6") + "* CAPACITY_TYPE_SECONDARY_STORAGE = 6" + + "* CAPACITY_TYPE_VLAN = 7" + + "* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8" + + "* CAPACITY_TYPE_LOCAL_STORAGE = 9.") private Integer type; diff --git a/api/src/com/cloud/capacity/Capacity.java b/api/src/com/cloud/capacity/Capacity.java index 2151a86c3f8..e31ae19543c 100755 --- a/api/src/com/cloud/capacity/Capacity.java +++ b/api/src/com/cloud/capacity/Capacity.java @@ -31,6 +31,7 @@ public interface Capacity { public static final short CAPACITY_TYPE_SECONDARY_STORAGE = 6; public static final short CAPACITY_TYPE_VLAN = 7; public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8; + public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9; public long getId(); diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index d8f1d78eb1c..079c0c0967c 100755 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -284,7 +284,11 @@ public class AlertManagerImpl implements AlertManager { long disk = 0l; Pair sizes = _volumeDao.getCountAndTotalByPool(pool.getId()); disk = sizes.second(); - _storageMgr.createCapacityEntry(pool, disk); + if (pool.isShared()){ + _storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, disk); + }else { + _storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk); + } } try { diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index 9fec5776ee5..7290b2381c4 100755 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; import javax.ejb.Local; import javax.naming.ConfigurationException; @@ -41,7 +40,6 @@ import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.exception.ConnectionException; -import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.host.dao.HostDao; @@ -80,8 +78,6 @@ public class CapacityManagerImpl implements CapacityManager, StateListener DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size, T vm, Account owner); DiskProfile allocateTemplatedVolume(Type type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, Account owner); - void createCapacityEntry(StoragePoolVO storagePool, long allocated); + void createCapacityEntry(StoragePoolVO storagePool, short capacityType, long allocated); void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException; diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 2c7acf72478..85d156e1f9d 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -71,6 +71,7 @@ import com.cloud.api.commands.CreateVolumeCmd; import com.cloud.api.commands.DeletePoolCmd; import com.cloud.api.commands.UpdateStoragePoolCmd; import com.cloud.async.AsyncJobManager; +import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManagerListener; @@ -1801,18 +1802,18 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag @Override public void createCapacityEntry(StoragePoolVO storagePool) { - createCapacityEntry(storagePool, 0); + createCapacityEntry(storagePool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, 0); } @Override - public void createCapacityEntry(StoragePoolVO storagePool, long allocated) { + public void createCapacityEntry(StoragePoolVO storagePool, short capacityType ,long allocated) { SearchCriteria capacitySC = _capacityDao.createSearchCriteria(); List capacities = _capacityDao.search(capacitySC, null); capacitySC = _capacityDao.createSearchCriteria(); capacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, storagePool.getId()); capacitySC.addAnd("dataCenterId", SearchCriteria.Op.EQ, storagePool.getDataCenterId()); - capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED); + capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType); capacities = _capacityDao.search(capacitySC, null); @@ -1822,7 +1823,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag } if (capacities.size() == 0) { CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, storagePool.getCapacityBytes() - * provFactor, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED); + * provFactor, capacityType); _capacityDao.persist(capacity); } else { CapacityVO capacity = capacities.get(0); @@ -1840,7 +1841,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag _capacityDao.update(capacity.getId(), capacity); } } - s_logger.debug("Successfully set Capacity - " + storagePool.getCapacityBytes() * _overProvisioningFactor + " for CAPACITY_TYPE_STORAGE_ALLOCATED, DataCenterId - " + s_logger.debug("Successfully set Capacity - " + storagePool.getCapacityBytes() * _overProvisioningFactor + " for capacity type - " +capacityType+ " , DataCenterId - " + storagePool.getDataCenterId() + ", HostOrPoolId - " + storagePool.getId() + ", PodId " + storagePool.getPodId()); }