use of com.emc.storageos.model.block.BlockConsistencyGroupRestRep in project coprhd-controller by CoprHD.
the class ApiSystemTestUtil method createConsistencyGroup.
public URI createConsistencyGroup(String cgName, URI project) {
BlockConsistencyGroupCreate input = new BlockConsistencyGroupCreate();
input.setName(cgName);
input.setProject(project);
try {
BlockConsistencyGroupRestRep rep = client.blockConsistencyGroups().create(input);
return rep.getId();
} catch (ServiceErrorException ex) {
log.error("Exception creating consistency group: " + cgName, ex);
throw ex;
}
}
use of com.emc.storageos.model.block.BlockConsistencyGroupRestRep in project coprhd-controller by CoprHD.
the class BlockMapper method map.
public static BlockConsistencyGroupRestRep map(BlockConsistencyGroup from, Set<URI> volumes, DbClient dbClient) {
if (from == null) {
return null;
}
BlockConsistencyGroupRestRep to = new BlockConsistencyGroupRestRep();
mapDataObjectFields(from, to);
to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, from.getVirtualArray()));
to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
if (!NullColumnValueGetter.isNullURI(from.getStorageController())) {
to.setStorageController(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageController()));
}
to.setArrayConsistency(from.getArrayConsistency());
// Default snapshot session support to false
to.setSupportsSnapshotSessions(Boolean.FALSE);
if (dbClient != null && from.getSystemConsistencyGroups() != null) {
for (String systemId : from.getSystemConsistencyGroups().keySet()) {
StorageSystem system = dbClient.queryObject(StorageSystem.class, URI.create(systemId));
if (system != null && system.checkIfVmax3()) {
to.setSupportsSnapshotSessions(Boolean.TRUE);
}
}
}
try {
if (from.getSystemConsistencyGroups() != null) {
to.setSystemConsistencyGroups(new StringSetMapAdapter().marshal(from.getSystemConsistencyGroups()));
if (!to.getSupportsSnapshotSessions()) {
// we can flag this as true.
if (dbClient != null && to.getSystemConsistencyGroups() != null) {
for (StringSetMapAdapter.Entry entry : to.getSystemConsistencyGroups()) {
String storageSystemId = entry.getKey();
if (storageSystemId != null) {
StorageSystem system = dbClient.queryObject(StorageSystem.class, URI.create(storageSystemId));
if (system != null && system.checkIfVmax3()) {
to.setSupportsSnapshotSessions(Boolean.TRUE);
break;
}
}
}
}
}
}
} catch (Exception e) {
// internally ignored
logger.debug(e.getMessage(), e);
}
if (from.getTypes() != null) {
to.setTypes(from.getTypes());
}
if (dbClient != null) {
List<RelatedResourceRep> volumesResourceRep = new ArrayList<RelatedResourceRep>();
final URIQueryResultList cgVolumesResults = new URIQueryResultList();
dbClient.queryByConstraint(getVolumesByConsistencyGroup(from.getId()), cgVolumesResults);
Iterator<Volume> volumeIterator = dbClient.queryIterativeObjects(Volume.class, cgVolumesResults);
boolean first = true;
while (volumeIterator.hasNext()) {
// Get the first RP or SRDF volume. From this we are able to obtain the
// link status and protection set (RP) information for all volumes in the
// CG.
Volume volume = volumeIterator.next();
if (first) {
if (from.getTypes().contains(BlockConsistencyGroup.Types.RP.toString()) && !NullColumnValueGetter.isNullNamedURI(volume.getProtectionSet())) {
// Get the protection set from the first volume and set the appropriate fields
ProtectionSet protectionSet = dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
to.setRpConsistenyGroupId(protectionSet.getProtectionId());
to.setLinkStatus(protectionSet.getProtectionStatus());
to.setRpProtectionSystem(protectionSet.getProtectionSystem());
} else if (from.getTypes().contains(BlockConsistencyGroup.Types.SRDF.toString())) {
// Operations cannot be performed individually on volumes within an SRDF CG, hence
// we can take any one of the volume's link status and update the CG link status.
to.setLinkStatus(volume.getLinkStatus());
}
}
// Only display CG volumes that are non-RP or RP source volumes. Exclude RP+VPlex backing volumes.
if ((!volume.checkForRp() && !RPHelper.isAssociatedToAnyRpVplexTypes(volume, dbClient)) || (volume.checkForRp() && PersonalityTypes.SOURCE.name().equals(volume.getPersonality()))) {
volumesResourceRep.add(toRelatedResource(ResourceTypeEnum.VOLUME, volume.getId()));
}
first = false;
}
to.setVolumes(volumesResourceRep);
}
return to;
}
use of com.emc.storageos.model.block.BlockConsistencyGroupRestRep in project coprhd-controller by CoprHD.
the class BlockConsistencyGroups method delete.
private static void delete(List<URI> ids) {
if (ids != null) {
ViPRCoreClient client = BourneUtil.getViprClient();
for (URI id : ids) {
Task<BlockConsistencyGroupRestRep> task = client.blockConsistencyGroups().deactivate(id);
}
flash.put("info", MessagesUtils.get("resources.consistencygroups.deactivate", ids.size()));
}
consistencyGroups(null);
}
use of com.emc.storageos.model.block.BlockConsistencyGroupRestRep in project coprhd-controller by CoprHD.
the class BlockConsistencyGroups method removeVolume.
@FlashException(referrer = { "consistencyGroupDetails" })
public static void removeVolume(String consistencyGroupId, String volumeId) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<URI> uris = new ArrayList<URI>();
uris.add(uri(volumeId));
BlockConsistencyGroupUpdate blockConsistencyGroupUpdate = new BlockConsistencyGroupUpdate();
BlockConsistencyGroupVolumeList volumeList = new BlockConsistencyGroupVolumeList();
volumeList.setVolumes(uris);
blockConsistencyGroupUpdate.setRemoveVolumesList(volumeList);
Task<BlockConsistencyGroupRestRep> task = client.blockConsistencyGroups().update(uri(consistencyGroupId), blockConsistencyGroupUpdate);
flash.put("info", MessagesUtils.get("resources.consistencygroup.volume.removed", task.getOpId()));
consistencyGroupDetails(consistencyGroupId);
}
use of com.emc.storageos.model.block.BlockConsistencyGroupRestRep in project coprhd-controller by CoprHD.
the class BlockConsistencyGroups method consistencyGroupDetails.
public static void consistencyGroupDetails(String consistencyGroupId) {
ViPRCoreClient client = BourneUtil.getViprClient();
AffectedResources.BlockConsistencyGroupDetails blockConsistencyGroup = new AffectedResources.BlockConsistencyGroupDetails(uri(consistencyGroupId));
if (blockConsistencyGroup.blockConsistencyGroup == null) {
flash.error(MessagesUtils.get(UNKNOWN, consistencyGroupId));
ConsistencyGroups.list();
}
Tasks<BlockConsistencyGroupRestRep> tasksResponse = client.blockConsistencyGroups().getTasks(blockConsistencyGroup.blockConsistencyGroup.getId());
List<Task<BlockConsistencyGroupRestRep>> tasks = tasksResponse.getTasks();
renderArgs.put("tasks", tasks);
List<VolumeRestRep> volumes = blockConsistencyGroup.volumes;
Map<URI, String> virtualArrays = ResourceUtils.mapNames(client.varrays().list());
Map<URI, String> virtualPools = ResourceUtils.mapNames(client.blockVpools().list());
List<Volume> volumeDetails = Lists.newArrayList();
for (VolumeRestRep volume : volumes) {
volumeDetails.add(new Volume(volume, virtualArrays, virtualPools));
}
render(blockConsistencyGroup, volumeDetails);
}
Aggregations