Search in sources :

Example 1 with BlockConsistencyGroupRestRep

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;
    }
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) BlockConsistencyGroupCreate(com.emc.storageos.model.block.BlockConsistencyGroupCreate) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 2 with BlockConsistencyGroupRestRep

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;
}
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 3 with BlockConsistencyGroupRestRep

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);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) URI(java.net.URI)

Example 4 with BlockConsistencyGroupRestRep

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);
}
Also used : BlockConsistencyGroupVolumeList(com.emc.storageos.model.block.BlockConsistencyGroupUpdate.BlockConsistencyGroupVolumeList) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) BlockConsistencyGroupUpdate(com.emc.storageos.model.block.BlockConsistencyGroupUpdate) URI(java.net.URI) FlashException(controllers.util.FlashException)

Example 5 with BlockConsistencyGroupRestRep

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);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) URI(java.net.URI) Volume(models.datatable.BlockVolumesDataTable.Volume) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Aggregations

BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)15 Asset (com.emc.sa.asset.annotation.Asset)12 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)10 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)10 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)3 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)2 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)2 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)2 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)2 SRDFSourceFilter (com.emc.vipr.client.core.filters.SRDFSourceFilter)2 FlashException (controllers.util.FlashException)2 HashSet (java.util.HashSet)2 CreateConsistencyGroupFullCopy (com.emc.sa.service.vipr.block.consistency.tasks.CreateConsistencyGroupFullCopy)1 DetachConsistencyGroupFullCopy (com.emc.sa.service.vipr.block.consistency.tasks.DetachConsistencyGroupFullCopy)1