use of com.emc.vipr.client.Task in project coprhd-controller by CoprHD.
the class MobilityGroupMigrationService method execute.
@Override
public void execute() throws Exception {
boolean migrationTasksFailed = false;
if (mobilityGroupMethod != null && mobilityGroupMethod.equalsIgnoreCase(BlockProvider.INGEST_AND_MIGRATE_OPTION_KEY)) {
ingestVolumes();
}
List<Task<VolumeRestRep>> tasks = new ArrayList<>();
Tasks<VolumeRestRep> migrationTasks = execute(new ChangeBlockVolumeVirtualPoolNoWait(mapVpoolVolumes(), targetVirtualPool));
tasks.addAll(migrationTasks.getTasks());
if (tasks.isEmpty()) {
ExecutionUtils.fail("failTask.mobilityGroupMigration.noVolumesMigrated", new Object[] {}, new Object[] {});
}
while (!tasks.isEmpty()) {
waitAndRefresh(tasks);
for (Task<VolumeRestRep> successfulTask : ComputeUtils.getSuccessfulTasks(tasks)) {
URI volumeId = successfulTask.getResourceId();
addAffectedResource(volumeId);
tasks.remove(successfulTask);
}
for (Task<VolumeRestRep> failedTask : ComputeUtils.getFailedTasks(tasks)) {
String errorMessage = failedTask.getMessage() == null ? "" : failedTask.getMessage();
ExecutionUtils.currentContext().logError("mobilityGroupMigration.changeVirtualPool.failure", failedTask.getResource().getName(), errorMessage);
tasks.remove(failedTask);
migrationTasksFailed = true;
}
}
if (migrationTasksFailed) {
ExecutionUtils.fail("failTask.MobilityGroupMigration.migrationsFailed", new Object[] {}, new Object[] {});
}
}
use of com.emc.vipr.client.Task in project coprhd-controller by CoprHD.
the class BlockVolumes method volume.
public static void volume(String volumeId, String continuousCopyId) {
ViPRCoreClient client = BourneUtil.getViprClient();
VolumeRestRep volume = null;
if (isVolumeId(volumeId)) {
if (isContinuousCopyId(continuousCopyId)) {
volume = client.blockVolumes().getContinuousCopy(uri(volumeId), uri(continuousCopyId));
renderArgs.put("isContinuousCopy", Boolean.TRUE);
renderArgs.put("isBlockContinuousCopy", isBlockContinuousCopyId(continuousCopyId));
renderArgs.put("isVplexContinuousCopy", isVplexContinuousCopyId(continuousCopyId));
} else {
try {
volume = client.blockVolumes().get(uri(volumeId));
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
flash.error(MessagesUtils.get(UNKNOWN, volumeId));
volumes(null);
}
throw e;
}
}
}
if (volume == null) {
notFound(Messages.get("resources.volume.notfound"));
}
if (volume.getVirtualArray() != null) {
// NOSONAR
// ("Suppressing Sonar violation of Possible null pointer dereference of volume. When volume is null, the previous if condition handles with throw")
renderArgs.put("virtualArray", VirtualArrayUtils.getVirtualArrayRef(volume.getVirtualArray()));
}
if (volume.getVirtualPool() != null) {
renderArgs.put("virtualPool", VirtualPoolUtils.getBlockVirtualPoolRef(volume.getVirtualPool()));
}
if (volume.getConsistencyGroup() != null) {
renderArgs.put("consistencyGroup", BlockConsistencyGroupUtils.getBlockConsistencyGroupRef(volume.getConsistencyGroup()));
}
if (volume.getStorageController() != null) {
renderArgs.put("storageSystem", StorageSystemUtils.getStorageSystemRef(volume.getStorageController()));
}
if (volume.getCompressionRatio() != null) {
renderArgs.put("compressionRatio", volume.getCompressionRatio());
}
if (volume.getAccessState() == null || volume.getAccessState().isEmpty()) {
renderArgs.put("isAccessStateEmpty", "true");
}
Tasks<VolumeRestRep> tasksResponse = client.blockVolumes().getTasks(volume.getId());
List<Task<VolumeRestRep>> tasks = tasksResponse.getTasks();
renderArgs.put("tasks", tasks);
render(volume);
}
use of com.emc.vipr.client.Task in project coprhd-controller by CoprHD.
the class FileSnapshots method delete.
private static void delete(List<URI> ids) {
if (ids != null) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<Task<FileSnapshotRestRep>> tasks = Lists.newArrayList();
for (URI id : ids) {
Task<FileSnapshotRestRep> task = client.fileSnapshots().deactivate(id);
tasks.add(task);
}
if (!tasks.isEmpty()) {
flash.put("info", MessagesUtils.get("resources.filesnapshots.deactivate", tasks.size()));
}
}
snapshots(null);
}
use of com.emc.vipr.client.Task in project coprhd-controller by CoprHD.
the class FileSnapshots method snapshot.
public static void snapshot(String snapshotId) {
ViPRCoreClient client = BourneUtil.getViprClient();
FileSnapshotRestRep snapshot = null;
try {
snapshot = client.fileSnapshots().get(uri(snapshotId));
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
flash.error(MessagesUtils.get(UNKNOWN, snapshotId));
snapshots(null);
}
throw e;
}
if (snapshot != null) {
if (snapshot.getParent() != null) {
FileShareRestRep fileSystem = client.fileSystems().get(snapshot.getParent());
renderArgs.put("fileSystem", fileSystem);
}
Tasks<FileSnapshotRestRep> tasksResponse = client.fileSnapshots().getTasks(snapshot.getId());
List<Task<FileSnapshotRestRep>> tasks = tasksResponse.getTasks();
renderArgs.put("tasks", tasks);
} else {
flash.error(MessagesUtils.get(UNKNOWN, snapshotId));
snapshots(null);
}
render(snapshot);
}
use of com.emc.vipr.client.Task in project coprhd-controller by CoprHD.
the class FileSystems method fileSystem.
public static void fileSystem(String fileSystemId) {
ViPRCoreClient client = BourneUtil.getViprClient();
FileShareRestRep fileSystem = null;
try {
fileSystem = client.fileSystems().get(uri(fileSystemId));
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
flash.error(MessagesUtils.get(UNKNOWN, fileSystemId));
fileSystems(null);
}
throw e;
}
if (fileSystem != null) {
if (fileSystem.getVirtualArray() != null) {
VirtualArrayRestRep virtualArray = client.varrays().get(fileSystem.getVirtualArray());
renderArgs.put("virtualArray", virtualArray);
}
if (fileSystem.getVirtualPool() != null) {
FileVirtualPoolRestRep virtualPool = client.fileVpools().get(fileSystem.getVirtualPool());
renderArgs.put("virtualPool", virtualPool);
}
if (Security.isSystemAdminOrRestrictedSystemAdmin()) {
if (fileSystem.getStorageSystem() != null) {
StorageSystemRestRep storageSystem = client.storageSystems().get(fileSystem.getStorageSystem());
renderArgs.put("storageSystem", storageSystem);
}
if (fileSystem.getPool() != null) {
StoragePoolRestRep storagePool = client.storagePools().get(fileSystem.getPool());
renderArgs.put("storagePool", storagePool);
}
if (fileSystem.getStoragePort() != null) {
StoragePortRestRep storagePort = client.storagePorts().get(fileSystem.getStoragePort());
renderArgs.put("storagePort", storagePort);
}
}
Tasks<FileShareRestRep> tasksResponse = client.fileSystems().getTasks(fileSystem.getId());
List<Task<FileShareRestRep>> tasks = tasksResponse.getTasks();
renderArgs.put("tasks", tasks);
} else {
notFound(MessagesUtils.get("resources.filesystems.notfound"));
}
renderArgs.put("permissionTypeOptions", PERMISSION_TYPES);
render(fileSystem);
}
Aggregations