Search in sources :

Example 36 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileServiceProfileTemplates.

private void reconcileServiceProfileTemplates(ComputeSystem cs, List<LsServer> serviceProfileTemplates) {
    _log.info("Reconciling ServiceProfileTemplates");
    Map<String, UCSServiceProfileTemplate> removeTemplates = new HashMap<>();
    Map<String, UCSServiceProfileTemplate> updateTemplates = new HashMap<>();
    Map<String, UCSServiceProfileTemplate> addTemplates = new HashMap<>();
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceTemplate : serviceTemplates) {
        removeTemplates.put(serviceTemplate.getDn(), serviceTemplate);
    }
    // discovered data
    for (LsServer lsServer : serviceProfileTemplates) {
        UCSServiceProfileTemplate spt = removeTemplates.get(lsServer.getDn());
        if (spt != null) {
            updateTemplates.put(lsServer.getDn(), spt);
            removeTemplates.remove(spt.getDn());
            updateUCSServiceProfileTemplate(spt, lsServer);
        } else {
            spt = new UCSServiceProfileTemplate();
            addTemplates.put(lsServer.getDn(), spt);
            createUCSServiceProfileTemplate(cs, spt, lsServer);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addTemplates.values()));
    persistDataObjects(new ArrayList<DataObject>(updateTemplates.values()));
    for (String profileName : removeTemplates.keySet()) {
        _log.info("Marked for deletion UCSServiceProfileTemplate: " + profileName);
    }
    // Handle SPTs that are removed on the device.
    // Step1: Remove all references to the SPT in the Compute Virtual Pool.
    // Step2: Delete the SPT from the list of existing SPTs.
    removeServiceProfileTemplatesFromComputeVirtualPool(removeTemplates.values());
    deleteDataObjects(new ArrayList<DataObject>(removeTemplates.values()));
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 37 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesVnics.

private void reconcileServiceProfileTemplatesVnics(ComputeSystem cs, List<LsServer> lsServers) {
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    Map<String, LsServer> lsServerMap = new HashMap<>();
    for (LsServer lsServer : lsServers) {
        lsServerMap.put(lsServer.getDn(), lsServer);
    }
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceProfileTemplate : serviceTemplates) {
        LsServer lsServer = lsServerMap.get(serviceProfileTemplate.getDn());
        if (lsServer == null) {
            continue;
        }
        Map<String, Object> serviceProfileTemplateDetails = getServiceProfileTemplateDetails(lsServer);
        Map<String, ComputeVnic> removeVnics = new HashMap<>();
        Map<String, ComputeVnic> addVnics = new HashMap<>();
        Map<String, ComputeVnic> updateVnics = new HashMap<>();
        URIQueryResultList uriVnics = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
        List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
        for (ComputeVnic vnic : vnics) {
            removeVnics.put(vnic.getName(), vnic);
        }
        for (VnicEther vnic : (List<VnicEther>) serviceProfileTemplateDetails.get("vnics")) {
            ComputeVnic nic = removeVnics.get(vnic.getName());
            if (nic != null) {
                updateVnics.put(vnic.getName(), nic);
                removeVnics.remove(nic.getLabel());
                updateComputeVnics(nic, vnic);
            } else {
                nic = new ComputeVnic();
                addVnics.put(vnic.getName(), nic);
                createComputeVnics(serviceProfileTemplate, nic, vnic);
            }
        }
        createDataObjects(new ArrayList<DataObject>(addVnics.values()));
        persistDataObjects(new ArrayList<DataObject>(updateVnics.values()));
        for (String name : removeVnics.keySet()) {
            _log.info("Marked for deletion ComputeElementHBA: " + name);
        }
        deleteDataObjects(new ArrayList<DataObject>(removeVnics.values()));
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) VnicEther(com.emc.cloud.platform.ucs.out.model.VnicEther) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeVnic(com.emc.storageos.db.client.model.ComputeVnic) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)37 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)20 ConfigConfMo (com.emc.cloud.platform.ucs.in.model.ConfigConfMo)9 ConfigConfig (com.emc.cloud.platform.ucs.in.model.ConfigConfig)9 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)9 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)9 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 MalformedURLException (java.net.MalformedURLException)9 HashMap (java.util.HashMap)9 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)8 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 DataObject (com.emc.storageos.db.client.model.DataObject)7 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)7 JAXBElement (javax.xml.bind.JAXBElement)7 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)6 ConfigSet (com.emc.cloud.platform.ucs.out.model.ConfigSet)5 Test (org.testng.annotations.Test)5 ConfigResolveClass (com.emc.cloud.platform.ucs.in.model.ConfigResolveClass)4 EqFilter (com.emc.cloud.platform.ucs.in.model.EqFilter)3