use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method findSnapshotsByProject.
private List<BlockSnapshotRestRep> findSnapshotsByProject(ViPRCoreClient client, URI project) {
log.info("Finding snapshots by project {}", project);
List<SearchResultResourceRep> snapshotRefs = client.blockSnapshots().performSearchBy(SearchConstants.PROJECT_PARAM, project);
List<URI> ids = new ArrayList<>();
for (SearchResultResourceRep ref : snapshotRefs) {
ids.add(ref.getId());
}
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(ids, null);
log.info("Got snapshots: [{}]", snapshots.size());
return snapshots;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.
@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
return new ArrayList<AssetOption>();
}
List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
final ViPRCoreClient client = api(ctx);
if (isVolumeType(volumeOrConsistencyType)) {
snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
} else {
snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
}
return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotOptions.
protected List<AssetOption> constructSnapshotOptions(ViPRCoreClient client, URI project, List<BlockSnapshotRestRep> snapshots) {
List<AssetOption> options = Lists.newArrayList();
Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
for (BlockSnapshotRestRep snapshot : snapshots) {
options.add(new AssetOption(snapshot.getId(), getBlockObjectLabel(client, snapshot, volumeNames)));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotOptions.
protected List<AssetOption> constructSnapshotOptions(List<BlockSnapshotRestRep> snapshots) {
List<AssetOption> options = Lists.newArrayList();
for (BlockSnapshotRestRep snapshot : snapshots) {
options.add(new AssetOption(snapshot.getId(), getMessage("block.snapshot.labelNoVolume", snapshot.getName(), snapshot.getWwn())));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getCurrentExportPortGroups.
@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
ExportGroupRestRep exportGroup = client.blockExports().get(exportId);
List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
List<ExportBlockParam> blockParams = exportGroup.getVolumes();
Set<URI> storageSystemURISet = new HashSet<URI>();
if (!CollectionUtils.isEmpty(blockParams)) {
for (ExportBlockParam blockParam : blockParams) {
// Get each volume in the export group to get the storage system ID
if (blockParam != null) {
URI resourceId = blockParam.getId();
URI storageDeviceURI = null;
if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
VolumeRestRep volume = client.blockVolumes().get(resourceId);
storageDeviceURI = volume.getStorageController();
} else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
storageDeviceURI = snapshot.getStorageController();
}
if (storageDeviceURI != null) {
storageSystemURISet.add(storageDeviceURI);
}
} else {
log.error("Block param not found in export group: {}", exportId);
}
}
}
if (!CollectionUtils.isEmpty(storageSystemURISet)) {
Set<URI> portGroupSet = new HashSet<URI>();
for (URI storageSystemURI : storageSystemURISet) {
// Now use the storage system ID as well to query the storage port groups
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
if (!CollectionUtils.isEmpty(portGroupList)) {
for (StoragePortGroupRestRep portGroup : portGroupList) {
if (portGroupSet.add(portGroup.getId())) {
storagePortGroups.add(portGroup);
}
}
}
}
}
return createPortGroupOptions(storagePortGroups);
}
return options;
}
Aggregations