Search in sources :

Example 16 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method removeHostFromVcenterCluster.

/**
 * This will attempt to remove host from vCenter cluster.
 *
 * @param hostId
 * @param stepId
 */
public void removeHostFromVcenterCluster(URI hostId, String stepId) {
    log.info("removeHostFromVcenterCluster {}", hostId);
    Host host = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        host = _dbClient.queryObject(Host.class, hostId);
        if (NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
            log.info("datacenter is null, nothing to do");
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        if (NullColumnValueGetter.isNullURI(host.getCluster())) {
            log.warn("cluster is null, nothing to do");
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_068);
        String taskId = stepId;
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.UPDATE_VCENTER_CLUSTER);
        _dbClient.createTaskOpStatus(VcenterDataCenter.class, host.getVcenterDataCenter(), taskId, op);
        AsyncTask task = new AsyncTask(VcenterDataCenter.class, host.getVcenterDataCenter(), taskId);
        final String workflowKey = "updateVcenterCluster";
        if (!WorkflowService.getInstance().hasWorkflowBeenCreated(taskId, workflowKey)) {
            vcenterController.updateVcenterCluster(task, host.getCluster(), null, new URI[] { host.getId() }, null);
            // Mark this workflow as created/executed so we don't do it
            // again on retry/resume
            WorkflowService.getInstance().markWorkflowBeenCreated(taskId, workflowKey);
        }
    } catch (VcenterControllerException e) {
        log.warn("VcenterControllerException when trying to removeHostFromVcenterCluster: " + e.getMessage(), e);
        if (e.getCause() instanceof VcenterObjectNotFoundException) {
            log.info("did not find the host, considering success");
            WorkflowStepCompleter.stepSucceded(stepId);
        } else if (e.getCause() instanceof VcenterObjectConnectionException) {
            log.info("host is not connected, considering success");
            WorkflowStepCompleter.stepSucceded(stepId);
        } else {
            log.error("failure " + e);
            WorkflowStepCompleter.stepFailed(stepId, e);
        }
    } catch (InternalException e) {
        log.error("InternalException when trying to removeHostFromVcenterCluster: " + e.getMessage(), e);
        WorkflowStepCompleter.stepFailed(stepId, e);
    } catch (Exception e) {
        log.error("unexpected exception: " + e.getMessage(), e);
        ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToRemoveHostVcenterCluster(host != null ? host.getHostName() : hostId.toString(), e);
        WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
    }
}
Also used : VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Host(com.emc.storageos.db.client.model.Host) Operation(com.emc.storageos.db.client.model.Operation) 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) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 17 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method putHostInMaintenanceMode.

/**
 * This will attempt to put host into maintenance mode on a Vcenter.
 *
 * @param hostId
 * @param stepId
 */
public void putHostInMaintenanceMode(URI hostId, String stepId) {
    log.info("putHostInMaintenanceMode {}", hostId);
    Host host = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        host = _dbClient.queryObject(Host.class, hostId);
        if (NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
            log.info("datacenter is null, nothing to do");
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        if (NullColumnValueGetter.isNullURI(host.getCluster())) {
            log.warn("cluster is null, nothing to do");
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        vcenterController.enterMaintenanceMode(host.getVcenterDataCenter(), host.getCluster(), host.getId());
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (VcenterControllerException e) {
        log.warn("VcenterControllerException when trying to putHostInMaintenanceMode: " + e.getMessage(), e);
        if (e.getCause() instanceof VcenterObjectNotFoundException) {
            if (checkPreviouslyFailedDecommission(host)) {
                log.info("did not find the host, considering success based on previous delete host operation");
                WorkflowStepCompleter.stepSucceded(stepId);
            } else {
                log.info("did not find the host, considering failure as no previous delete host operation found");
                WorkflowStepCompleter.stepFailed(stepId, e);
            }
        } else if (e.getCause() instanceof VcenterObjectConnectionException) {
            if (checkPreviouslyFailedDecommission(host)) {
                log.info("host is not connected, considering success based on previous delete host operation");
                WorkflowStepCompleter.stepSucceded(stepId);
            } else {
                log.info("host is not connected, considering failure as no previous delete host operation found");
                WorkflowStepCompleter.stepFailed(stepId, e);
            }
        } else {
            log.error("failure " + e);
            WorkflowStepCompleter.stepFailed(stepId, e);
        }
    } catch (InternalException e) {
        log.error("InternalException when trying to putHostInMaintenanceMode: " + e.getMessage(), e);
        WorkflowStepCompleter.stepFailed(stepId, e);
    } catch (Exception e) {
        log.error("unexpected exception" + e.getMessage(), e);
        ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToPutHostInMaintenanceMode(host != null ? host.getHostName() : hostId.toString(), e);
        WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
    }
}
Also used : VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) Host(com.emc.storageos.db.client.model.Host) 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) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)17 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)17 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)15 VcenterSystemException (com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException)11 HostSystem (com.vmware.vim25.mo.HostSystem)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)6 Host (com.emc.storageos.db.client.model.Host)5 Cluster (com.emc.storageos.db.client.model.Cluster)4 Vcenter (com.emc.storageos.db.client.model.Vcenter)4 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 VcenterApiClient (com.emc.storageos.vcentercontroller.VcenterApiClient)4 ClusterComputeResource (com.vmware.vim25.mo.ClusterComputeResource)4 Task (com.vmware.vim25.mo.Task)3 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)2 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)2 HostScsiDisk (com.vmware.vim25.HostScsiDisk)2 HostStorageDeviceInfo (com.vmware.vim25.HostStorageDeviceInfo)2