Search in sources :

Example 6 with ImageStore

use of com.cloud.storage.ImageStore in project cloudstack by apache.

the class AddSwiftCmd method execute.

@Override
public void execute() {
    Map<String, String> dm = new HashMap<String, String>();
    dm.put(ApiConstants.ACCOUNT, getAccount());
    dm.put(ApiConstants.USERNAME, getUsername());
    dm.put(ApiConstants.KEY, getKey());
    try {
        ImageStore result = _storageService.discoverImageStore(null, getUrl(), "Swift", null, dm);
        ImageStoreResponse storeResponse = null;
        if (result != null) {
            storeResponse = _responseGenerator.createImageStoreResponse(result);
            storeResponse.setResponseName(getCommandName());
            storeResponse.setObjectName("secondarystorage");
            setResponseObject(storeResponse);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Swift secondary storage");
        }
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) HashMap(java.util.HashMap) DiscoveryException(com.cloud.exception.DiscoveryException) ImageStore(com.cloud.storage.ImageStore)

Example 7 with ImageStore

use of com.cloud.storage.ImageStore in project cloudstack by apache.

the class AddImageStoreCmd method execute.

@Override
public void execute() {
    try {
        ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails());
        ImageStoreResponse storeResponse = null;
        if (result != null) {
            storeResponse = _responseGenerator.createImageStoreResponse(result);
            storeResponse.setResponseName(getCommandName());
            storeResponse.setObjectName("imagestore");
            setResponseObject(storeResponse);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
        }
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DiscoveryException(com.cloud.exception.DiscoveryException) ImageStore(com.cloud.storage.ImageStore)

Example 8 with ImageStore

use of com.cloud.storage.ImageStore in project cloudstack by apache.

the class CreateSecondaryStagingStoreCmd method execute.

@Override
public void execute() {
    try {
        ImageStore result = _storageService.createSecondaryStagingStore(this);
        ImageStoreResponse storeResponse = null;
        if (result != null) {
            storeResponse = _responseGenerator.createImageStoreResponse(result);
            storeResponse.setResponseName(getCommandName());
            storeResponse.setObjectName("secondarystorage");
            this.setResponseObject(storeResponse);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
        }
    } catch (Exception ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServerApiException(org.apache.cloudstack.api.ServerApiException) ImageStore(com.cloud.storage.ImageStore)

Example 9 with ImageStore

use of com.cloud.storage.ImageStore in project cloudstack by apache.

the class UpdateImageStoreCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    ImageStore result = _storageService.updateImageStoreStatus(getId(), getReadonly());
    ImageStoreResponse storeResponse = null;
    if (result != null) {
        storeResponse = _responseGenerator.createImageStoreResponse(result);
        storeResponse.setResponseName(getCommandName() + "response");
        storeResponse.setObjectName("imagestore");
        setResponseObject(storeResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update Image store status");
    }
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ImageStore(com.cloud.storage.ImageStore)

Example 10 with ImageStore

use of com.cloud.storage.ImageStore in project cloudstack by apache.

the class AddImageStoreS3CMD method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    Map<String, String> dm = new HashMap();
    dm.put(ApiConstants.S3_ACCESS_KEY, getAccessKey());
    dm.put(ApiConstants.S3_SECRET_KEY, getSecretKey());
    dm.put(ApiConstants.S3_END_POINT, getEndPoint());
    dm.put(ApiConstants.S3_BUCKET_NAME, getBucketName());
    if (getSigner() != null && (getSigner().equals(ApiConstants.S3_V3_SIGNER) || getSigner().equals(ApiConstants.S3_V4_SIGNER))) {
        dm.put(ApiConstants.S3_SIGNER, getSigner());
    }
    if (isHttps() != null) {
        dm.put(ApiConstants.S3_HTTPS_FLAG, isHttps().toString());
    }
    if (getConnectionTimeout() != null) {
        dm.put(ApiConstants.S3_CONNECTION_TIMEOUT, getConnectionTimeout().toString());
    }
    if (getMaxErrorRetry() != null) {
        dm.put(ApiConstants.S3_MAX_ERROR_RETRY, getMaxErrorRetry().toString());
    }
    if (getSocketTimeout() != null) {
        dm.put(ApiConstants.S3_SOCKET_TIMEOUT, getSocketTimeout().toString());
    }
    if (getConnectionTtl() != null) {
        dm.put(ApiConstants.S3_CONNECTION_TTL, getConnectionTtl().toString());
    }
    if (getUseTCPKeepAlive() != null) {
        dm.put(ApiConstants.S3_USE_TCP_KEEPALIVE, getUseTCPKeepAlive().toString());
    }
    try {
        ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm);
        ImageStoreResponse storeResponse;
        if (result != null) {
            storeResponse = _responseGenerator.createImageStoreResponse(result);
            storeResponse.setResponseName(getCommandName());
            storeResponse.setObjectName("imagestore");
            setResponseObject(storeResponse);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 Image Store.");
        }
    } catch (DiscoveryException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) HashMap(java.util.HashMap) DiscoveryException(com.cloud.exception.DiscoveryException) ImageStore(com.cloud.storage.ImageStore)

Aggregations

ImageStore (com.cloud.storage.ImageStore)13 ImageStoreResponse (org.apache.cloudstack.api.response.ImageStoreResponse)8 DiscoveryException (com.cloud.exception.DiscoveryException)7 ServerApiException (org.apache.cloudstack.api.ServerApiException)7 ImageStoreResponse (com.cloud.api.response.ImageStoreResponse)4 ServerApiException (com.cloud.api.ServerApiException)3 StorageService (com.cloud.storage.StorageService)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 ResponseGenerator (com.cloud.api.ResponseGenerator)1 StoragePoolJoinVO (com.cloud.api.query.vo.StoragePoolJoinVO)1 StorageStats (com.cloud.storage.StorageStats)1 BigDecimal (java.math.BigDecimal)1 ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)1 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)1