use of com.cloud.storage.ImageStore in project cloudstack by apache.
the class AddSecondaryStorageCmd method execute.
@Override
public void execute() {
try {
ImageStore result = _storageService.discoverImageStore(null, getUrl(), "NFS", getZoneId(), null);
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 secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.storage.ImageStore in project cloudstack by apache.
the class AddSecondaryStorageCmdTest method testExecuteForResult.
@Test
public void testExecuteForResult() throws Exception {
StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
ImageStore store = Mockito.mock(ImageStore.class);
Mockito.when(resourceService.discoverImageStore(isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(store);
ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
addImageStoreCmd._responseGenerator = responseGenerator;
ImageStoreResponse responseHost = new ImageStoreResponse();
responseHost.setName("Test");
Mockito.doReturn(responseHost).when(responseGenerator).createImageStoreResponse(store);
addImageStoreCmd.execute();
Mockito.verify(responseGenerator).createImageStoreResponse(store);
ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
assertEquals(responseHost, actualResponse);
assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
use of com.cloud.storage.ImageStore in project cosmic by MissionCriticalCloud.
the class CreateSecondaryStagingStoreCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
try {
final 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 (final Exception ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.storage.ImageStore in project cosmic by MissionCriticalCloud.
the class AddSecondaryStorageCmdTest method testExecuteForResult.
@Test
public void testExecuteForResult() throws Exception {
final StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
final ImageStore store = Mockito.mock(ImageStore.class);
Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(store);
final ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
addImageStoreCmd._responseGenerator = responseGenerator;
final ImageStoreResponse responseHost = new ImageStoreResponse();
responseHost.setName("Test");
Mockito.when(responseGenerator.createImageStoreResponse(store)).thenReturn(responseHost);
addImageStoreCmd.execute();
Mockito.verify(responseGenerator).createImageStoreResponse(store);
final ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
Assert.assertEquals(responseHost, actualResponse);
Assert.assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
use of com.cloud.storage.ImageStore in project cloudstack by apache.
the class UpdateCloudToUseObjectStoreCmd method execute.
@Override
public void execute() {
try {
ImageStore result = _storageService.migrateToObjectStore(getName(), getUrl(), getProviderName(), 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());
}
}
Aggregations