use of com.emc.sa.asset.annotation.AssetDependencies 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.sa.asset.annotation.AssetDependencies 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;
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumes.
@Asset("blockVolume")
@AssetDependencies("project")
public List<AssetOption> getVolumes(AssetOptionsContext ctx, URI project) {
debug("getting volumes (project=%s)", project);
ViPRCoreClient client = api(ctx);
return createVolumeOptions(client, listVolumes(client, project));
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getCopyNameByConsistencyGroup.
@Asset("journalCopyName")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getCopyNameByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
ViPRCoreClient client = api(ctx);
List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
Set<String> copyNames = Sets.newHashSet();
if (volumes != null && !volumes.isEmpty()) {
RelatedResourceRep volume = volumes.get(0);
VolumeRestRep volumeRep = client.blockVolumes().get(volume);
if (volumeRep.getProtection() != null && volumeRep.getProtection().getRpRep() != null) {
if (volumeRep.getProtection().getRpRep().getCopyName() != null) {
String copyName = volumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
if (volumeRep.getHaVolumes() != null) {
List<RelatedResourceRep> haVolumes = volumeRep.getHaVolumes();
List<URI> haVolumeIds = new ArrayList<URI>();
for (RelatedResourceRep haVolume : haVolumes) {
haVolumeIds.add(haVolume.getId());
}
List<VolumeRestRep> haVolumeReps = client.blockVolumes().getByIds(haVolumeIds, null);
for (VolumeRestRep haVolumeRep : haVolumeReps) {
if (haVolumeRep.getProtection() != null && haVolumeRep.getProtection().getRpRep() != null && haVolumeRep.getProtection().getRpRep().getCopyName() != null) {
String copyName = haVolumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
}
}
if (volumeRep.getProtection().getRpRep().getRpTargets() != null) {
List<VirtualArrayRelatedResourceRep> targetVolumes = volumeRep.getProtection().getRpRep().getRpTargets();
List<URI> targetVolumeIds = new ArrayList<URI>();
for (VirtualArrayRelatedResourceRep targetVolume : targetVolumes) {
targetVolumeIds.add(targetVolume.getId());
}
List<VolumeRestRep> targetVolumeReps = client.blockVolumes().getByIds(targetVolumeIds, null);
for (VolumeRestRep targetVolumeRep : targetVolumeReps) {
String copyName = targetVolumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
}
}
}
List<AssetOption> copyNameAssets = Lists.newArrayList();
for (String copyName : copyNames) {
copyNameAssets.add(newAssetOption(copyName, copyName));
}
AssetOptionsUtils.sortOptionsByLabel(copyNameAssets);
return copyNameAssets;
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getAffectedExports.
@Asset("exportPathAffectedExports")
@AssetDependencies({ "host", "exportPathVirtualArray", "exportPathExport", "exportPathMinPathsOptions", "exportPathMaxPathsOptions", "exportPathPathsPerInitiatorOptions", "exportPathExistingPath", "exportPathStorageSystem", "exportPathPorts" })
public List<AssetOption> getAffectedExports(AssetOptionsContext ctx, URI hostOrClusterId, URI vArrayId, URI exportId, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, String useExisting, URI storageSystemId, String ports) {
ViPRCoreClient client = api(ctx);
// the asset option list
List<AssetOption> options = Lists.newArrayList();
List<URI> exportPathPorts = parseExportPathPorts(ports);
ExportPathsAdjustmentPreviewRestRep portPreview = generateExportPathPreview(ctx, hostOrClusterId, vArrayId, exportId, minPaths, maxPaths, pathsPerInitiator, useExisting, storageSystemId, exportPathPorts);
List<NamedRelatedResourceRep> affectedList = portPreview.getAffectedExportGroups();
List<URI> exportIds = new ArrayList<URI>();
for (NamedRelatedResourceRep affected : affectedList) {
exportIds.add(affected.getId());
}
List<ExportGroupRestRep> exports = client.blockExports().getByIds(exportIds);
for (ExportGroupRestRep export : exports) {
// TODO: need to optimize the way that we retrieve the project name.
String projectName = client.projects().get(export.getProject().getId()).getName();
String label = getMessage("exportPathAdjustment.affectedExports", projectName, export.getName());
options.add(new AssetOption(export.getName(), label));
}
return options;
}
Aggregations