Package org.apache.cloudstack.api.response

Examples of org.apache.cloudstack.api.response.StoragePoolResponse


        this._count = "select count(distinct id) from storage_pool_view WHERE ";
    }

    @Override
    public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
        StoragePoolResponse poolResponse = new StoragePoolResponse();
        poolResponse.setId(pool.getUuid());
        poolResponse.setName(pool.getName());
        poolResponse.setState(pool.getStatus());
        poolResponse.setPath(pool.getPath());
        poolResponse.setIpAddress(pool.getHostAddress());
        poolResponse.setZoneId(pool.getZoneUuid());
        poolResponse.setZoneName(pool.getZoneName());
        poolResponse.setType(pool.getPoolType().toString());
        poolResponse.setPodId(pool.getPodUuid());
        poolResponse.setPodName(pool.getPodName());
        poolResponse.setCreated(pool.getCreated());
        if (pool.getScope() != null) {
            poolResponse.setScope(pool.getScope().toString());
        }
        if (pool.getHypervisor() != null) {
            poolResponse.setHypervisor(pool.getHypervisor().toString());
        }

        long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
        poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
        poolResponse.setDiskSizeAllocated(allocatedSize);
        poolResponse.setCapacityIops(pool.getCapacityIops());

        // TODO: StatsCollector does not persist data
        StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
        if (stats != null) {
            Long used = stats.getByteUsed();
            poolResponse.setDiskSizeUsed(used);
        }

        poolResponse.setClusterId(pool.getClusterUuid());
        poolResponse.setClusterName(pool.getClusterName());
        poolResponse.setTags(pool.getTag());

        // set async job
        if (pool.getJobId() != null) {
            poolResponse.setJobId(pool.getJobUuid());
            poolResponse.setJobStatus(pool.getJobStatus());
        }

        poolResponse.setObjectName("storagepool");
        return poolResponse;
    }
View Full Code Here


        return response;
    }

    @Override
    public StoragePoolResponse newStoragePoolForMigrationResponse(StoragePoolJoinVO pool) {
        StoragePoolResponse poolResponse = new StoragePoolResponse();
        poolResponse.setId(pool.getUuid());
        poolResponse.setName(pool.getName());
        poolResponse.setState(pool.getStatus());
        poolResponse.setPath(pool.getPath());
        poolResponse.setIpAddress(pool.getHostAddress());
        poolResponse.setZoneId(pool.getZoneUuid());
        poolResponse.setZoneName(pool.getZoneName());
        if (pool.getPoolType() != null) {
            poolResponse.setType(pool.getPoolType().toString());
        }
        poolResponse.setPodId(pool.getPodUuid());
        poolResponse.setPodName(pool.getPodName());
        poolResponse.setCreated(pool.getCreated());
        poolResponse.setScope(pool.getScope().toString());
        if (pool.getHypervisor() != null) {
            poolResponse.setHypervisor(pool.getHypervisor().toString());
        }

        short capacityType = pool.getScope() == ScopeType.HOST ? Capacity.CAPACITY_TYPE_LOCAL_STORAGE
                : Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED;
        long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(), capacityType);
        poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
        poolResponse.setDiskSizeAllocated(allocatedSize);
        poolResponse.setCapacityIops(pool.getCapacityIops());

        // TODO: StatsCollector does not persist data
        StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
        if (stats != null) {
            Long used = stats.getByteUsed();
            poolResponse.setDiskSizeUsed(used);
        }

        poolResponse.setClusterId(pool.getClusterUuid());
        poolResponse.setClusterName(pool.getClusterName());
        poolResponse.setTags(pool.getTag());

        // set async job
        poolResponse.setJobId(pool.getJobUuid());
        poolResponse.setJobStatus(pool.getJobStatus());

        poolResponse.setObjectName("storagepool");
        return poolResponse;
    }
View Full Code Here

    public static List<StoragePoolResponse> createStoragePoolResponse(StoragePoolJoinVO... pools) {
        Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
        // Initialise the vrdatalist with the input data
        for (StoragePoolJoinVO vr : pools) {
            StoragePoolResponse vrData = vrDataList.get(vr.getId());
            if ( vrData == null ){
                // first time encountering this vm
                vrData = ApiDBUtils.newStoragePoolResponse(vr);
            }
            else{
View Full Code Here

    public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
        Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
        // Initialise the vrdatalist with the input data
        for (StoragePoolJoinVO vr : pools) {
            StoragePoolResponse vrData = vrDataList.get(vr.getId());
            if ( vrData == null ) {
                // first time encountering this vm
                vrData = ApiDBUtils.newStoragePoolForMigrationResponse(vr);
            } else {
                // update tags
View Full Code Here

    @Override
    public void execute(){
        StoragePool result = _storageService.updateStoragePool(this);
        if (result != null){
            StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update storage pool");
        }
    }
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 {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool");
            }
        } catch (ResourceUnavailableException ex1) {
View Full Code Here

    @Override
    public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
        StoragePool result = _storageService.preparePrimaryStorageForMaintenance(getId());
        if (result != null){
            StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
            response.setResponseName("storagepool");
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
        }
    }
View Full Code Here

        List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();

        List<? extends StoragePool> allPools = pools.first();
        List<? extends StoragePool> suitablePoolList = pools.second();
        for (StoragePool pool : allPools) {
            StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
            Boolean suitableForMigration = false;
            for (StoragePool suitablePool : suitablePoolList) {
                if (suitablePool.getId() == pool.getId()) {
                    suitableForMigration = true;
                    break;
                }
            }
            poolResponse.setSuitableForMigration(suitableForMigration);
            poolResponse.setObjectName("storagepool");
            poolResponses.add(poolResponse);
        }

        response.setResponses(poolResponses);
        response.setResponseName(getCommandName());
View Full Code Here

    @Override
    public void execute() throws ResourceUnavailableException{
        StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
        if (result != null) {
            StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
        }
    }
View Full Code Here

    public static List<StoragePoolResponse> createStoragePoolResponse(StoragePoolJoinVO... pools) {
        Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
        // Initialise the vrdatalist with the input data
        for (StoragePoolJoinVO vr : pools) {
            StoragePoolResponse vrData = vrDataList.get(vr.getId());
            if ( vrData == null ){
                // first time encountering this vm
                vrData = ApiDBUtils.newStoragePoolResponse(vr);
            }
            else{
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.api.response.StoragePoolResponse

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.