Search in sources :

Example 11 with NamedRelatedResourceRep

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

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

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

the class TaskMapper method toTask.

public static TaskResourceRep toTask(Task task) {
    TaskResourceRep taskResourceRep = new TaskResourceRep();
    mapDataObjectFields(task, taskResourceRep);
    taskResourceRep.setId(task.getId());
    taskResourceRep.setResource(toNamedRelatedResource(task.getResource()));
    // Check to see if there are any associated resources
    List<NamedRelatedResourceRep> associatedRefs = Lists.newArrayList();
    for (URI assocId : task.getAssociatedResourcesList()) {
        DataObject associatedObject = getConfig().getDbClient().queryObject(assocId);
        if (associatedObject != null) {
            associatedRefs.add(toNamedRelatedResource(associatedObject));
        } else {
            log.warn(String.format("For task %s could not find associated object %s", task.getId(), assocId));
        }
    }
    taskResourceRep.setAssociatedResources(associatedRefs);
    if (!StringUtils.isBlank(task.getRequestId())) {
        taskResourceRep.setOpId(task.getRequestId());
    }
    if (task.getWorkflow() != null) {
        taskResourceRep.setWorkflow(toRelatedResource(ResourceTypeEnum.WORKFLOW, task.getWorkflow()));
    }
    if (!task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
        taskResourceRep.setTenant(DbObjectMapper.toRelatedResource(ResourceTypeEnum.TENANT, task.getTenant()));
    }
    // Operation
    taskResourceRep.setState(task.getStatus());
    if (task.getServiceCode() != null) {
        taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
    } else {
        taskResourceRep.setMessage(task.getMessage());
        if (!task.getWarningMessages().isEmpty()) {
            taskResourceRep.setWarningMessages(new ArrayList<String>(task.getWarningMessages()));
        }
    }
    taskResourceRep.setDescription(task.getDescription());
    // COP-23486
    // 
    // This is a workaround to migration post-commit delete source volumes. We would like to be able to
    // mark this Task as one that cannot be rolled back, however at the time there is no framework to
    // detect the state of not being able to rollback, so we will catch this specific situation from the
    // message so we can "flip the flag" of allowable operations by the UI.
    taskResourceRep.setAllowedOperations(Task.AllowedOperations.none_specified.name());
    if (task.getWorkflow() != null) {
        Workflow wf = configInstance.getDbClient().queryObject(Workflow.class, task.getWorkflow());
        if (wf != null && NullColumnValueGetter.isNotNullValue(wf.getCompletionMessage()) && wf.getCompletionMessage().contains("post-migration delete of original source backing volumes")) {
            taskResourceRep.setAllowedOperations(Task.AllowedOperations.retry_only.name());
        }
    }
    taskResourceRep.setStartTime(task.getStartTime());
    taskResourceRep.setEndTime(task.getEndTime());
    taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
    taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
    taskResourceRep.setQueueName(task.getQueueName());
    return taskResourceRep;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Workflow(com.emc.storageos.db.client.model.Workflow) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 14 with NamedRelatedResourceRep

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

the class TaskMapper method toTask.

public static TaskResourceRep toTask(DataObject resource, List<? extends DataObject> assocResources, String taskId, Operation operation) {
    TaskResourceRep task = toTask(resource, taskId, operation);
    List<NamedRelatedResourceRep> associatedReps = new ArrayList<NamedRelatedResourceRep>();
    for (DataObject assoc : assocResources) {
        associatedReps.add(toNamedRelatedResource(assoc));
    }
    task.setAssociatedResources(associatedReps);
    return task;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 15 with NamedRelatedResourceRep

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

the class ComputeMapper method map.

/**
 * Utility mapper method to map fields of {@link ComputeImageServer} columnFamily to {@link ComputeImageServerRestRep} rest
 * representation.
 *
 * @param dbclient
 *            {@link DbClient} instance
 * @param from
 *            {@link ComputeImageServer} instance that has to be mapped.
 * @return {@link ComputeImageServerRestRep}
 */
public static ComputeImageServerRestRep map(DbClient dbclient, ComputeImageServer from) {
    if (from == null) {
        return null;
    }
    ComputeImageServerRestRep to = new ComputeImageServerRestRep();
    mapDataObjectFields(from, to);
    try {
        to.setLink(new RestLinkRep("self", RestLinkFactory.simpleServiceLink(ResourceTypeEnum.COMPUTE_IMAGESERVER, from.getId())));
    } catch (URISyntaxException e) {
        LOG.warn("Error while creating self link URI.", e);
    }
    to.setImageServerIp(from.getImageServerIp());
    to.setImageServerSecondIp(from.getImageServerSecondIp());
    to.setTftpBootDir(from.getTftpBootDir());
    to.setComputeImageServerStatus(from.getComputeImageServerStatus());
    to.setImageServerUser(from.getImageServerUser());
    to.setOsInstallTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getOsInstallTimeoutMs())).intValue());
    to.setSshTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getSshTimeoutMs())).intValue());
    to.setImageImportTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getImageImportTimeoutMs())).intValue());
    to.setComputeImages(new ArrayList<NamedRelatedResourceRep>());
    to.setFailedImages(new ArrayList<NamedRelatedResourceRep>());
    if (from.getComputeImages() != null) {
        for (String computeimage : from.getComputeImages()) {
            ComputeImage image = dbclient.queryObject(ComputeImage.class, URIUtil.uri(computeimage));
            if (image == null) {
                LOG.warn("Could not find compute image in database with id '" + computeimage + "'");
                continue;
            }
            to.getComputeImages().add(DbObjectMapper.toNamedRelatedResource(ResourceTypeEnum.COMPUTE_IMAGE, image.getId(), image.getLabel()));
        }
    }
    if (from.getFailedComputeImages() != null) {
        for (String failedImageID : from.getFailedComputeImages()) {
            ComputeImage failedImage = dbclient.queryObject(ComputeImage.class, URIUtil.uri(failedImageID));
            if (failedImage == null) {
                LOG.warn("Could not find failed compute image in database with id '" + failedImageID + "'");
                continue;
            }
            to.getFailedImages().add(DbObjectMapper.toNamedRelatedResource(ResourceTypeEnum.COMPUTE_IMAGE, failedImage.getId(), failedImage.getLabel()));
        }
    }
    return to;
}
Also used : RestLinkRep(com.emc.storageos.model.RestLinkRep) URISyntaxException(java.net.URISyntaxException) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Aggregations

NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)111 URI (java.net.URI)47 ArrayList (java.util.ArrayList)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)22 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)18 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 HashMap (java.util.HashMap)8 GET (javax.ws.rs.GET)8 Produces (javax.ws.rs.Produces)8 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)7 Path (javax.ws.rs.Path)7 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 SnapshotList (com.emc.storageos.model.SnapshotList)5 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)5 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)5 HashSet (java.util.HashSet)5 List (java.util.List)5