Search in sources :

Example 1 with LsbootSanImagePath

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

the class UcsDiscoveryWorker method reconcileComputeSanBootImage.

private ComputeSanBootImage reconcileComputeSanBootImage(LsbootSanImage sanImage, ComputeSanBootImage computeSanImage, ComputeSanBoot sanBoot) {
    if (computeSanImage != null) {
        computeSanImage.setDn(sanImage.getDn());
        computeSanImage.setVnicName(sanImage.getVnicName());
        _dbClient.persistObject(computeSanImage);
    }
    if (computeSanImage == null) {
        computeSanImage = new ComputeSanBootImage();
        URI uriSanBootImage = URIUtil.createId(ComputeSanBootImage.class);
        computeSanImage.setId(uriSanBootImage);
        computeSanImage.setType(sanImage.getType());
        computeSanImage.setVnicName(sanImage.getVnicName());
        computeSanImage.setDn(sanImage.getDn());
        computeSanImage.setComputeSanBoot(sanBoot.getId());
        _dbClient.createObject(computeSanImage);
    }
    Map<String, ComputeSanBootImagePath> computeSanBootImagePathMap = new HashMap<String, ComputeSanBootImagePath>();
    URIQueryResultList sanImagePathUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(computeSanImage.getId()), sanImagePathUris);
    List<ComputeSanBootImagePath> sanBootPathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
    if (sanBootPathList != null && !sanBootPathList.isEmpty()) {
        for (ComputeSanBootImagePath sanBootImagePath : sanBootPathList) {
            computeSanBootImagePathMap.put(sanBootImagePath.getType(), sanBootImagePath);
        }
    }
    if (sanImage.getContent() != null && !sanImage.getContent().isEmpty()) {
        for (Serializable e2 : sanImage.getContent()) {
            if (e2 instanceof JAXBElement<?>) {
                if (((JAXBElement) e2).getValue() instanceof LsbootSanImagePath) {
                    LsbootSanImagePath lsSanImagePath = (LsbootSanImagePath) ((JAXBElement) e2).getValue();
                    ComputeSanBootImagePath sanBootImagePath = computeSanBootImagePathMap.get(lsSanImagePath.getType());
                    computeSanBootImagePathMap.remove(lsSanImagePath.getType());
                    sanBootImagePath = reconcileComputeSanBootImagePath(lsSanImagePath, sanBootImagePath, computeSanImage);
                }
            }
        }
    }
    deleteComputeSanBootImagePaths(new ArrayList<ComputeSanBootImagePath>(computeSanBootImagePathMap.values()));
    return computeSanImage;
}
Also used : ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) LsbootSanImagePath(com.emc.cloud.platform.ucs.out.model.LsbootSanImagePath) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) JAXBElement(javax.xml.bind.JAXBElement) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

LsbootSanImagePath (com.emc.cloud.platform.ucs.out.model.LsbootSanImagePath)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ComputeSanBootImage (com.emc.storageos.db.client.model.ComputeSanBootImage)1 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)1 Serializable (java.io.Serializable)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 JAXBElement (javax.xml.bind.JAXBElement)1