Search in sources :

Example 61 with StoragePoolVO

use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreHelper method deletePrimaryDataStore.

public boolean deletePrimaryDataStore(final DataStore store) {
    final List<StoragePoolHostVO> hostPoolRecords = this.storagePoolHostDao.listByPoolId(store.getId());
    final StoragePoolVO poolVO = this.dataStoreDao.findById(store.getId());
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    for (final StoragePoolHostVO host : hostPoolRecords) {
        storagePoolHostDao.deleteStoragePoolHostDetails(host.getHostId(), host.getPoolId());
    }
    poolVO.setUuid(null);
    this.dataStoreDao.update(poolVO.getId(), poolVO);
    dataStoreDao.remove(poolVO.getId());
    deletePoolStats(poolVO.getId());
    // Delete op_host_capacity entries
    this._capacityDao.removeBy(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, null, null, null, poolVO.getId());
    txn.commit();
    s_logger.debug("Storage pool id=" + poolVO.getId() + " is removed successfully");
    return true;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 62 with StoragePoolVO

use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreHelper method attachZone.

public DataStore attachZone(final DataStore store, final HypervisorType hypervisor) {
    final StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
    pool.setScope(ScopeType.ZONE);
    pool.setHypervisor(hypervisor);
    pool.setStatus(StoragePoolStatus.Up);
    this.dataStoreDao.update(pool.getId(), pool);
    return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}
Also used : StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 63 with StoragePoolVO

use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreHelper method cancelMaintain.

public boolean cancelMaintain(final DataStore store) {
    final StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
    pool.setStatus(StoragePoolStatus.Up);
    dataStoreDao.update(store.getId(), pool);
    return true;
}
Also used : StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 64 with StoragePoolVO

use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreHelper method attachHost.

public DataStore attachHost(final DataStore store, final HostScope scope, final StoragePoolInfo existingInfo) {
    StoragePoolHostVO poolHost = storagePoolHostDao.findByPoolHost(store.getId(), scope.getScopeId());
    if (poolHost == null) {
        poolHost = new StoragePoolHostVO(store.getId(), scope.getScopeId(), existingInfo.getLocalPath());
        storagePoolHostDao.persist(poolHost);
    }
    final StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
    pool.setScope(scope.getScopeType());
    pool.setUsedBytes(existingInfo.getCapacityBytes() - existingInfo.getAvailableBytes());
    pool.setCapacityBytes(existingInfo.getCapacityBytes());
    pool.setStatus(StoragePoolStatus.Up);
    this.dataStoreDao.update(pool.getId(), pool);
    this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getUsedBytes());
    return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
}
Also used : StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 65 with StoragePoolVO

use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreHelper method attachZone.

public DataStore attachZone(final DataStore store) {
    final StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
    pool.setScope(ScopeType.ZONE);
    pool.setStatus(StoragePoolStatus.Up);
    this.dataStoreDao.update(pool.getId(), pool);
    return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}
Also used : StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Aggregations

StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)86 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)29 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)22 Test (org.junit.Test)18 HostVO (com.cloud.host.HostVO)15 VolumeVO (com.cloud.storage.VolumeVO)15 ArrayList (java.util.ArrayList)15 Answer (com.cloud.agent.api.Answer)14 Account (com.cloud.user.Account)13 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)12 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)11 StoragePool (com.cloud.storage.StoragePool)10 AttachAnswer (com.cloud.storage.command.AttachAnswer)10 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)9 VMInstanceVO (com.cloud.vm.VMInstanceVO)9 RebootAnswer (com.cloud.agent.api.RebootAnswer)8 PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)8 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)8 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)8