Search in sources :

Example 6 with ComputeSanBootImage

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

the class UcsDiscoveryWorker method deleteComputeSanBootImages.

private void deleteComputeSanBootImages(List<ComputeSanBootImage> sanBootImageList) {
    List<ComputeSanBootImage> removeSanBootImages = new ArrayList<ComputeSanBootImage>();
    for (ComputeSanBootImage image : sanBootImageList) {
        URIQueryResultList sanImagePathUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(image.getId()), sanImagePathUris);
        List<ComputeSanBootImagePath> sanBootPathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
        if (sanBootPathList != null && !sanBootPathList.isEmpty()) {
            deleteComputeSanBootImagePaths(sanBootPathList);
        }
        removeSanBootImages.add(image);
    }
    deleteDataObjects(new ArrayList<DataObject>(removeSanBootImages));
}
Also used : ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ArrayList(java.util.ArrayList) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 7 with ComputeSanBootImage

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

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

Example 9 with ComputeSanBootImage

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

the class UcsDiscoveryWorker method deleteComputeSanBoot.

private void deleteComputeSanBoot(List<ComputeSanBoot> sanBootList) {
    List<ComputeSanBoot> removeSanBoots = new ArrayList<ComputeSanBoot>();
    for (ComputeSanBoot sanBoot : sanBootList) {
        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()) {
            deleteComputeSanBootImages(sanBootImageList);
        }
        removeSanBoots.add(sanBoot);
    }
    deleteDataObjects(new ArrayList<DataObject>(removeSanBoots));
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) ArrayList(java.util.ArrayList) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 ComputeSanBootImage (com.emc.storageos.db.client.model.ComputeSanBootImage)9 ComputeSanBoot (com.emc.storageos.db.client.model.ComputeSanBoot)6 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)4 ComputeLanBoot (com.emc.storageos.db.client.model.ComputeLanBoot)3 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)3 DataObject (com.emc.storageos.db.client.model.DataObject)3 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)3 Serializable (java.io.Serializable)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 JAXBElement (javax.xml.bind.JAXBElement)3 LsbootSanImage (com.emc.cloud.platform.ucs.out.model.LsbootSanImage)2 ComputeElementHBA (com.emc.storageos.db.client.model.ComputeElementHBA)2 ComputeVnic (com.emc.storageos.db.client.model.ComputeVnic)2 LsbootSanImagePath (com.emc.cloud.platform.ucs.out.model.LsbootSanImagePath)1 ComputeBootPolicy (com.emc.storageos.db.client.model.ComputeBootPolicy)1 StringSet (com.emc.storageos.db.client.model.StringSet)1