use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceTest method testSetNoBoot.
@Test(groups = "onDemand50")
public void testSetNoBoot() throws ClientGeneralException {
LsServer lsServer = ucsmService.setServiceProfileToNoBoot(UCSM_SERVICE3, UCSM_HOST3_USERNAME, UCSM_HOST3_PASSWORD, SP_DN, new StringBuilder());
Assert.assertNotNull(lsServer, "Couldn't update the LsServer's boot order " + SP_DN);
System.out.println("Current State of the lsServer : " + lsServer.getOperState());
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceTest method testSetSanBootTarget.
@Test(groups = "onDemand50", dependsOnMethods = "testSetLanBoot")
public void testSetSanBootTarget() throws ClientGeneralException {
String aSide = "fc0";
String bside = "fc1";
Map<String, Map<String, Integer>> hbaToStoragePortMap = new HashMap<String, Map<String, Integer>>();
hbaToStoragePortMap.put(bside, ImmutableMap.of("50:00:09:73:00:12:9D:60", 1, "50:00:09:73:00:12:9D:1C", 1, "50:00:09:73:00:12:9D:7F", 1));
hbaToStoragePortMap.put(aSide, ImmutableMap.of("50:00:09:73:00:12:9D:60", 0, "50:00:09:73:00:12:9D:1C", 0, "50:00:09:73:00:12:9D:7F", 0));
LsServer lsServer = ucsmService.setServiceProfileToSanBoot(UCSM_SERVICE3, UCSM_HOST3_USERNAME, UCSM_HOST3_PASSWORD, SP_DN, hbaToStoragePortMap, new StringBuilder());
Assert.assertNotNull(lsServer, "Couldn't update the LsServer's boot order " + SP_DN);
System.out.println("Current State of the lsServer : " + lsServer.getOperState());
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UcsComputeDevice method setSanBootTarget.
@Override
public void setSanBootTarget(ComputeSystem cs, URI computeElementId, URI hostId, URI volumeId, boolean waitForServerRestart) throws InternalException {
ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, computeElementId);
Map<String, Map<String, Integer>> hbaToStoragePorts = getHBAToStoragePorts(volumeId, hostId);
// zoning map will be empty in older releases. Do we need to still continue this operation?
try {
if (null != computeElement) {
StringBuilder errorMessage = new StringBuilder();
LsServer lsServer = ucsmService.setServiceProfileToSanBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), hbaToStoragePorts, errorMessage);
if (lsServer != null) {
if (waitForServerRestart) {
pullAndPollManagedObject(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), LsServer.class);
}
} else {
throw new RuntimeException("Failed to set SAN boot target due to error from UCSM Service \n " + errorMessage);
}
} else {
throw new RuntimeException("ComputeElement object is null for id " + computeElementId);
}
} catch (Exception e) {
throw ComputeSystemControllerException.exceptions.unableToSetSanBootTarget(computeElementId.toString(), e);
}
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UcsComputeDevice method unbindHostFromTemplate.
@Override
public String unbindHostFromTemplate(URI computeSystemId, URI hostId) throws InternalException {
LOGGER.info("unbindHostFromTemplate");
Host host = _dbClient.queryObject(Host.class, hostId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
String sptDn = null;
try {
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_069);
// No need to check for initiators here, we are only unbinding the service profile template
if (host != null && !NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getUuid() != null) {
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
URI sptId = URI.create(ce.getSptId());
UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
sptDn = template.getDn();
LsServer sp = ucsmService.getLsServer(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), host.getUuid());
if (sp != null) {
URL ucsmURL = getUcsmURL(cs);
StringBuilder errorMessage = new StringBuilder();
if (null == ucsmService.unbindSPFromTemplate(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), sp.getDn(), errorMessage)) {
LOGGER.error("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
throw new RuntimeException("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
}
LOGGER.info("Successfully unbound host {} from template {}", host.getLabel(), template.getLabel());
} else {
LOGGER.error("Unable to unbind service profile to template. LsServer is null");
throw new RuntimeException("Unable to unbind service profile to template. LsServer is null");
}
} else {
LOGGER.error("Unable to unbind service profile to template, due to insufficient host data. Host or ComputeElement or host UUID is null");
throw new RuntimeException("Unable to unbind service profile to template, due to insufficient host data. Host or host's computeElement or host UUID is null");
}
} catch (Exception e) {
LOGGER.error("Unable to unbind service profile from template due to a exception", e);
throw ComputeSystemControllerException.exceptions.unbindHostFromTemplateFailed(host != null ? host.getId().toString() : null, e);
}
return sptDn;
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UcsComputeDevice method modifyLsServerNoBoot.
/**
* Modify the LsServer to have a no boot policy
* @param cs ComputeSystem instance
* @param contextStepId parent StepId
* @param stepId Id of step being executed.
* @return LsServer instance
*/
public LsServer modifyLsServerNoBoot(ComputeSystem cs, String contextStepId, String stepId) {
WorkflowStepCompleter.stepExecuting(stepId);
String spDn = (String) workflowService.loadStepData(contextStepId);
LOGGER.info("Modifying Service Profile to have no Boot Policy: " + spDn);
LsServer lsServer = null;
try {
StringBuilder errorMessage = new StringBuilder();
lsServer = ucsmService.setServiceProfileToNoBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), spDn, errorMessage);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_062);
if (null == lsServer) {
throw new RuntimeException("UCS invocation to set serviceProfile to No Boot failed, null LsServer was returned. \n " + errorMessage.toString());
}
WorkflowStepCompleter.stepSucceded(stepId);
LOGGER.info("Done updating Service Profile : " + spDn + " from Service Profile Template : " + spDn);
} catch (Exception e) {
LOGGER.error("Unable to modify LsServer...", e);
WorkflowStepCompleter.stepFailed(stepId, ComputeSystemControllerException.exceptions.unableToProvisionHost(spDn, cs.getNativeGuid(), e));
}
return lsServer;
}
Aggregations