use of com.emc.cloud.platform.ucs.in.model.LsbootSan 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;
}
use of com.emc.cloud.platform.ucs.in.model.LsbootSan in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method createLsbootSan.
private LsbootSan createLsbootSan(String spDN, Map<String, Map<String, Integer>> hbaToStoragePortMap, LsServer lsServerCurrent) throws ClientGeneralException {
Map<String, String> hbaToSwitchIdMap = getHBAToSwitchIdMap(lsServerCurrent);
LsbootSan lsbootSan = new LsbootSan();
lsbootSan.setOrder("1");
lsbootSan.setRn("san");
for (String hba : hbaToStoragePortMap.keySet()) {
Map<String, Integer> ports = hbaToStoragePortMap.get(hba);
LsbootSanCatSanImage lsbootSanCatSanImage = createLsbootSanCatSanImage(ports, hba, hbaToSwitchIdMap);
lsbootSan.getContent().add(factory.createLsbootSanCatSanImage(lsbootSanCatSanImage));
}
return lsbootSan;
}
Aggregations