Search in sources :

Example 6 with ComputeSystem

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;
}
Also used : ComputeSystemList(com.emc.storageos.model.compute.ComputeSystemList) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with ComputeSystem

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);
}
Also used : URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) Path(javax.ws.rs.Path) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with ComputeSystem

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);
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 9 with ComputeSystem

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);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 10 with ComputeSystem

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));
    }
}
Also used : Map(java.util.Map) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)50 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)15 URI (java.net.URI)15 Host (com.emc.storageos.db.client.model.Host)14 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)13 Produces (javax.ws.rs.Produces)13 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)12 Path (javax.ws.rs.Path)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)10 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)8 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)7 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)7 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)7 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)7 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)7 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 MalformedURLException (java.net.MalformedURLException)6 POST (javax.ws.rs.POST)6 URL (java.net.URL)5