use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationVirtualArrays.
@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
final ViPRCoreClient client = api(ctx);
List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
List<AssetOption> options = new ArrayList<AssetOption>();
boolean isRP = false;
URI sourceVarrayId = null;
List<VolumeRestRep> allRPSourceVols = null;
if (volList != null && !volList.isEmpty()) {
VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
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 {
options.add(newAssetOption(URI.create("none"), "None"));
return options;
}
// if the volumes are RP (vplex or not) add the RP targets as options
if (isRP) {
options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
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);
}
if (options.isEmpty()) {
options.add(newAssetOption(URI.create("none"), "None"));
}
return options;
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getTargetVirtualArrays.
@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "unprotectedFilesystem" })
public List<AssetOption> getTargetVirtualArrays(AssetOptionsContext context, URI filePolicy, URI fsId) {
ViPRCoreClient client = api(context);
FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
if (policyRest.getType().equals("file_snapshot")) {
VirtualArrayRestRep vArray = null;
List<AssetOption> options = Lists.newArrayList();
FileShareRestRep fsObj = client.fileSystems().get(fsId);
if (fsObj != null) {
vArray = client.varrays().get(fsObj.getVirtualArray().getId());
options.add(createBaseResourceOption(vArray));
}
return options;
} else {
return getFileVirtualArrays(context);
}
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getVirtualArray.
@Asset("virtualArray")
@AssetDependencies({ "host" })
public List<AssetOption> getVirtualArray(AssetOptionsContext context, URI hostOrClusterId) {
ViPRCoreClient client = api(context);
List<URI> hostIds = HostProvider.getHostIds(client, hostOrClusterId);
Map<URI, VirtualArrayRestRep> virtualArrays = null;
Map<URI, VirtualArrayRestRep> allVirtualArrays = Maps.newHashMap();
for (URI hostId : hostIds) {
Map<URI, VirtualArrayRestRep> connectedVirtualArrays = ResourceUtils.mapById(client.varrays().findByConnectedHost(hostId));
if (virtualArrays == null) {
virtualArrays = connectedVirtualArrays;
} else {
virtualArrays.keySet().retainAll(connectedVirtualArrays.keySet());
}
allVirtualArrays.putAll(connectedVirtualArrays);
}
// Creates options for the virtual arrays, showing an indication whether the virtual array is only
// partially connected to the cluster
List<AssetOption> fullyConnectedOptions = new ArrayList<>();
List<AssetOption> partiallyConnectedOptions = new ArrayList<>();
List<VirtualArrayRestRep> varraysByTenant = client.varrays().getByTenant(context.getTenant());
for (VirtualArrayRestRep varray : allVirtualArrays.values()) {
if (!contains(varray.getId(), varraysByTenant)) {
continue;
}
boolean fullyConnected = virtualArrays.containsKey(varray.getId());
if (fullyConnected) {
fullyConnectedOptions.add(new AssetOption(varray.getId(), varray.getName()));
} else {
String label = getMessage("virtualArray.partiallyConnected", varray.getName());
partiallyConnectedOptions.add(new AssetOption(varray.getId(), label));
}
}
AssetOptionsUtils.sortOptionsByLabel(fullyConnectedOptions);
AssetOptionsUtils.sortOptionsByLabel(partiallyConnectedOptions);
// Place the fully connected options first
List<AssetOption> options = new ArrayList<>();
options.addAll(fullyConnectedOptions);
options.addAll(partiallyConnectedOptions);
return options;
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method createVolumeWithVarrayOptions.
protected static List<AssetOption> createVolumeWithVarrayOptions(ViPRCoreClient client, Collection<? extends BlockObjectRestRep> blockObjects) {
List<URI> varrayIds = getVirtualArrayIds(blockObjects);
Map<URI, VirtualArrayRestRep> varrayNames = getVirutalArrayNames(client, varrayIds);
List<AssetOption> options = Lists.newArrayList();
for (BlockObjectRestRep blockObject : blockObjects) {
options.add(createVolumeWithVarrayOption(blockObject, varrayNames));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class FindVirtualArrayInitiators method executeTask.
@Override
public Set<Initiator> executeTask() throws Exception {
IdFilter<VirtualArrayRestRep> filter = new IdFilter<VirtualArrayRestRep>(varray);
Set<Initiator> results = Sets.newHashSet();
for (Initiator initiator : initiators) {
String initiatorPort = initiator.getInitiatorPort();
List<VirtualArrayRestRep> virtualArrays = getClient().varrays().findByInitiatorPort(initiatorPort, filter);
// Filter will only return the virtual array we are searching for
if (!virtualArrays.isEmpty()) {
results.add(initiator);
}
}
return results;
}
Aggregations