Search in sources :

Example 26 with ComputeElement

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

the class ComputeControllerImpl method createHosts.

@Override
public void createHosts(URI varray, URI vcpoolId, AsyncTask[] tasks) throws InternalException {
    _log.info("createHosts");
    for (AsyncTask task : tasks) {
        Host host = _dbClient.queryObject(Host.class, task._id);
        if (host != null) {
            if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
                ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
                execCompute("createHost", computeElement.getComputeSystem(), vcpoolId, varray, task._id, task._opId);
            } else {
                _dbClient.error(Host.class, task._id, task._opId, ComputeSystemControllerException.exceptions.noComputeElementAssociatedWithHost(host.getNativeGuid().toString(), host.getId().toString(), null));
            }
        } else {
            // if the host comes out to be null... Skipping for now
            continue;
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Host(com.emc.storageos.db.client.model.Host)

Example 27 with ComputeElement

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

the class ComputeControllerImpl method deactivateHost.

@Override
public void deactivateHost(AsyncTask[] tasks) throws InternalException {
    AsyncTask task = tasks[0];
    Host host = _dbClient.queryObject(Host.class, task._id);
    if (host != null) {
        if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
            ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
            execCompute("deactivateHost", computeElement.getComputeSystem(), task._id, task._opId);
        } else {
            _dbClient.error(Host.class, task._id, task._opId, ComputeSystemControllerException.exceptions.noComputeElementAssociatedWithHost(host.getNativeGuid().toString(), host.getId().toString(), null));
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Host(com.emc.storageos.db.client.model.Host)

Example 28 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement 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 29 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement 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 30 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement 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)

Aggregations

ComputeElement (com.emc.storageos.db.client.model.ComputeElement)52 Host (com.emc.storageos.db.client.model.Host)24 URI (java.net.URI)20 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)10 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)10 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)9 MalformedURLException (java.net.MalformedURLException)9 Produces (javax.ws.rs.Produces)9 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)8 HashMap (java.util.HashMap)8 Path (javax.ws.rs.Path)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 ComputeVirtualPool (com.emc.storageos.db.client.model.ComputeVirtualPool)6 UCSServiceProfile (com.emc.storageos.db.client.model.UCSServiceProfile)6 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)6 Cluster (com.emc.storageos.db.client.model.Cluster)4