Search in sources :

Example 36 with BlockController

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

the class StorageSystemService method createStoragePortGroup.

/**
 * Create a storage port group
 *
 * @param id
 *            the URN of a ViPR storage port.
 *
 * @brief Create a storage port
 * @return The pending task
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep createStoragePortGroup(@PathParam("id") URI id, StoragePortGroupCreateParam param) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    // Only support for VMAX
    if (!DiscoveredDataObject.Type.vmax.name().equals(system.getSystemType())) {
        APIException.badRequests.operationNotSupportedForSystemType(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP.name(), system.getSystemType());
    }
    ArgValidator.checkFieldNotEmpty(param.getName(), "name");
    String portGroupName = param.getName();
    List<URI> ports = param.getStoragePorts();
    for (URI port : ports) {
        ArgValidator.checkFieldUriType(port, StoragePort.class, "portURI");
        StoragePort sport = _dbClient.queryObject(StoragePort.class, port);
        ArgValidator.checkEntityNotNull(sport, port, isIdEmbeddedInURL(port));
    }
    checkForDuplicatePortGroupName(portGroupName, id);
    StoragePortGroup portGroup = new StoragePortGroup();
    portGroup.setLabel(portGroupName);
    if (param.getRegistered()) {
        portGroup.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
    } else {
        portGroup.setRegistrationStatus(RegistrationStatus.UNREGISTERED.name());
    }
    portGroup.setStorageDevice(id);
    portGroup.setStoragePorts(StringSetUtil.uriListToStringSet(ports));
    portGroup.setId(URIUtil.createId(StoragePortGroup.class));
    portGroup.setMutable(false);
    _dbClient.createObject(portGroup);
    String task = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(StoragePortGroup.class, portGroup.getId(), task, ResourceOperationTypeEnum.CREATE_STORAGE_PORT_GROUP);
    _dbClient.updateObject(portGroup);
    auditOp(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP, true, null, param.getName(), id.toString());
    recordStoragePoolPortEvent(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP, OperationTypeEnum.CREATE_STORAGE_PORT_GROUP.getDescription(), portGroup.getId(), "StoragePortGroup");
    TaskResourceRep taskRes = toTask(portGroup, task, op);
    BlockController controller = getController(BlockController.class, system.getSystemType());
    controller.createStoragePortGroup(system.getId(), portGroup.getId(), task);
    return taskRes;
}
Also used : MapStoragePortGroup(com.emc.storageos.api.mapper.functions.MapStoragePortGroup) StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) BlockController(com.emc.storageos.volumecontroller.BlockController) MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 37 with BlockController

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

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

the class AbstractBlockFullCopyApiImpl method detach.

/**
 * {@inheritDoc}
 */
@Override
public TaskList detach(BlockObject fcSourceObj, Volume fullCopyVolume) {
    // Create the task list.
    TaskList taskList = new TaskList();
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // If the source is in a CG, then we will activate the corresponding
    // full copies for all the volumes in the CG. Since we did not allow
    // full copies for volumes or snaps in CGs prior to Jedi, there should
    // be a full copy for all volumes in the CG.
    Map<URI, Volume> fullCopyMap = getFullCopySetMap(fcSourceObj, fullCopyVolume);
    Set<URI> fullCopyURIs = fullCopyMap.keySet();
    // send detach full copy request to controller.
    if ((BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) || (BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient))) {
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY);
        op.ready("Full copy is already detached");
        for (URI fullCopyURI : fullCopyURIs) {
            _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, op);
            TaskResourceRep task = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
            taskList.addTask(task);
            if (!BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) {
                // Make sure the replica state is set to detached.
                Volume volume = fullCopyVolume;
                if (!fullCopyURI.equals(fullCopyVolume.getId())) {
                    volume = _dbClient.queryObject(Volume.class, fullCopyURI);
                }
                ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(volume, _dbClient);
                volume.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
                volume.setReplicaState(ReplicationState.DETACHED.name());
                _dbClient.persistObject(volume);
            }
        }
    } else {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        for (URI fullCopyURI : fullCopyURIs) {
            Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY);
            fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
            TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
            taskList.getTaskList().add(fullCopyVolumeTask);
        }
        if (NullColumnValueGetter.isNotNullValue(fullCopyVolume.getReplicationGroupInstance())) {
            addConsistencyGroupTasks(Arrays.asList(fcSourceObj), taskList, taskId, ResourceOperationTypeEnum.DETACH_CONSISTENCY_GROUP_FULL_COPY);
        }
        try {
            controller.detachFullCopy(storageSystem.getId(), new ArrayList<URI>(fullCopyURIs), taskId);
        } catch (ControllerException ce) {
            s_logger.error("Failed to detach volume full copy {}", fullCopyVolume.getId(), ce);
            handleFailedRequest(taskId, taskList, new ArrayList<Volume>(fullCopyMap.values()), ce, false);
        }
    }
    return taskList;
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 39 with BlockController

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

the class AbstractBlockFullCopyApiImpl method getSyncPercentage.

/**
 * Gets the percent synchronized for the passed full copy volume.
 *
 * @param sourceURI The URI of the full copy source.
 * @param fullCopyVolume A reference to the full copy volume.
 *
 * @return The percent synchronized.
 */
protected Integer getSyncPercentage(URI sourceURI, Volume fullCopyVolume) {
    Integer result = null;
    URI fullCopyURI = fullCopyVolume.getId();
    if (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient)) {
        String taskId = UUID.randomUUID().toString();
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        try {
            result = controller.checkSyncProgress(storageSystem.getId(), sourceURI, fullCopyURI, taskId);
        } catch (ControllerException ce) {
            s_logger.error("Failed to check synchronization progress for volume full copy {}", fullCopyURI, ce);
        }
    } else {
        result = 0;
    }
    if (result == null) {
        throw APIException.badRequests.protectionUnableToGetSynchronizationProgress();
    }
    return result;
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 40 with BlockController

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

the class AbstractBlockFullCopyApiImpl method activate.

/**
 * {@inheritDoc}
 */
@Override
public TaskList activate(BlockObject fcSourceObj, Volume fullCopyVolume) {
    // Create the task list.
    TaskList taskList = new TaskList();
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // If the source is in a CG, then we will activate the corresponding
    // full copies for all the volumes in the CG. Since we did not allow
    // full copies for volumes or snaps in CGs prior to Jedi, there should
    // be a full copy for all volumes in the CG.
    Map<URI, Volume> fullCopyMap = getFullCopySetMap(fcSourceObj, fullCopyVolume);
    Set<URI> fullCopyURIs = fullCopyMap.keySet();
    // to controller.
    if (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient)) {
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.ACTIVATE_VOLUME_FULL_COPY);
        op.ready("Full copy is already activated");
        for (URI fullCopyURI : fullCopyURIs) {
            _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, op);
            TaskResourceRep task = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
            taskList.addTask(task);
        }
    } else {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        for (URI fullCopyURI : fullCopyURIs) {
            Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.ACTIVATE_VOLUME_FULL_COPY);
            fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
            TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
            taskList.getTaskList().add(fullCopyVolumeTask);
        }
        addConsistencyGroupTasks(Arrays.asList(fcSourceObj), taskList, taskId, ResourceOperationTypeEnum.ACTIVATE_CONSISTENCY_GROUP_FULL_COPY);
        try {
            controller.activateFullCopy(storageSystem.getId(), new ArrayList<URI>(fullCopyURIs), taskId);
        } catch (ControllerException ce) {
            s_logger.error("Failed to activate volume full copy {}", fullCopyVolume.getId(), ce);
            handleFailedRequest(taskId, taskList, new ArrayList<Volume>(fullCopyMap.values()), ce, false);
        }
    }
    return taskList;
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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