Search in sources :

Example 1 with EqFilter

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

the class UCSMServiceImpl method getVlanById.

@Override
public FabricVlan getVlanById(String ucsmURL, String username, String password, String vlanId) throws ClientGeneralException {
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigResolveClass configResolveClass = new ConfigResolveClass();
    configResolveClass.setClassId(NamingClassId.FABRIC_VLAN);
    configResolveClass.setInHierarchical("true");
    FilterFilter inFilter = new FilterFilter();
    EqFilter eqFilter = new EqFilter();
    eqFilter.setProperty("id");
    eqFilter.setClazz(NamingClassId.FABRIC_VLAN);
    eqFilter.setValue(vlanId);
    inFilter.setAbstractFilter(factory.createEq(eqFilter));
    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 FabricVlan) {
                            return (FabricVlan) managedObject.getValue();
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : QName(javax.xml.namespace.QName) ConfigResolveClass(com.emc.cloud.platform.ucs.in.model.ConfigResolveClass) JAXBElement(javax.xml.bind.JAXBElement) FabricVlan(com.emc.cloud.platform.ucs.out.model.FabricVlan) 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)

Example 2 with EqFilter

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

the class UCSMServiceImpl method getLsServer.

public LsServer getLsServer(ComputeSession computeSession, String uuid) throws ClientGeneralException {
    try {
        ConfigResolveClass configResolveClass = new ConfigResolveClass();
        configResolveClass.setClassId(NamingClassId.LS_SERVER);
        configResolveClass.setInHierarchical("true");
        // configResolveClass.getContent()
        FilterFilter inFilter = new FilterFilter();
        EqFilter eqFilter = new EqFilter();
        eqFilter.setClazz(NamingClassId.LS_SERVER);
        eqFilter.setProperty("uuid");
        eqFilter.setValue(uuid);
        inFilter.setAbstractFilter(factory.createEq(eqFilter));
        configResolveClass.getContent().add(new JAXBElement<>(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) {
                                return (LsServer) managedObject.getValue();
                            }
                        }
                    }
                }
            }
        }
    } catch (ClientGeneralException e) {
        log.error("Unable to get all associated lsServers", e);
        throw e;
    }
    return null;
}
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) 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) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 3 with EqFilter

use of com.emc.cloud.platform.ucs.in.model.EqFilter 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)

Example 4 with EqFilter

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

the class UCSMServiceImpl method getAllAssociatedLsServers.

@Override
public Map<String, LsServer> getAllAssociatedLsServers(String ucsmURL, String username, String password) throws ClientGeneralException {
    Map<String, LsServer> associatedLsServers = Collections.synchronizedMap(new HashMap<String, LsServer>());
    ;
    try {
        ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
        ConfigResolveClass configResolveClass = new ConfigResolveClass();
        configResolveClass.setClassId(NamingClassId.LS_SERVER);
        configResolveClass.setInHierarchical("true");
        // configResolveClass.getContent()
        FilterFilter inFilter = new FilterFilter();
        EqFilter eqFilter = new EqFilter();
        eqFilter.setProperty("assocState");
        eqFilter.setClazz(NamingClassId.LS_SERVER);
        eqFilter.setValue("associated");
        inFilter.setAbstractFilter(factory.createEq(eqFilter));
        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) {
                                LsServer lsServer = (LsServer) managedObject.getValue();
                                associatedLsServers.put(lsServer.getPnDn(), lsServer);
                            }
                        }
                    }
                }
            }
        }
    } catch (ClientGeneralException e) {
        log.error("Unable to get all associated lsServers", e);
        throw e;
    }
    return associatedLsServers;
}
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) 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) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Aggregations

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