Search in sources :

Example 1 with StorageController

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

the class SMISProviderService method startStorageSystem.

/**
 * Invoke connect storage. Once system is verified to be registered.
 * Statistics, Events will be collected for only registered systems.
 *
 * @param system Storage system to start Metering & Monitoring.
 * @throws ControllerException
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void startStorageSystem(StorageSystem system) throws ControllerException {
    String systemType = system.getSystemType();
    Class controllerClass = StorageSystemService.storageSystemClass(systemType);
    StorageController controller = (StorageController) getController(controllerClass, systemType);
    controller.connectStorage(system.getId());
}
Also used : StorageController(com.emc.storageos.volumecontroller.StorageController)

Example 2 with StorageController

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

the class StorageSystemService method stopStorageSystem.

/**
 * Invoke disconnect storage to stop events and statistics gathering of this
 * storage system.
 *
 * @param storageSystem A reference to the storage system.
 * @throws ControllerException When an error occurs disconnecting the
 *             storage system.
 */
private void stopStorageSystem(StorageSystem storageSystem) throws ControllerException {
    if (!DiscoveredDataObject.Type.vplex.name().equals(storageSystem.getSystemType())) {
        StorageController controller = getStorageController(storageSystem.getSystemType());
        controller.disconnectStorage(storageSystem.getId());
    }
}
Also used : StorageController(com.emc.storageos.volumecontroller.StorageController)

Example 3 with StorageController

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

the class StorageSystemService method updateStorageSystem.

/**
 * Allows the user to update credentials for a manually created storage systems.
 * Allows the user to update only the name field for vmax and vnx block systems.
 *
 * @param id the URN of a ViPR storage system
 * @param param The storage system details to update.
 *
 * @brief Update storage system credentials
 * @return A StorageSystemRestRep reference specifying the storage system
 *         data.
 *
 * @throws BadRequestException When the system is not valid.
 * @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 })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateStorageSystem(@PathParam("id") URI id, StorageSystemUpdateRequestParam param) throws ControllerException {
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    StorageSystem.Type systemType = StorageSystem.Type.valueOf(system.getSystemType());
    if (param.getName() != null && !param.getName().isEmpty() && !param.getName().equalsIgnoreCase(system.getLabel())) {
        checkForDuplicateName(param.getName(), StorageSystem.class);
        system.setLabel(param.getName());
    }
    // If unlimited resources is set to false, then max resources should also be specified. If not specified, throw error
    if (null != param.getIsUnlimitedResourcesSet()) {
        if (param.getIsUnlimitedResourcesSet()) {
            system.setIsResourceLimitSet(false);
        } else {
            if (null != param.getMaxResources()) {
                system.setIsResourceLimitSet(true);
                system.setMaxResources(param.getMaxResources());
            } else {
                throw APIException.badRequests.parameterMaxResourcesMissing();
            }
        }
    } else if (null != param.getMaxResources()) {
        system.setMaxResources(param.getMaxResources());
        system.setIsResourceLimitSet(true);
    }
    // create Task with ready state and return it. Discovery not needed.
    if (systemType.equals(StorageSystem.Type.vmax) || systemType.equals(StorageSystem.Type.vnxblock) || systemType.equals(StorageSystem.Type.hds) || systemType.equals(StorageSystem.Type.openstack) || systemType.equals(StorageSystem.Type.scaleio) || systemType.equals(StorageSystem.Type.xtremio) || systemType.equals(StorageSystem.Type.ceph)) {
        // this check is to inform the user that he/she can not update fields other than name and max_resources.
        if (param.getIpAddress() != null || param.getPortNumber() != null || param.getUserName() != null || param.getPassword() != null || param.getSmisProviderIP() != null || param.getSmisPortNumber() != null || param.getSmisUserName() != null || param.getSmisPassword() != null || param.getSmisUseSSL() != null) {
            throw APIException.badRequests.onlyNameAndMaxResourceCanBeUpdatedForSystemWithType(systemType.name());
        }
        _dbClient.updateObject(system);
        String taskId = UUID.randomUUID().toString();
        TaskList taskList = new TaskList();
        Operation op = new Operation();
        op.ready("Updated Storage System name");
        op.setResourceType(ResourceOperationTypeEnum.UPDATE_STORAGE_SYSTEM);
        _dbClient.createTaskOpStatus(StorageSystem.class, system.getId(), taskId, op);
        taskList.getTaskList().add(toTask(system, taskId, op));
        return taskList.getTaskList().listIterator().next();
    }
    if (systemType.equals(StorageSystem.Type.vnxfile)) {
        validateVNXFileSMISProviderMandatoryDetails(param);
    }
    String existingIPAddress = system.getIpAddress();
    Integer existingPortNumber = system.getPortNumber();
    // check to ensure a system does not exist with the new ip + port combo
    if (((param.getIpAddress() != null && !param.getIpAddress().equals(existingIPAddress)) || (param.getPortNumber() != null && !param.getPortNumber().equals(existingPortNumber)))) {
        String ipAddress = (param.getIpAddress() != null) ? param.getIpAddress() : system.getIpAddress();
        Integer portNumber = (param.getPortNumber() != null) ? param.getPortNumber() : system.getPortNumber();
        if (systemType.equals(StorageSystem.Type.isilon) || systemType.equals(StorageSystem.Type.unity) || systemType.equals(StorageSystem.Type.vnxfile) || systemType.equals(StorageSystem.Type.vnxe)) {
            ArgValidator.checkFieldValidInetAddress(ipAddress, "ip_address");
        } else {
            ArgValidator.checkFieldValidIP(ipAddress, "ip_address");
        }
        ArgValidator.checkFieldRange(portNumber, 1, 65535, "port_number");
        validateStorageSystemExists(ipAddress, portNumber);
        system.setMgmtAccessPoint(ipAddress + "-" + portNumber);
    }
    updateStorageObj(system, param);
    auditOp(OperationTypeEnum.UPDATE_STORAGE_SYSTEM, true, null, id.toString(), param.getIpAddress(), param.getPortNumber());
    startStorageSystem(system);
    // execute discovery
    StorageController controller = getController(FileController.class, system.getSystemType());
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(StorageSystem.class, system.getId(), taskId));
    TaskList taskList = discoverStorageSystems(tasks, controller);
    return taskList.getTaskList().listIterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) StorageController(com.emc.storageos.volumecontroller.StorageController) 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 4 with StorageController

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

the class StorageSystemService method startStorageSystem.

/**
 * Invoke connect storage. Once system is verified to be registered.
 * Statistics, Events will be collected for only registered systems.
 *
 * @param system Storage system to start Metering & Monitoring.
 * @throws ControllerException
 */
private void startStorageSystem(StorageSystem system) throws ControllerException {
    if (!DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType())) {
        StorageController controller = getStorageController(system.getSystemType());
        controller.connectStorage(system.getId());
    }
}
Also used : StorageController(com.emc.storageos.volumecontroller.StorageController)

Example 5 with StorageController

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

the class StorageSystemService method getStorageController.

/**
 * Return the storage controller for a given system type.
 *
 * @param systemType The type of the storage system.
 *
 * @return A reference to the storage controller
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private StorageController getStorageController(String systemType) {
    Class controllerClass = storageSystemClass(systemType);
    StorageController controller = (StorageController) getController(controllerClass, systemType);
    return controller;
}
Also used : StorageController(com.emc.storageos.volumecontroller.StorageController)

Aggregations

StorageController (com.emc.storageos.volumecontroller.StorageController)5 Operation (com.emc.storageos.db.client.model.Operation)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 TaskList (com.emc.storageos.model.TaskList)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)1 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1