Search in sources :

Example 16 with Task

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[] {});
    }
}
Also used : Task(com.emc.vipr.client.Task) ArrayList(java.util.ArrayList) ChangeBlockVolumeVirtualPoolNoWait(com.emc.sa.service.vipr.block.tasks.ChangeBlockVolumeVirtualPoolNoWait) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep) URI(java.net.URI)

Example 17 with Task

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);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 18 with Task

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);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) URI(java.net.URI)

Example 19 with Task

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);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 20 with Task

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);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) StoragePoolRestRep(com.emc.storageos.model.pools.StoragePoolRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Aggregations

Task (com.emc.vipr.client.Task)21 URI (java.net.URI)13 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)11 ArrayList (java.util.ArrayList)6 ExecutionException (com.emc.sa.engine.ExecutionException)5 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)5 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)5 GetHost (com.emc.sa.service.vipr.tasks.GetHost)5 Host (com.emc.storageos.db.client.model.Host)5 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)4 ViPRException (com.emc.vipr.client.exceptions.ViPRException)4 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)4 HashMap (java.util.HashMap)4 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)3 FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)3 HostRestRep (com.emc.storageos.model.host.HostRestRep)3 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)2 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)2