Search in sources :

Example 1 with LsbootSanImage

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

the class UcsDiscoveryWorker method reconcileComputeSanBoot.

private ComputeSanBoot reconcileComputeSanBoot(LsbootStorage lsbootStorage, ComputeSanBoot sanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
    if (sanBoot != null) {
        sanBoot.setLabel(lsbootStorage.getDn());
        if (lsbootStorage.getOrder() != null) {
            sanBoot.setOrder(Integer.valueOf(lsbootStorage.getOrder()));
        }
        _dbClient.persistObject(sanBoot);
    }
    if (sanBoot == null) {
        sanBoot = new ComputeSanBoot();
        URI uriSanBoot = URIUtil.createId(ComputeSanBoot.class);
        sanBoot.setId(uriSanBoot);
        if (bootDef != null) {
            sanBoot.setComputeBootDef(bootDef.getId());
        }
        if (bootPolicy != null) {
            sanBoot.setComputeBootPolicy(bootPolicy.getId());
        }
        sanBoot.setLabel(lsbootStorage.getDn());
        if (lsbootStorage.getOrder() != null) {
            sanBoot.setOrder(Integer.valueOf(lsbootStorage.getOrder()));
        }
        sanBoot.setIsFirstBootDevice(true);
        _dbClient.createObject(sanBoot);
    }
    Map<String, ComputeSanBootImage> computeSanBootImageMap = new HashMap<String, ComputeSanBootImage>();
    URIQueryResultList sanImageUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(sanBoot.getId()), sanImageUris);
    List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
    if (sanBootImageList != null && !sanBootImageList.isEmpty()) {
        for (ComputeSanBootImage image : sanBootImageList) {
            computeSanBootImageMap.put(image.getType(), image);
        }
    }
    if (lsbootStorage.getContent() != null && !lsbootStorage.getContent().isEmpty()) {
        for (Serializable e : lsbootStorage.getContent()) {
            if (e instanceof JAXBElement<?>) {
                if (((JAXBElement) e).getValue() instanceof LsbootSanImage) {
                    LsbootSanImage lsSanImage = (LsbootSanImage) ((JAXBElement) e).getValue();
                    ComputeSanBootImage sanBootImage = computeSanBootImageMap.get(lsSanImage.getType());
                    computeSanBootImageMap.remove(lsSanImage.getType());
                    sanBootImage = reconcileComputeSanBootImage(lsSanImage, sanBootImage, sanBoot);
                }
            }
        }
    }
    deleteComputeSanBootImages(new ArrayList<ComputeSanBootImage>(computeSanBootImageMap.values()));
    return sanBoot;
}
Also used : Serializable(java.io.Serializable) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) HashMap(java.util.HashMap) LsbootSanImage(com.emc.cloud.platform.ucs.out.model.LsbootSanImage) 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)

Example 2 with LsbootSanImage

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

the class UcsDiscoveryWorker method reconcileComputeSanBoot.

private ComputeSanBoot reconcileComputeSanBoot(LsbootSan lsbootSan, ComputeSanBoot sanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
    if (sanBoot != null) {
        sanBoot.setLabel(lsbootSan.getDn());
        if (lsbootSan.getOrder() != null) {
            sanBoot.setOrder(Integer.valueOf(lsbootSan.getOrder()));
        }
        _dbClient.persistObject(sanBoot);
    }
    if (sanBoot == null) {
        sanBoot = new ComputeSanBoot();
        URI uriSanBoot = URIUtil.createId(ComputeSanBoot.class);
        sanBoot.setId(uriSanBoot);
        sanBoot.setLabel(lsbootSan.getDn());
        if (bootDef != null) {
            sanBoot.setComputeBootDef(bootDef.getId());
        }
        if (bootPolicy != null) {
            sanBoot.setComputeBootPolicy(bootPolicy.getId());
        }
        if (lsbootSan.getOrder() != null) {
            sanBoot.setOrder(Integer.valueOf(lsbootSan.getOrder()));
        }
        sanBoot.setIsFirstBootDevice(true);
        _dbClient.createObject(sanBoot);
    }
    Map<String, ComputeSanBootImage> computeSanBootImageMap = new HashMap<String, ComputeSanBootImage>();
    URIQueryResultList sanImageUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(sanBoot.getId()), sanImageUris);
    List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
    if (sanBootImageList != null && !sanBootImageList.isEmpty()) {
        for (ComputeSanBootImage image : sanBootImageList) {
            computeSanBootImageMap.put(image.getType(), image);
        }
    }
    if (lsbootSan.getContent() != null && !lsbootSan.getContent().isEmpty()) {
        for (Serializable e : lsbootSan.getContent()) {
            if (e instanceof JAXBElement<?>) {
                if (((JAXBElement) e).getValue() instanceof LsbootSanImage) {
                    LsbootSanImage lsSanImage = (LsbootSanImage) ((JAXBElement) e).getValue();
                    ComputeSanBootImage sanBootImage = computeSanBootImageMap.get(lsSanImage.getType());
                    computeSanBootImageMap.remove(lsSanImage.getType());
                    sanBootImage = reconcileComputeSanBootImage(lsSanImage, sanBootImage, sanBoot);
                }
            }
        }
    }
    deleteComputeSanBootImages(new ArrayList<ComputeSanBootImage>(computeSanBootImageMap.values()));
    return sanBoot;
}
Also used : Serializable(java.io.Serializable) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) HashMap(java.util.HashMap) LsbootSanImage(com.emc.cloud.platform.ucs.out.model.LsbootSanImage) 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

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