Search in sources :

Example 6 with DiscoveredObjectTaskScheduler

use of com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler in project coprhd-controller by CoprHD.

the class HostService method doDiscoverHost.

/**
 * Host Discovery
 *
 * @param host {@link Host} The Host to be discovered.
 * @param taskId {@link String} taskId for the host discovery. as new taskId is generated if null passed.
 * @param updateTaskStatus if true, mark the task status as completed for non-discovered host
 * @return the task used to track the discovery job
 */
protected TaskResourceRep doDiscoverHost(URI hostId, String taskId, boolean updateTaskStatus) {
    Host host = queryObject(Host.class, hostId, true);
    if (taskId == null) {
        taskId = UUID.randomUUID().toString();
    }
    if (host.getDiscoverable() != null && !host.getDiscoverable()) {
        host.setDiscoveryStatus(DataCollectionJobStatus.COMPLETE.name());
        _dbClient.updateObject(host);
    }
    if ((host.getDiscoverable() == null || host.getDiscoverable())) {
        ComputeSystemController controller = getController(ComputeSystemController.class, "host");
        DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
        ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
        tasks.add(new AsyncTask(Host.class, host.getId(), taskId));
        TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
        return taskList.getTaskList().iterator().next();
    } else {
        // if not discoverable, manually create a ready task
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.DISCOVER_HOST);
        if (updateTaskStatus) {
            op.ready("Host is not discoverable");
        } else {
            op.pending();
        }
        _dbClient.createTaskOpStatus(Host.class, host.getId(), taskId, op);
        return toTask(host, taskId, op);
    }
}
Also used : TaskList(com.emc.storageos.model.TaskList) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) Operation(com.emc.storageos.db.client.model.Operation)

Example 7 with DiscoveredObjectTaskScheduler

use of com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler 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)

Example 8 with DiscoveredObjectTaskScheduler

use of com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler in project coprhd-controller by CoprHD.

the class NetworkSystemService method doDiscoverNetworkSystem.

/**
 * Common code for submitting a request for discovery. The request may not be performed
 * by the discovery framework if a discovery was recently performed or is ongoing for
 * the network system.
 *
 * @param device the network system to be discovered to re-discovered.
 *            provided, a new taskId is generated.
 * @return the task used to track the discovery job
 */
private TaskResourceRep doDiscoverNetworkSystem(NetworkSystem device) {
    NetworkController controller = getNetworkController(device.getSystemType());
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new NetworkJobExec(controller));
    String taskId = UUID.randomUUID().toString();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    tasks.add(new AsyncTask(NetworkSystem.class, device.getId(), taskId));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().iterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) NetworkController(com.emc.storageos.networkcontroller.NetworkController)

Example 9 with DiscoveredObjectTaskScheduler

use of com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler in project coprhd-controller by CoprHD.

the class ProtectionSystemService method discoverProtectionSystem.

/**
 * Allows the user to manually discover the registered protection system with
 * the passed id.
 *
 * @param id the URN of a ViPR protection system.
 * @QueryParam namespace
 *             ProtectionSystem Auto Discovery is grouped into multiple namespaces.
 *             Namespace is used to discover specific parts of Storage System.
 *
 *             Possible Values :
 *             UNMANAGED_CGS
 *             ALL
 *
 *             UNMANAGED_CGS will discover all the consistency groups which are present in the
 *             Protection System (RPA).
 *
 * @brief Discover protection system
 * @throws ControllerException When an error occurs discovering the protection
 *             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 discoverProtectionSystem(@PathParam("id") URI id, @QueryParam("namespace") String namespace) {
    ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, id);
    ArgValidator.checkEntity(protectionSystem, id, isIdEmbeddedInURL(id), true);
    // 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)) {
        throw APIException.badRequests.invalidParameterProtectionSystemNamespace(namespace);
    }
    String deviceType = protectionSystem.getSystemType();
    ProtectionController controller = getController(RPController.class, deviceType);
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(ProtectionSystem.class, protectionSystem.getId(), taskId, namespace));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().listIterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) MapProtectionSystem(com.emc.storageos.api.mapper.functions.MapProtectionSystem) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController) 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 10 with DiscoveredObjectTaskScheduler

use of com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler in project coprhd-controller by CoprHD.

the class ComputeSystemService method doDiscoverComputeSystem.

private TaskResourceRep doDiscoverComputeSystem(ComputeSystem cs) {
    ComputeController controller = getController(ComputeController.class, cs.getSystemType());
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ComputeSystemJobExec(controller));
    String taskId = UUID.randomUUID().toString();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    tasks.add(new AsyncTask(ComputeSystem.class, cs.getId(), taskId));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().iterator().next();
}
Also used : ComputeController(com.emc.storageos.computecontroller.ComputeController) TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Aggregations

DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)12 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)12 ArrayList (java.util.ArrayList)12 TaskList (com.emc.storageos.model.TaskList)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)6 POST (javax.ws.rs.POST)6 Path (javax.ws.rs.Path)4 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)3 URI (java.net.URI)3 ComputeSystemController (com.emc.storageos.computesystemcontroller.ComputeSystemController)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)1 MapProtectionSystem (com.emc.storageos.api.mapper.functions.MapProtectionSystem)1 MapVcenter (com.emc.storageos.api.mapper.functions.MapVcenter)1