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());
}
}
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);
}
}
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);
}
}
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;
}
}
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);
}
}
Aggregations