Search in sources :

Example 1 with BlockController

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

the class RPDeviceController method createBlockSnapshotStep.

/**
 * Invokes the storage specific BlockController method to perform the snapshot operation
 *
 * @param storageURI
 *            Storage System URI
 * @param snapshotList
 *            List of snaps in the request
 * @param createInactive
 *            Specifies whether the snapshot is created and activated or just created
 * @param readOnly
 *            Specifies whether the snapshot is created as read only
 * @param stepId
 *            workflow step Id for this step.
 * @return true if successful, false otherwise
 */
public boolean createBlockSnapshotStep(URI storageURI, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String stepId) {
    WorkflowStepCompleter.stepExecuting(stepId);
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageURI);
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.createSnapshot(storageURI, snapshotList, createInactive, readOnly, stepId);
    } catch (Exception e) {
        WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(e));
        return false;
    }
    return true;
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with BlockController

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

the class BlockControllerImpl method pauseNativeContinuousCopies.

@Override
public void pauseNativeContinuousCopies(URI storage, List<URI> mirrors, Boolean sync, String opId) throws InternalException {
    try {
        // Direct RMI call to expedite this call without any potential distribute-Q delay
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        Controller controller = lookupDeviceController(storageSystem);
        BlockController blkcontroller = (BlockController) controller;
        blkcontroller.pauseNativeContinuousCopies(storage, mirrors, sync, opId);
    } catch (RetryableDatabaseException e) {
        if (e.getServiceCode() == ServiceCode.DBSVC_CONNECTION_ERROR) {
            // netflix curator ConnectionException is not serializable
            // and thus should not be sent back to rmi client.
            _log.error("Failed to queue task due to dbsvc disconnected. Error: {}", e.getMessage());
            _log.error(e.getMessage(), e);
            throw DatabaseException.retryables.connectionFailed();
        }
        throw e;
    }
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) Controller(com.emc.storageos.Controller) BlockController(com.emc.storageos.volumecontroller.BlockController) AbstractDiscoveredSystemController(com.emc.storageos.impl.AbstractDiscoveredSystemController) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) RetryableDatabaseException(com.emc.storageos.db.exceptions.RetryableDatabaseException)

Example 3 with BlockController

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

the class StorageProviderService method scanStorageProviders.

/**
 * Scan all Storage providers.
 *
 * @brief Scan Storage providers
 * @return TasList of all created asynchronous tasks
 */
@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("/scan")
public TaskList scanStorageProviders() {
    TaskList taskList = new TaskList();
    List<URI> providerURIList = _dbClient.queryByType(StorageProvider.class, true);
    /**
     * TODO needs to remove hard code device type to fetch the controller instance
     */
    BlockController controller = getController(BlockController.class, "vnxblock");
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
    if (providerURIList != null) {
        for (URI providerURI : providerURIList) {
            String taskId = UUID.randomUUID().toString();
            tasks.add(new AsyncTask(StorageProvider.class, providerURI, taskId));
        }
        taskList = scheduler.scheduleAsyncTasks(tasks);
    }
    return taskList;
}
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) URI(java.net.URI) 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 4 with BlockController

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

the class StorageProviderService method addStorageSystem.

/**
 * Allows the user to add a storage system and rescans the provider.
 * After that corresponding provider should be able to be rescanned and add this system back to the list of managed systems.
 *
 * @param id id the URN of a ViPR Storage provider
 * @param param The storage system details.
 *
 * @brief Add a new storage system and rescan the provider.
 * @return An asynchronous task corresponding to the scan job scheduled for the provider.
 *
 * @throws BadRequestException When the system type is not valid or a
 *             storage system with the same native guid already exists.
 * @throws com.emc.storageos.db.exceptions.DatabaseException When an error occurs querying the database.
 * @throws ControllerException When an error occurs discovering the storage
 *             system.
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
@Path("/{id}/storage-systems")
public TaskResourceRep addStorageSystem(@PathParam("id") URI id, StorageSystemProviderRequestParam param) throws ControllerException {
    TaskResourceRep taskRep;
    URIQueryResultList list = new URIQueryResultList();
    ArgValidator.checkFieldNotEmpty(param.getSystemType(), "system_type");
    if (!StorageSystem.Type.isProviderStorageSystem(param.getSystemType())) {
        throw APIException.badRequests.cannotAddStorageSystemTypeToStorageProvider(param.getSystemType());
    }
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id);
    ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id));
    ArgValidator.checkFieldNotEmpty(param.getSerialNumber(), "serialNumber");
    String nativeGuid = NativeGUIDGenerator.generateNativeGuid(param.getSystemType(), param.getSerialNumber());
    // check for duplicate StorageSystem.
    List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid);
    if (systems != null && !systems.isEmpty()) {
        throw APIException.badRequests.invalidParameterProviderStorageSystemAlreadyExists("nativeGuid", nativeGuid);
    }
    int cleared = DecommissionedResource.removeDecommissionedFlag(_dbClient, nativeGuid, StorageSystem.class);
    if (cleared == 0) {
        log.info("Cleared {} decommissioned systems", cleared);
    } else {
        log.info("Did not find any decommissioned systems to clear. Continue to scan.");
    }
    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());
    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) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) 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) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with BlockController

use of com.emc.storageos.volumecontroller.BlockController 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)

Aggregations

BlockController (com.emc.storageos.volumecontroller.BlockController)48 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 Operation (com.emc.storageos.db.client.model.Operation)23 URI (java.net.URI)23 ArrayList (java.util.ArrayList)20 TaskList (com.emc.storageos.model.TaskList)16 Produces (javax.ws.rs.Produces)15 Volume (com.emc.storageos.db.client.model.Volume)13 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)13 Path (javax.ws.rs.Path)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 Consumes (javax.ws.rs.Consumes)12 POST (javax.ws.rs.POST)11 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)10 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)8 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)8 Controller (com.emc.storageos.Controller)7 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)7