Search in sources :

Example 1 with ComputeBootDef

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

the class ComputeSystemService method isUpdatingSPTValidForVarrays.

private boolean isUpdatingSPTValidForVarrays(StringSet varrayIds, UCSServiceProfileTemplate serviceProfileTemplate) {
    boolean isValid = true;
    _log.debug("Is uSPT:" + serviceProfileTemplate.getLabel() + " valid for varrays");
    URIQueryResultList uriBootPolicies = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(serviceProfileTemplate.getComputeSystem()), uriBootPolicies);
    List<ComputeBootPolicy> bootPolicyList = _dbClient.queryObject(ComputeBootPolicy.class, uriBootPolicies, true);
    ComputeBootDef bootDef = null;
    URIQueryResultList bootDefUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
    List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
    if (!bootDefs.isEmpty()) {
        _log.debug("has boot def");
        bootDef = bootDefs.get(0);
        URIQueryResultList uriSanBoot = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), uriSanBoot);
        List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
        for (ComputeSanBoot computeSanBoot : computeSanBoots) {
            isValid = isSanBootValidForVarrays(varrayIds, computeSanBoot);
        }
    } else if (serviceProfileTemplate.getAssociatedBootPolicy() != null) {
        _log.debug("has boot policy:" + serviceProfileTemplate.getAssociatedBootPolicy());
        for (ComputeBootPolicy bootPolicy : bootPolicyList) {
            if (bootPolicy.getDn().equals(serviceProfileTemplate.getAssociatedBootPolicy())) {
                URIQueryResultList uriSanBoot = new URIQueryResultList();
                _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), uriSanBoot);
                List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
                for (ComputeSanBoot computeSanBoot : computeSanBoots) {
                    isValid = isSanBootValidForVarrays(varrayIds, computeSanBoot);
                }
            }
        }
    } else {
        _log.info("Updating SPT with no boot policy or boot def set is invalid");
    }
    _log.info("SPT:" + serviceProfileTemplate.getLabel() + "isValid:" + isValid);
    return isValid;
}
Also used : ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) List(java.util.List) ArrayList(java.util.ArrayList) ComputeSystemList(com.emc.storageos.model.compute.ComputeSystemList) TaskList(com.emc.storageos.model.TaskList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeBootPolicy(com.emc.storageos.db.client.model.ComputeBootPolicy) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with ComputeBootDef

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

the class UcsDiscoveryWorker method reconcileComputeBootDef.

private ComputeBootDef reconcileComputeBootDef(LsbootDef lsBootDef, UCSServiceProfileTemplate spt, ComputeSystem cs) {
    ComputeBootDef bootDef = null;
    URIQueryResultList bootDefUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(spt.getId()), bootDefUris);
    List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
    if (!bootDefs.isEmpty()) {
        bootDef = bootDefs.get(0);
        bootDef.setComputeSystem(cs.getId());
        bootDef.setServiceProfileTemplate(spt.getId());
        // bootDef.setDn(lsBootDef.getDn());
        if (lsBootDef.getEnforceVnicName().equals("yes")) {
            bootDef.setEnforceVnicVhbaNames(true);
        } else {
            bootDef.setEnforceVnicVhbaNames(false);
        }
        _dbClient.persistObject(bootDef);
    }
    if (bootDef == null) {
        bootDef = new ComputeBootDef();
        URI uri = URIUtil.createId(ComputeBootDef.class);
        bootDef.setId(uri);
        bootDef.setComputeSystem(cs.getId());
        bootDef.setServiceProfileTemplate(spt.getId());
        // bootDef.setDn(lsBootDef.getDn());
        if (lsBootDef.getEnforceVnicName().equals("yes")) {
            bootDef.setEnforceVnicVhbaNames(true);
        } else {
            bootDef.setEnforceVnicVhbaNames(false);
        }
        _dbClient.createObject(bootDef);
    }
    ComputeSanBoot sanBoot = null;
    ComputeLanBoot lanBoot = null;
    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()) {
        sanBoot = sanBootList.get(0);
    }
    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()) {
        lanBoot = lanBootList.get(0);
    }
    boolean hasLanBoot = false;
    boolean hasSanBoot = false;
    Integer nonSanBootOrder = null;
    Integer sanBootOrder = null;
    if (lsBootDef.getContent() != null && !lsBootDef.getContent().isEmpty()) {
        for (Serializable element : lsBootDef.getContent()) {
            if (element instanceof JAXBElement<?>) {
                if (((JAXBElement) element).getValue() instanceof LsbootLan) {
                    LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
                    lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, bootDef, null);
                    hasLanBoot = true;
                    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, bootDef, null);
                    hasSanBoot = true;
                    sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
                } else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
                    LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
                    sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, bootDef, null);
                    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);
    }
    return bootDef;
}
Also used : Serializable(java.io.Serializable) LsbootVirtualMedia(com.emc.cloud.platform.ucs.out.model.LsbootVirtualMedia) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) URI(java.net.URI) 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) ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) 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 3 with ComputeBootDef

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

the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesBootDefinitions.

private void reconcileServiceProfileTemplatesBootDefinitions(ComputeSystem cs, List<LsServer> lsServers) {
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    Map<String, LsServer> lsServerMap = new HashMap<>();
    for (LsServer lsServer : lsServers) {
        lsServerMap.put(lsServer.getDn(), lsServer);
    }
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceProfileTemplate : serviceTemplates) {
        LsServer lsServer = lsServerMap.get(serviceProfileTemplate.getDn());
        if (lsServer == null) {
            continue;
        }
        Map<String, Object> serviceProfileTemplateDetails = getServiceProfileTemplateDetails(lsServer);
        LsbootDef lsbootDef = (LsbootDef) serviceProfileTemplateDetails.get("associatedBootPolicy");
        if (lsbootDef != null) {
            _log.debug("Reconcile bootdef for SPT:" + serviceProfileTemplate.getLabel());
            ComputeBootDef computeBootDef = reconcileComputeBootDef(lsbootDef, serviceProfileTemplate, cs);
        } else {
            // Remove any computeBootDefs that are no longer needed.
            URIQueryResultList bootDefUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
            List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
            deleteComputeBootDefs(bootDefs);
        }
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) LsbootDef(com.emc.cloud.platform.ucs.out.model.LsbootDef) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with ComputeBootDef

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

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

the class ComputeSystemService method isUpdatingSPTValid.

public boolean isUpdatingSPTValid(UCSServiceProfileTemplate serviceProfileTemplate, DbClient dbClient) {
    boolean valid = false;
    // Check whether boot definition or boot policy is specified
    // If so, check if enforce vnic names is specified and if so validate vnic names.
    URIQueryResultList uriBootPolicies = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(serviceProfileTemplate.getComputeSystem()), uriBootPolicies);
    List<ComputeBootPolicy> bootPolicyList = dbClient.queryObject(ComputeBootPolicy.class, uriBootPolicies, true);
    ComputeBootDef bootDef = null;
    URIQueryResultList bootDefUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
    List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
    if (!bootDefs.isEmpty()) {
        _log.debug("has boot def");
        bootDef = bootDefs.get(0);
        valid = isSPTBootDefinitionValid(serviceProfileTemplate, bootDef);
    } else if (serviceProfileTemplate.getAssociatedBootPolicy() != null) {
        _log.debug("has boot policy:" + serviceProfileTemplate.getAssociatedBootPolicy());
        for (ComputeBootPolicy bootPolicy : bootPolicyList) {
            if (bootPolicy.getDn().equals(serviceProfileTemplate.getAssociatedBootPolicy())) {
                valid = isSPTBootPolicyValid(serviceProfileTemplate, bootPolicy);
            }
        }
    } else {
        _log.info("Updating SPT with no boot policy or boot def set is invalid");
    }
    return valid;
}
Also used : ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) ComputeBootPolicy(com.emc.storageos.db.client.model.ComputeBootPolicy) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 ComputeBootDef (com.emc.storageos.db.client.model.ComputeBootDef)5 ComputeSanBoot (com.emc.storageos.db.client.model.ComputeSanBoot)3 ComputeBootPolicy (com.emc.storageos.db.client.model.ComputeBootPolicy)2 ComputeLanBoot (com.emc.storageos.db.client.model.ComputeLanBoot)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 ArrayList (java.util.ArrayList)2 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 LsbootDef (com.emc.cloud.platform.ucs.out.model.LsbootDef)1 LsbootIScsi (com.emc.cloud.platform.ucs.out.model.LsbootIScsi)1 LsbootLan (com.emc.cloud.platform.ucs.out.model.LsbootLan)1 LsbootSan (com.emc.cloud.platform.ucs.out.model.LsbootSan)1 LsbootStorage (com.emc.cloud.platform.ucs.out.model.LsbootStorage)1 LsbootVirtualMedia (com.emc.cloud.platform.ucs.out.model.LsbootVirtualMedia)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 TaskList (com.emc.storageos.model.TaskList)1 ComputeSystemList (com.emc.storageos.model.compute.ComputeSystemList)1