Search in sources :

Example 1 with ExecutionContext

use of com.emc.sa.engine.ExecutionContext in project coprhd-controller by CoprHD.

the class BlockStorageUtils method checkVolumeLimit.

public static void checkVolumeLimit(ViPRCoreClient client, URI project) {
    ExecutionContext context = ExecutionUtils.currentContext();
    long limit = context.getResourceLimit(Constants.RESOURCE_LIMIT_PROJECT_VOLUMES);
    int numOfVolumes = client.blockVolumes().countByProject(project);
    // Show alert in case of approaching 90% of the limit
    if (numOfVolumes >= limit * Constants.RESOURCE_LIMIT_ALERT_RATE) {
        context.logWarn("alert.createVolume.exceedingResourceLimit", numOfVolumes, limit);
    }
}
Also used : ExecutionContext(com.emc.sa.engine.ExecutionContext)

Example 2 with ExecutionContext

use of com.emc.sa.engine.ExecutionContext in project coprhd-controller by CoprHD.

the class InstallOsHelper method installOs.

public void installOs() {
    ExecutionContext context = ExecutionUtils.currentContext();
    List<ViPRTaskMonitor<HostRestRep>> tasks = new ArrayList<>();
    for (HostRestRep host : hostToOsInstall.keySet()) {
        OsInstallParam osInstall = hostToOsInstall.get(host);
        if (osInstall != null) {
            try {
            // tasks.add(ExecutionUtils.startViprTask(new InstallOs(host, osInstall)));
            } catch (ExecutionException e) {
                context.logError("computeutils.installOs.failure", host.getId(), e.getMessage());
            }
        }
    }
    if (!ExecutionUtils.waitForTask(tasks, this)) {
    // TODO: Re-throw the error?
    // ExecutionUtils.checkForError(tasks);
    }
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) ExecutionContext(com.emc.sa.engine.ExecutionContext) ArrayList(java.util.ArrayList) ViPRTaskMonitor(com.emc.sa.engine.ViPRTaskMonitor) OsInstallParam(com.emc.storageos.model.compute.OsInstallParam) ExecutionException(com.emc.sa.engine.ExecutionException)

Example 3 with ExecutionContext

use of com.emc.sa.engine.ExecutionContext in project coprhd-controller by CoprHD.

the class CreateBlockSnapshotService method precheck.

@Override
public void precheck() {
    if (ConsistencyUtils.isVolumeStorageType(storageType)) {
        volumes = new ArrayList<>();
        volumes = BlockStorageUtils.getBlockResources(uris(volumeIds));
    }
    if (BlockProvider.SNAPSHOT_SESSION_TYPE_VALUE.equals(type) || BlockProvider.CG_SNAPSHOT_SESSION_TYPE_VALUE.equals(type)) {
        if (linkedSnapshotName != null && !linkedSnapshotName.isEmpty()) {
            // is populated, make sure that linkedSnapshotCount > 0.
            if (linkedSnapshotCount == null || linkedSnapshotCount.intValue() <= 0) {
                ExecutionUtils.fail("failTask.CreateBlockSnapshot.linkedSnapshotCount.precheck", new Object[] {}, new Object[] {});
            }
            // Ensure that copy mode is selected
            if (linkedSnapshotCopyMode == null || !(BlockProvider.LINKED_SNAPSHOT_COPYMODE_VALUE.equals(linkedSnapshotCopyMode) || BlockProvider.LINKED_SNAPSHOT_NOCOPYMODE_VALUE.equals(linkedSnapshotCopyMode))) {
                ExecutionUtils.fail("failTask.CreateBlockSnapshot.linkedSnapshotCopyMode.precheck", new Object[] {}, new Object[] {});
            }
        }
    }
    // deletion both snapshot session and snapshot in single shot.
    if (isRetentionRequired()) {
        if (ConsistencyUtils.isVolumeStorageType(storageType)) {
            for (String volumeId : volumeIds) {
                if (!BlockProvider.SNAPSHOT_SESSION_TYPE_VALUE.equals(type) && isSnapshotSessionSupportedForVolume(uri(volumeId))) {
                    ExecutionUtils.fail("failTask.CreateBlockSnapshot.localArraySnapshotTypeNotSupportedForScheduler.precheck", new Object[] {}, new Object[] {});
                }
            }
        } else {
            for (String consistencyGroupId : volumeIds) {
                if (!BlockProvider.CG_SNAPSHOT_SESSION_TYPE_VALUE.equals(type) && isSnapshotSessionSupportedForCG(uri(consistencyGroupId))) {
                    ExecutionUtils.fail("failTask.CreateBlockSnapshot.CGSnapshotTypeNotSupportedForScheduler.precheck", new Object[] {}, new Object[] {});
                }
            }
        }
    }
    // Show alert in case of approaching 90% of the limit
    ExecutionContext context = ExecutionUtils.currentContext();
    long limit = context.getResourceLimit(Constants.RESOURCE_LIMIT_PROJECT_SNAPSHOTS);
    int numOfSnapshots = 0;
    if (BlockProvider.SNAPSHOT_SESSION_TYPE_VALUE.equals(type) || BlockProvider.CG_SNAPSHOT_SESSION_TYPE_VALUE.equals(type)) {
        numOfSnapshots = getClient().blockSnapshotSessions().countByProject(project);
    } else {
        numOfSnapshots = getClient().blockSnapshots().countByProject(project);
    }
    if (numOfSnapshots >= limit * Constants.RESOURCE_LIMIT_ALERT_RATE) {
        context.logWarn("alert.createSnapshot.exceedingResourceLimit", numOfSnapshots, limit);
    }
}
Also used : ExecutionContext(com.emc.sa.engine.ExecutionContext)

Aggregations

ExecutionContext (com.emc.sa.engine.ExecutionContext)3 ExecutionException (com.emc.sa.engine.ExecutionException)1 ViPRTaskMonitor (com.emc.sa.engine.ViPRTaskMonitor)1 OsInstallParam (com.emc.storageos.model.compute.OsInstallParam)1 HostRestRep (com.emc.storageos.model.host.HostRestRep)1 ArrayList (java.util.ArrayList)1