use of com.emc.cloud.platform.ucs.in.model.LsbootLan in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method createLsbootLan.
private LsbootLan createLsbootLan(LsServer lsServerCurrent, String order) {
LsbootLan lsbootLan = new LsbootLan();
lsbootLan.setRn(BootType.LAN.toString().toLowerCase());
lsbootLan.setProt("pxe");
lsbootLan.setOrder(order);
List<com.emc.cloud.platform.ucs.out.model.VnicEther> vnics = getVnics(lsServerCurrent);
Collections.sort(vnics, new Comparator<com.emc.cloud.platform.ucs.out.model.VnicEther>() {
@Override
public int compare(com.emc.cloud.platform.ucs.out.model.VnicEther o1, com.emc.cloud.platform.ucs.out.model.VnicEther o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
if (vnics != null && !vnics.isEmpty()) {
lsbootLan.getContent().add(factory.createLsbootLanImagePath(createLsbootLanImagePath(LanImagePathType.primary, vnics.get(0))));
}
if (vnics != null && vnics.size() >= 2) {
lsbootLan.getContent().add(factory.createLsbootLanImagePath(createLsbootLanImagePath(LanImagePathType.secondary, vnics.get(1))));
}
return lsbootLan;
}
use of com.emc.cloud.platform.ucs.in.model.LsbootLan in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method setLsBootDefOnLsServer.
private LsServer setLsBootDefOnLsServer(String ucsmURL, String username, String password, String spDn, BootType bootType, Map<String, Map<String, Integer>> hbaToStoragePortMap, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
String version = getDeviceVersion(ucsmURL, username, password);
LsServer lsServerCurrent = getManagedObject(ucsmURL, username, password, spDn, true, LsServer.class);
if (lsServerCurrent == null) {
log.error("Unable to fetch LsServer for spDn {}", spDn);
String[] s = { "Unable to fetch LsServer for spDn " + spDn };
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
}
ConfigConfMo lsbootDefConfigMo = new ConfigConfMo();
lsbootDefConfigMo.setInHierarchical(Boolean.toString(true));
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(spDn);
lsServer.getContent().add(factory.createLsbootDef(createLsBootDef(bootType, spDn, version, lsServerCurrent, hbaToStoragePortMap)));
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
lsbootDefConfigMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer returnedLsServer = pushLsServer(computeSession, factory, lsbootDefConfigMo, errorMessage);
List<com.emc.cloud.platform.ucs.out.model.LsbootDef> lsBootDefs = getSubElements(returnedLsServer.getContent(), com.emc.cloud.platform.ucs.out.model.LsbootDef.class);
boolean operationVerified = false;
switch(bootType) {
case LAN:
List<com.emc.cloud.platform.ucs.out.model.LsbootLan> lsBootLans = getSubElements(lsBootDefs.get(0).getContent(), com.emc.cloud.platform.ucs.out.model.LsbootLan.class);
if (lsBootLans != null) {
for (com.emc.cloud.platform.ucs.out.model.LsbootLan lsBootLan : lsBootLans) {
if (lsBootLan.getOrder().equals("1")) {
operationVerified = true;
break;
}
}
}
break;
case SAN:
if (UcsmVersionChecker.verifyVersionDetails("2.2", version) < 0) {
// UCS Model change as of 2.2
List<com.emc.cloud.platform.ucs.out.model.LsbootStorage> lsBootStorages = getSubElements(lsBootDefs.get(0).getContent(), com.emc.cloud.platform.ucs.out.model.LsbootStorage.class);
if (lsBootStorages != null) {
for (com.emc.cloud.platform.ucs.out.model.LsbootStorage lsBootStorage : lsBootStorages) {
if (lsBootStorage.getOrder().equals("1")) {
operationVerified = true;
break;
}
}
}
} else {
List<com.emc.cloud.platform.ucs.out.model.LsbootSan> lsBootSans = getSubElements(lsBootDefs.get(0).getContent(), com.emc.cloud.platform.ucs.out.model.LsbootSan.class);
if (lsBootSans != null) {
for (com.emc.cloud.platform.ucs.out.model.LsbootSan lsBootSan : lsBootSans) {
if (lsBootSan.getOrder().equals("1")) {
operationVerified = true;
break;
}
}
}
}
break;
case NONE:
if ((lsBootDefs != null) && (lsBootDefs.isEmpty())) {
operationVerified = true;
}
break;
case EMPTY:
if ((lsBootDefs != null) && (lsBootDefs.size() == 1) && ((lsBootDefs.get(0).getContent() == null) || (lsBootDefs.get(0).getContent().size() == 0))) {
operationVerified = true;
}
}
if (!operationVerified) {
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to set boot definition '" + bootType.name() + "' on LsServer : " + spDn });
}
return returnedLsServer;
}
Aggregations