use of com.emc.cloud.platform.ucs.in.model.LsPower in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method setLsServerPowerState.
/**
* @param ucsmURL
* @param username
* @param password
* @param lsServerDN
* - is the DN of the lsServer (unique for the UCSM that's
* represented by ucsmURL)
* @param powerState
* - is "up" or "down"
* @return
* @throws ClientGeneralException
*/
@Override
public LsServer setLsServerPowerState(String ucsmURL, String username, String password, String lsServerDN, String powerState, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigConfMo configConfMo = new ConfigConfMo();
configConfMo.setInHierarchical("true");
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(lsServerDN);
LsPower lsPower = new LsPower();
lsPower.setRn("power");
lsPower.setState(powerState);
lsServer.getContent().add(factory.createLsPower(lsPower));
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
configConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer returnedLsServer = pushLsServer(computeSession, factory, configConfMo, errorMessage);
List<LsPower> lsPowers = getSubElements(returnedLsServer.getContent(), LsPower.class);
if ((lsPowers == null) || lsPowers.isEmpty() || (lsPowers.get(0) == null) || !lsPowers.get(0).getState().equals(powerState)) {
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to set power state to '" + powerState + "' on LsServer : " + lsServerDN });
}
return returnedLsServer;
}
use of com.emc.cloud.platform.ucs.in.model.LsPower in project coprhd-controller by CoprHD.
the class ConfigMOMarshallingTest method testMarshalling.
@Test(groups = "onDemand")
public void testMarshalling() throws ClientGeneralException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, JAXBException {
String lsServerDN = "org-root/ls-vlad2-os-install";
String powerState = "up";
ConfigConfMo configConfMo = new ConfigConfMo();
configConfMo.setInHierarchical("true");
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(lsServerDN);
LsPower lsPower = new LsPower();
lsPower.setRn("power");
lsPower.setState(powerState);
lsServer.getContent().add(factory.createLsPower(lsPower));
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
configConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
JAXBElement<ConfigConfMo> jaxbElement = factory.createConfigConfMo(configConfMo);
StringWriter writer = new StringWriter();
if (jaxbElement != null) {
Marshaller marshaller = ucsInContext.createMarshaller();
marshaller.marshal(jaxbElement, writer);
}
String payload = writer.toString();
System.out.println("Payload : " + payload);
}
Aggregations