Search in sources :

Example 11 with ComputeSystem

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

the class ComputeDeviceControllerImpl method addStepsPreOsInstall.

/**
 * Create/Add Pre-OS install steps to the workflow.
 *
 * @param workflow
 *            {@link Workflow} instance
 * @param waitFor
 *            If non-null, the step will not be queued for execution in the
 *            Dispatcher until the Step or StepGroup indicated by the
 *            waitFor has completed. The waitFor may either be a string
 *            representation of a Step UUID, or the name of a StepGroup.
 * @param computeSystemId
 *            {@link URI} computeSystem Id
 * @param hostId
 *            {@link URI} host Id
 * @param prepStepId
 *            {@link String} step Id
 * @return waitFor step name
 */
@Override
public String addStepsPreOsInstall(Workflow workflow, String waitFor, URI computeSystemId, URI hostId, String prepStepId) {
    log.info("addStepsPreOsInstall");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    Host host = _dbClient.queryObject(Host.class, hostId);
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
    // TODO COP-28960 check for null ce
    URI computeElementId = ce.getId();
    log.info("sptId:" + ce.getSptId());
    if (ce.getSptId() != null) {
        URI sptId = URI.create(ce.getSptId());
        UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
        // TODO COP-28960 check template not null
        log.info("is updating:" + template.getUpdating());
        if (template.getUpdating()) {
            waitFor = workflow.createStep(UNBIND_HOST_FROM_TEMPLATE, "prepare host for os install by unbinding it from service profile template", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("unbindHostFromTemplateStep", computeSystemId, hostId), new Workflow.Method("rollbackUnbindHostFromTemplate", computeSystemId, hostId), null);
        }
        // Set host to boot from lan
        waitFor = workflow.createStep(OS_INSTALL_SET_LAN_BOOT, "Set the host to boot from LAN", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("setLanBootTargetStep", computeSystemId, computeElementId, hostId), new Workflow.Method("setNoBootStep", computeSystemId, computeElementId, hostId), null);
        // Set the OS install Vlan on the first vnic
        waitFor = workflow.createStep(OS_INSTALL_PREPARE_OS_NETWORK, "prepare network for os install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("prepareOsInstallNetworkStep", computeSystemId, computeElementId), new Workflow.Method("rollbackOsInstallNetwork", computeSystemId, computeElementId, prepStepId), prepStepId);
    } else {
        log.error("sptId is null!");
        throw new IllegalArgumentException("addStepsPreOsInstall method failed.  Could not find Serviceprofile template id from computeElement" + ce.getLabel());
    }
    return waitFor;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 12 with ComputeSystem

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

the class ComputeDeviceControllerImpl method rebindHostToTemplate.

private void rebindHostToTemplate(URI computeSystemId, URI hostId) throws InternalException {
    log.info("rebindHostToTemplate");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    getDevice(cs.getSystemType()).rebindHostToTemplate(computeSystemId, hostId);
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 13 with ComputeSystem

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

the class ComputeDeviceControllerImpl method prepareOsInstallNetwork.

private Map<String, Boolean> prepareOsInstallNetwork(URI computeSystemId, URI computeElementId) throws InternalException {
    log.info("prepareOsInstallNetwork");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    return getDevice(cs.getSystemType()).prepareOsInstallNetwork(computeSystemId, computeElementId);
}
Also used : ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 14 with ComputeSystem

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

the class ComputeDeviceControllerImpl method deactivateComputeSystemHost.

/**
 * Deactivate compute system host
 *
 * @param csId
 *            {@link URI} compute system URI
 * @param hostId
 *            {@link URI} host URI
 * @param stepId
 *            step id
 */
public void deactivateComputeSystemHost(URI csId, URI hostId, String stepId) {
    log.info("deactivateComputeSystemHost");
    Host host = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
        host = _dbClient.queryObject(Host.class, hostId);
        if (null != host) {
            // Added check before we get here
            if (NullColumnValueGetter.isNullURI(host.getComputeElement()) && NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
                // NO-OP
                log.info("Host " + host.getLabel() + " has no computeElement association and no service profile association");
                WorkflowStepCompleter.stepSucceded(stepId);
                return;
            }
            getDevice(cs.getSystemType()).deactivateHost(cs, host);
        } else {
            throw new RuntimeException("Host null for uri " + hostId);
        }
    } catch (Exception exception) {
        log.error("Error on deactivate ComputeSystemHost with hostid {} and computementid {}", hostId, csId, exception);
        ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToDeactivateHost(host != null ? host.getHostName() : hostId.toString(), exception);
        WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
        return;
    }
    WorkflowStepCompleter.stepSucceded(stepId);
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) Host(com.emc.storageos.db.client.model.Host) 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)

Example 15 with ComputeSystem

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

the class ComputeDeviceControllerImpl method rollbackUnbindHostFromTemplate.

/**
 * Roll back method to undo changes of a unbindhost from template step
 *
 * @param computeSystemId
 *            {@link URI} computeSystem URI
 * @param hostId
 *            {@link URI} host URI
 * @param stepId
 *            {@link String} step id
 */
public void rollbackUnbindHostFromTemplate(URI computeSystemId, URI hostId, String stepId) {
    log.info("rollbackUnbindHostFromTemplate");
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
        rebindHostToTemplate(cs.getId(), hostId);
        // TODO COP-28961 check if rebind succeeded, and if not, mark rollback as failed
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception e) {
        String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
        ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
        log.error("Unexpected exception rollbackUnbindHostFromTemplate: " + e.getMessage(), e);
        WorkflowStepCompleter.stepFailed(stepId, controllerException);
    }
}
Also used : 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)

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