Search in sources :

Example 26 with AsyncTask

use of com.emc.storageos.volumecontroller.AsyncTask 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 27 with AsyncTask

use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.

the class VcenterService method doDiscoverVcenter.

/**
 * Vcenter Discovery
 *
 * @param vcenter the Vcenter to be discovered.
 *            provided, a new taskId is generated.
 * @return the task used to track the discovery job
 */
protected TaskResourceRep doDiscoverVcenter(Vcenter vcenter) {
    ComputeSystemController controller = getController(ComputeSystemController.class, "vcenter");
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
    String taskId = UUID.randomUUID().toString();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    tasks.add(new AsyncTask(Vcenter.class, vcenter.getId(), taskId));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    TaskResourceRep taskResourceRep = taskList.getTaskList().iterator().next();
    updateTaskTenant(taskResourceRep);
    return taskResourceRep;
}
Also used : MapVcenter(com.emc.storageos.api.mapper.functions.MapVcenter) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)

Example 28 with AsyncTask

use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.

the class StorageProviderService method registerStorageProvider.

/**
 * Register Storage Provider
 *
 * @param param
 * @brief Define a new storage provider
 * @return TaskResponse
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep registerStorageProvider(StorageProviderCreateParam param) throws ControllerException {
    ArgValidator.checkFieldNotEmpty(param.getName(), "name");
    checkForDuplicateName(param.getName(), StorageProvider.class);
    ArgValidator.checkFieldNotEmpty(param.getIpAddress(), "ip_address");
    ArgValidator.checkFieldNotNull(param.getPortNumber(), "port_number");
    ArgValidator.checkFieldNotEmpty(param.getUserName(), "user_name");
    ArgValidator.checkFieldNotEmpty(param.getPassword(), "password");
    ArgValidator.checkFieldRange(param.getPortNumber(), 1, 65535, "port_number");
    if (storageDriverManager == null || !storageDriverManager.isDriverManaged(param.getInterfaceType())) {
        // check this only for providers which are not managed by drivers
        ArgValidator.checkFieldValueFromEnum(param.getInterfaceType(), "interface_type", StorageProvider.InterfaceType.class);
    }
    String providerKey = param.getIpAddress() + "-" + param.getPortNumber();
    List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerKey);
    if (providers != null && !providers.isEmpty()) {
        throw APIException.badRequests.invalidParameterStorageProviderAlreadyRegistered(providerKey);
    }
    // Set the SSL parameter
    Boolean useSSL = param.getUseSSL();
    if (useSSL == null) {
        useSSL = StorageProviderCreateParam.USE_SSL_DEFAULT;
    }
    StorageProvider provider = new StorageProvider();
    provider.setId(URIUtil.createId(StorageProvider.class));
    provider.setLabel(param.getName());
    provider.setIPAddress(param.getIpAddress());
    provider.setPortNumber(param.getPortNumber());
    provider.setUserName(param.getUserName());
    provider.setPassword(param.getPassword());
    provider.setUseSSL(useSSL);
    provider.setInterfaceType(param.getInterfaceType());
    provider.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
    provider.setConnectionStatus(ConnectionStatus.INITIALIZING.name());
    provider.setSecondaryUsername(param.getSecondaryUsername());
    provider.setSecondaryPassword(param.getSecondaryPassword());
    provider.setSecondaryURL(param.getSecondaryURL());
    provider.setElementManagerURL(param.getElementManagerURL());
    if (param.getSioCLI() != null) {
        // TODO: Validate the input?
        provider.addKey(StorageProvider.GlobalKeys.SIO_CLI.name(), param.getSioCLI());
    }
    if (StorageProvider.InterfaceType.ibmxiv.name().equalsIgnoreCase(provider.getInterfaceType())) {
        provider.setManufacturer("IBM");
        // For XIV, Secondary manager URL would hold HSM URL and it is expected that these values are provided during create
        verifySecondaryParams(param.getSecondaryURL());
        if (null != param.getSecondaryUsername()) {
            ArgValidator.checkFieldNotEmpty(param.getSecondaryUsername(), "secondary_username");
        }
        if (null != param.getSecondaryPassword()) {
            ArgValidator.checkFieldNotEmpty(param.getSecondaryPassword(), "secondary_password");
        }
    }
    _dbClient.createObject(provider);
    auditOp(OperationTypeEnum.REGISTER_STORAGEPROVIDER, true, null, provider.getLabel(), provider.getId().toString(), provider.getIPAddress(), provider.getPortNumber(), provider.getUserName(), provider.getInterfaceType());
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(StorageProvider.class, provider.getId(), taskId));
    BlockController controller = getController(BlockController.class, provider.getInterfaceType());
    log.debug("controller.getClass().getName() :{}", controller.getClass().getName());
    log.debug("controller.getClass().getSimpleName() :{}", controller.getClass().getSimpleName());
    /**
     * Creates MonitoringJob token for vnxblock/vmax, hds, cinder and IBM XIV device on zooKeeper queue
     */
    // TODO : If all interface types have monitoring impl class added (scaleIO is missing),
    // this check can be removed.
    String interfaceType = provider.getInterfaceType();
    if (StorageProvider.InterfaceType.hicommand.name().equalsIgnoreCase(interfaceType) || StorageProvider.InterfaceType.smis.name().equalsIgnoreCase(interfaceType) || StorageProvider.InterfaceType.cinder.name().equalsIgnoreCase(interfaceType) || StorageProvider.InterfaceType.ibmxiv.name().equalsIgnoreCase(interfaceType)) {
        controller.startMonitoring(new AsyncTask(StorageProvider.class, provider.getId(), taskId), getSystemTypeByInterface(interfaceType));
    }
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
    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) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) MapStorageProvider(com.emc.storageos.api.mapper.functions.MapStorageProvider) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 29 with AsyncTask

use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.

the class StorageSystemService method discoverStorageSystemsAll.

/**
 * Allows the user to manually discover all storage systems.
 *
 * @brief Discover all storage systems
 */
@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("/discover")
public TaskList discoverStorageSystemsAll() {
    Iterator<URI> storageIter = _dbClient.queryByType(StorageSystem.class, true).iterator();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
    while (storageIter.hasNext()) {
        URI storage = storageIter.next();
        String taskId = UUID.randomUUID().toString();
        tasks.add(new AsyncTask(StorageSystem.class, storage, taskId));
    }
    BlockController controller = getController(BlockController.class, "vnxblock");
    return discoverStorageSystems(tasks, controller);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayList(java.util.ArrayList) URI(java.net.URI) 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 30 with AsyncTask

use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.

the class ComputeImageService method doRemoveImage.

/*
     * Schedules the remove task.
     */
private TaskResourceRep doRemoveImage(ComputeImage ci) {
    log.info("doRemoveImage");
    ImageServerController controller = getController(ImageServerController.class, null);
    AsyncTask task = new AsyncTask(ComputeImage.class, ci.getId(), UUID.randomUUID().toString());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.REMOVE_IMAGE);
    _dbClient.createTaskOpStatus(ComputeImage.class, ci.getId(), task._opId, op);
    controller.deleteImage(task);
    log.info("Removing image " + ci.getImageName());
    return TaskMapper.toTask(ci, task._opId, op);
}
Also used : ImageServerController(com.emc.storageos.imageservercontroller.ImageServerController) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Operation(com.emc.storageos.db.client.model.Operation)

Aggregations

AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)34 ArrayList (java.util.ArrayList)22 TaskList (com.emc.storageos.model.TaskList)17 Consumes (javax.ws.rs.Consumes)16 Produces (javax.ws.rs.Produces)16 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)15 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)12 Operation (com.emc.storageos.db.client.model.Operation)11 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)11 POST (javax.ws.rs.POST)11 Path (javax.ws.rs.Path)11 URI (java.net.URI)10 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)8 BlockController (com.emc.storageos.volumecontroller.BlockController)8 Host (com.emc.storageos.db.client.model.Host)6 ImageServerController (com.emc.storageos.imageservercontroller.ImageServerController)5 MapProtectionSystem (com.emc.storageos.api.mapper.functions.MapProtectionSystem)4 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)4 ProtectionController (com.emc.storageos.protectioncontroller.ProtectionController)4