Search in sources :

Example 1 with LsbootLanImagePath

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

the class UcsDiscoveryWorker method reconcileComputeLanBoot.

private ComputeLanBoot reconcileComputeLanBoot(LsbootLan lsbootLan, ComputeLanBoot lanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
    if (lanBoot != null) {
        if (lsbootLan.getOrder() != null) {
            lanBoot.setOrder(Integer.valueOf(lsbootLan.getOrder()));
        }
        lanBoot.setProt(lsbootLan.getProt());
        lanBoot.setLabel(lsbootLan.getDn());
        _dbClient.persistObject(lanBoot);
    }
    if (lanBoot == null) {
        lanBoot = new ComputeLanBoot();
        URI uriLanBoot = URIUtil.createId(ComputeLanBoot.class);
        lanBoot.setId(uriLanBoot);
        if (bootDef != null) {
            lanBoot.setComputeBootDef(bootDef.getId());
        }
        if (bootPolicy != null) {
            lanBoot.setComputeBootPolicy(bootPolicy.getId());
        }
        if (lsbootLan.getOrder() != null) {
            lanBoot.setOrder(Integer.valueOf(lsbootLan.getOrder()));
        }
        lanBoot.setProt(lsbootLan.getProt());
        lanBoot.setLabel(lsbootLan.getDn());
        _dbClient.createObject(lanBoot);
    }
    Map<String, ComputeLanBootImagePath> lanBootImageMap = new HashMap<String, ComputeLanBootImagePath>();
    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()) {
        for (ComputeLanBootImagePath lanImage : lanBootPathList) {
            lanBootImageMap.put(lanImage.getType(), lanImage);
        }
    }
    if (lsbootLan.getContent() != null && !lsbootLan.getContent().isEmpty()) {
        for (Serializable e : lsbootLan.getContent()) {
            if (e instanceof JAXBElement<?>) {
                if (((JAXBElement) e).getValue() instanceof LsbootLanImagePath) {
                    LsbootLanImagePath lanImagePath = (LsbootLanImagePath) ((JAXBElement) e).getValue();
                    ComputeLanBootImagePath lanBootImagePath = lanBootImageMap.get(lanImagePath.getType());
                    lanBootImageMap.remove(lanImagePath.getType());
                    lanBootImagePath = reconcileComputeLanBootImagePath(lanImagePath, lanBootImagePath, lanBoot);
                }
            }
        }
    }
    deleteComputeLanBootImagePaths(new ArrayList<ComputeLanBootImagePath>(lanBootImageMap.values()));
    return lanBoot;
}
Also used : ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) Serializable(java.io.Serializable) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) HashMap(java.util.HashMap) JAXBElement(javax.xml.bind.JAXBElement) URI(java.net.URI) LsbootLanImagePath(com.emc.cloud.platform.ucs.out.model.LsbootLanImagePath) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

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