use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.
the class BlockProvider method listTargetVirtualPools.
/**
* Returns a list of virtual pools where volume can be moved
*/
protected List<BlockVirtualPoolRestRep> listTargetVirtualPools(AssetOptionsContext ctx, URI volumeId, ResourceFilter<BlockVirtualPoolRestRep> filter) {
ViPRCoreClient client = api(ctx);
List<VirtualPoolChangeRep> vpoolChanges = client.blockVolumes().listVirtualPoolChangeCandidates(volumeId);
List<URI> vpoolIds = Lists.newArrayList();
for (VirtualPoolChangeRep change : vpoolChanges) {
if (change.getAllowed()) {
vpoolIds.add(change.getId());
}
}
return client.blockVpools().getByIds(vpoolIds, filter);
}
use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.
the class BlockProvider method createVpoolChangeOptions.
protected List<AssetOption> createVpoolChangeOptions(String vpoolChangeOperation, List<VirtualPoolChangeRep> vpoolChanges) {
List<AssetOption> options = Lists.newArrayList();
List<AssetOption> available = Lists.newArrayList();
List<AssetOption> wrongOperation = Lists.newArrayList();
List<AssetOption> notAllowed = Lists.newArrayList();
for (VirtualPoolChangeRep vpoolChange : vpoolChanges) {
if (vpoolChange.getAllowed() && vpoolChange.getAllowedChangeOperations() != null) {
for (StringHashMapEntry allowedChangeOperation : vpoolChange.getAllowedChangeOperations()) {
String operation = allowedChangeOperation.getName();
boolean isCorrectOperation = StringUtils.isNotBlank(operation) && operation.equalsIgnoreCase(vpoolChangeOperation);
if (isCorrectOperation) {
available.add(new AssetOption(vpoolChange.getId(), vpoolChange.getName()));
} else {
wrongOperation.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeOperation", vpoolChange.getName(), getAllowedChangeOperationNames(vpoolChange.getAllowedChangeOperations()))));
}
}
} else {
notAllowed.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeReason", vpoolChange.getName(), vpoolChange.getNotAllowedReason())));
}
}
options.addAll(available);
options.addAll(wrongOperation);
options.addAll(notAllowed);
return options;
}
use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.
the class BlockProvider method getTargetVirtualPoolsForVpool.
@Asset("targetVirtualPool")
@AssetDependencies({ "project", "blockVirtualPool", "virtualPoolChangeOperation", "virtualPoolChangeVolumeWithSourceFilter", "displayJournals" })
public List<AssetOption> getTargetVirtualPoolsForVpool(AssetOptionsContext ctx, URI projectId, URI virtualPoolId, String vpoolChangeOperation, String filteredVolumes, String displayJournals) {
List<URI> volumeIds = Lists.newArrayList();
if (filteredVolumes != null && !filteredVolumes.isEmpty()) {
// Best case we are passed in the volumes selected by the user
// as comma delimited string so we do not have to load them from
// the API.
info("Filtered volumes selected by user: %s", filteredVolumes);
List<String> parsedVolumeIds = TextUtils.parseCSV(filteredVolumes);
for (String id : parsedVolumeIds) {
volumeIds.add(uri(id));
}
} else {
// Worst case we need to get the volumes from the API.
info("Loading all volumes for vpool: %s", virtualPoolId.toString());
List<VolumeRestRep> volumes = null;
if (YES_VALUE.equals(displayJournals)) {
volumes = listJournalVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
} else {
volumes = listSourceVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
}
for (VolumeRestRep volume : volumes) {
volumeIds.add(volume.getId());
}
}
if (CollectionUtils.isNotEmpty(volumeIds)) {
BulkIdParam input = new BulkIdParam();
input.setIds(volumeIds);
List<VirtualPoolChangeRep> vpoolChanges = api(ctx).blockVpools().listVirtualPoolChangeCandidates(virtualPoolId, input);
return createVpoolChangeOptions(vpoolChangeOperation, vpoolChanges);
}
return Collections.emptyList();
}
Aggregations