use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockVolumes.
@Asset("unassignedVplexBlockVolume")
@AssetDependencies({ "project", "host", "virtualArray" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, final URI projectId, URI hostOrClusterId, URI virtualArrayId) {
// get a list of all 'source' volumes that :
// - are in this project and not exported to the given host/cluster
// - are a 'source' volume
// - are vplex volumes
ViPRCoreClient client = api(ctx);
Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, virtualArrayId);
UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
VplexVolumeFilter vplexVolumeFilter = new VplexVolumeFilter();
CachedResources<BlockVirtualPoolRestRep> blockVpools = new CachedResources<>(client.blockVpools());
VplexVolumeVirtualPoolFilter virtualPoolFilter = new VplexVolumeVirtualPoolFilter(blockVpools);
BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
FilterChain<VolumeRestRep> filter = sourceTargetVolumesFilter.and(unexportedFilter).and(bootVolumeFilter.not()).and(vplexVolumeFilter.or(virtualPoolFilter));
// perform the query and apply the filter
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, filter);
// get a list of all volumes from our list that are in the target VArray, or use the target VArray for protection
List<BlockObjectRestRep> acceptedVolumes = getVPlexVolumesInTargetVArray(client, virtualArrayId, volumes);
return createVolumeOptions(client, acceptedVolumes);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPortGroups.
@Asset("exportChangePortGroup")
@AssetDependencies({ "host", "exportPathStorageSystem", "exportPathVirtualArray", "exportCurrentPortGroup" })
public List<AssetOption> getExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI storageSystemId, URI varrayId, URI exportCurrentPortGroupId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(varrayId, null, storageSystemId, null, null, true);
// Get a handle of the actual port group list
List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
// Filter out the current port group as we do not want the user to see this an a valid option
ResourceFilter<StoragePortGroupRestRep> filterExistingPG = new DefaultResourceFilter<StoragePortGroupRestRep>() {
@Override
public boolean accept(StoragePortGroupRestRep pg) {
return !pg.getId().equals(exportCurrentPortGroupId);
}
};
ResourceUtils.applyFilter(portGroups, filterExistingPG);
return createPortGroupOptions(portGroups);
}
return options;
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method listTargetVirtualPools.
/**
* Returns a list of virtual pools where volume can be moved
*/
protected List<BlockVirtualPoolRestRep> listTargetVirtualPools(AssetOptionsContext ctx, URI volumeId, ResourceFilter<BlockVirtualPoolRestRep> filter) {
ViPRCoreClient client = api(ctx);
List<VirtualPoolChangeRep> vpoolChanges = client.blockVolumes().listVirtualPoolChangeCandidates(volumeId);
List<URI> vpoolIds = Lists.newArrayList();
for (VirtualPoolChangeRep change : vpoolChanges) {
if (change.getAllowed()) {
vpoolIds.add(change.getId());
}
}
return client.blockVpools().getByIds(vpoolIds, filter);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumesWithContinuousCopies.
@Asset("volumeWithContinuousCopies")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithContinuousCopies(AssetOptionsContext ctx, URI project) {
final ViPRCoreClient client = api(ctx);
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, new SourceTargetVolumesFilter() {
@Override
public boolean accept(VolumeRestRep volume) {
if (volume.getProtection() == null) {
return false;
}
MirrorRestRep mirrors = volume.getProtection().getMirrorRep();
if (mirrors == null || mirrors.getMirrors() == null || mirrors.getMirrors().isEmpty()) {
return false;
}
return true;
}
});
return createVolumeOptions(client, volumes);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationReplicationGroups.
@Asset("replicationGroup")
@AssetDependencies({ "application", "applicationSnapshotVirtualArray" })
public List<AssetOption> getApplicationReplicationGroups(AssetOptionsContext ctx, URI applicationId, String virtualArrayParameter) {
ViPRCoreClient client = api(ctx);
boolean isTarget = false;
URI virtualArray = null;
if (virtualArrayParameter != null && StringUtils.split(virtualArrayParameter, ':')[0].equals("tgt")) {
virtualArray = URI.create(StringUtils.substringAfter(virtualArrayParameter, ":"));
isTarget = true;
} else {
isTarget = false;
}
Set<String> subGroups = Sets.newHashSet();
NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
VolumeRestRep volume = client.blockVolumes().get(volumeId);
VolumeRestRep parentVolume = volume;
if (volume.getHaVolumes() != null && !volume.getHaVolumes().isEmpty()) {
volume = BlockStorageUtils.getVPlexSourceVolume(client, volume);
}
if (volume != null && volume.getReplicationGroupInstance() != null) {
if (isTarget) {
if (volume.getVirtualArray().getId().equals(virtualArray)) {
subGroups.add(volume.getReplicationGroupInstance());
}
} else {
if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
subGroups.add(volume.getReplicationGroupInstance());
}
}
}
}
return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(subGroups));
}
Aggregations