use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method createPortGroupOptions.
private List<AssetOption> createPortGroupOptions(List<StoragePortGroupRestRep> portGroups) {
List<AssetOption> options = Lists.newArrayList();
for (StoragePortGroupRestRep group : portGroups) {
String portMetric = (group.getPortMetric() != null) ? String.valueOf(Math.round(group.getPortMetric() * 100 / 100)) + "%" : "N/A";
String volumeCount = (group.getVolumeCount() != null) ? String.valueOf(group.getVolumeCount()) : "N/A";
String nGuid = group.getNativeGuid();
String nativeGuid = EMPTY_STRING;
try {
// Remove the PG name from the native GUID.
// Ex:
// From -> SYMMETRIX+000196801518+lglw7136_pg
// To -> SYMMETRIX+000196801518
nativeGuid = nGuid.substring(0, nGuid.lastIndexOf("+", nGuid.length()));
} catch (Exception e) {
nativeGuid = nGuid;
warn("Issue encountered parsing native guid %s, exception: %s", nativeGuid, e.getMessage());
}
String label = getMessage("exportPortGroup.portGroups", group.getName(), nativeGuid, portMetric, volumeCount);
options.add(new AssetOption(group.getId(), label));
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getVirtualArrayByConsistencyGroup.
@Asset("virtualArrayByConsistencyGroup")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getVirtualArrayByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
ViPRCoreClient client = api(ctx);
List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
List<AssetOption> targets = Lists.newArrayList();
if (!volumes.isEmpty()) {
RelatedResourceRep varrayId = client.blockVolumes().get(volumes.get(0)).getVirtualArray();
VirtualArrayRestRep virtualArray = client.varrays().get(varrayId);
targets.add(createBaseResourceOption(virtualArray));
}
return targets;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class BlockProvider method getLocalSnapshotBlockVolumes.
@Asset("localSnapshotBlockVolume")
@AssetDependencies({ "project" })
public List<AssetOption> getLocalSnapshotBlockVolumes(AssetOptionsContext context, URI project) {
final ViPRCoreClient client = api(context);
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 (isLocalSnapshotSupported(detail.vpool)) {
options.add(createVolumeOption(client, null, detail.volume, volumeNames));
}
}
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class ClusterProvider method getVblockClusterOptions.
@Asset("vblockCluster")
public List<AssetOption> getVblockClusterOptions(AssetOptionsContext ctx) {
debug("getting vblock clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ClusterRestRep value : clusters) {
List<HostRestRep> hostList = api(ctx).hosts().getByCluster(value.getId());
for (HostRestRep host : hostList) {
// If Cluster has an esx or No-OS host and if host has a computeElement - then add it to the list
if (host.getType() != null && (host.getType().equalsIgnoreCase(Host.HostType.Esx.name()) || host.getType().equalsIgnoreCase(Host.HostType.No_OS.name())) && host.getComputeElement() != null && !NullColumnValueGetter.isNullURI(host.getComputeElement().getId())) {
String dataCenterName = getDataCenterName(ctx, value);
options.add(createClusterOption(ctx, value, dataCenterName));
break;
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class ClusterProvider method getClusterOptions.
@Asset("cluster")
public List<AssetOption> getClusterOptions(AssetOptionsContext ctx) {
debug("getting clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ClusterRestRep value : clusters) {
String dataCenterName = getDataCenterName(ctx, value);
options.add(createClusterOption(ctx, value, dataCenterName));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations