Search in sources :

Example 6 with ComputeSystemRestRep

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

the class ComputeSystemServiceApiTest method deactivateComputeSystem.

private Boolean deactivateComputeSystem(ComputeSystemRestRep cs) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InterruptedException {
    if (cs == null) {
        System.out.println("Unable to run the test as there's no Compute System to run the test against");
        return false;
    }
    System.out.println("De-activating compute element: " + BeanUtils.describe(cs));
    TaskResourceRep deactivateTask = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + cs.getId() + DEACTIVATE_RELATIVE_PATH).post(TaskResourceRep.class);
    System.out.println("Waiting for compute element deactivation: ");
    Thread.sleep(60000 / 8);
    cs = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + cs.getId()).get(ComputeSystemRestRep.class);
    if (cs.getInactive().booleanValue() == false) {
        return false;
    }
    System.out.println("Compute System should be deleted from the system! Safe to run the test over...");
    return true;
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 7 with ComputeSystemRestRep

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

the class HostService method findComputeElementsMatchingVarrayAndCVP.

/*
     * Returns a map of compute system URI to compute elements available on that compute system
     */
private Map<URI, List<URI>> findComputeElementsMatchingVarrayAndCVP(ComputeVirtualPool cvp, VirtualArray varray) {
    Map<URI, List<URI>> computeSystemToComputeElementsMap = new HashMap<URI, List<URI>>();
    _log.debug("Look up compute elements for cvp " + cvp.getId());
    List<String> cvpCEList = new ArrayList<String>();
    if (cvp.getMatchedComputeElements() != null) {
        Iterator<String> iter = cvp.getMatchedComputeElements().iterator();
        while (iter.hasNext()) {
            String uriStr = iter.next();
            cvpCEList.add(uriStr);
        }
    }
    // Find all SPTs assigned for this CVP and their corresponding ComputeSystems
    Map<URI, URI> cvpTemplatesMap = new HashMap<URI, URI>();
    if (cvp.getServiceProfileTemplates() != null) {
        for (String templateIdString : cvp.getServiceProfileTemplates()) {
            URI templateId = URI.create(templateIdString);
            UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, templateId);
            if (template.getUpdating() == true) {
                if (!computeSystemService.isUpdatingSPTValid(template, _dbClient)) {
                    throw APIException.badRequests.invalidUpdatingSPT(template.getLabel());
                }
                StringSet varrayIds = new StringSet();
                varrayIds.add(varray.getId().toString());
                if (!computeSystemService.isServiceProfileTemplateValidForVarrays(varrayIds, templateId)) {
                    throw APIException.badRequests.incompatibleSPT(template.getLabel(), varray.getLabel());
                }
            }
            cvpTemplatesMap.put(template.getComputeSystem(), templateId);
        }
    }
    _log.debug("Look up compute systems for virtual array " + varray.getId());
    ComputeSystemBulkRep computeSystemBulkRep = virtualArrayService.getComputeSystems(varray.getId());
    if (computeSystemBulkRep.getComputeSystems() != null) {
        for (ComputeSystemRestRep computeSystemRestRep : computeSystemBulkRep.getComputeSystems()) {
            _log.debug("Found compute system " + computeSystemRestRep.getId() + " for virtual array " + varray.getId());
            if (!cvpTemplatesMap.containsKey(computeSystemRestRep.getId())) {
                _log.info("The CVP has no service profile templates assigned from compute system " + computeSystemRestRep.getName() + ". So no blades will be used from this compute system.");
                continue;
            }
            ComputeElementListRestRep computeElementListRestRep = computeSystemService.getComputeElements(computeSystemRestRep.getId());
            if (computeElementListRestRep.getList() != null) {
                List<URI> computeElementList = new ArrayList<URI>();
                for (ComputeElementRestRep computeElementRestRep : computeElementListRestRep.getList()) {
                    _log.debug("Compute system contains compute element " + computeElementRestRep.getId());
                    for (String computeElement : cvpCEList) {
                        if (computeElement.equals(computeElementRestRep.getId().toString())) {
                            if (computeElementRestRep.getAvailable() && computeElementRestRep.getRegistrationStatus().equals(RegistrationStatus.REGISTERED.name())) {
                                computeElementList.add(computeElementRestRep.getId());
                                _log.debug("Added compute element " + computeElementRestRep.getId());
                            } else {
                                _log.debug("found unavailable compute element" + computeElementRestRep.getId());
                            }
                        }
                    }
                }
                computeSystemToComputeElementsMap.put(computeSystemRestRep.getId(), computeElementList);
            }
        }
    } else {
        throw APIException.badRequests.noComputeSystemsFoundForVarray();
    }
    return computeSystemToComputeElementsMap;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI) ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) StringSet(com.emc.storageos.db.client.model.StringSet) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) UnManagedExportMaskList(com.emc.storageos.model.block.UnManagedExportMaskList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InitiatorList(com.emc.storageos.model.host.InitiatorList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) MountInfoList(com.emc.storageos.model.file.MountInfoList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) LinkedList(java.util.LinkedList) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 8 with ComputeSystemRestRep

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

the class ComputeVirtualPoolService method findComputeElementsFromDeviceAssociations.

private List<URI> findComputeElementsFromDeviceAssociations(ComputeVirtualPool computeVirtualPool) {
    // Get CEs from associated varrays
    List<URI> ceList = new ArrayList<URI>();
    if (computeVirtualPool.getVirtualArrays() != null) {
        for (String virtualArrayId : computeVirtualPool.getVirtualArrays()) {
            URI virtualArrayURI = URI.create(virtualArrayId);
            ArgValidator.checkUri(virtualArrayURI);
            this.queryObject(VirtualArray.class, virtualArrayURI, true);
            _log.debug("Look up compute systems for virtual array " + virtualArrayURI);
            ComputeSystemBulkRep computeSystemBulkRep = virtualArrayService.getComputeSystems(virtualArrayURI);
            if (computeSystemBulkRep.getComputeSystems() != null) {
                for (ComputeSystemRestRep computeSystemRestRep : computeSystemBulkRep.getComputeSystems()) {
                    _log.debug("Found compute system " + computeSystemRestRep.getId() + " for virtual array " + virtualArrayURI);
                    ComputeElementListRestRep computeElementListRestRep = computeSystemService.getComputeElements(computeSystemRestRep.getId());
                    if (computeElementListRestRep.getList() != null) {
                        for (ComputeElementRestRep computeElementRestRep : computeElementListRestRep.getList()) {
                            _log.debug("Compute system contains compute element " + computeElementRestRep.getId());
                            ceList.add(computeElementRestRep.getId());
                        }
                    }
                }
            }
        }
    }
    return ceList;
}
Also used : ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) ArrayList(java.util.ArrayList) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI)

Example 9 with ComputeSystemRestRep

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

the class ComputeSystems method edit.

public static void edit(String id) {
    try {
        addReferenceData();
        ComputeSystemRestRep computeSystem = ComputeSystemUtils.getComputeSystem(id);
        if (computeSystem != null) {
            if (computeSystem.getVlans() != null) {
                List<StringOption> vlanOptions = new ArrayList<StringOption>();
                vlanOptions.add(VlanListTypes.option(VlanListTypes.NO_OSINSTALL_NONE));
                List<String> vlanList = new ArrayList<String>(Arrays.asList(computeSystem.getVlans().split(",")));
                for (String vlan : vlanList) {
                    vlanOptions.add(VlanListTypes.option(vlan));
                }
                renderArgs.put("computeSystemVlanList", vlanOptions);
            }
            List<StringOption> computeImageServerOptions = new ArrayList<StringOption>();
            computeImageServerOptions.add(ComputeImageServerListTypes.option(ComputeImageServerListTypes.NO_COMPUTE_IMAGE_SERVER_NONE));
            List<ComputeImageServerRestRep> computeImageServersList = ComputeImageServerUtils.getComputeImageServers();
            if (computeImageServersList != null) {
                List<String> computeImageServersArrayList = new ArrayList<String>();
                for (ComputeImageServerRestRep cisrr : computeImageServersList) {
                    if (cisrr.getComputeImageServerStatus().equalsIgnoreCase(AVAILABLE)) {
                        computeImageServersArrayList.add(cisrr.getName());
                    }
                }
                for (String imageServerId : computeImageServersArrayList) {
                    computeImageServerOptions.add(ComputeImageServerListTypes.option(imageServerId));
                }
                renderArgs.put("availableComputeImageServersList", computeImageServerOptions);
            }
            ComputeSystemForm computeSystems = new ComputeSystemForm(computeSystem);
            render("@edit", computeSystems);
        } else {
            flash.error(MessagesUtils.get(UNKNOWN, id));
            list();
        }
    } catch (Exception e) {
        flashException(e);
        list();
    }
}
Also used : StringOption(util.StringOption) ArrayList(java.util.ArrayList) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) Common.flashException(controllers.Common.flashException) URISyntaxException(java.net.URISyntaxException) FlashException(controllers.util.FlashException) ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep)

Example 10 with ComputeSystemRestRep

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

the class ComputeSystems method listElements.

public static void listElements(String computeSystemId) {
    ComputeSystemRestRep computeSystem = ComputeSystemUtils.getComputeSystem(computeSystemId);
    ComputeSystemElementDataTable dataTable = new ComputeSystemElementDataTable();
    render("@listElements", computeSystem, dataTable);
}
Also used : ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) ComputeSystemElementDataTable(models.datatable.ComputeSystemElementDataTable)

Aggregations

ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)12 ArrayList (java.util.ArrayList)6 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)3 ComputeSystemBulkRep (com.emc.storageos.model.compute.ComputeSystemBulkRep)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)2 ComputeVirtualPoolRestRep (com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ComputeSystemElementDataTable (models.datatable.ComputeSystemElementDataTable)2 StringOption (util.StringOption)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 TaskList (com.emc.storageos.model.TaskList)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1