use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method getComputeSystemList.
/**
* Gets a list of all (active) ViPR Compute Systems.
*
* @brief List compute systems
* @return A list of Name/Id pairs representing active Compute Systems. The
* IDs returned can be used to fetch more detailed information about
* Compute Systems
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ComputeSystemList getComputeSystemList() {
List<URI> ids = _dbClient.queryByType(ComputeSystem.class, true);
ComputeSystemList list = new ComputeSystemList();
Iterator<ComputeSystem> iter = _dbClient.queryIterativeObjects(ComputeSystem.class, ids);
while (iter.hasNext()) {
list.getComputeSystems().add(toNamedRelatedResource(iter.next()));
}
return list;
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method updateComputeSystem.
/**
* Updates the Compute System, and (re)discovers it
*
* @param id
* the URN of a ViPR Compute System to be updated
* @param param
* An instance of {@link ComputeSystemUpdate} that represents the
* attributes of a Compute Systemt that are to be updated.
* @brief Update compute system
* @return Returns an instance of {@link TaskResourceRep} which represents
* the Task created for update (as it triggers rediscovery). The
* task can then be queried to know status and progress.
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateComputeSystem(@PathParam("id") URI id, ComputeSystemUpdate param) throws InternalException {
ArgValidator.checkFieldUriType(id, ComputeSystem.class, "id");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, id);
ArgValidator.checkEntityNotNull(cs, id, isIdEmbeddedInURL(id));
// ipAddress is not allowed for update
if (param.getIpAddress() != null) {
throw APIException.badRequests.changesNotSupportedFor("IP Address", "Compute Systems");
}
// Check for existing device.
checkForDuplicateDevice(cs.getId(), param.getIpAddress(), param.getPortNumber(), param.getName());
if (param.getName() != null) {
cs.setLabel(param.getName());
}
if (param.getIpAddress() != null) {
cs.setIpAddress(param.getIpAddress());
}
if (param.getPortNumber() != null) {
cs.setPortNumber(param.getPortNumber());
}
if (param.getUseSSL() != null) {
cs.setSecure(param.getUseSSL());
}
if (param.getUserName() != null) {
cs.setUsername(param.getUserName());
}
if (param.getPassword() != null) {
cs.setPassword(param.getPassword());
}
if (param.getOsInstallNetwork() != null) {
if (StringUtils.isBlank(param.getOsInstallNetwork())) {
cs.setOsInstallNetwork("");
} else {
if (cs.getVlans() != null) {
if (cs.getVlans().contains(param.getOsInstallNetwork())) {
cs.setOsInstallNetwork(param.getOsInstallNetwork());
} else {
throw APIException.badRequests.invalidParameterOsInstallNetworkDoesNotExist(param.getOsInstallNetwork());
}
} else {
// allow vlan to be set without successful discovery
cs.setOsInstallNetwork(param.getOsInstallNetwork());
}
}
}
URI imageServerURI = param.getComputeImageServer();
associateImageServerToComputeSystem(imageServerURI, cs);
cs.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(cs));
_dbClient.updateObject(cs);
recordAndAudit(cs, OperationTypeEnum.UPDATE_COMPUTE_SYSTEM, true, null);
return doDiscoverComputeSystem(cs);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method unbindHostFromTemplate.
private String unbindHostFromTemplate(URI computeSystemId, URI hostId) throws InternalException {
log.info("unbindHostFromTemplate");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
return getDevice(cs.getSystemType()).unbindHostFromTemplate(computeSystemId, hostId);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method unbindHostFromTemplateStep.
/**
* Unbind host from service profile template
*
* @param computeSystemId
* {@link URI} computeSystem URI
* @param hostId
* {@link URI} host URI
* @param stepId
* {@link String} step id
*/
public void unbindHostFromTemplateStep(URI computeSystemId, URI hostId, String stepId) {
log.info("unbindHostFromTemplateStep");
ComputeSystem computeSystem = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
computeSystem = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
String sptDn = unbindHostFromTemplate(computeSystemId, hostId);
_workflowService.storeStepData(stepId, sptDn);
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ServiceCoded sce = ImageServerControllerException.exceptions.unexpectedException(opName, e);
if (computeSystem != null) {
sce = ComputeSystemControllerException.exceptions.unableToUpdateHostAfterOSInstall(hostId.toString(), e);
}
log.error("Exception unbindHostFromTemplateStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, sce);
} catch (Exception e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
log.error("Unexpected exception unbindHostFromTemplateStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, controllerException);
}
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method removeOsInstallNetworkStep.
/**
* Method to remove OS install network post OS installation
*
* @param computeSystemId
* {@link URI} computeSystem Id
* @param computeElementId
* {@link URI} computeElement Id
* @param contextStepId
* {@link String} parent step Id
* @param stepId
* current step id
*/
public void removeOsInstallNetworkStep(URI computeSystemId, URI computeElementId, String contextStepId, String stepId) {
log.info("removeOsInstallNetworkStep");
try {
WorkflowStepCompleter.stepExecuting(stepId);
@SuppressWarnings("unchecked") Map<String, Boolean> vlanMap = (Map<String, Boolean>) _workflowService.loadStepData(contextStepId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
removeOsInstallNetwork(computeSystemId, cs.getSystemType(), computeElementId, vlanMap);
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
log.error("Exception removeOsInstallNetworkStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, e);
} catch (Exception e) {
log.error("Unexpected exception removeOsInstallNetworkStep: " + e.getMessage(), e);
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
WorkflowStepCompleter.stepFailed(stepId, ImageServerControllerException.exceptions.unexpectedException(opName, e));
}
}
Aggregations