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