use of com.emc.storageos.model.adapters.StringSetMapAdapter 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.adapters.StringSetMapAdapter in project coprhd-controller by CoprHD.
the class BlockMapper method map.
public static UnManagedVolumeRestRep map(UnManagedVolume from) {
if (from == null) {
return null;
}
UnManagedVolumeRestRep to = new UnManagedVolumeRestRep();
mapDataObjectFields(from, to);
to.setNativeGuid(from.getNativeGuid());
try {
to.setVolumeInformation(new StringSetMapAdapter().marshal(from.getVolumeInformation()));
} catch (Exception e) {
// Intentionally ignored
}
to.setVolumeCharacteristics(new StringMapAdapter().marshal(from.getVolumeCharacterstics()));
to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageSystemUri()));
to.setStoragePool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getStoragePoolUri()));
List<String> uems = new ArrayList<String>();
for (String uem : from.getUnmanagedExportMasks()) {
uems.add(uem);
}
to.setUnManagedExportMasks(uems);
List<String> initiatorUris = new ArrayList<String>();
for (String uri : from.getInitiatorUris()) {
initiatorUris.add(uri);
}
to.setInitiatorUris(initiatorUris);
List<String> initiatorNetworkIds = new ArrayList<String>();
for (String id : from.getInitiatorNetworkIds()) {
initiatorNetworkIds.add(id);
}
to.setInitiatorNetworkIds(initiatorNetworkIds);
List<String> storagePortUris = new ArrayList<String>();
for (String uri : from.getStoragePortUris()) {
storagePortUris.add(uri);
}
to.setStoragePortUris(storagePortUris);
List<String> supportedVPoolUris = new ArrayList<String>();
for (String uri : from.getSupportedVpoolUris()) {
supportedVPoolUris.add(uri);
}
to.setSupportedVPoolUris(supportedVPoolUris);
to.setWWN(from.getWwn());
return to;
}
use of com.emc.storageos.model.adapters.StringSetMapAdapter in project coprhd-controller by CoprHD.
the class FileMapper method map.
public static UnManagedFileSystemRestRep map(UnManagedFileSystem from) {
if (from == null) {
return null;
}
UnManagedFileSystemRestRep to = new UnManagedFileSystemRestRep();
mapDataObjectFields(from, to);
to.setNativeGuid(from.getNativeGuid());
try {
to.setFileSystemInformation(new StringSetMapAdapter().marshal(from.getFileSystemInformation()));
} catch (Exception e) {
_log.error("Exception while setting FileSystem information ", e);
}
to.setFileSystemCharacteristics(new StringMapAdapter().marshal(from.getFileSystemCharacterstics()));
to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageSystemUri()));
to.setStoragePool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getStoragePoolUri()));
if (null != from.getSupportedVpoolUris() && !from.getSupportedVpoolUris().isEmpty()) {
List<String> supportedVPoolList = new ArrayList<String>(from.getSupportedVpoolUris());
to.setSupportedVPoolUris(supportedVPoolList);
}
return to;
}
Aggregations