Search in sources :

Example 1 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class ApiTest method updateAllIsilonPorts.

/**
 * Update the discovered Isilon storage ports to set the transport zone.
 *
 * @param isilonDevice : Isilon Device.
 */
private void updateAllIsilonPorts(StorageSystemRestRep isilonDevice) {
    // Register all the discovered storage ports .
    StoragePortList portList = rZAdmin.path(String.format("/vdc/storage-systems/%s/storage-ports", isilonDevice.getId()).toString()).get(StoragePortList.class);
    List<NamedRelatedResourceRep> portURIList = portList.getPorts();
    for (RelatedResourceRep portURI : portURIList) {
        updateStoragePortTZ(isilonDevice.getId(), portURI);
    }
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) StoragePortList(com.emc.storageos.model.ports.StoragePortList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 2 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolTest method testComputeVirtualPoolCrud.

// @Test
// public void testComputeVirtualPoolGet() throws Exception {
// 
// // long timestamp = System.currentTimeMillis();
// 
// System.out.println("-Running testComputeVirtualPoolGet");
// 
// ComputeVirtualPoolList cvpResp = rSys.path("/compute/vpools")
// .get(ComputeVirtualPoolList.class);
// List<NamedRelatedResourceRep> cvpList = cvpResp.getComputeVirtualPool();
// Assert.assertTrue(cvpList.size() > 0);
// 
// }
@Test
public void testComputeVirtualPoolCrud() throws Exception {
    long timestamp = System.currentTimeMillis();
    System.out.println("-Running testComputeVirtualPool");
    // Create vArray (neighborhood) for test
    VirtualArrayCreateParam neighborhoodParam = new VirtualArrayCreateParam();
    neighborhoodParam.setLabel("nb1-temp" + String.valueOf(timestamp));
    // VirtualArrayRestRep n1 =
    // rSys.path("/vdc/varrays").header(RequestProcessingUtils.AUTH_TOKEN_HEADER,
    // _rootToken).post(VirtualArrayRestRep.class, neighborhoodParam);
    VirtualArrayRestRep n1 = rSys.path("/vdc/varrays").post(VirtualArrayRestRep.class, neighborhoodParam);
    Assert.assertNotNull(n1.getId());
    System.out.println("-Newly created vArray id - " + n1.getId().toString());
    // Create Compute Virtual Pool
    ComputeVirtualPoolCreateParam createParams = new ComputeVirtualPoolCreateParam();
    createParams.setDescription("VCP created by Unit Test");
    createParams.setName("VCP-Unit-Test-1");
    createParams.setSystemType("Cisco_UCSM");
    createParams.setMinCpuSpeed(2500);
    createParams.setMaxCpuSpeed(8000);
    createParams.setMinTotalCores(1);
    Integer newMaxCores = 8;
    createParams.setMaxTotalCores(newMaxCores);
    Set<String> vArrays = new HashSet<String>();
    vArrays.add(n1.getId().toString());
    createParams.setVarrays(vArrays);
    ComputeVirtualPoolRestRep cvpCreateResp = rSys.path("/compute/vpools").post(ComputeVirtualPoolRestRep.class, createParams);
    URI newId = cvpCreateResp.getId();
    Assert.assertNotNull(newId);
    System.out.println("-Newly created Compute Virtual Pool id - " + newId.toString());
    System.out.println("---max cores - " + cvpCreateResp.getMaxTotalCores());
    Assert.assertTrue(cvpCreateResp.getMaxTotalCores() == newMaxCores);
    // Get list of virtual pools
    ComputeVirtualPoolList cvpResp = rSys.path("/compute/vpools").get(ComputeVirtualPoolList.class);
    List<NamedRelatedResourceRep> cvpList = cvpResp.getComputeVirtualPool();
    Assert.assertTrue(!cvpList.isEmpty());
    // Get details of newly created Compute Virtual Pool
    ComputeVirtualPoolRestRep cvpGetResp = rSys.path("/compute/vpools/" + newId.toString()).get(ComputeVirtualPoolRestRep.class);
    Assert.assertNotNull(cvpGetResp.getId());
    System.out.println("id - " + cvpGetResp.getId().toString());
    System.out.println("name - " + cvpGetResp.getName());
    System.out.println("description - " + cvpGetResp.getDescription());
    List<RelatedResourceRep> vArrayResp = cvpGetResp.getVirtualArrays();
    Assert.assertTrue(!vArrayResp.isEmpty());
    // Get Matching Compute Elements
    ClientResponse ceResp = rSys.path("/compute/vpools/" + newId.toString() + "/matched-compute-elements").get(ClientResponse.class);
    // List<ComputeElementRestRep> ceList = ceResp.getList();
    Assert.assertTrue(ceResp.getStatus() == 200);
    // Update CVP
    System.out.println("- Updating - " + newId.toString());
    ComputeVirtualPoolUpdateParam updParams = new ComputeVirtualPoolUpdateParam();
    Integer updMaxCores = 4;
    updParams.setMaxTotalCores(updMaxCores);
    ComputeVirtualPoolRestRep updateResp = rSys.path("/compute/vpools/" + newId.toString()).put(ComputeVirtualPoolRestRep.class, updParams);
    System.out.println("---max cores - " + updateResp.getMaxTotalCores());
    Assert.assertTrue(updateResp.getMaxTotalCores() == updMaxCores);
    // Delete CVP
    ClientResponse delCvpResp = rSys.path("/compute/vpools/" + newId.toString() + "/deactivate").post(ClientResponse.class);
    Assert.assertTrue(delCvpResp != null);
    Assert.assertTrue(delCvpResp.getStatus() == 200);
    // Delete vArray
    ClientResponse deleteResp = rSys.path("/vdc/varrays/" + n1.getId().toString() + "/deactivate").post(ClientResponse.class);
    Assert.assertTrue(deleteResp != null);
    Assert.assertTrue(deleteResp.getStatus() == 200);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VirtualArrayCreateParam(com.emc.storageos.model.varray.VirtualArrayCreateParam) ComputeVirtualPoolList(com.emc.storageos.model.vpool.ComputeVirtualPoolList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) ComputeVirtualPoolUpdateParam(com.emc.storageos.model.vpool.ComputeVirtualPoolUpdateParam) ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ComputeVirtualPoolCreateParam(com.emc.storageos.model.vpool.ComputeVirtualPoolCreateParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class BlockMapper method map.

public static UnManagedExportMaskRestRep map(UnManagedExportMask from) {
    if (from == null) {
        return null;
    }
    UnManagedExportMaskRestRep to = new UnManagedExportMaskRestRep();
    mapDataObjectFields(from, to);
    to.setNativeId(from.getNativeId());
    to.setMaskName(from.getMaskName());
    to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageSystemUri()));
    if ((from.getKnownInitiatorUris() != null) && (!from.getKnownInitiatorUris().isEmpty())) {
        List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
        for (String uri : from.getKnownInitiatorUris()) {
            reps.add(toRelatedResource(ResourceTypeEnum.INITIATOR, URI.create(uri)));
        }
        to.setKnownInitiatorUris(reps);
    }
    if ((from.getKnownStoragePortUris() != null) && (!from.getKnownStoragePortUris().isEmpty())) {
        List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
        for (String uri : from.getKnownStoragePortUris()) {
            reps.add(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, URI.create(uri)));
        }
        to.setKnownStoragePortUris(reps);
    }
    if ((from.getKnownVolumeUris() != null) && (!from.getKnownVolumeUris().isEmpty())) {
        List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
        for (String uri : from.getKnownVolumeUris()) {
            reps.add(toRelatedResource(ResourceTypeEnum.VOLUME, URI.create(uri)));
        }
        to.setKnownStorageVolumeUris(reps);
    }
    if ((from.getUnmanagedVolumeUris() != null) && (!from.getUnmanagedVolumeUris().isEmpty())) {
        List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
        for (String uri : from.getUnmanagedVolumeUris()) {
            reps.add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, URI.create(uri)));
        }
        to.setUnmanagedVolumeUris(reps);
    }
    to.setUnmanagedInitiatorNetworkIds(from.getUnmanagedInitiatorNetworkIds());
    to.setUnmanagedStoragePortNetworkIds(from.getUnmanagedStoragePortNetworkIds());
    return to;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) UnManagedExportMaskRestRep(com.emc.storageos.model.block.UnManagedExportMaskRestRep)

Example 4 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep 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 5 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class BlockMapper method map.

/**
 * Maps a BlockSnapshotSession instance to its Rest representation.
 *
 * @param dbClient A reference to a database client.
 * @param from An instance of BlockSnapshotSession.
 *
 * @return An instance of BlockSnapshotSessionRestRep
 */
public static BlockSnapshotSessionRestRep map(DbClient dbClient, BlockSnapshotSession from) {
    if (from == null) {
        return null;
    }
    BlockSnapshotSessionRestRep to = new BlockSnapshotSessionRestRep();
    // Map base class fields.
    mapDataObjectFields(from, to);
    // Map snapshot session consistency group.
    URI consistencyGroup = from.getConsistencyGroup();
    if (consistencyGroup != null) {
        to.setConsistencyGroup(toRelatedResource(ResourceTypeEnum.BLOCK_CONSISTENCY_GROUP, consistencyGroup));
    }
    // Map snapshot session parent i.e., the snapshot session source.
    NamedURI parentNamedURI = from.getParent();
    if (parentNamedURI != null) {
        URI parentURI = parentNamedURI.getURI();
        // It may be possible that the source for the snapshot
        // session is a backend source volume for a VPLEX volume
        // if we support creating snapshot sessions for VPLEX
        // volumes backed by storage that supports snapshot sessions.
        // In this case, the parent we want to reflect in the response
        // is the VPLEX volume.
        URIQueryResultList results = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeByAssociatedVolumesConstraint(parentURI.toString()), results);
        Iterator<URI> resultsIter = results.iterator();
        if (resultsIter.hasNext()) {
            parentURI = resultsIter.next();
        }
        // volume for an array snapshot, which is a BlockSnapshot.
        if (URIUtil.isType(parentURI, Volume.class)) {
            to.setParent(toRelatedResource(ResourceTypeEnum.VOLUME, parentURI));
        } else {
            to.setParent(toRelatedResource(ResourceTypeEnum.BLOCK_SNAPSHOT, parentURI));
        }
    }
    // Map project
    NamedURI projectURI = from.getProject();
    if (projectURI != null) {
        to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, projectURI.getURI()));
    }
    // Map storage controller
    URI storageURI = from.getStorageController();
    if (storageURI != null) {
        to.setStorageController(storageURI);
    }
    // Map linked targets.
    StringSet linkedTargetIds = from.getLinkedTargets();
    if ((linkedTargetIds != null) && (!linkedTargetIds.isEmpty())) {
        List<RelatedResourceRep> linkedTargetReps = new ArrayList<RelatedResourceRep>();
        for (String linkedTargetId : linkedTargetIds) {
            URI linkedTargetURI = URI.create(linkedTargetId);
            // Linked targets are instances of BlockSnapshot.
            linkedTargetReps.add(toRelatedResource(ResourceTypeEnum.BLOCK_SNAPSHOT, linkedTargetURI));
        }
        to.setLinkedTargets(linkedTargetReps);
    }
    // Map session label.
    to.setSessionLabel(from.getSessionLabel());
    // Map replication group name.
    to.setReplicationGroupInstance(from.getReplicationGroupInstance());
    // Map session set name.
    to.setSessionSetName(from.getSessionSetName());
    return to;
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)41 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)25 ArrayList (java.util.ArrayList)19 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)14 URI (java.net.URI)12 Asset (com.emc.sa.asset.annotation.Asset)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)5 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 StoragePortList (com.emc.storageos.model.ports.StoragePortList)4 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)3