Search in sources :

Example 1 with VirtualArrayRestRep

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

the class InternalVirtualArrayServiceClient method setDeviceRegistered.

/**
 * Set device registered flag for varray
 *
 * @param id the URN of a ViPR varray
 * @param value the device registered status
 * @return the updated virtual array info
 */
public VirtualArrayRestRep setDeviceRegistered(URI id, Boolean deviceRegistered) {
    String setFlag = String.format(INTERNAL_VARRAY_SET_REGISTERED, id.toString(), String.valueOf(deviceRegistered));
    WebResource rRoot = createRequest(setFlag);
    VirtualArrayRestRep resp = null;
    try {
        resp = addSignature(rRoot).put(VirtualArrayRestRep.class);
    } catch (UniformInterfaceException e) {
        _log.warn("could not set registered status to varray {}. Err:{}", id, e);
        if (e.getResponse().getStatus() == 404) {
            throw APIException.notFound.unableToFindEntityInURL(id);
        }
    }
    return resp;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) WebResource(com.sun.jersey.api.client.WebResource)

Example 2 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep 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 VirtualArrayRestRep

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

the class BlockProvider method getBlockVolumes.

@Asset("unassignedBlockVolume")
@AssetDependencies({ "host", "project", "blockStorageType" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId, String blockStorageType) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    // get varray IDs for host/cluster
    List<VirtualArrayRestRep> varrays = new ArrayList<>();
    if (EXCLUSIVE_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Host.class)) {
        varrays = client.varrays().findByConnectedHost(hostOrClusterId);
    } else if (SHARED_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Cluster.class)) {
        varrays = client.varrays().findByConnectedCluster(hostOrClusterId);
    }
    List<URI> varrayIds = new ArrayList<>();
    for (VirtualArrayRestRep varray : varrays) {
        varrayIds.add(varray.getId());
    }
    // remove volumes not in hosts/cluster's varray
    Iterator<VolumeRestRep> itr = volumes.iterator();
    while (itr.hasNext()) {
        if (!varrayIds.contains(itr.next().getVirtualArray().getId())) {
            itr.remove();
        }
    }
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with VirtualArrayRestRep

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

the class BlockProvider method getRpFailoverTargets.

protected List<AssetOption> getRpFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
    URI protectionSetId = volume.getProtection().getRpRep().getProtectionSet().getId();
    ProtectionSetRestRep localProtectionSet = client.blockVolumes().getProtectionSet(volume.getId(), protectionSetId);
    String sourceSiteName = volume.getProtection().getRpRep().getInternalSiteName();
    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
    List<RelatedResourceRep> rpTargets = localProtectionSet.getVolumes();
    for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(rpTargets, RecoverPointPersonalityFilter.TARGET)) {
        String targetSiteName = protectionSetVolume.getProtection().getRpRep().getInternalSiteName();
        boolean isLocal = StringUtils.equals(sourceSiteName, targetSiteName);
        String rpType = isLocal ? "local" : "remote";
        VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
        String label = getMessage("recoverpoint.target", name(protectionSetVolume), rpType, name(virtualArray));
        targetVolumes.put(stringId(protectionSetVolume), label);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
        options.add(new AssetOption(entry.getKey(), entry.getValue()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) CachedResources(com.emc.vipr.client.core.util.CachedResources) ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with VirtualArrayRestRep

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

the class BlockProvider method getVirtualArrayByConsistencyGroup.

@Asset("virtualArrayByConsistencyGroup")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getVirtualArrayByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
    ViPRCoreClient client = api(ctx);
    List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
    List<AssetOption> targets = Lists.newArrayList();
    if (!volumes.isEmpty()) {
        RelatedResourceRep varrayId = client.blockVolumes().get(volumes.get(0)).getVirtualArray();
        VirtualArrayRestRep virtualArray = client.varrays().get(varrayId);
        targets.add(createBaseResourceOption(virtualArray));
    }
    return targets;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)56 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)15 URI (java.net.URI)15 AssetOption (com.emc.vipr.model.catalog.AssetOption)14 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 ArrayList (java.util.ArrayList)10 FlashException (controllers.util.FlashException)9 HashSet (java.util.HashSet)8 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)6 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)4 HashMap (java.util.HashMap)4 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)3