use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportedBlockSnapshotsByVolume.
@Asset("exportedBlockSnapshot")
@AssetDependencies({ "project" })
public List<AssetOption> getExportedBlockSnapshotsByVolume(AssetOptionsContext ctx, URI project) {
debug("getting exported blockSnapshots (project=%s)", project);
final ViPRCoreClient client = api(ctx);
List<URI> snapshotIds = Lists.newArrayList();
for (ExportGroupRestRep export : client.blockExports().findByProject(project)) {
for (ExportBlockParam resource : export.getVolumes()) {
if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resource.getId())) {
snapshotIds.add(resource.getId());
}
}
}
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(snapshotIds);
return createVolumeWithVarrayOptions(client, snapshots);
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportVolumePortGroups.
@Asset("exportVolumePortGroups")
@AssetDependencies({ "unassignedBlockVolume", "host", "project" })
public List<AssetOption> getExportVolumePortGroups(AssetOptionsContext ctx, String selectedVolumes, URI hostOrClusterId, URI projectId) {
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")) {
List<URI> volumeIds = Lists.newArrayList();
info("Volumes selected by user: %s", selectedVolumes);
List<String> parsedVolumeIds = TextUtils.parseCSV(selectedVolumes);
for (String id : parsedVolumeIds) {
volumeIds.add(uri(id));
}
List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds);
Set<URI> virtualArrays = new HashSet<URI>();
Set<URI> storageSystems = new HashSet<URI>();
Set<URI> virtualPools = new HashSet<URI>();
for (VolumeRestRep volume : volumes) {
virtualArrays.add(volume.getVirtualArray().getId());
storageSystems.add(volume.getStorageController());
virtualPools.add(volume.getVirtualPool().getId());
}
if (virtualArrays.size() == 1 && storageSystems.size() == 1 && virtualPools.size() == 1) {
Iterator<URI> it = virtualArrays.iterator();
URI varrayId = it.next();
ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
Iterator<URI> ssIt = storageSystems.iterator();
Iterator<URI> vpIt = virtualPools.iterator();
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), vpIt.next(), null, true);
return createPortGroupOptions(portGroups.getStoragePortGroups());
}
}
return options;
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep 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;
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method createExportWithVarrayOptions.
protected static List<AssetOption> createExportWithVarrayOptions(ViPRCoreClient client, Collection<? extends ExportGroupRestRep> exportObjects) {
List<URI> varrayIds = getExportVirtualArrayIds(exportObjects);
Map<URI, VirtualArrayRestRep> varrayNames = getVirutalArrayNames(client, varrayIds);
List<AssetOption> options = Lists.newArrayList();
for (ExportGroupRestRep export : exportObjects) {
options.add(createExportWithVarrayOption(export, varrayNames));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportSnapshotForHostPortGroups.
@Asset("exportSnapshotForHostPortGroups")
@AssetDependencies({ "unassignedBlockSnapshot", "host", "project" })
public List<AssetOption> getExportSnapshotForHostPortGroups(AssetOptionsContext ctx, String selectedSnapshots, URI hostOrClusterId, URI projectId) {
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")) {
List<URI> snapshotIds = Lists.newArrayList();
info("Snapshots selected by user: %s", selectedSnapshots);
List<String> parsedSnapshotIds = TextUtils.parseCSV(selectedSnapshots);
for (String id : parsedSnapshotIds) {
snapshotIds.add(uri(id));
}
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(snapshotIds);
Set<URI> virtualArrays = new HashSet<URI>();
Set<URI> storageSystems = new HashSet<URI>();
for (BlockSnapshotRestRep snapshot : snapshots) {
virtualArrays.add(snapshot.getVirtualArray().getId());
storageSystems.add(snapshot.getStorageController());
}
if (virtualArrays.size() == 1 && storageSystems.size() == 1) {
Iterator<URI> it = virtualArrays.iterator();
URI varrayId = it.next();
ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
Iterator<URI> ssIt = storageSystems.iterator();
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), null, null, true);
return createPortGroupOptions(portGroups.getStoragePortGroups());
}
}
return options;
}
Aggregations