Search in sources :

Example 1 with BulkIdParam

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

the class VMWareProvider method getVolumeHLUs.

private Map<URI, Integer> getVolumeHLUs(AssetOptionsContext context, List<URI> volumeIds) {
    BulkIdParam bulkParam = new BulkIdParam();
    Map<URI, Integer> volumeHLUs = Maps.newHashMap();
    bulkParam.getIds().addAll(volumeIds);
    List<ITLRestRep> bulkResponse = api(context).blockVolumes().getExports(bulkParam).getExportList();
    for (ITLRestRep export : bulkResponse) {
        volumeHLUs.put(export.getBlockObject().getId(), export.getHlu());
    }
    return volumeHLUs;
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) URI(java.net.URI)

Example 2 with BulkIdParam

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

the class VirtualArrays method getAvailableAttributes.

/**
 * Gets the available attributes for the given virtual arrays.
 * <p>
 * API Call: <tt>GET /vdc/varrays/available-attributes</tt>
 *
 * @param virtualArrayIds
 *            the IDs of the virtual arrays.
 * @return the list of available attributes.
 */
public Map<URI, List<VirtualPoolAvailableAttributesResourceRep>> getAvailableAttributes(Collection<URI> virtualArrayIds) {
    BulkIdParam input = new BulkIdParam((List<URI>) virtualArrayIds);
    VArrayAttributeList response = client.post(VArrayAttributeList.class, input, PathConstants.AVAILABLE_ATTRIBUTES_FOR_ALL_VARRAY);
    Map<URI, List<VirtualPoolAvailableAttributesResourceRep>> availableAttributes = new HashMap<URI, List<VirtualPoolAvailableAttributesResourceRep>>();
    for (AttributeList attributes : response.getAttributes()) {
        availableAttributes.put(attributes.getVArrayId(), attributes.getAttributes());
    }
    return availableAttributes;
}
Also used : VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) VirtualPoolAvailableAttributesResourceRep(com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep) BulkIdParam(com.emc.storageos.model.BulkIdParam) HashMap(java.util.HashMap) AttributeList(com.emc.storageos.model.varray.AttributeList) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) ResourceUtils.defaultList(com.emc.vipr.client.core.util.ResourceUtils.defaultList) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) AttributeList(com.emc.storageos.model.varray.AttributeList) StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) VirtualArrayConnectivityList(com.emc.storageos.model.varray.VirtualArrayConnectivityList) List(java.util.List) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) URI(java.net.URI)

Example 3 with BulkIdParam

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

the class AutoTieringPolicies method getByVirtualArrays.

/**
 * Gets all auto tier policies for all virtual arrays.
 *
 * @param virtualArrayIds
 *            the ID of the virtual array.
 * @param provisioningType
 *            the provisioning type, if null matches any provisioning type.
 * @param uniqueNames
 *            when true duplicate named policies will be ignored.
 * @param filter
 * @return the list of auto tier policies.
 *
 * @see #getByRefs(java.util.Collection)
 * @see VirtualArrays
 */
public List<AutoTieringPolicyRestRep> getByVirtualArrays(Collection<URI> virtualArrayIds, String provisioningType, Boolean uniqueNames, ResourceFilter<AutoTieringPolicyRestRep> filter) {
    UriBuilder builder = client.uriBuilder(PathConstants.AUTO_TIER_FOR_ALL_VARRAY);
    if ((provisioningType != null) && (provisioningType.length() > 0)) {
        builder.queryParam("provisioning_type", provisioningType);
    }
    if (uniqueNames != null) {
        builder.queryParam("unique_auto_tier_policy_names", uniqueNames);
    }
    BulkIdParam input = new BulkIdParam((List<URI>) virtualArrayIds);
    AutoTierPolicyList response = client.postURI(AutoTierPolicyList.class, input, builder.build());
    return defaultList(getByRefs(response.getAutoTierPolicies(), filter));
}
Also used : AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkIdParam(com.emc.storageos.model.BulkIdParam) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI)

Example 4 with BulkIdParam

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

the class InternalApiTest method testFSReleaseUsingInternalClient.

@Test
public void testFSReleaseUsingInternalClient() throws Exception {
    // get tenant
    TenantResponse tenant = rSys.path("/tenant").get(TenantResponse.class);
    Assert.assertNotNull(tenant);
    // create a project to host a normal file system
    ProjectParam projectParam = new ProjectParam();
    projectParam.setName("test-internalapi-" + System.currentTimeMillis());
    ProjectElement projectResp = rSys.path("/tenants/" + tenant.getTenant().toString() + "/projects").post(ProjectElement.class, projectParam);
    Assert.assertNotNull(projectResp);
    // create a normal file system which we can then release
    FileSystemParam fsparam = new FileSystemParam();
    fsparam.setVpool(_cosId);
    fsparam.setLabel("test-internalapi-" + System.currentTimeMillis());
    fsparam.setVarray(_nhId);
    fsparam.setSize("20971520");
    TaskResourceRep taskResp = rSys.path("/file/filesystems").queryParam("project", projectResp.getId().toString()).post(TaskResourceRep.class, fsparam);
    Assert.assertTrue(taskResp != null);
    Assert.assertNotNull(taskResp.getOpId());
    Assert.assertNotNull(taskResp.getResource());
    URI fsId = taskResp.getResource().getId();
    String opId = taskResp.getOpId();
    // get the file system object we just created
    ClientResponse response = rSys.path("/file/filesystems/" + fsId.toString()).get(ClientResponse.class);
    Assert.assertTrue(response != null);
    Assert.assertEquals(200, response.getStatus());
    // wait for for the file system create to complete
    int checkCount = 1200;
    String status;
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        taskResp = rSys.path("/file/filesystems/" + fsId + "/tasks/" + opId).get(TaskResourceRep.class);
        status = taskResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare create timed out", false);
    }
    // a normal file system should be present in the bulk results
    BulkIdParam bulkIds = rSys.path("/file/filesystems/bulk").get(BulkIdParam.class);
    Assert.assertNotNull("bulk ids should not be null", bulkIds);
    FileShareBulkRep bulkFileShares = rSys.path("/file/filesystems/bulk").post(FileShareBulkRep.class, bulkIds);
    Assert.assertNotNull("bulk response should not be null", bulkFileShares);
    boolean found = false;
    for (FileShareRestRep fs : bulkFileShares.getFileShares()) {
        if (fs.getId().equals(fsId)) {
            found = true;
        }
    }
    Assert.assertTrue("unable to find public FileShare in the bulk results", found);
    // only token is used in release file system operation and hence
    // setting dummy strings for username and tenant ID do not matter
    StorageOSUser user = new StorageOSUser("dummyUserName", "dummyTeneatId");
    user.setToken(_rootToken);
    FileShareRestRep fileShareResponse = _internalFileClient.releaseFileSystem(fsId, user);
    Assert.assertNotNull(fileShareResponse);
    // after release, the file system should no longer be present in the bulk results
    bulkFileShares = rSys.path("/file/filesystems/bulk").post(FileShareBulkRep.class, bulkIds);
    Assert.assertNotNull("bulk response should not be null", bulkFileShares);
    found = false;
    for (FileShareRestRep fs : bulkFileShares.getFileShares()) {
        if (fs.getId().equals(fsId)) {
            found = true;
        }
    }
    Assert.assertFalse("found internal FileShare in the bulk results", found);
    // undo the release of the file system
    fileShareResponse = _internalFileClient.undoReleaseFileSystem(fsId);
    Assert.assertNotNull(fileShareResponse);
    // release it again
    fileShareResponse = _internalFileClient.releaseFileSystem(fsId, user);
    Assert.assertNotNull(fileShareResponse);
    // delete the file system via the internal api
    FileSystemDeleteParam deleteParam = new FileSystemDeleteParam();
    deleteParam.setForceDelete(false);
    taskResp = _internalFileClient.deactivateFileSystem(fsId, _rootToken, deleteParam);
    Assert.assertNotNull(taskResp);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSystemParam(com.emc.storageos.model.file.FileSystemParam) ProjectParam(com.emc.storageos.model.project.ProjectParam) BulkIdParam(com.emc.storageos.model.BulkIdParam) FileShareBulkRep(com.emc.storageos.model.file.FileShareBulkRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) FileSystemDeleteParam(com.emc.storageos.model.file.FileSystemDeleteParam) URI(java.net.URI) ProjectElement(com.emc.storageos.model.project.ProjectElement) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) TenantResponse(com.emc.storageos.model.tenant.TenantResponse) Test(org.junit.Test)

Example 5 with BulkIdParam

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

the class GeoServiceClient method queryObjects.

/**
 * Get the GeoVisible resources with given ids
 *
 * @param clazz the resource type to be queried
 * @param ids List of the resource IDs
 * @return list of resources
 * @throws Exception
 */
public <T extends GeoVisibleResource> Iterator<T> queryObjects(Class<T> clazz, List<URI> ids) throws Exception {
    BulkIdParam param = new BulkIdParam();
    param.setIds(ids);
    WebResource rRoot = createRequest(GEOVISIBLE_URI + clazz.getName() + "/objects");
    rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
    ClientResponse resp = addSignature(rRoot).post(ClientResponse.class, param);
    InputStream input = resp.getEntityInputStream();
    ObjectInputStream objInputStream = new ObjectInputStream(input);
    @SuppressWarnings("unchecked") ResourcesResponse<T> resources = (ResourcesResponse<T>) objInputStream.readObject();
    List<T> list = resources.getObjects();
    return list.iterator();
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) BulkIdParam(com.emc.storageos.model.BulkIdParam) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) WebResource(com.sun.jersey.api.client.WebResource) ResourcesResponse(com.emc.storageos.geomodel.ResourcesResponse) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

BulkIdParam (com.emc.storageos.model.BulkIdParam)15 URI (java.net.URI)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ResourcesResponse (com.emc.storageos.geomodel.ResourcesResponse)2 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 WebResource (com.sun.jersey.api.client.WebResource)2 InputStream (java.io.InputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 MapCustomConfig (com.emc.storageos.api.mapper.functions.MapCustomConfig)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 ComputeFabricUplinkPort (com.emc.storageos.db.client.model.ComputeFabricUplinkPort)1