Search in sources :

Example 26 with ComputeSystem

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

the class ComputeDeviceControllerImpl method powerDownComputeElement.

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

Example 27 with ComputeSystem

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

the class ComputeDeviceControllerImpl method addStepsDeactivateHost.

/**
 * Method to add required steps to deactivate a host
 *
 * @param workflow
 *            {@link Workflow} instance
 * @param waitFor
 *            {@link String} 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 hostId
 *            {@link URI} host URI
 * @param deactivateBootVolume
 *            boolean indicating if boot volume has to be deleted.
 * @return waitFor step name
 */
@Override
public String addStepsDeactivateHost(Workflow workflow, String waitFor, URI hostId, boolean deactivateBootVolume, List<VolumeDescriptor> volumeDescriptors) throws InternalException {
    Host host = _dbClient.queryObject(Host.class, hostId);
    if (host == null) {
        log.error("No host found with Id: {}", hostId);
        return waitFor;
    } else if (NullColumnValueGetter.isNullURI(host.getServiceProfile()) && NullColumnValueGetter.isNullURI(host.getComputeElement())) {
        /**
         * No steps need to be added - as this was not a host that we
         * created in ViPR. If it was serviceProfile or computeElement property of the host
         * would have been set.
         */
        log.info("Host: {} has no associated serviceProfile or computeElement. So skipping service profile and boot volume deletion steps", host.getLabel());
        return waitFor;
    }
    ComputeSystem cs = null;
    if (!NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
        UCSServiceProfile serviceProfile = _dbClient.queryObject(UCSServiceProfile.class, host.getServiceProfile());
        if (serviceProfile != null) {
            cs = _dbClient.queryObject(ComputeSystem.class, serviceProfile.getComputeSystem());
            if (cs == null) {
                log.error("ServiceProfile " + serviceProfile.getDn() + " has an invalid computeSystem reference: " + serviceProfile.getComputeSystem());
                return waitFor;
            }
        }
    } else if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
        ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
        if (computeElement != null) {
            cs = _dbClient.queryObject(ComputeSystem.class, computeElement.getComputeSystem());
            if (cs == null) {
                log.error("ComputeElement " + computeElement.getDn() + " has an invalid computeSystem reference: " + computeElement.getComputeSystem());
                return waitFor;
            }
        }
    }
    if (cs == null) {
        log.error("Could not determine the Compute System the host {} is provisioned on. Skipping service profile and boot volume deletion steps", host.getLabel());
        return waitFor;
    } else {
        // TODO: need to break this up into individual smaller steps so that we can try to recover using rollback if decommission failed
        waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_HOST, "Unbind blade from service profile", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("deactivateComputeSystemHost", cs.getId(), hostId), null, null);
        if (deactivateBootVolume && !NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
            waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_BOOT_VOLUME_UNTAG, "Untag the boot volume for the host", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("untagBlockBootVolume", hostId, volumeDescriptors), null, null);
            waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_BOOT_VOLUME, "Delete the boot volume for the host", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("deleteBlockBootVolume", hostId, volumeDescriptors), null, null);
        } else if (!deactivateBootVolume) {
            log.info("flag deactivateBootVolume set to false");
        } else if (!NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
            log.info("Host " + host.getLabel() + " has no bootVolume association");
        }
    }
    return waitFor;
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 28 with ComputeSystem

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

the class ComputeDeviceControllerImpl method addStepsPostOsInstall.

/**
 * Create/Add PostOsInstall 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 computeElementId
 *            {@link URI} computeElement Id
 * @param hostId
 *            {@link URI} host Id
 * @param contextStepId
 *            {@link String} step Id
 * @param volumeId
 *            {@link URI} bootvolume Id
 * @return waitFor step name
 */
@Override
public String addStepsPostOsInstall(Workflow workflow, String waitFor, URI computeSystemId, URI computeElementId, URI hostId, String contextStepId, URI volumeId) {
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    waitFor = workflow.createStep(OS_INSTALL_REMOVE_OS_NETWORK, "remove network after os install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("removeOsInstallNetworkStep", computeSystemId, computeElementId, contextStepId), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
    waitFor = workflow.createStep(OS_INSTALL_SET_SAN_BOOT_TARGET, "Set the SAN boot target based on the storage ports used in the volume export", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("setSanBootTargetStep", computeSystemId, computeElementId, hostId, volumeId), new Workflow.Method("setNoBootStep", computeSystemId, computeElementId, hostId), null);
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
    if (ce.getSptId() != null) {
        URI sptId = URI.create(ce.getSptId());
        UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
        // TODO COP-28960 check for template not null
        if (template.getUpdating()) {
            waitFor = workflow.createStep(REBIND_HOST_TO_TEMPLATE, "Rebind host to service profile template after OS install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("rebindHostToTemplateStep", computeSystemId, hostId), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
        }
    } else {
        log.error("Serviceprofile ID attribute is null.");
        throw new IllegalArgumentException("addStepsPostOsInstall 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) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 29 with ComputeSystem

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

the class ComputeDeviceControllerImpl method rollbackOsInstallNetwork.

/**
 * Roll back method to undo changes of a prepareOsInstallNetworkStep
 *
 * @param computeSystemId
 *            {@link URI} compute system URI
 * @param computeElementId
 *            {@link URI} compute element URI
 * @param prepareStepId
 *            parent workflow step id
 * @param stepId
 *            current step id
 */
public void rollbackOsInstallNetwork(URI computeSystemId, URI computeElementId, String prepareStepId, String stepId) {
    log.info("rollbackOsInstallNetwork");
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
        ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
        @SuppressWarnings("unchecked") Map<String, Boolean> vlanMap = (Map<String, Boolean>) _workflowService.loadStepData(prepareStepId);
        log.info("vlanMap {}", vlanMap);
        if (vlanMap != null) {
            removeOsInstallNetwork(cs.getId(), cs.getSystemType(), ce.getId(), vlanMap);
        }
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception e) {
        String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
        ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
        log.error("Unexpected exception rollbackOsInstallNetwork: " + e.getMessage(), e);
        WorkflowStepCompleter.stepFailed(stepId, controllerException);
    }
}
Also used : ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) 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)

Example 30 with ComputeSystem

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

the class ComputeDeviceControllerImpl method createHost.

/**
 * Create host using the specified params
 *
 * @param csId
 *            {@link URI} computesystem Id
 * @param vcpoolId
 *            {@link URI} vcpoolId
 * @param varray
 *            {@link URI} varray Id
 * @param hostId
 *            {@link URI} host Id
 * @param opId
 *            (@link String} operation Id
 */
@Override
public void createHost(URI csId, URI vcpoolId, URI varray, URI hostId, String opId) throws InternalException {
    log.info("createHost");
    Host host = _dbClient.queryObject(Host.class, hostId);
    // TODO COP-28960 check for null -- host, ce, etc.
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
    ComputeVirtualPool vcp = _dbClient.queryObject(ComputeVirtualPool.class, vcpoolId);
    VirtualArray vArray = _dbClient.queryObject(VirtualArray.class, varray);
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, ce.getComputeSystem());
    TaskCompleter tc = new ComputeHostCompleter(hostId, opId, OperationTypeEnum.CREATE_HOST, EVENT_SERVICE_TYPE);
    getDevice(cs.getSystemType()).createHost(cs, host, vcp, vArray, tc);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

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