use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileSystems method fileSystemMirrors.
public static void fileSystemMirrors(String fileSystemId) {
URI id = uri(fileSystemId);
ViPRCoreClient client = BourneUtil.getViprClient();
FileProtectionRestRep targetFileSystems = client.fileSystems().get(id).getProtection();
List<FileShareRestRep> fileMirrors = new ArrayList<FileShareRestRep>();
for (VirtualArrayRelatedResourceRep virtualResource : targetFileSystems.getTargetFileSystems()) {
fileMirrors.add(client.fileSystems().get(virtualResource.getId()));
}
String personality = targetFileSystems.getPersonality();
// The code will be refactored once 1:n or cascaded FS replication is supported
if (!fileMirrors.isEmpty()) {
FileShareRestRep fsRestRep = fileMirrors.get(0);
fsRestRep.getProtection().setMirrorStatus(targetFileSystems.getMirrorStatus());
}
// Verify the replication is at fs level or not
boolean replicationAtFs = false;
FileShareRestRep fs = client.fileSystems().get(id);
if (fs != null) {
FilePolicyRestRep replicationPolicy = getReplicationPolicy(client, fs);
if (replicationPolicy != null) {
if (FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(replicationPolicy.getAppliedAt())) {
replicationAtFs = true;
}
renderArgs.put("replicationPolicy", replicationPolicy);
}
renderArgs.put("replicationAtFsLevel", replicationAtFs);
}
renderArgs.put("personality", personality);
renderArgs.put("fileMirrors", fileMirrors);
renderArgs.put("fileSystemId", fileSystemId);
render();
}
use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getFailoverFileTarget.
@Asset("failoverFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailoverFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
if (protectedFileSystem != null) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
debug("getting failoverFileTargets (protectedFileSystem=%s)", protectedFileSystem);
FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
FileProtectionRestRep protection = file.getProtection();
if (protection != null) {
List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
for (VirtualArrayRelatedResourceRep target : targets) {
FileShareRestRep fileshare = client.fileSystems().get(target.getId());
options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
return Lists.newArrayList();
}
use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getFailbackFileTarget.
@Asset("failbackFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailbackFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
if (protectedFileSystem != null) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
debug("getting failbackFileTargets (protectedFileSystem=%s)", protectedFileSystem);
FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
FileProtectionRestRep protection = file.getProtection();
if (protection != null) {
List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
for (VirtualArrayRelatedResourceRep target : targets) {
FileShareRestRep fileshare = client.fileSystems().get(target.getId());
options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
return Lists.newArrayList();
}
use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getSrdfFailoverTargets.
protected List<AssetOption> getSrdfFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<VirtualArrayRelatedResourceRep> srdfTargets = volume.getProtection().getSrdfRep().getSRDFTargetVolumes();
for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(srdfTargets, new SRDFTargetFilter())) {
VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
String label = getMessage("srdf.target", name(protectionSetVolume), name(virtualArray));
targetVolumes.put(stringId(protectionSetVolume), label);
}
List<AssetOption> options = Lists.newArrayList();
for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
options.add(new AssetOption(entry.getKey(), entry.getValue()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getFailoverTarget.
@Asset("failoverTarget")
@AssetDependencies("protectedBlockVolume")
public List<AssetOption> getFailoverTarget(AssetOptionsContext ctx, URI protectedBlockVolume) {
if (protectedBlockVolume != null) {
ViPRCoreClient client = api(ctx);
if (BlockProviderUtils.isType(protectedBlockVolume, VOLUME_TYPE)) {
debug("getting failoverTargets (protectedBlockVolume=%s)", protectedBlockVolume);
VolumeRestRep volume = client.blockVolumes().get(protectedBlockVolume);
ProtectionRestRep protection = volume.getProtection();
if (protection != null) {
// RecoverPoint protection
if (protection.getRpRep() != null && protection.getRpRep().getProtectionSet() != null) {
return getRpFailoverTargets(client, volume);
}
// VMAX SRDF protection
if (protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
return getSrdfFailoverTargets(client, volume);
}
}
} else if (BlockProviderUtils.isType(protectedBlockVolume, BLOCK_CONSISTENCY_GROUP_TYPE)) {
debug("getting failoverTargets for consistency group %s", protectedBlockVolume);
BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(protectedBlockVolume);
List<VolumeRestRep> srcVolumes = null;
// Get RP source volumes
if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), RecoverPointPersonalityFilter.SOURCE);
}
// Get SRDF source volumes
if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
}
if (srcVolumes != null && !srcVolumes.isEmpty()) {
// Get the first source volume and obtain its target references
VolumeRestRep srcVolume = srcVolumes.get(0);
if (cg.getTypes() != null) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
// Process the RP targets
if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
targets = srcVolume.getProtection().getRpRep().getRpTargets();
}
// Process the SRDF targets
if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
targets = srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes();
}
for (VolumeRestRep targetVolume : client.blockVolumes().getByRefs(targets)) {
VirtualArrayRestRep virtualArray = virtualArrays.get(targetVolume.getVirtualArray());
String label = getMessage(name(virtualArray));
targetVolumes.put(stringId(virtualArray), label);
}
List<AssetOption> options = Lists.newArrayList();
for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
options.add(new AssetOption(entry.getKey(), entry.getValue()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
}
}
}
return Lists.newArrayList();
}
Aggregations