Package com.cloud.storage

Examples of com.cloud.storage.StoragePool


        User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
        if (forceDestroyStorage) {
            // put local storage into mainenance mode, will set all the VMs on
            // this local storage into stopped state
            StoragePool storagePool = _storageMgr.findLocalStorageOnHost(host.getId());
            if (storagePool != null) {
                if (storagePool.getStatus() == StoragePoolStatus.Up || storagePool.getStatus() == StoragePoolStatus.ErrorInMaintenance) {
                    try {
                        storagePool = _storageSvr.preparePrimaryStorageForMaintenance(storagePool.getId());
                        if (storagePool == null) {
                            s_logger.debug("Failed to set primary storage into maintenance mode");
                            throw new UnableDeleteHostException("Failed to set primary storage into maintenance mode");
                        }
                    } catch (Exception e) {
                        s_logger.debug("Failed to set primary storage into maintenance mode, due to: " + e.toString());
                        throw new UnableDeleteHostException("Failed to set primary storage into maintenance mode, due to: " + e.toString());
                    }
                }

                List<VMInstanceVO> vmsOnLocalStorage = _storageMgr.listByStoragePool(storagePool.getId());
                for (VMInstanceVO vm : vmsOnLocalStorage) {
                    try {
                        if (!_vmMgr.destroy(vm, caller, _accountMgr.getAccount(vm.getAccountId()))) {
                            String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId();
                            s_logger.warn(errorMsg);
View Full Code Here


    protected SearchBuilder<SnapshotPolicyVO> PoliciesForSnapSearch;

   
   
    protected Answer sendToPool(Volume vol, Command cmd) {
        StoragePool pool = _storagePoolDao.findById(vol.getPoolId());
        VMInstanceVO vm = _vmDao.findById(vol.getInstanceId());

        long[] hostIdsToTryFirst = null;
        if (vm != null) {
            if(vm.getHostId() != null) {
View Full Code Here

                }
            }
        } else {
            List<StoragePool> availablePool;
            while (!(availablePool = super.allocateToPool(dskCh, vmProfile, plan, myAvoids, 1)).isEmpty()) {
                StoragePool pool = availablePool.get(0);
                myAvoids.addPool(pool.getId());
                List<StoragePoolHostVO> hostsInSPool = _poolHostDao.listByPoolId(pool.getId());
                assert (hostsInSPool.size() == 1) : "Local storage pool should be one host per pool";

                s_logger.debug("Found suitable local storage pool " + pool.getId() + ", adding to list");
                suitablePools.add(pool);

                if (suitablePools.size() == returnUpTo) {
                    break;
                }
View Full Code Here

                throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
            }
            CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: " + getHostId());
        }

        StoragePool destStoragePool = null;
        if (getStoragePoolId() != null) {
            destStoragePool = _storageService.getStoragePool(getStoragePoolId());
            if (destStoragePool == null) {
                throw new InvalidParameterValueException("Unable to find the storage pool to migrate the VM");
            }
View Full Code Here

            // this local storage into stopped state
            StoragePoolVO storagePool = _storageMgr.findLocalStorageOnHost(host.getId());
            if (storagePool != null) {
                if (storagePool.getStatus() == StoragePoolStatus.Up || storagePool.getStatus() == StoragePoolStatus.ErrorInMaintenance) {
                    try {
                        StoragePool pool = _storageSvr.preparePrimaryStorageForMaintenance(storagePool.getId());
                        if (pool == null) {
                            s_logger.debug("Failed to set primary storage into maintenance mode");

                            throw new UnableDeleteHostException("Failed to set primary storage into maintenance mode");
                        }
View Full Code Here

    }

    @Override
    public void execute(){
        try {
            StoragePool result = _storageService.createPool(this);
            if (result != null) {
                StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
                response.setResponseName(getCommandName());
                this.setResponseObject(response);
            } else {
View Full Code Here

        return Account.ACCOUNT_ID_SYSTEM;
    }

    @Override
    public void execute(){
        StoragePool result = _storageService.updateStoragePool(this);
        if (result != null){
            StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
View Full Code Here

        boolean planChangedByReadyVolume = false;
        List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
        if(!vols.isEmpty()){
            VolumeVO vol = vols.get(0);
            StoragePool pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(vol.getPoolId());

            if (!pool.isInMaintenance()) {
                long rootVolDcId = pool.getDataCenterId();
                Long rootVolPodId = pool.getPodId();
                Long rootVolClusterId = pool.getClusterId();
                if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
                    Long clusterIdSpecified = planToDeploy.getClusterId();
                    if (clusterIdSpecified != null && rootVolClusterId != null) {
                        if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
                            // cannot satisfy the plan passed in to the
View Full Code Here

    @Inject
    PrimaryDataStoreDao primaryStoreDao;

    @Override
    public boolean hostConnect(long hostId, long poolId) {
        StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
        ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
        final Answer answer = agentMgr.easySend(hostId, cmd);

        if (answer == null) {
            throw new CloudRuntimeException("Unable to get an answer to the modify storage pool command" + pool.getId());
        }

        if (!answer.getResult()) {
            String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId;
            alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
            throw new CloudRuntimeException("Unable establish connection from storage head to storage pool "
                    + pool.getId() + " due to " + answer.getDetails() + pool.getId());
        }

        assert (answer instanceof ModifyStoragePoolAnswer) : "Well, now why won't you actually return the ModifyStoragePoolAnswer when it's ModifyStoragePoolCommand? Pool="
                + pool.getId() + "Host=" + hostId;
        ModifyStoragePoolAnswer mspAnswer = (ModifyStoragePoolAnswer) answer;

        StoragePoolHostVO poolHost = storagePoolHostDao.findByPoolHost(pool.getId(), hostId);
        if (poolHost == null) {
            poolHost = new StoragePoolHostVO(pool.getId(), hostId, mspAnswer.getPoolInfo().getLocalPath()
                    .replaceAll("//", "/"));
            storagePoolHostDao.persist(poolHost);
        } else {
            poolHost.setLocalPath(mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
        }

        StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId);
        poolVO.setUsedBytes(mspAnswer.getPoolInfo().getAvailableBytes());
        poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
        primaryStoreDao.update(pool.getId(), poolVO);

        s_logger.info("Connection established between " + pool + " host + " + hostId);
        return true;
    }
View Full Code Here

    private BackupSnapshotAnswer bsa;

    @Before
    public void setUp() {

        StoragePool pool = Mockito.mock(StoragePool.class);

        bsc = new BackupSnapshotCommand(
                "secondaryStoragePoolURL", 101L, 102L, 103L, 104L,
                "volumePath", pool, "snapshotUuid", "snapshotName",
                "prevSnapshotUuid", "prevBackupUuid", false, "vmName", 5);
View Full Code Here

TOP

Related Classes of com.cloud.storage.StoragePool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.