Search in sources :

Example 6 with ComputeSanBoot

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

the class UcsDiscoveryWorker method updateComputeBootPolicy.

private void updateComputeBootPolicy(ComputeBootPolicy bootPolicy, LsbootPolicy lsBootPolicy) {
    bootPolicy.setDn(lsBootPolicy.getDn());
    bootPolicy.setName(lsBootPolicy.getName());
    if (lsBootPolicy.getEnforceVnicName().equals("yes")) {
        bootPolicy.setEnforceVnicVhbaNames(true);
    } else {
        bootPolicy.setEnforceVnicVhbaNames(false);
    }
    _dbClient.persistObject(bootPolicy);
    ComputeSanBoot sanBoot = null;
    ComputeLanBoot lanBoot = null;
    URIQueryResultList sanBootUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), sanBootUris);
    List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
    if (sanBootList != null && !sanBootList.isEmpty()) {
        sanBoot = sanBootList.get(0);
    }
    URIQueryResultList lanBootUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.getId()), lanBootUris);
    List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
    if (lanBootList != null && !lanBootList.isEmpty()) {
        lanBoot = lanBootList.get(0);
    }
    boolean hasLanBoot = false;
    boolean hasSanBoot = false;
    Integer nonSanBootOrder = null;
    Integer sanBootOrder = null;
    if (lsBootPolicy.getContent() != null && !lsBootPolicy.getContent().isEmpty()) {
        for (Serializable element : lsBootPolicy.getContent()) {
            if (element instanceof JAXBElement<?>) {
                if (((JAXBElement) element).getValue() instanceof LsbootLan) {
                    LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
                    lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, null, bootPolicy);
                    hasLanBoot = true;
                    // This looks crazy, but there were some profiles on the UCS, where bootOrder did not start at 1; this should handle
                    // that case too
                    Integer order = Integer.parseInt(lsbootLan.getOrder());
                    if (nonSanBootOrder == null) {
                        nonSanBootOrder = order;
                    } else if (order < nonSanBootOrder) {
                        nonSanBootOrder = order;
                    }
                } else if (((JAXBElement) element).getValue() instanceof LsbootStorage) {
                    LsbootStorage lsbootStorage = (LsbootStorage) ((JAXBElement) element).getValue();
                    sanBoot = reconcileComputeSanBoot(lsbootStorage, sanBoot, null, bootPolicy);
                    hasSanBoot = true;
                    sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
                } else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
                    LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
                    sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, null, bootPolicy);
                    hasSanBoot = true;
                    sanBootOrder = Integer.parseInt(lsbootSan.getOrder());
                } else if (((JAXBElement) element).getValue() instanceof LsbootVirtualMedia) {
                    LsbootVirtualMedia lsbootVirtualMedia = (LsbootVirtualMedia) ((JAXBElement) element).getValue();
                    Integer order = Integer.parseInt(lsbootVirtualMedia.getOrder());
                    if (nonSanBootOrder == null) {
                        nonSanBootOrder = order;
                    } else if (order < nonSanBootOrder) {
                        nonSanBootOrder = order;
                    }
                } else if (((JAXBElement) element).getValue() instanceof LsbootIScsi) {
                    LsbootIScsi lsbootIScsi = (LsbootIScsi) ((JAXBElement) element).getValue();
                    Integer order = Integer.parseInt(lsbootIScsi.getOrder());
                    if (nonSanBootOrder == null) {
                        nonSanBootOrder = order;
                    } else if (order < nonSanBootOrder) {
                        nonSanBootOrder = order;
                    }
                }
            }
        }
    }
    if (hasSanBoot && nonSanBootOrder != null) {
        sanBoot = (ComputeSanBoot) _dbClient.queryObject(sanBoot.getId());
        if (nonSanBootOrder < sanBootOrder) {
            sanBoot.setIsFirstBootDevice(false);
        } else {
            sanBoot.setIsFirstBootDevice(true);
        }
        _dbClient.persistObject(sanBoot);
    }
    if (!hasSanBoot && sanBoot != null) {
        List<ComputeSanBoot> sanBoots = new ArrayList<ComputeSanBoot>();
        sanBoots.add(sanBoot);
        deleteComputeSanBoot(sanBoots);
    }
    if (!hasLanBoot && lanBoot != null) {
        List<ComputeLanBoot> lanBoots = new ArrayList<ComputeLanBoot>();
        lanBoots.add(lanBoot);
        deleteComputeLanBoot(lanBoots);
    }
}
Also used : Serializable(java.io.Serializable) LsbootVirtualMedia(com.emc.cloud.platform.ucs.out.model.LsbootVirtualMedia) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) LsbootSan(com.emc.cloud.platform.ucs.out.model.LsbootSan) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) LsbootLan(com.emc.cloud.platform.ucs.out.model.LsbootLan) LsbootStorage(com.emc.cloud.platform.ucs.out.model.LsbootStorage) LsbootIScsi(com.emc.cloud.platform.ucs.out.model.LsbootIScsi)

Example 7 with ComputeSanBoot

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

the class UcsDiscoveryWorker method deleteComputeBootDefs.

private void deleteComputeBootDefs(List<ComputeBootDef> bootDefs) {
    for (ComputeBootDef bootDef : bootDefs) {
        // Retrieve associated ComputeSanBoot and delete it
        URIQueryResultList sanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), sanBootUris);
        List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
        if (sanBootList != null && !sanBootList.isEmpty()) {
            deleteComputeSanBoot(sanBootList);
        }
        // Retrieve associated ComputeLanBoot and delete it
        URIQueryResultList lanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootDef.getId()), lanBootUris);
        List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
        if (lanBootList != null && !lanBootList.isEmpty()) {
            deleteComputeLanBoot(lanBootList);
        }
    }
    deleteDataObjects(new ArrayList<DataObject>(bootDefs));
}
Also used : ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 8 with ComputeSanBoot

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

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

use of com.emc.storageos.db.client.model.ComputeSanBoot 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)10 ComputeSanBoot (com.emc.storageos.db.client.model.ComputeSanBoot)10 ComputeLanBoot (com.emc.storageos.db.client.model.ComputeLanBoot)6 ComputeSanBootImage (com.emc.storageos.db.client.model.ComputeSanBootImage)6 ArrayList (java.util.ArrayList)5 Serializable (java.io.Serializable)4 JAXBElement (javax.xml.bind.JAXBElement)4 ComputeBootDef (com.emc.storageos.db.client.model.ComputeBootDef)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 URI (java.net.URI)3 LsbootIScsi (com.emc.cloud.platform.ucs.out.model.LsbootIScsi)2 LsbootLan (com.emc.cloud.platform.ucs.out.model.LsbootLan)2 LsbootSan (com.emc.cloud.platform.ucs.out.model.LsbootSan)2 LsbootSanImage (com.emc.cloud.platform.ucs.out.model.LsbootSanImage)2 LsbootStorage (com.emc.cloud.platform.ucs.out.model.LsbootStorage)2 LsbootVirtualMedia (com.emc.cloud.platform.ucs.out.model.LsbootVirtualMedia)2 ComputeBootPolicy (com.emc.storageos.db.client.model.ComputeBootPolicy)2 ComputeElementHBA (com.emc.storageos.db.client.model.ComputeElementHBA)2