use of com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask in project coprhd-controller by CoprHD.
the class StorageSystemService method discoverSystem.
/**
* Allows the user to manually discover the registered storage system with
* the passed id.
*
* @param id the URN of a ViPR storage system.
* @QueryParam namespace
* StorageSystem Auto Discovery is grouped into multiple namespaces.
* Namespace is used to discover specific parts of Storage System.
*
* Possible Values :
* UNMANAGED_VOLUMES
* UNMANAGED_FIESYSTEMS
* ALL
*
* UNMANAGED_VOLUMES will discover all the Volumes which are present in the Array,
* and only supported on vmax and vnxblock.
* Using UNMANAGED_VOLUMES Namespace in other system types would result in error.
*
* UNMANAGED_FILESYSTEMS will discover all the fileystems which are present in the Array,
* and only supported on netapp.
*
* Using UNMANAGED_FILESYSTEMS Namespace in other system types would result in error.
*
* @brief Discover storage system
* @throws ControllerException When an error occurs discovering the storage
* system.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/discover")
public TaskResourceRep discoverSystem(@PathParam("id") URI id, @QueryParam("namespace") String namespace) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(storageSystem, id, isIdEmbeddedInURL(id), true);
String deviceType = storageSystem.getSystemType();
// If Namespace is empty or null set it to ALL as default
if (namespace == null || namespace.trim().length() < 1) {
namespace = Discovery_Namespaces.ALL.toString();
}
if (!validateNameSpace(namespace, storageSystem)) {
throw APIException.badRequests.invalidParameterStorageSystemNamespace(namespace);
}
// Trigger unmanaged resource discovery only when system is compatible.
if ((Discovery_Namespaces.UNMANAGED_VOLUMES.name().equalsIgnoreCase(namespace) || Discovery_Namespaces.BLOCK_SNAPSHOTS.name().equalsIgnoreCase(namespace) || Discovery_Namespaces.UNMANAGED_FILESYSTEMS.name().equalsIgnoreCase(namespace)) && !CompatibilityStatus.COMPATIBLE.name().equalsIgnoreCase(storageSystem.getCompatibilityStatus())) {
throw APIException.badRequests.cannotDiscoverUnmanagedResourcesForUnsupportedSystem();
}
BlockController controller = getController(BlockController.class, deviceType);
DiscoveredObjectTaskScheduler scheduler = null;
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
if (Discovery_Namespaces.ARRAY_AFFINITY.name().equalsIgnoreCase(namespace)) {
if (!storageSystem.deviceIsType(Type.vmax) && !storageSystem.deviceIsType(Type.vnxblock) && !storageSystem.deviceIsType(Type.xtremio) && !storageSystem.deviceIsType(Type.unity)) {
throw APIException.badRequests.cannotDiscoverArrayAffinityForUnsupportedSystem(storageSystem.getSystemType());
}
scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ArrayAffinityJobExec(controller));
URI providerURI = storageSystem.getActiveProviderURI();
List<URI> systemIds = new ArrayList<URI>();
systemIds.add(id);
if (!NullColumnValueGetter.isNullURI(providerURI) && (storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.vnxblock) || storageSystem.deviceIsType(Type.xtremio))) {
List<URI> sysURIs = _dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> storageSystems = _dbClient.queryIterativeObjects(StorageSystem.class, sysURIs);
while (storageSystems.hasNext()) {
StorageSystem systemObj = storageSystems.next();
if (systemObj == null) {
_log.warn("StorageSystem is no longer in the DB. It could have been deleted or decommissioned");
continue;
}
if (providerURI.equals(systemObj.getActiveProviderURI()) && !id.equals(systemObj.getId())) {
systemIds.add(systemObj.getId());
}
}
}
tasks.add(new ArrayAffinityAsyncTask(StorageSystem.class, systemIds, null, taskId));
} else {
scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
tasks.add(new AsyncTask(StorageSystem.class, storageSystem.getId(), taskId, namespace));
}
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList.getTaskList().listIterator().next();
}
use of com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask in project coprhd-controller by CoprHD.
the class DiscoveredObjectTaskScheduler method scheduleAsyncTasks.
public TaskList scheduleAsyncTasks(List<AsyncTask> tasks) {
TaskList list = new TaskList();
for (AsyncTask task : tasks) {
if (task instanceof ArrayAffinityAsyncTask) {
List<URI> systemIds = ((ArrayAffinityAsyncTask) task).getSystemIds();
for (URI uri : systemIds) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, uri);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, uri, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
} else {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, task._id, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
try {
_taskExecutor.executeTasks(tasks.toArray(new AsyncTask[tasks.size()]));
} catch (ControllerException | APIException ex) {
for (AsyncTask task : tasks) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = _dbClient.error(task._clazz, task._id, task._opId, ex);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
return list;
}
use of com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method createDiscoverJobsForTasks.
private static ArrayList<DataCollectionJob> createDiscoverJobsForTasks(AsyncTask[] tasks, String jobType) {
ArrayList<DataCollectionJob> jobs = new ArrayList<DataCollectionJob>();
for (AsyncTask task : tasks) {
if (task instanceof ArrayAffinityAsyncTask) {
List<URI> hostIds = ((ArrayAffinityAsyncTask) task).getHostIds();
List<URI> systemIds = ((ArrayAffinityAsyncTask) task).getSystemIds();
ArrayAffinityDataCollectionTaskCompleter completer = new ArrayAffinityDataCollectionTaskCompleter(task._clazz, systemIds, task._opId, jobType);
DataCollectionJob job = new DataCollectionArrayAffinityJob(hostIds, systemIds, completer, task._namespace);
jobs.add(job);
} else {
DiscoverTaskCompleter completer = new DiscoverTaskCompleter(task, jobType);
if (null == task._namespace) {
task._namespace = Discovery_Namespaces.ALL.toString();
}
DataCollectionJob job = new DataCollectionDiscoverJob(completer, task._namespace);
jobs.add(job);
}
}
return jobs;
}
use of com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask in project coprhd-controller by CoprHD.
the class HostService method createHostArrayAffinityTasks.
/**
* Create array affinity tasks for hosts.
*
* @param hostIds
* the hosts whose preferred systems need to be discovered
*/
public TaskList createHostArrayAffinityTasks(List<URI> hostIds) {
TaskList taskList = new TaskList();
String taskId = UUID.randomUUID().toString();
String jobType = "";
Map<URI, List<URI>> providerToSystemsMap = new HashMap<URI, List<URI>>();
Map<URI, String> providerToSystemTypeMap = new HashMap<URI, String>();
List<URI> sysURIs = _dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> storageSystems = _dbClient.queryIterativeObjects(StorageSystem.class, sysURIs);
while (storageSystems.hasNext()) {
StorageSystem systemObj = storageSystems.next();
if (systemObj == null) {
_log.warn("StorageSystem is no longer in the DB. It could have been deleted or decommissioned");
continue;
}
if (systemObj.deviceIsType(Type.vmax) || systemObj.deviceIsType(Type.vnxblock) || systemObj.deviceIsType(Type.xtremio)) {
if (systemObj.getActiveProviderURI() == null || NullColumnValueGetter.getNullURI().equals(systemObj.getActiveProviderURI())) {
_log.info("Skipping {} Job : StorageSystem {} does not have an active provider", jobType, systemObj.getLabel());
continue;
}
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, systemObj.getActiveProviderURI());
if (provider == null || provider.getInactive()) {
_log.info("Skipping {} Job : StorageSystem {} does not have a valid active provider", jobType, systemObj.getLabel());
continue;
}
List<URI> systemIds = providerToSystemsMap.get(provider.getId());
if (systemIds == null) {
systemIds = new ArrayList<URI>();
providerToSystemsMap.put(provider.getId(), systemIds);
providerToSystemTypeMap.put(provider.getId(), systemObj.getSystemType());
}
systemIds.add(systemObj.getId());
} else if (systemObj.deviceIsType(Type.unity)) {
List<URI> systemIds = new ArrayList<URI>();
systemIds.add(systemObj.getId());
providerToSystemsMap.put(systemObj.getId(), systemIds);
providerToSystemTypeMap.put(systemObj.getId(), systemObj.getSystemType());
} else {
_log.info("Skip unsupported system {}, system type {}", systemObj.getLabel(), systemObj.getSystemType());
continue;
}
}
for (Map.Entry<URI, List<URI>> entry : providerToSystemsMap.entrySet()) {
List<URI> systemIds = entry.getValue();
BlockController controller = getController(BlockController.class, providerToSystemTypeMap.get(entry.getKey()));
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new StorageSystemService.ArrayAffinityJobExec(controller));
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
tasks.add(new ArrayAffinityAsyncTask(StorageSystem.class, systemIds, hostIds, taskId));
taskList.getTaskList().addAll(scheduler.scheduleAsyncTasks(tasks).getTaskList());
}
return taskList;
}
Aggregations