Search in sources :

Example 1 with ComputeVnic

use of com.emc.storageos.db.client.model.ComputeVnic in project coprhd-controller by CoprHD.

the class ComputeSystemService method isSPTBootDefinitionValid.

private boolean isSPTBootDefinitionValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootDef bootDef) {
    boolean valid = true;
    _log.debug("validating SPT Boot Def " + bootDef.getId().toString());
    if (bootDef.getEnforceVnicVhbaNames() == true) {
        _log.debug("enforce vhba vnic names -- true");
        URIQueryResultList uriVhbas = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
        List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
        URIQueryResultList uriSanBoot = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), uriSanBoot);
        List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
        if (computeSanBoots == null || computeSanBoots.isEmpty()) {
            _log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
            valid = false;
        }
        for (ComputeSanBoot computeSanBoot : computeSanBoots) {
            if (!computeSanBoot.getIsFirstBootDevice()) {
                _log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
                valid = false;
            }
            URIQueryResultList sanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
            List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
            for (ComputeSanBootImage image : sanBootImageList) {
                boolean matched = false;
                for (ComputeElementHBA hba : vhbas) {
                    if (hba.getLabel().equals(image.getVnicName())) {
                        matched = true;
                    }
                }
                if (!matched) {
                    _log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
                    valid = false;
                }
            }
        }
        URIQueryResultList uriVnics = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
        List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
        URIQueryResultList uriLanBoot = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootDef.getId()), uriLanBoot);
        List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
        for (ComputeLanBoot computeLanBoot : computeLanBoots) {
            URIQueryResultList lanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
            List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
            for (ComputeLanBootImagePath image : lanBootImageList) {
                boolean matched = false;
                for (ComputeVnic nic : vnics) {
                    if (nic.getName().equals(image.getVnicName())) {
                        matched = true;
                    }
                }
                if (!matched) {
                    _log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
                    valid = false;
                }
            }
        }
    }
    return valid;
}
Also used : ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) ComputeVnic(com.emc.storageos.db.client.model.ComputeVnic)

Example 2 with ComputeVnic

use of com.emc.storageos.db.client.model.ComputeVnic in project coprhd-controller by CoprHD.

the class ComputeSystemService method isSPTBootPolicyValid.

private boolean isSPTBootPolicyValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootPolicy bootPolicy) {
    boolean valid = true;
    _log.debug("validating SPT Boot Policy" + bootPolicy.getId().toString());
    if (bootPolicy.getEnforceVnicVhbaNames() == true) {
        _log.debug("enforce vhba vnic names -- true");
        URIQueryResultList uriVhbas = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
        List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
        URIQueryResultList uriSanBoot = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), uriSanBoot);
        List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
        if (computeSanBoots == null || computeSanBoots.isEmpty()) {
            _log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
            valid = false;
        }
        for (ComputeSanBoot computeSanBoot : computeSanBoots) {
            if (!computeSanBoot.getIsFirstBootDevice()) {
                _log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
                valid = false;
            }
            URIQueryResultList sanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
            List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
            for (ComputeSanBootImage image : sanBootImageList) {
                boolean matched = false;
                for (ComputeElementHBA hba : vhbas) {
                    if (hba.getLabel().equals(image.getVnicName())) {
                        matched = true;
                    }
                }
                if (!matched) {
                    _log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
                    valid = false;
                }
            }
        }
        URIQueryResultList uriVnics = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
        List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
        URIQueryResultList uriLanBoot = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.getId()), uriLanBoot);
        List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
        for (ComputeLanBoot computeLanBoot : computeLanBoots) {
            URIQueryResultList lanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
            List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
            for (ComputeLanBootImagePath image : lanBootImageList) {
                boolean matched = false;
                for (ComputeVnic nic : vnics) {
                    if (nic.getName().equals(image.getVnicName())) {
                        matched = true;
                    }
                }
                if (!matched) {
                    _log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
                    valid = false;
                }
            }
        }
    }
    return valid;
}
Also used : ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) ComputeVnic(com.emc.storageos.db.client.model.ComputeVnic)

Example 3 with ComputeVnic

use of com.emc.storageos.db.client.model.ComputeVnic 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

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 ComputeVnic (com.emc.storageos.db.client.model.ComputeVnic)3 ComputeElementHBA (com.emc.storageos.db.client.model.ComputeElementHBA)2 ComputeLanBoot (com.emc.storageos.db.client.model.ComputeLanBoot)2 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)2 ComputeSanBoot (com.emc.storageos.db.client.model.ComputeSanBoot)2 ComputeSanBootImage (com.emc.storageos.db.client.model.ComputeSanBootImage)2 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 VnicEther (com.emc.cloud.platform.ucs.out.model.VnicEther)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1