Search in sources :

Example 1 with ArrayAffinityAsyncTask

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();
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) URI(java.net.URI) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ArrayAffinityAsyncTask

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;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ControllerException(com.emc.storageos.volumecontroller.ControllerException) TaskList(com.emc.storageos.model.TaskList) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI)

Example 3 with ArrayAffinityAsyncTask

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;
}
Also used : DataCollectionJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionJob) DataCollectionDiscoverJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionDiscoverJob) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) DataCollectionArrayAffinityJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionArrayAffinityJob) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) ArrayList(java.util.ArrayList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayAffinityDataCollectionTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ArrayAffinityDataCollectionTaskCompleter) URI(java.net.URI)

Example 4 with ArrayAffinityAsyncTask

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;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) UnManagedExportMaskList(com.emc.storageos.model.block.UnManagedExportMaskList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InitiatorList(com.emc.storageos.model.host.InitiatorList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) MountInfoList(com.emc.storageos.model.file.MountInfoList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) LinkedList(java.util.LinkedList) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)4 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)4 URI (java.net.URI)4 TaskList (com.emc.storageos.model.TaskList)3 ArrayList (java.util.ArrayList)3 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 BlockController (com.emc.storageos.volumecontroller.BlockController)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 Operation (com.emc.storageos.db.client.model.Operation)1 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)1 UnManagedExportMaskList (com.emc.storageos.model.block.UnManagedExportMaskList)1 UnManagedVolumeList (com.emc.storageos.model.block.UnManagedVolumeList)1 MountInfoList (com.emc.storageos.model.file.MountInfoList)1 HostList (com.emc.storageos.model.host.HostList)1 InitiatorList (com.emc.storageos.model.host.InitiatorList)1 IpInterfaceList (com.emc.storageos.model.host.IpInterfaceList)1