use of com.emc.cloud.platform.ucs.out.model.LsPower in project coprhd-controller by CoprHD.
the class UCSMServiceTest method testSetLsServerPowerState.
@Test(groups = "onDemand1")
public void testSetLsServerPowerState() throws ClientGeneralException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Map<String, LsServer> associatedLsServers = ucsmService.getAllAssociatedLsServers(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD);
String powerStateToSet = null;
if (associatedLsServers != null && !associatedLsServers.isEmpty()) {
for (LsServer lsServer : associatedLsServers.values()) {
if (SP_DN.equals(lsServer.getDn())) {
if (lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
for (Object object : lsServer.getContent()) {
if (object instanceof JAXBElement<?>) {
if (((JAXBElement) object).getValue() instanceof LsPower) {
LsPower lsPower = ((JAXBElement<LsPower>) object).getValue();
if ("up".equals(lsPower.getState())) {
powerStateToSet = "down";
} else if ("down".equals(lsPower.getState())) {
powerStateToSet = "up";
}
LsServer lsServerOut = ucsmService.setLsServerPowerState(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD, lsServer.getDn(), powerStateToSet, new StringBuilder());
if (lsServerOut.getContent() != null && !lsServerOut.getContent().isEmpty()) {
for (Object object2 : lsServerOut.getContent()) {
if (object2 instanceof JAXBElement<?>) {
if (((JAXBElement) object2).getValue() instanceof LsPower) {
LsPower lsPower2 = ((JAXBElement<LsPower>) object2).getValue();
Assert.assertTrue(powerStateToSet.equals(lsPower2.getState()));
}
}
}
}
}
}
}
}
}
}
}
System.out.println("Number of associated lsServers found: " + associatedLsServers.size());
}
Aggregations