use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.
the class TaskUtils method getWorkflowSteps.
@Util
public static List<WorkflowStep> getWorkflowSteps(URI workflowId) {
List<WorkflowStepRestRep> workflowSteps = getViprClient().workflows().getSteps(workflowId);
// Order Workflow steps by date started, not started tasks will sink to the bottom of the list
Collections.sort(workflowSteps, new Comparator<WorkflowStepRestRep>() {
@Override
public int compare(WorkflowStepRestRep o1, WorkflowStepRestRep o2) {
if (o1.getStartTime() == null && o2.getStartTime() == null) {
// If both steps not started yet, then just order on creation time
return o1.getCreationTime().compareTo(o2.getCreationTime());
}
if (o1.getStartTime() == null && o2.getStartTime() != null) {
return 1;
}
if (o1.getStartTime() != null && o2.getStartTime() == null) {
return -1;
}
return o1.getStartTime().compareTo(o2.getStartTime());
}
});
// Get the names of all resources
Map<String, DataObjectRestRep> systemObjects = Maps.newHashMap();
for (WorkflowStepRestRep step : workflowSteps) {
ResourceType type = ResourceType.fromResourceId(step.getSystem());
DataObjectRestRep dataObject = null;
switch(type) {
case STORAGE_SYSTEM:
dataObject = getViprClient().storageSystems().get(uri(step.getSystem()));
break;
case PROTECTION_SYSTEM:
dataObject = getViprClient().protectionSystems().get(uri(step.getSystem()));
break;
case NETWORK_SYSTEM:
dataObject = getViprClient().networkSystems().get(uri(step.getSystem()));
break;
case COMPUTE_SYSTEM:
dataObject = getViprClient().computeSystems().get(uri(step.getSystem()));
break;
}
if (dataObject != null) {
systemObjects.put(step.getSystem(), dataObject);
}
}
List<WorkflowStep> steps = Lists.newArrayList();
for (WorkflowStepRestRep workflowStep : workflowSteps) {
steps.add(new WorkflowStep(workflowStep, systemObjects));
}
return steps;
}
use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.
the class Tasks method details.
public static void details(String taskId) {
if (StringUtils.isBlank(taskId)) {
listAll(false);
}
TaskResourceRep task = TaskUtils.getTask(uri(taskId));
if (task == null) {
flash.error(MessagesUtils.get(UNKNOWN, taskId));
listAll(false);
}
if (task != null && task.getResource() != null && task.getResource().getId() != null) {
ResourceType resourceType = ResourceType.fromResourceId(task.getResource().getId().toString());
renderArgs.put("resourceType", resourceType);
}
String orderId = TagUtils.getOrderIdTagValue(task);
String orderNumber = TagUtils.getOrderNumberTagValue(task);
Common.angularRenderArgs().put("task", TaskUtils.getTaskSummary(task));
TaskLogsDataTable dataTable = new TaskLogsDataTable();
render(task, dataTable, orderId, orderNumber);
}
use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.
the class TestBlockStorageUtils method newGetBlockResources.
static final List<BlockObjectRestRep> newGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
List<BlockObjectRestRep> blockResources = Lists.newArrayList();
List<URI> blockVolumes = new ArrayList<URI>();
List<URI> blockSnapshots = new ArrayList<URI>();
for (URI resourceId : uris) {
ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
switch(volumeType) {
case VOLUME:
blockVolumes.add(resourceId);
break;
case BLOCK_SNAPSHOT:
blockSnapshots.add(resourceId);
break;
default:
break;
}
}
blockResources.addAll(client.blockVolumes().getByIds(blockVolumes));
blockResources.addAll(client.blockSnapshots().getByIds(blockSnapshots));
return blockResources;
}
use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.
the class GetBlockResource method executeTask.
@SuppressWarnings("incomplete-switch")
@Override
public BlockObjectRestRep executeTask() throws Exception {
ViPRCoreClient client = getClient();
ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
switch(volumeType) {
case VOLUME:
VolumeRestRep volume = client.blockVolumes().get(resourceId);
if (volume != null) {
return volume;
}
break;
case BLOCK_SNAPSHOT:
BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
if (snapshot != null) {
return snapshot;
}
break;
}
throw stateException("GetBlockResource.illegalState.notFound", resourceId);
}
use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPathStorageSystem.
@SuppressWarnings("incomplete-switch")
@Asset("exportPathStorageSystem")
@AssetDependencies({ "exportPathExport" })
public List<AssetOption> getExportPathStorageSystem(AssetOptionsContext ctx, URI exportId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
List<URI> storageSystemIds = new ArrayList<URI>();
ExportGroupRestRep export = client.blockExports().get(exportId);
List<ExportBlockParam> volumes = export.getVolumes();
for (ExportBlockParam volume : volumes) {
URI resourceId = volume.getId();
ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
switch(volumeType) {
case VOLUME:
VolumeRestRep v = client.blockVolumes().get(resourceId);
if (v != null) {
storageSystemIds.add(v.getStorageController());
}
break;
case BLOCK_SNAPSHOT:
BlockSnapshotRestRep s = client.blockSnapshots().get(resourceId);
if (s != null) {
storageSystemIds.add(s.getStorageController());
}
break;
}
}
List<StorageSystemRestRep> storageSystems = client.storageSystems().getByIds(storageSystemIds);
for (StorageSystemRestRep storageSystem : storageSystems) {
String systemType = storageSystem.getSystemType();
if (Type.vmax.name().equalsIgnoreCase(systemType) || Type.vplex.name().equalsIgnoreCase(systemType)) {
options.add(new AssetOption(storageSystem.getId(), storageSystem.getName()));
}
}
return options;
}
Aggregations