Search in sources :

Example 1 with ComputeElementHBA

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

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

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

the class UcsComputeDevice method getInitiatorToHBAMapping.

private Map<String, String> getInitiatorToHBAMapping(URI computeElement) {
    Map<String, String> hostInitiatorToHBAMapping = new HashMap<String, String>();
    List<ComputeElementHBA> hbas = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, computeElement, ComputeElementHBA.class, "computeElement");
    for (ComputeElementHBA hba : hbas) {
        hostInitiatorToHBAMapping.put(hba.getPort(), hba.getLabel());
    }
    return hostInitiatorToHBAMapping;
}
Also used : HashMap(java.util.HashMap) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA)

Example 4 with ComputeElementHBA

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

the class UcsComputeDevice method removeHostInitiatorsFromNetworks.

/**
 * Gets rid of the Initiators that were added to network. Also gets rid of
 * the ComputeElementHBAs that were created when the service profile was
 * bound to the host
 *
 * @param host
 */
private void removeHostInitiatorsFromNetworks(Host host) {
    URIQueryResultList ceHBAUriList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getHostComputeElemetHBAsConstraint(host.getId()), ceHBAUriList);
    Set<Network> networks = new HashSet<Network>();
    List<String> endpoints = new ArrayList<String>();
    List<ComputeElementHBA> computeElementHBAs = _dbClient.queryObject(ComputeElementHBA.class, ceHBAUriList, true);
    for (ComputeElementHBA computeElementHBA : computeElementHBAs) {
        endpoints.add(computeElementHBA.getPort());
        networks.addAll(CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, Network.class, "nativeId", computeElementHBA.getVsanId()));
        _dbClient.markForDeletion(computeElementHBA);
    }
    for (Network network : networks) {
        Collection<String> removedEndpoints = network.removeEndpoints(endpoints);
        NetworkAssociationHelper.handleEndpointsRemoved(network, removedEndpoints, _dbClient, _coordinator);
    }
    _dbClient.persistObject(networks);
}
Also used : Network(com.emc.storageos.db.client.model.Network) ArrayList(java.util.ArrayList) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 5 with ComputeElementHBA

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

the class UcsDiscoveryWorker method reconcileVhbas.

private void reconcileVhbas(ComputeSystem cs, Map<String, LsServer> associatedLsServers, VhbaHelper lookUpVsan) {
    _log.info("Reconciling Vhbas");
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), uris);
    List<ComputeElement> elements = _dbClient.queryObject(ComputeElement.class, uris, true);
    for (ComputeElement computeElement : elements) {
        Map<String, ComputeElementHBA> removeVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> addVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> updateVhbas = new HashMap<>();
        URIQueryResultList uriVhbas = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeElementComputeElemetHBAsConstraint(computeElement.getId()), uriVhbas);
        List<ComputeElementHBA> vbhas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
        for (ComputeElementHBA hba : vbhas) {
            removeVhbas.put(hba.getLabel(), hba);
        }
        LsServer lsServer = associatedLsServers.get(computeElement.getLabel());
        if (lsServer != null && lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
            for (Serializable contentElement : lsServer.getContent()) {
                if (contentElement instanceof JAXBElement<?> && ((JAXBElement) contentElement).getValue() instanceof VnicFc) {
                    VnicFc vnicFc = (VnicFc) ((JAXBElement) contentElement).getValue();
                    ComputeElementHBA hba = removeVhbas.get(vnicFc.getName());
                    if (hba != null) {
                        updateVhbas.put(vnicFc.getName(), hba);
                        removeVhbas.remove(hba.getLabel());
                        updateComputeElementHBA(hba, vnicFc);
                    } else {
                        hba = new ComputeElementHBA();
                        addVhbas.put(vnicFc.getName(), hba);
                        createComputeElementHBA(cs, computeElement, hba, vnicFc);
                    }
                }
            }
        }
        createDataObjects(new ArrayList<DataObject>(addVhbas.values()));
        persistDataObjects(new ArrayList<DataObject>(updateVhbas.values()));
        // Do not delete vHBAs that are still linked to the ViPR host
        Iterator<Map.Entry<String, ComputeElementHBA>> vhbaIterator = removeVhbas.entrySet().iterator();
        while (vhbaIterator.hasNext()) {
            Map.Entry<String, ComputeElementHBA> entry = vhbaIterator.next();
            if (entry.getValue().getHost() != null) {
                vhbaIterator.remove();
            } else {
                _log.info("vHBA is marked for deletion {}", entry.getKey());
            }
        }
        deleteDataObjects(new ArrayList<DataObject>(removeVhbas.values()));
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) JAXBElement(javax.xml.bind.JAXBElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VnicFc(com.emc.cloud.platform.ucs.out.model.VnicFc) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ComputeElementHBA (com.emc.storageos.db.client.model.ComputeElementHBA)9 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)8 ArrayList (java.util.ArrayList)4 VnicFc (com.emc.cloud.platform.ucs.out.model.VnicFc)3 Network (com.emc.storageos.db.client.model.Network)3 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)3 HashMap (java.util.HashMap)3 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)2 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)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 ComputeVnic (com.emc.storageos.db.client.model.ComputeVnic)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 Serializable (java.io.Serializable)2 HashSet (java.util.HashSet)2 List (java.util.List)2 JAXBElement (javax.xml.bind.JAXBElement)2