Search in sources :

Example 1 with ComputeBootPolicy

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

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

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

the class UcsDiscoveryWorker method reconcileBootPolicies.

private void reconcileBootPolicies(ComputeSystem cs, List<LsbootPolicy> lsBootPolicies) {
    _log.info("Reconciling BootPolicies");
    Map<String, ComputeBootPolicy> removeBootPolicies = new HashMap<>();
    Map<String, ComputeBootPolicy> updateBootPolicies = new HashMap<>();
    Map<String, ComputeBootPolicy> addBootPolicies = new HashMap<>();
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(cs.getId()), uris);
    List<ComputeBootPolicy> bootPolicies = _dbClient.queryObject(ComputeBootPolicy.class, uris, true);
    for (ComputeBootPolicy bootPolicy : bootPolicies) {
        removeBootPolicies.put(bootPolicy.getDn(), bootPolicy);
    }
    // discovered data
    for (LsbootPolicy lsbootPolicy : lsBootPolicies) {
        ComputeBootPolicy bootPolicy = removeBootPolicies.get(lsbootPolicy.getDn());
        if (bootPolicy != null) {
            updateBootPolicies.put(lsbootPolicy.getDn(), bootPolicy);
            removeBootPolicies.remove(bootPolicy.getDn());
            updateComputeBootPolicy(bootPolicy, lsbootPolicy);
        } else {
            bootPolicy = new ComputeBootPolicy();
            addBootPolicies.put(lsbootPolicy.getDn(), bootPolicy);
            createComputeBootPolicy(cs, bootPolicy, lsbootPolicy);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addBootPolicies.values()));
    persistDataObjects(new ArrayList<DataObject>(updateBootPolicies.values()));
    for (String key : removeBootPolicies.keySet()) {
        _log.info("Marked for deletion BootPolicy: " + key);
    }
    deleteBootPolicies(new ArrayList<ComputeBootPolicy>(removeBootPolicies.values()));
}
Also used : LsbootPolicy(com.emc.cloud.platform.ucs.out.model.LsbootPolicy) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) ComputeBootPolicy(com.emc.storageos.db.client.model.ComputeBootPolicy) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with ComputeBootPolicy

use of com.emc.storageos.db.client.model.ComputeBootPolicy 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)4 ComputeBootPolicy (com.emc.storageos.db.client.model.ComputeBootPolicy)4 ComputeBootDef (com.emc.storageos.db.client.model.ComputeBootDef)2 ComputeSanBoot (com.emc.storageos.db.client.model.ComputeSanBoot)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 ArrayList (java.util.ArrayList)2 LsbootPolicy (com.emc.cloud.platform.ucs.out.model.LsbootPolicy)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 ComputeLanBoot (com.emc.storageos.db.client.model.ComputeLanBoot)1 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)1 ComputeSanBootImage (com.emc.storageos.db.client.model.ComputeSanBootImage)1 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)1 TaskList (com.emc.storageos.model.TaskList)1 ComputeSystemList (com.emc.storageos.model.compute.ComputeSystemList)1 HashMap (java.util.HashMap)1 List (java.util.List)1