Search in sources :

Example 1 with StringSetMapAdapter

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;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StringSetMapAdapter(com.emc.storageos.model.adapters.StringSetMapAdapter) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with StringSetMapAdapter

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;
}
Also used : StringSetMapAdapter(com.emc.storageos.model.adapters.StringSetMapAdapter) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep) ArrayList(java.util.ArrayList) StringMapAdapter(com.emc.storageos.model.adapters.StringMapAdapter)

Example 3 with StringSetMapAdapter

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;
}
Also used : StringSetMapAdapter(com.emc.storageos.model.adapters.StringSetMapAdapter) UnManagedFileSystemRestRep(com.emc.storageos.model.file.UnManagedFileSystemRestRep) ArrayList(java.util.ArrayList) StringMapAdapter(com.emc.storageos.model.adapters.StringMapAdapter)

Aggregations

StringSetMapAdapter (com.emc.storageos.model.adapters.StringSetMapAdapter)3 ArrayList (java.util.ArrayList)3 StringMapAdapter (com.emc.storageos.model.adapters.StringMapAdapter)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 Volume (com.emc.storageos.db.client.model.Volume)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)1 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)1 UnManagedFileSystemRestRep (com.emc.storageos.model.file.UnManagedFileSystemRestRep)1