Search in sources :

Example 1 with ConfigResolveDn

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

the class UCSMServiceImpl method getManagedObject.

@Override
public <T> T getManagedObject(String ucsmURL, String username, String password, String dn, boolean hierarchical, Class<T> returnType) throws ClientGeneralException {
    T managedObject = null;
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigResolveDn configResolveDn = new ConfigResolveDn();
    configResolveDn.setDn(dn);
    configResolveDn.setInHierarchical(new Boolean(hierarchical).toString());
    com.emc.cloud.platform.ucs.out.model.ConfigResolveDn configResolveClassOut = computeSession.execute(factory.createConfigResolveDn(configResolveDn), com.emc.cloud.platform.ucs.out.model.ConfigResolveDn.class);
    com.emc.cloud.platform.ucs.out.model.ConfigConfig configConfig = null;
    if (configResolveClassOut.getContent() != null && !configResolveClassOut.getContent().isEmpty()) {
        for (Object object : configResolveClassOut.getContent()) {
            if (object instanceof JAXBElement<?>) {
                if (!(((JAXBElement) object).getValue() instanceof com.emc.cloud.platform.ucs.out.model.ConfigConfig)) {
                    continue;
                }
                configConfig = ((JAXBElement<com.emc.cloud.platform.ucs.out.model.ConfigConfig>) object).getValue();
                if (configConfig != null && configConfig.getManagedObject() != null) {
                    if (returnType.isInstance(configConfig.getManagedObject().getValue())) {
                        managedObject = returnType.cast(configConfig.getManagedObject().getValue());
                        /**
                         * Short circuit.... No need to run through the
                         * other elements, as only one element is expected!
                         */
                        return managedObject;
                    }
                }
            }
        }
    }
    return managedObject;
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) ConfigResolveDn(com.emc.cloud.platform.ucs.in.model.ConfigResolveDn) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig)

Example 2 with ConfigResolveDn

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

the class UCSMServiceImpl method getDeviceVersion.

@Override
public String getDeviceVersion(String ucsmURL, String username, String password) throws ClientGeneralException {
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigResolveDn configResolveDn = new ConfigResolveDn();
    configResolveDn.setInHierarchical("false");
    configResolveDn.setDn("sys/mgmt/fw-system");
    com.emc.cloud.platform.ucs.out.model.ConfigResolveDn configreSolveDnOut = (com.emc.cloud.platform.ucs.out.model.ConfigResolveDn) computeSession.execute(factory.createConfigResolveDn(configResolveDn), Object.class);
    if (configreSolveDnOut != null && !configreSolveDnOut.getContent().isEmpty()) {
        for (Object object : configreSolveDnOut.getContent()) {
            if (!(object instanceof JAXBElement<?>)) {
                continue;
            }
            JAXBElement jaxbObject = (JAXBElement) object;
            if (jaxbObject.getValue() == null || !(jaxbObject.getValue() instanceof com.emc.cloud.platform.ucs.out.model.ConfigConfig)) {
                continue;
            }
            com.emc.cloud.platform.ucs.out.model.ConfigConfig confObject = (com.emc.cloud.platform.ucs.out.model.ConfigConfig) jaxbObject.getValue();
            if (confObject.getManagedObject() == null || confObject.getManagedObject().getValue() == null) {
                continue;
            }
            if (!(confObject.getManagedObject().getValue() instanceof com.emc.cloud.platform.ucs.out.model.FirmwareRunning)) {
                continue;
            }
            return ((com.emc.cloud.platform.ucs.out.model.FirmwareRunning) confObject.getManagedObject().getValue()).getVersion();
        }
    }
    return null;
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) ConfigResolveDn(com.emc.cloud.platform.ucs.in.model.ConfigResolveDn) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig)

Aggregations

ConfigConfig (com.emc.cloud.platform.ucs.in.model.ConfigConfig)2 ConfigResolveDn (com.emc.cloud.platform.ucs.in.model.ConfigResolveDn)2 JAXBElement (javax.xml.bind.JAXBElement)2