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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations