Search in sources :

Example 1 with OrFilter

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

the class UCSMServiceImpl method getServiceProfileTemplates.

@Override
public List<LsServer> getServiceProfileTemplates(String ucsmURL, String username, String password) throws ClientGeneralException {
    List<LsServer> serviceProfileTemplates = Collections.synchronizedList(new ArrayList<LsServer>());
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigResolveClass configResolveClass = new ConfigResolveClass();
    configResolveClass.setClassId(NamingClassId.LS_SERVER);
    configResolveClass.setInHierarchical("true");
    FilterFilter inFilter = new FilterFilter();
    OrFilter orFilter = new OrFilter();
    EqFilter eqFilterInitTemplate = new EqFilter();
    eqFilterInitTemplate.setProperty("type");
    eqFilterInitTemplate.setClazz(NamingClassId.LS_SERVER);
    eqFilterInitTemplate.setValue("initial-template");
    EqFilter eqFilterUpdatingTemplate = new EqFilter();
    eqFilterUpdatingTemplate.setProperty("type");
    eqFilterUpdatingTemplate.setClazz(NamingClassId.LS_SERVER);
    eqFilterUpdatingTemplate.setValue("updating-template");
    orFilter.getAbstractFilter().add(factory.createEq(eqFilterUpdatingTemplate));
    orFilter.getAbstractFilter().add(factory.createEq(eqFilterInitTemplate));
    inFilter.setAbstractFilter(factory.createOr(orFilter));
    configResolveClass.getContent().add(new JAXBElement<FilterFilter>(new QName("inFilter"), FilterFilter.class, inFilter));
    com.emc.cloud.platform.ucs.out.model.ConfigResolveClass configResolveClassOut = computeSession.execute(factory.createConfigResolveClass(configResolveClass), com.emc.cloud.platform.ucs.out.model.ConfigResolveClass.class);
    ConfigSet configSet = null;
    if (configResolveClassOut.getContent() != null && !configResolveClassOut.getContent().isEmpty()) {
        for (Object object : configResolveClassOut.getContent()) {
            if (object instanceof JAXBElement<?>) {
                if (!(((JAXBElement) object).getValue() instanceof ConfigSet)) {
                    continue;
                }
                configSet = ((JAXBElement<ConfigSet>) object).getValue();
                if (configSet != null && configSet.getManagedObject() != null && !configSet.getManagedObject().isEmpty()) {
                    for (JAXBElement<?> managedObject : configSet.getManagedObject()) {
                        if (managedObject.getValue() instanceof LsServer) {
                            serviceProfileTemplates.add((LsServer) managedObject.getValue());
                            LsServer spt = (LsServer) managedObject.getValue();
                            log.info("SPT Name:" + spt.getName());
                        }
                    }
                }
            }
        }
    }
    return serviceProfileTemplates;
}
Also used : QName(javax.xml.namespace.QName) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ConfigResolveClass(com.emc.cloud.platform.ucs.in.model.ConfigResolveClass) OrFilter(com.emc.cloud.platform.ucs.in.model.OrFilter) JAXBElement(javax.xml.bind.JAXBElement) FilterFilter(com.emc.cloud.platform.ucs.in.model.FilterFilter) EqFilter(com.emc.cloud.platform.ucs.in.model.EqFilter) ConfigSet(com.emc.cloud.platform.ucs.out.model.ConfigSet)

Aggregations

ConfigResolveClass (com.emc.cloud.platform.ucs.in.model.ConfigResolveClass)1 EqFilter (com.emc.cloud.platform.ucs.in.model.EqFilter)1 FilterFilter (com.emc.cloud.platform.ucs.in.model.FilterFilter)1 OrFilter (com.emc.cloud.platform.ucs.in.model.OrFilter)1 ConfigSet (com.emc.cloud.platform.ucs.out.model.ConfigSet)1 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1