Search in sources :

Example 1 with VnicEther

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

the class UcsDiscoveryWorker method getServiceProfileTemplateDetails.

private Map<String, Object> getServiceProfileTemplateDetails(LsServer spt) {
    Map<String, Object> serviceProfileTemplateDetails = new HashMap<>();
    int vhbaCount = 0;
    int vnicCount = 0;
    List<VnicEther> vnics = new ArrayList<>();
    List<VnicFc> vhbas = new ArrayList<>();
    if (spt.getContent() != null && !spt.getContent().isEmpty()) {
        for (Serializable element : spt.getContent()) {
            if (element instanceof JAXBElement<?>) {
                if (((JAXBElement) element).getValue() instanceof LsRequirement) {
                    LsRequirement lsRequirement = (LsRequirement) ((JAXBElement) element).getValue();
                    serviceProfileTemplateDetails.put("associatedServerPool", lsRequirement.getName());
                } else if (((JAXBElement) element).getValue() instanceof VnicEther) {
                    vnics.add(((VnicEther) ((JAXBElement) element).getValue()));
                    vnicCount++;
                } else if (((JAXBElement) element).getValue() instanceof VnicFc) {
                    vhbas.add(((VnicFc) ((JAXBElement) element).getValue()));
                    vhbaCount++;
                } else if (((JAXBElement) element).getValue() instanceof LsbootDef) {
                    LsbootDef lsbootDef = (LsbootDef) ((JAXBElement) element).getValue();
                    serviceProfileTemplateDetails.put("associatedBootPolicy", lsbootDef);
                }
            }
        }
        serviceProfileTemplateDetails.put("vhbaCount", vhbaCount);
        serviceProfileTemplateDetails.put("vnicCount", vnicCount);
        serviceProfileTemplateDetails.put("vhbas", vhbas);
        serviceProfileTemplateDetails.put("vnics", vnics);
    }
    return serviceProfileTemplateDetails;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VnicEther(com.emc.cloud.platform.ucs.out.model.VnicEther) JAXBElement(javax.xml.bind.JAXBElement) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) VnicFc(com.emc.cloud.platform.ucs.out.model.VnicFc) LsRequirement(com.emc.cloud.platform.ucs.out.model.LsRequirement) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) LsbootDef(com.emc.cloud.platform.ucs.out.model.LsbootDef)

Example 2 with VnicEther

use of com.emc.cloud.platform.ucs.out.model.VnicEther 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

VnicEther (com.emc.cloud.platform.ucs.out.model.VnicEther)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LsRequirement (com.emc.cloud.platform.ucs.out.model.LsRequirement)1 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 LsbootDef (com.emc.cloud.platform.ucs.out.model.LsbootDef)1 VnicFc (com.emc.cloud.platform.ucs.out.model.VnicFc)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ComputeVnic (com.emc.storageos.db.client.model.ComputeVnic)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 Serializable (java.io.Serializable)1 List (java.util.List)1 JAXBElement (javax.xml.bind.JAXBElement)1