Search in sources :

Example 1 with ComputeVirtualPoolRestRep

use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep 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 2 with ComputeVirtualPoolRestRep

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

the class ComputeVirtualPools method listElements.

public static void listElements(String computePoolId) {
    ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(computePoolId);
    ComputeVirtualPoolElementDataTable dataTable = new ComputeVirtualPoolElementDataTable();
    render("@listElements", computeVirtualPool, dataTable);
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) ComputeVirtualPoolElementDataTable(models.datatable.ComputeVirtualPoolElementDataTable)

Example 3 with ComputeVirtualPoolRestRep

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

the class ComputeVirtualPools method getServiceProfileTemplates.

public static void getServiceProfileTemplates(ComputeVirtualPoolsForm computeVirtualPool) {
    List<ComputeSystemRestRep> allComputes = Lists.newArrayList();
    List<StringOption> templateList = Lists.newArrayList();
    List<String> temps = Lists.newArrayList();
    if (computeVirtualPool.id != null) {
        ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(computeVirtualPool.id);
        for (NamedRelatedResourceRep tmp : computePool.getServiceProfileTemplates()) {
            temps.add(tmp.getId().toString());
        }
    }
    Map<String, Set<String>> csTemplatesMap = new HashMap<String, Set<String>>();
    Map<String, String> computeSystemsMap = new HashMap<String, String>();
    Map<String, String> templatesMap = new HashMap<String, String>();
    if (computeVirtualPool.virtualArrays != null) {
        for (String arrayId : computeVirtualPool.virtualArrays) {
            List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(uri(arrayId));
            for (ComputeSystemRestRep acomp : arrayComputes) {
                String compId = acomp.getId().toString();
                if (!computeSystemsMap.containsKey(compId)) {
                    computeSystemsMap.put(compId, acomp.getName());
                }
                Set<String> spts = csTemplatesMap.get(compId);
                if (spts == null) {
                    spts = new HashSet<String>();
                }
                for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
                    spts.add(spt.getId().toString());
                    if (!templatesMap.containsKey(spt.getId().toString())) {
                        templatesMap.put(spt.getId().toString(), spt.getName());
                    }
                }
                csTemplatesMap.put(compId, spts);
            }
        }
        for (Entry<String, Set<String>> comp : csTemplatesMap.entrySet()) {
            Set<String> compTemplates = comp.getValue();
            if (compTemplates != null && !compTemplates.isEmpty()) {
                String systemName = ComputeSystemTypes.getDisplayValue(ComputeSystemTypes.UCS) + " " + computeSystemsMap.get(comp.getKey());
                computeVirtualPool.systems.add(new StringOption(comp.getKey(), systemName));
                List<StringOption> templateOptions = Lists.newArrayList();
                templateOptions.add(new StringOption("NONE", ""));
                for (String template : compTemplates) {
                    templateOptions.add(new StringOption(template, templatesMap.get(template)));
                    if (!temps.isEmpty()) {
                        for (String templateId : temps) {
                            if (templateId.contains(template)) {
                                templateList.add(new StringOption(comp.getKey(), template));
                            }
                        }
                    }
                }
                computeVirtualPool.systemOptions.put(comp.getKey(), templateOptions);
            }
        }
        computeVirtualPool.selectedTemplates = "{}";
        if (!templateList.isEmpty()) {
            String jsonString = "{\"";
            for (int index = 0; index < templateList.size(); index++) {
                if (jsonString.indexOf("urn") > 0) {
                    jsonString = jsonString + ",\"";
                }
                jsonString = jsonString + templateList.get(index).id + "\":\"" + templateList.get(index).name + "\"";
            }
            jsonString = jsonString + "}";
            computeVirtualPool.selectedTemplates = jsonString;
        }
    } else {
        computeVirtualPool.selectedTemplates = "{}";
    }
    render("@templates", computeVirtualPool);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) StringOption(util.StringOption) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 4 with ComputeVirtualPoolRestRep

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

the class ComputeVirtualPools method save.

public static void save(ComputeVirtualPoolsForm computeVirtualPool) {
    try {
        computeVirtualPool.validate("computeVirtualPool");
        if (Validation.hasErrors()) {
            Logger.info("has errors error: %s", Validation.errors().toString());
            handleError(computeVirtualPool);
        }
        ComputeVirtualPoolRestRep vpool = computeVirtualPool.save();
        if (TenantUtils.canReadAllTenants() && VirtualPoolUtils.canUpdateACLs()) {
            saveTenantACLs(vpool.getId().toString(), computeVirtualPool.tenants, computeVirtualPool.enableTenants);
        }
        flash.success(MessagesUtils.get(SAVED, computeVirtualPool.name));
        list();
    } catch (Exception e) {
        flashException(e);
        handleError(computeVirtualPool);
    }
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) Common.flashException(controllers.Common.flashException) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 5 with ComputeVirtualPoolRestRep

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

the class ComputeVirtualPools method edit.

public static void edit(String id) {
    try {
        addReferenceData();
        ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
        if (computeVirtualPool == null) {
            flash.error(MessagesUtils.get(UNKNOWN, id));
            list();
        }
        ComputeVirtualPoolsForm form = new ComputeVirtualPoolsForm(computeVirtualPool);
        form.loadTenant(computeVirtualPool);
        edit(form);
    } catch (Exception e) {
        flashException(e);
        list();
    }
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) Common.flashException(controllers.Common.flashException) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

ComputeVirtualPoolRestRep (com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)16 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)3 Asset (com.emc.sa.asset.annotation.Asset)2 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 ViPRException (com.emc.vipr.client.exceptions.ViPRException)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 Common.flashException (controllers.Common.flashException)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 ComputeVirtualPoolElementDataTable (models.datatable.ComputeVirtualPoolElementDataTable)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)1 VirtualArrayCreateParam (com.emc.storageos.model.varray.VirtualArrayCreateParam)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 ComputeVirtualPoolCreateParam (com.emc.storageos.model.vpool.ComputeVirtualPoolCreateParam)1 ComputeVirtualPoolList (com.emc.storageos.model.vpool.ComputeVirtualPoolList)1 ComputeVirtualPoolUpdateParam (com.emc.storageos.model.vpool.ComputeVirtualPoolUpdateParam)1