use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationVolumes.
@Asset("applicationBlockVolume")
@AssetDependencies("application")
public List<AssetOption> getApplicationVolumes(AssetOptionsContext ctx, URI application) {
final ViPRCoreClient client = api(ctx);
List<NamedRelatedResourceRep> volList = client.application().listVolumes(application);
List<AssetOption> options = new ArrayList<AssetOption>();
if (volList != null && !volList.isEmpty()) {
List<VolumeRestRep> allVols = client.blockVolumes().getByRefs(volList);
Map<String, List<VolumeRestRep>> repGrpVolMap = new HashMap<String, List<VolumeRestRep>>();
for (VolumeRestRep vol : allVols) {
if (!BlockProviderUtils.isRPTargetReplicationGroup(vol.getReplicationGroupInstance())) {
if (repGrpVolMap.get(vol.getReplicationGroupInstance()) == null) {
repGrpVolMap.put(vol.getReplicationGroupInstance(), new ArrayList<VolumeRestRep>());
}
repGrpVolMap.get(vol.getReplicationGroupInstance()).add(vol);
}
}
for (Entry<String, List<VolumeRestRep>> entry : repGrpVolMap.entrySet()) {
for (VolumeRestRep vol : entry.getValue()) {
options.add(new AssetOption(vol.getId(), getMessage("application.volumes.replication_group", vol.getName(), vol.getReplicationGroupInstance())));
}
}
}
return options;
}
use of com.emc.storageos.model.NamedRelatedResourceRep 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.storageos.model.NamedRelatedResourceRep 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.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getFilesystemsWithPolicies.
@Asset("fileFilesystemWithPolicies")
@AssetDependencies("project")
public List<AssetOption> getFilesystemsWithPolicies(AssetOptionsContext ctx, URI project) {
List<AssetOption> options = Lists.newArrayList();
List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
List<FileShareRestRep> fileSystems = api(ctx).fileSystems().findByProject(project);
for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
for (FileShareRestRep fileSystem : fileSystems) {
for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
if (resource.getId().equals(fileSystem.getId())) {
options.add(new AssetOption(fileSystem.getId(), fileSystem.getName()));
break;
}
}
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getFileContinuousCopies.
@Asset("fileContinuousCopies")
@AssetDependencies("fileWithContinuousCopies")
public List<AssetOption> getFileContinuousCopies(AssetOptionsContext ctx, URI fileId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
List<NamedRelatedResourceRep> mirrors = client.fileSystems().getFileContinuousCopies(fileId);
for (NamedRelatedResourceRep mirror : mirrors) {
FileShareRestRep fileShare = client.fileSystems().get(mirror.getId());
options.add(new AssetOption(fileShare.getId(), fileShare.getName()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations