Search in sources :

Example 36 with DiscoveredSystemObject

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

the class MeteringTaskCompleter method updateObjectState.

protected void updateObjectState(DbClient dbClient, DiscoveredDataObject.DataCollectionJobStatus jobStatus) {
    Class type = getType();
    if (DiscoveredSystemObject.class.isAssignableFrom(type)) {
        try {
            DiscoveredSystemObject dbObject = (DiscoveredSystemObject) DataObject.createInstance(type, getId());
            dbObject.trackChanges();
            dbObject.setMeteringStatus(jobStatus.toString());
            dbClient.persistObject(dbObject);
        } catch (InstantiationException ex) {
            DatabaseException.fatals.queryFailed(ex);
        } catch (IllegalAccessException ex) {
            DatabaseException.fatals.queryFailed(ex);
        }
    } else {
        throw new RuntimeException("Unsupported system Type : " + type.toString());
    }
}
Also used : DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject)

Example 37 with DiscoveredSystemObject

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

the class ComputeSystemDiscoveryEngine method discoverInLock.

/**
 * Performs the discovery, within a lock.
 *
 * @param targetId
 *            the ID of the target to discover.
 */
protected void discoverInLock(String targetId) {
    DiscoveredSystemObject target = modelClient.findById(URI.create(targetId));
    if (target == null) {
        LOG.error("Could not find: " + targetId);
        throw ComputeSystemControllerException.exceptions.targetNotFound(targetId);
    }
    ComputeSystemDiscoveryAdapter adapter = getDiscoveryAdapter(targetId);
    if (adapter != null) {
        if (LOG.isInfoEnabled()) {
            LOG.info("Discovering target " + target.getLabel() + " [" + targetId + "]");
        }
        try {
            adapter.discoverTarget(targetId);
            if (LOG.isInfoEnabled()) {
                LOG.info("Discovery completed for " + target.getLabel() + " [" + targetId + "]");
            }
        } catch (CompatibilityException e) {
            String errorMessage = adapter.getErrorMessage(e);
            LOG.error("Device is incompatible: " + target.getLabel() + " [" + targetId + "]: " + errorMessage);
            adapter.discoveryFailure(target, DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name(), errorMessage);
            throw e;
        } catch (RuntimeException e) {
            String errorMessage = adapter.getErrorMessage(e);
            LOG.error("Discovery failed for " + target.getLabel() + " [" + targetId + "]: " + errorMessage, e);
            adapter.discoveryFailure(target, DiscoveredDataObject.CompatibilityStatus.UNKNOWN.name(), errorMessage);
            throw ComputeSystemControllerException.exceptions.discoverFailed(targetId, e);
        }
    } else {
        LOG.warn("No discovery adapter for target " + target.getLabel() + " [" + targetId + "]");
        target.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.UNKNOWN.name());
        dbClient.persistObject(target);
        throw ComputeSystemControllerException.exceptions.discoveryAdapterNotFound(target.getLabel(), targetId);
    }
}
Also used : CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject)

Example 38 with DiscoveredSystemObject

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

the class DiscoveryStatusUtils method markAsSucceeded.

/**
 * Marks the target as succeeded.
 *
 * @param target
 *            the target object.
 */
public static void markAsSucceeded(ModelClient modelClient, DataObject target) {
    if (target instanceof DiscoveredSystemObject) {
        DiscoveredSystemObject obj = (DiscoveredSystemObject) target;
        obj.setDiscoveryStatus(DataCollectionJobStatus.COMPLETE.name());
        obj.setLastDiscoveryStatusMessage("");
        obj.setLastDiscoveryRunTime(System.currentTimeMillis());
        obj.setSuccessDiscoveryTime(System.currentTimeMillis());
        modelClient.save(obj);
    }
}
Also used : DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject)

Example 39 with DiscoveredSystemObject

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

the class ExportWorkflowEntryPoints method exportGroupUpdate.

/**
 * This function is called from a main workflow that performs updated to an export
 * group on may storage arrays. This step performs the updates for one array. It
 * simply invokes the workflow that was pre-created that will do the needed adds/removes,
 *
 * @param storageURI
 *            the storage array of the masks to be updated
 * @param exportGroupURI
 *            the export group URI
 * @param storageWorkflow
 *            the pre-created workflow for this storage array.
 * @param token
 *            the task Id
 * @throws ControllerException
 *             when an exception is encountered in the workflow execution.
 */
public void exportGroupUpdate(URI storageURI, URI exportGroupURI, Workflow storageWorkflow, String token) throws ControllerException {
    try {
        WorkflowStepCompleter.stepExecuting(token);
        final String workflowKey = "exportGroupUpdate";
        if (!WorkflowService.getInstance().hasWorkflowBeenCreated(token, workflowKey)) {
            DiscoveredSystemObject storage = ExportWorkflowUtils.getStorageSystem(_dbClient, storageURI);
            MaskingOrchestrator orchestrator = getOrchestrator(storage.getSystemType());
            orchestrator.exportGroupUpdate(storageURI, exportGroupURI, storageWorkflow, token);
            // Mark this workflow as created/executed so we don't do it again on retry/resume
            WorkflowService.getInstance().markWorkflowBeenCreated(token, workflowKey);
        }
    } catch (Exception e) {
        DeviceControllerException exception = DeviceControllerException.exceptions.exportGroupUpdateFailed(e);
        WorkflowStepCompleter.stepFailed(token, exception);
        throw exception;
    }
}
Also used : DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 40 with DiscoveredSystemObject

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

the class ExportWorkflowEntryPoints method exportAddPathsStep.

public void exportAddPathsStep(URI storageURI, URI exportGroupURI, URI varray, URI exportMaskURI, Map<URI, List<URI>> adjustedPaths, Map<URI, List<URI>> removePaths, String token) throws ControllerException {
    try {
        WorkflowStepCompleter.stepExecuting(token);
        final String workflowKey = "addPaths";
        if (!WorkflowService.getInstance().hasWorkflowBeenCreated(token, workflowKey)) {
            DiscoveredSystemObject storage = ExportWorkflowUtils.getStorageSystem(_dbClient, storageURI);
            MaskingOrchestrator orchestrator = getOrchestrator(storage.getSystemType());
            orchestrator.portRebalance(storageURI, exportGroupURI, varray, exportMaskURI, adjustedPaths, removePaths, true, token);
            // Mark this workflow as created/executed so we don't do it again on retry/resume
            WorkflowService.getInstance().markWorkflowBeenCreated(token, workflowKey);
        } else {
            _log.info("Sub-workflow for exportAddPathsStep was already created");
        }
    } catch (Exception e) {
        DeviceControllerException exception = DeviceControllerException.exceptions.exportGroupPortRebalanceError(e);
        WorkflowStepCompleter.stepFailed(token, exception);
    }
}
Also used : DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Aggregations

DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)15 ControllerException (com.emc.storageos.volumecontroller.ControllerException)14 WorkflowException (com.emc.storageos.workflow.WorkflowException)14 Workflow (com.emc.storageos.workflow.Workflow)13 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)4 URI (java.net.URI)3 Controller (com.emc.storageos.Controller)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CompatibilityException (com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException)1 StoragePortGroup (com.emc.storageos.db.client.model.StoragePortGroup)1 RetryableDatabaseException (com.emc.storageos.db.exceptions.RetryableDatabaseException)1 AbstractDiscoveredSystemController (com.emc.storageos.impl.AbstractDiscoveredSystemController)1 ProtectionExportController (com.emc.storageos.protectioncontroller.ProtectionExportController)1 RPController (com.emc.storageos.protectioncontroller.RPController)1 RPDeviceController (com.emc.storageos.protectioncontroller.impl.recoverpoint.RPDeviceController)1 WorkflowRestartedException (com.emc.storageos.workflow.WorkflowRestartedException)1 IOException (java.io.IOException)1