use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method buildPathOptions.
/* helper for building the list of asset option for affected and removed paths */
private List<AssetOption> buildPathOptions(AssetOptionsContext ctx, List<InitiatorPortMapRestRep> list, String message) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
for (InitiatorPortMapRestRep ipm : list) {
InitiatorRestRep initiator = ipm.getInitiator();
List<NamedRelatedResourceRep> ports = ipm.getStoragePorts();
String portList = new String(" ");
List<URI> portURIs = new ArrayList<URI>();
for (NamedRelatedResourceRep port : ports) {
StoragePortRestRep p = client.storagePorts().get(port.getId());
portList += p.getPortName() + " ";
portURIs.add(port.getId());
}
Map<URI, List<URI>> key = new HashMap<URI, List<URI>>();
key.put(initiator.getId(), portURIs);
String label = getMessage(message, initiator.getHostName(), initiator.getName(), portList);
String keyString = EMPTY_STRING;
try {
keyString = CatalogSerializationUtils.serializeToString(key);
} catch (Exception ex) {
}
options.add(new AssetOption(keyString, label));
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption 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;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationSnapshotVirtualArrays.
@Asset("applicationSnapshotVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationSnapshotVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
final ViPRCoreClient client = api(ctx);
List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
List<AssetOption> options = new ArrayList<AssetOption>();
boolean isVplex = false;
boolean isRP = false;
URI sourceVarrayId = null;
List<VolumeRestRep> allRPSourceVols = null;
if (volList != null && !volList.isEmpty()) {
VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
StorageSystemRestRep sys = client.storageSystems().get(vol.getStorageController());
if (sys.getSystemType().equals("vplex")) {
isVplex = true;
sourceVarrayId = vol.getVirtualArray().getId();
}
if (BlockProviderUtils.isVolumeRP(vol)) {
isRP = true;
allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
VolumeRestRep rpvol = allRPSourceVols.get(0);
sourceVarrayId = rpvol.getVirtualArray().getId();
}
}
} else {
return options;
}
// if it's neither RP nor vplex, it's just a simple block volume application; site is not needed
if (!isVplex && !isRP) {
options.add(newAssetOption(URI.create("none"), "None"));
}
// if the volumes are vplex or RP display source as an option
if (isVplex || isRP) {
options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
}
// if the volumes are RP (vplex or not) add the RP targets as options
if (isRP) {
Set<URI> targetVarrayIds = new HashSet<URI>();
List<AssetOption> targetOptions = new ArrayList<AssetOption>();
List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
for (VolumeRestRep targetVol : allRPTargetVols) {
targetVarrayIds.add(targetVol.getVirtualArray().getId());
}
List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
for (VirtualArrayRestRep targetVarray : targetVarrays) {
targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
}
// sort the targets
AssetOptionsUtils.sortOptionsByLabel(targetOptions);
options.addAll(targetOptions);
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class ComputeProvider method getComputeVirtualPoolOptions.
@Asset("computeVirtualPool")
public List<AssetOption> getComputeVirtualPoolOptions(AssetOptionsContext ctx) {
debug("getting compute virtual pools");
Collection<ComputeVirtualPoolRestRep> computeVirtualPools = getComputeVirtualPools(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ComputeVirtualPoolRestRep value : computeVirtualPools) {
options.add(createComputeVirtualPoolOption(ctx, value));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class ConsistencyGroupProvider method getAllConsistencyGroup.
@Asset("consistencyGroupAll")
public List<AssetOption> getAllConsistencyGroup(AssetOptionsContext ctx) {
List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
for (ProjectRestRep project : projects) {
cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
}
List<AssetOption> options = createBaseResourceOptions(cgs);
return options;
}
Aggregations