Search in sources :

Example 6 with ImageStoreResponse

use of org.apache.cloudstack.api.response.ImageStoreResponse 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 7 with ImageStoreResponse

use of org.apache.cloudstack.api.response.ImageStoreResponse 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 8 with ImageStoreResponse

use of org.apache.cloudstack.api.response.ImageStoreResponse 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 9 with ImageStoreResponse

use of org.apache.cloudstack.api.response.ImageStoreResponse 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)

Example 10 with ImageStoreResponse

use of org.apache.cloudstack.api.response.ImageStoreResponse in project cloudstack by apache.

the class ListSwiftsCmd method execute.

@Override
public void execute() {
    ListImageStoresCmd cmd = new ListImageStoresCmd();
    cmd.setProvider("Swift");
    ListResponse<ImageStoreResponse> response = _queryService.searchForImageStores(cmd);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) ListImageStoresCmd(org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd)

Aggregations

ImageStoreResponse (org.apache.cloudstack.api.response.ImageStoreResponse)11 ImageStore (com.cloud.storage.ImageStore)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)7 DiscoveryException (com.cloud.exception.DiscoveryException)5 HashMap (java.util.HashMap)2 ImageStoreJoinVO (com.cloud.api.query.vo.ImageStoreJoinVO)1 StorageService (com.cloud.storage.StorageService)1 StorageStats (com.cloud.storage.StorageStats)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)1 ListImageStoresCmd (org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd)1 Test (org.junit.Test)1