Search in sources :

Example 31 with ComputeSystem

use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method discoverComputeSystem.

/**
 * Discover compute system
 *
 * @param csId
 *            {@link URI} computeSystem id
 */
@Override
public void discoverComputeSystem(URI csId) throws InternalException {
    log.info("discoverComputeSystems");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
    if (cs == null) {
        log.error("Could not get discovery target: " + csId);
        throw ComputeSystemControllerException.exceptions.targetNotFound(csId.toString());
    }
    getDevice(cs.getSystemType()).discoverComputeSystem(cs.getId());
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 32 with ComputeSystem

use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method prepareOsInstallNetworkStep.

/**
 * Method or step responsible for setting up the required OS install network
 *
 * @param computeSystemId
 *            {@link URI} compute system URI
 * @param computeElementId
 *            {@link URI} compute element URI
 * @param stepId
 *            {@link String} step id
 */
public void prepareOsInstallNetworkStep(URI computeSystemId, URI computeElementId, String stepId) {
    log.info("prepareOsInstallNetworkStep");
    ComputeSystem computeSystem = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        computeSystem = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_071);
        Map<String, Boolean> vlanMap = prepareOsInstallNetwork(computeSystemId, computeElementId);
        _workflowService.storeStepData(stepId, vlanMap);
        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.unableToSetOsInstallNetwork(computeSystem.getOsInstallNetwork(), computeElementId.toString(), e);
        }
        log.error("Exception prepareOsInstallNetworkStep: " + 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 prepareOsInstallNetworkStep: " + 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 33 with ComputeSystem

use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method setSanBootTarget.

/**
 * Method is responsible for setting boot from SAN
 *
 * @param computeSystemId
 *            {@link URI} computeSystem Id
 * @param computeElementId
 *            {@link URI} computeElement Id
 * @param hostId
 *            {@link URI} host Id
 * @param volumeId
 *            {@link URI} boot volume id
 * @param waitForServerRestart
 */
@Override
public void setSanBootTarget(URI computeSystemId, URI computeElementId, URI hostId, URI volumeId, boolean waitForServerRestart) throws InternalException {
    log.info("setSanBootTarget");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    getDevice(cs.getSystemType()).setSanBootTarget(cs, computeElementId, hostId, volumeId, waitForServerRestart);
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 34 with ComputeSystem

use of com.emc.storageos.db.client.model.ComputeSystem 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;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URL(java.net.URL) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 35 with ComputeSystem

use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.

the class UcsComputeDevice method clearDeviceSession.

@Override
public void clearDeviceSession(URI computeSystemId) throws InternalException {
    try {
        ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
        URL ucsmURL = getUcsmURL(cs);
        ucsmService.clearDeviceSession(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URL(java.net.URL) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

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