use of com.emc.storageos.model.block.VolumeRestRep 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.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationFullCopyNamesForSite.
@Asset("siteFullCopyName")
@AssetDependencies({ "application", "applicationVirtualArray" })
public List<AssetOption> getApplicationFullCopyNamesForSite(AssetOptionsContext ctx, URI applicationId, URI applicationVirtualArray) {
List<VolumeRestRep> fullCopies = getFullCopiesForApplication(ctx, applicationId);
Set<String> fullCopyNames = new HashSet<String>();
for (VolumeRestRep vol : fullCopies) {
if (vol != null && vol.getProtection() != null && vol.getProtection().getFullCopyRep() != null && vol.getProtection().getFullCopyRep().getFullCopySetName() != null && (applicationVirtualArray == null || vol.getVirtualArray().getId().equals(applicationVirtualArray))) {
fullCopyNames.add(vol.getProtection().getFullCopyRep().getFullCopySetName());
}
}
return createStringOptions(fullCopyNames);
}
use of com.emc.storageos.model.block.VolumeRestRep 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.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProviderUtils method getBlockVolumes.
public static List<VolumeRestRep> getBlockVolumes(ViPRCoreClient viprClient, URI tenantId, URI hostOrClusterId, boolean onlyMounted) {
List<URI> hostIds = buildHostIdsList(viprClient, hostOrClusterId, onlyMounted);
List<VolumeRestRep> volumes = Lists.newArrayList();
for (VolumeRestRep volume : getExportedBlockVolumes(viprClient, tenantId, hostOrClusterId)) {
boolean isMounted = isMounted(hostIds, volume);
if (onlyMounted && isMounted) {
volumes.add(volume);
} else if (!onlyMounted && !isMounted) {
volumes.add(volume);
}
}
return volumes;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProviderUtils method getBlockVolumesForDatastore.
/**
* Method to return all volumes associated with a specific datastore
*
* @param viprClient
* @param tenantId
* @param hostOrClusterId
* @param datastore name
*
* @return list of volumes associated with specified datastore
*/
public static List<VolumeRestRep> getBlockVolumesForDatastore(ViPRCoreClient viprClient, URI tenantId, URI hostOrClusterId, String datastore) {
List<URI> hostIds = buildHostIdsList(viprClient, hostOrClusterId, true);
List<VolumeRestRep> volumes = Lists.newArrayList();
for (VolumeRestRep volume : getExportedBlockVolumes(viprClient, tenantId, hostOrClusterId)) {
for (URI hostId : hostIds) {
String ds = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
if (StringUtils.isNotBlank(ds) && ds.equals(datastore)) {
volumes.add(volume);
}
}
}
return volumes;
}
Aggregations