use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BaseHostProvider method createHostOptions.
protected List<AssetOption> createHostOptions(AssetOptionsContext ctx, Collection<HostRestRep> hosts, Map<URI, String> clusters) {
List<AssetOption> options = Lists.newArrayList();
for (HostRestRep value : hosts) {
options.add(createHostOption(ctx, value, clusters));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockSnapshotType.
@Asset("blockSnapshotType")
@AssetDependencies({ "blockVolumeOrConsistencyType", "snapshotBlockVolume" })
public List<AssetOption> getBlockSnapshotType(AssetOptionsContext ctx, String storageType, URI blockVolumeOrCG) {
// These are hard coded values for now. In the future, this may be available through an API
List<AssetOption> options = Lists.newArrayList();
if (isConsistencyGroupType(blockVolumeOrCG)) {
options.add(CG_SNAPSHOT_TYPE_OPTION);
// Only add cg session option if the CG selected supports it
ViPRCoreClient client = api(ctx);
BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(blockVolumeOrCG);
if (isSnapshotSessionSupportedForCG(cg)) {
options.add(CG_SNAPSHOT_SESSION_TYPE_OPTION);
}
} else {
debug("getting blockSnapshotTypes (blockVolume=%s)", blockVolumeOrCG);
ViPRCoreClient client = api(ctx);
VolumeRestRep volume = client.blockVolumes().get(blockVolumeOrCG);
BlockVirtualPoolRestRep virtualPool = client.blockVpools().get(volume.getVirtualPool());
if (isLocalSnapshotSupported(virtualPool)) {
options.add(LOCAL_ARRAY_SNAPSHOT_TYPE_OPTION);
}
if (isRPSourceVolume(volume)) {
options.add(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_OPTION);
}
if (isSnapshotSessionSupportedForVolume(volume)) {
options.add(SNAPSHOT_SESSION_TYPE_OPTION);
}
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getSnapshotSessionBlockVolumes.
@Asset("snapshotSessionBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotSessionBlockVolumes(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) {
boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
boolean isInConsistencyGroup = !StringUtils.isEmpty(detail.volume.getReplicationGroupInstance());
boolean isSnapshotSessionSupported = isSnapshotSessionSupportedForVolume(detail.volume);
debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s, isXio3XVolume=%s ]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup, isSnapshotSessionSupported);
if (isSnapshotSessionSupported && localSnapSupported && !isInConsistencyGroup) {
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 getExportPathVirtualArray.
@Asset("exportPathVirtualArray")
@AssetDependencies({ "exportPathExport", "exportPathStorageSystem" })
public List<AssetOption> getExportPathVirtualArray(AssetOptionsContext ctx, URI exportId, URI storageSystemId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
ExportGroupRestRep export = client.blockExports().get(exportId);
List<URI> vArrayIds = new ArrayList<URI>();
vArrayIds.add(export.getVirtualArray().getId());
List<StringHashMapEntry> altArrays = export.getAltVirtualArrays() != null ? export.getAltVirtualArrays() : new ArrayList<StringHashMapEntry>();
for (StringHashMapEntry altArray : altArrays) {
if (altArray.getName().equalsIgnoreCase(storageSystemId.toString())) {
vArrayIds.add(URI.create(altArray.getValue()));
}
}
List<VirtualArrayRestRep> vArrays = client.varrays().getByIds(vArrayIds);
for (VirtualArrayRestRep vArray : vArrays) {
options.add(new AssetOption(vArray.getId(), vArray.getName()));
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPathPorts.
@Asset("exportPathPorts")
@AssetDependencies({ "exportPathVirtualArray", "exportPathStorageSystem", "exportPathExport" })
public List<AssetOption> getExportPathPorts(AssetOptionsContext ctx, URI vArrayId, URI storageSystemId, URI exportId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
// Get all the PGs for the varray/storage system/EG combo then check to
// see if there are any non-mutable PGs;
// if there are the storage ports displayed to the user would be limited
// to just those ones.
StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(vArrayId, exportId, storageSystemId, null, null, false);
// Keep a list of ports from the non-mutable PGs. This could remain
// empty if there are no PGs or none that are non-mutable.
List<URI> nonMutablePGPortURIs = new ArrayList<URI>();
if (portGroupsRestRep != null) {
// Drill down to get the PG and the storage ports
List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
if (!CollectionUtils.isEmpty(portGroups)) {
for (StoragePortGroupRestRep pg : portGroups) {
// Check to see if the PG is non-mutable
if (!pg.getMutable()) {
// Keep track of these storage ports, they will be used
// to filter out
// other storage ports.
StoragePortList pgPortsList = pg.getStoragePorts();
List<NamedRelatedResourceRep> pgPorts = pgPortsList.getPorts();
for (NamedRelatedResourceRep pgPort : pgPorts) {
nonMutablePGPortURIs.add(pgPort.getId());
}
}
}
}
}
List<StoragePortRestRep> ports = client.storagePorts().getByVirtualArray(vArrayId);
for (StoragePortRestRep port : ports) {
// Check to see if this port needs to be filtered out.
boolean filterOutPortBasedOnPG = (!nonMutablePGPortURIs.isEmpty()) ? !nonMutablePGPortURIs.contains(port.getId()) : false;
if (!filterOutPortBasedOnPG) {
if (port.getPortType().equals(StoragePort.PortType.frontend.toString()) && port.getStorageDevice().getId().equals(storageSystemId) && port.getOperationalStatus().equals(StoragePort.OperationalStatus.OK.toString())) {
if (port.getNetwork() != null) {
String portPercentBusy = (port.getPortPercentBusy() != null) ? String.valueOf(Math.round(port.getPortPercentBusy() * 100 / 100)) + "%" : "N/A";
String networkName = client.networks().get(port.getNetwork().getId()).getName();
String label = getMessage("exportPathAdjustment.ports", port.getPortName(), networkName, port.getPortNetworkId(), portPercentBusy);
options.add(new AssetOption(port.getId(), label));
}
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations