Search in sources :

Example 51 with JAXBElement

use of javax.xml.bind.JAXBElement in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileComputeSanBootImage.

private ComputeSanBootImage reconcileComputeSanBootImage(LsbootSanImage sanImage, ComputeSanBootImage computeSanImage, ComputeSanBoot sanBoot) {
    if (computeSanImage != null) {
        computeSanImage.setDn(sanImage.getDn());
        computeSanImage.setVnicName(sanImage.getVnicName());
        _dbClient.persistObject(computeSanImage);
    }
    if (computeSanImage == null) {
        computeSanImage = new ComputeSanBootImage();
        URI uriSanBootImage = URIUtil.createId(ComputeSanBootImage.class);
        computeSanImage.setId(uriSanBootImage);
        computeSanImage.setType(sanImage.getType());
        computeSanImage.setVnicName(sanImage.getVnicName());
        computeSanImage.setDn(sanImage.getDn());
        computeSanImage.setComputeSanBoot(sanBoot.getId());
        _dbClient.createObject(computeSanImage);
    }
    Map<String, ComputeSanBootImagePath> computeSanBootImagePathMap = new HashMap<String, ComputeSanBootImagePath>();
    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()) {
        for (ComputeSanBootImagePath sanBootImagePath : sanBootPathList) {
            computeSanBootImagePathMap.put(sanBootImagePath.getType(), sanBootImagePath);
        }
    }
    if (sanImage.getContent() != null && !sanImage.getContent().isEmpty()) {
        for (Serializable e2 : sanImage.getContent()) {
            if (e2 instanceof JAXBElement<?>) {
                if (((JAXBElement) e2).getValue() instanceof LsbootSanImagePath) {
                    LsbootSanImagePath lsSanImagePath = (LsbootSanImagePath) ((JAXBElement) e2).getValue();
                    ComputeSanBootImagePath sanBootImagePath = computeSanBootImagePathMap.get(lsSanImagePath.getType());
                    computeSanBootImagePathMap.remove(lsSanImagePath.getType());
                    sanBootImagePath = reconcileComputeSanBootImagePath(lsSanImagePath, sanBootImagePath, computeSanImage);
                }
            }
        }
    }
    deleteComputeSanBootImagePaths(new ArrayList<ComputeSanBootImagePath>(computeSanBootImagePathMap.values()));
    return computeSanImage;
}
Also used : ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) LsbootSanImagePath(com.emc.cloud.platform.ucs.out.model.LsbootSanImagePath) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) JAXBElement(javax.xml.bind.JAXBElement) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 52 with JAXBElement

use of javax.xml.bind.JAXBElement in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method updateComputeBootPolicy.

private void updateComputeBootPolicy(ComputeBootPolicy bootPolicy, LsbootPolicy lsBootPolicy) {
    bootPolicy.setDn(lsBootPolicy.getDn());
    bootPolicy.setName(lsBootPolicy.getName());
    if (lsBootPolicy.getEnforceVnicName().equals("yes")) {
        bootPolicy.setEnforceVnicVhbaNames(true);
    } else {
        bootPolicy.setEnforceVnicVhbaNames(false);
    }
    _dbClient.persistObject(bootPolicy);
    ComputeSanBoot sanBoot = null;
    ComputeLanBoot lanBoot = null;
    URIQueryResultList sanBootUris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.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.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.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 (lsBootPolicy.getContent() != null && !lsBootPolicy.getContent().isEmpty()) {
        for (Serializable element : lsBootPolicy.getContent()) {
            if (element instanceof JAXBElement<?>) {
                if (((JAXBElement) element).getValue() instanceof LsbootLan) {
                    LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
                    lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, null, bootPolicy);
                    hasLanBoot = true;
                    // This looks crazy, but there were some profiles on the UCS, where bootOrder did not start at 1; this should handle
                    // that case too
                    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, null, bootPolicy);
                    hasSanBoot = true;
                    sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
                } else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
                    LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
                    sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, null, bootPolicy);
                    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);
    }
}
Also used : Serializable(java.io.Serializable) LsbootVirtualMedia(com.emc.cloud.platform.ucs.out.model.LsbootVirtualMedia) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) 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) 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 53 with JAXBElement

use of javax.xml.bind.JAXBElement 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 54 with JAXBElement

use of javax.xml.bind.JAXBElement in project coprhd-controller by CoprHD.

the class UCSMServiceImpl method getAllLsServers.

private List<LsServer> getAllLsServers(String ucsmURL, String username, String password, boolean serviceProfilesOnly) throws ClientGeneralException {
    List<LsServer> lsServers = Collections.synchronizedList(new ArrayList<LsServer>());
    try {
        ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
        ConfigResolveClass configResolveClass = new ConfigResolveClass();
        configResolveClass.setClassId(NamingClassId.LS_SERVER);
        configResolveClass.setInHierarchical("true");
        // configResolveClass.getContent();
        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();
                                if (serviceProfilesOnly && !(lsServer.getType().equals("instance"))) {
                                    continue;
                                }
                                lsServers.add(lsServer);
                            }
                        }
                    }
                }
            }
        }
    } catch (ClientGeneralException e) {
        log.error("Unable to get all lsServers", e);
        throw e;
    }
    return lsServers;
}
Also used : LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ConfigResolveClass(com.emc.cloud.platform.ucs.in.model.ConfigResolveClass) JAXBElement(javax.xml.bind.JAXBElement) ConfigSet(com.emc.cloud.platform.ucs.out.model.ConfigSet) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 55 with JAXBElement

use of javax.xml.bind.JAXBElement in project coprhd-controller by CoprHD.

the class UCSMServiceImpl method getComputeBlades.

@Override
public List<ComputeBlade> getComputeBlades(String ucsmURL, String username, String password) throws ClientGeneralException {
    List<ComputeBlade> blades = new ArrayList<ComputeBlade>();
    try {
        ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
        ConfigResolveClass configResolveClass = new ConfigResolveClass();
        configResolveClass.setClassId(NamingClassId.COMPUTE_ITEM);
        configResolveClass.setInHierarchical("true");
        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 ComputeBlade) {
                                blades.add((ComputeBlade) managedObject.getValue());
                            }
                        }
                    }
                }
            }
        }
    } catch (ClientGeneralException e) {
        log.warn("Unable to get compute elements", e);
        throw e;
    }
    return blades;
}
Also used : ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) ArrayList(java.util.ArrayList) ConfigResolveClass(com.emc.cloud.platform.ucs.in.model.ConfigResolveClass) JAXBElement(javax.xml.bind.JAXBElement) ConfigSet(com.emc.cloud.platform.ucs.out.model.ConfigSet) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)650 QName (javax.xml.namespace.QName)194 Element (org.w3c.dom.Element)124 RequestSecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType)102 RequestSecurityTokenResponseType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType)95 ArrayList (java.util.ArrayList)93 MessageImpl (org.apache.cxf.message.MessageImpl)92 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)90 Test (org.junit.Test)87 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)86 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)83 Crypto (org.apache.wss4j.common.crypto.Crypto)82 JAXBException (javax.xml.bind.JAXBException)81 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)77 JAXBContext (javax.xml.bind.JAXBContext)75 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)72 Unmarshaller (javax.xml.bind.Unmarshaller)65 ServiceMBean (org.apache.cxf.sts.service.ServiceMBean)61 StaticService (org.apache.cxf.sts.service.StaticService)61 RequestSecurityTokenResponseCollectionType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType)58