use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getExportContinousCopyForHostPortGroups.
@Asset("exportContinousCopyForHostPortGroups")
@AssetDependencies({ "volumeWithContinuousCopies", "unassignedBlockContinuousCopies", "host", "project" })
public List<AssetOption> getExportContinousCopyForHostPortGroups(AssetOptionsContext ctx, URI volumeId, String selectedCopies, 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("Continous Copies selected by user: %s", selectedCopies);
List<String> parsedCopiesIds = TextUtils.parseCSV(selectedCopies);
for (String id : parsedCopiesIds) {
snapshotIds.add(uri(id));
}
List<BlockMirrorRestRep> copies = client.blockVolumes().getContinuousCopies(volumeId);
Set<URI> virtualArrays = new HashSet<URI>();
Set<URI> storageSystems = new HashSet<URI>();
Set<URI> virtualPools = new HashSet<URI>();
for (BlockMirrorRestRep copy : copies) {
virtualArrays.add(copy.getVirtualArray().getId());
storageSystems.add(copy.getStorageController());
virtualPools.add(copy.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.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getSnapshotBlockVolumes.
@Asset("snapshotBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotBlockVolumes(AssetOptionsContext context, URI project, String storageType) {
final ViPRCoreClient client = api(context);
if (isVolumeType(storageType)) {
List<VolumeRestRep> volumes = listVolumes(client, project);
List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
Map<URI, VolumeRestRep> volumeNames = ResourceUtils.mapById(volumes);
List<AssetOption> options = Lists.newArrayList();
for (VolumeDetail detail : volumeDetails) {
if (detail.vpool == null) {
continue;
}
boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
boolean isInConsistencyGroup = BlockProvider.isInConsistencyGroup(detail.volume);
debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup);
if (isRPSourceVolume || (localSnapSupported && (!isInConsistencyGroup || isRPTargetVolume))) {
options.add(createVolumeOption(client, null, detail.volume, volumeNames));
}
}
return options;
} else {
List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
return createBaseResourceOptions(consistencyGroups);
}
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPathStorageSystem.
@Asset("exportPathStorageSystem")
public List<AssetOption> getExportPathStorageSystem(AssetOptionsContext ctx) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
List<StorageSystemRestRep> storageSystems = client.storageSystems().getAll();
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.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getSrdfFailoverTargets.
protected List<AssetOption> getSrdfFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<VirtualArrayRelatedResourceRep> srdfTargets = volume.getProtection().getSrdfRep().getSRDFTargetVolumes();
for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(srdfTargets, new SRDFTargetFilter())) {
VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
String label = getMessage("srdf.target", name(protectionSetVolume), name(virtualArray));
targetVolumes.put(stringId(protectionSetVolume), label);
}
List<AssetOption> options = Lists.newArrayList();
for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
options.add(new AssetOption(entry.getKey(), entry.getValue()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption 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;
}
Aggregations