Search in sources :

Example 1 with ComputeSanBootImagePath

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

the class ComputeSystemService method isSanBootValidForVarrays.

private boolean isSanBootValidForVarrays(StringSet varrayIds, ComputeSanBoot computeSanBoot) {
    _log.debug("validate San Boot For Varrays");
    boolean isValid = true;
    if (computeSanBoot.getOrder() > 1) {
        _log.error("San boot should be the first boot device");
        isValid = false;
        return isValid;
    }
    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) {
        URIQueryResultList sanImagePathUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(image.getId()), sanImagePathUris);
        List<ComputeSanBootImagePath> sanBootImagePathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
        // Validate the sanboot targets
        StringSet portWWPNs = new StringSet();
        for (ComputeSanBootImagePath imagePath : sanBootImagePathList) {
            String portWWPN = imagePath.getPortWWN();
            portWWPNs.add(portWWPN);
        }
        if (!portWWPNs.isEmpty()) {
            isValid = isSanBootTargetValidForVarrays(varrayIds, portWWPNs);
            if (!isValid) {
                return isValid;
            }
        } else {
            _log.debug("No san boot targets specified");
        }
    }
    return isValid;
}
Also used : ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) StringSet(com.emc.storageos.db.client.model.StringSet) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with ComputeSanBootImagePath

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

Example 3 with ComputeSanBootImagePath

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

the class UcsDiscoveryWorker method deleteBootPolicies.

private void deleteBootPolicies(List<ComputeBootPolicy> bootPolicies) {
    List<ComputeSanBootImagePath> removeSanBootImagePaths = new ArrayList<ComputeSanBootImagePath>();
    List<ComputeSanBootImage> removeSanBootImages = new ArrayList<ComputeSanBootImage>();
    List<ComputeSanBoot> removeSanBoots = new ArrayList<ComputeSanBoot>();
    List<ComputeLanBootImagePath> removeLanBootImagePaths = new ArrayList<ComputeLanBootImagePath>();
    List<ComputeLanBoot> removeLanBoots = new ArrayList<ComputeLanBoot>();
    for (ComputeBootPolicy bootPolicy : bootPolicies) {
        // Retrieve associated ComputeSanBoot and delete it
        URIQueryResultList sanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootPolicy.getId()), sanBootUris);
        List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
        if (sanBootList != null && !sanBootList.isEmpty()) {
            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()) {
                    for (ComputeSanBootImage computeSanImage : sanBootImageList) {
                        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()) {
                            removeSanBootImagePaths.addAll(sanBootPathList);
                        }
                        removeSanBootImages.add(computeSanImage);
                    }
                }
                removeSanBoots.add(sanBoot);
            }
        }
        // Retrieve associated ComputeLanBoot and delete it
        URIQueryResultList lanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootPolicy.getId()), lanBootUris);
        List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
        if (lanBootList != null && !lanBootList.isEmpty()) {
            ComputeLanBoot lanBoot = lanBootList.get(0);
            URIQueryResultList lanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(lanBoot.getId()), lanImageUris);
            List<ComputeLanBootImagePath> lanBootPathList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
            if (lanBootPathList != null && !lanBootPathList.isEmpty()) {
                removeLanBootImagePaths.addAll(lanBootPathList);
            }
            removeLanBoots.add(lanBoot);
        }
    }
    deleteDataObjects(new ArrayList<DataObject>(removeLanBootImagePaths));
    deleteDataObjects(new ArrayList<DataObject>(removeLanBoots));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBootImagePaths));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBootImages));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBoots));
    deleteDataObjects(new ArrayList<DataObject>(bootPolicies));
}
Also used : ArrayList(java.util.ArrayList) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) ComputeBootPolicy(com.emc.storageos.db.client.model.ComputeBootPolicy)

Example 4 with ComputeSanBootImagePath

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

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

the class UcsDiscoveryWorker method reconcileComputeSanBootImagePath.

private ComputeSanBootImagePath reconcileComputeSanBootImagePath(LsbootSanImagePath lsSanImagePath, ComputeSanBootImagePath sanImagePath, ComputeSanBootImage computeSanImage) {
    if (sanImagePath != null) {
        sanImagePath.setDn(lsSanImagePath.getDn());
        sanImagePath.setType(lsSanImagePath.getType());
        // sanImagePath.setVnicName(lsSanImagePath.);
        if (lsSanImagePath.getLun() != null) {
            sanImagePath.setHlu(Long.parseLong(lsSanImagePath.getLun()));
        }
        sanImagePath.setPortWWN(lsSanImagePath.getWwn());
        sanImagePath.setComputeSanBootImage(computeSanImage.getId());
        _dbClient.persistObject(sanImagePath);
    }
    if (sanImagePath == null) {
        sanImagePath = new ComputeSanBootImagePath();
        URI uriSanBootImage = URIUtil.createId(ComputeSanBootImagePath.class);
        sanImagePath.setComputeSanBootImage(computeSanImage.getId());
        sanImagePath.setId(uriSanBootImage);
        sanImagePath.setDn(lsSanImagePath.getDn());
        sanImagePath.setType(lsSanImagePath.getType());
        // sanImagePath.setVnicName(sanImage.getVnicName());
        if (lsSanImagePath.getLun() != null) {
            sanImagePath.setHlu(Long.parseLong(lsSanImagePath.getLun()));
        }
        sanImagePath.setPortWWN(lsSanImagePath.getWwn());
        sanImagePath.setComputeSanBootImage(computeSanImage.getId());
        _dbClient.createObject(sanImagePath);
    }
    return sanImagePath;
}
Also used : ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) URI(java.net.URI)

Aggregations

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