Search in sources :

Example 31 with BlockController

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

the class InitiatorService method getInitiatorAlias.

/**
 * Shows the alias/initiator name for an initiator
 * if set on the Storage System
 *
 * @param id the URN of a ViPR initiator
 * @param sid the pstorage system uri
 * @prereq none
 * @brief Show the serial number and alias of an initiator
 * @return A reference to an InitiatorRestRep representing the Initiator Alias if Set..
 * @throws Exception When an error occurs querying the VMAX Storage System.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/alias/{sid}")
public InitiatorAliasRestRep getInitiatorAlias(@PathParam("id") URI id, @PathParam("sid") URI systemURI) {
    // Basic Checks
    Initiator initiator = queryResource(id);
    verifyUserPermisions(initiator);
    ArgValidator.checkFieldUriType(systemURI, StorageSystem.class, "id");
    StorageSystem system = _permissionsHelper.getObjectById(systemURI, StorageSystem.class);
    ArgValidator.checkEntity(system, systemURI, isIdEmbeddedInURL(systemURI));
    _log.info("Retrieving alias for initiator {} on system {}", id, systemURI);
    String initiatorAlias = null;
    if (system != null && StorageSystem.Type.vmax.toString().equalsIgnoreCase(system.getSystemType())) {
        BlockController controller = getController(BlockController.class, system.getSystemType());
        // Actual Control
        try {
            initiatorAlias = controller.getInitiatorAlias(systemURI, id);
        } catch (Exception e) {
            _log.error("Unexpected error: Getting alias failed.", e);
            throw APIException.badRequests.unableToProcessRequest(e.getMessage());
        }
    } else {
        throw APIException.badRequests.operationNotSupportedForSystemType(ALIAS, system.getSystemType());
    }
    // If the Alias is empty, set it to "/".
    if (NullColumnValueGetter.isNullValue(initiatorAlias)) {
        initiatorAlias = EMPTY_INITIATOR_ALIAS;
    }
    // Update the initiator
    initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
    _dbClient.updateObject(initiator);
    return new InitiatorAliasRestRep(system.getSerialNumber(), initiatorAlias);
}
Also used : MapInitiator(com.emc.storageos.api.mapper.functions.MapInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) BlockController(com.emc.storageos.volumecontroller.BlockController) InitiatorAliasRestRep(com.emc.storageos.model.host.InitiatorAliasRestRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Example 32 with BlockController

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

the class DefaultBlockServiceApiImpl method deleteConsistencyGroup.

/**
 * {@inheritDoc}
 */
@Override
public TaskResourceRep deleteConsistencyGroup(StorageSystem device, BlockConsistencyGroup consistencyGroup, String task) throws ControllerException {
    Operation op = _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroup.getId(), task, ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP);
    BlockController controller = getController(BlockController.class, device.getSystemType());
    controller.deleteConsistencyGroup(device.getId(), consistencyGroup.getId(), Boolean.TRUE, task);
    return toTask(consistencyGroup, task, op);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) Operation(com.emc.storageos.db.client.model.Operation)

Example 33 with BlockController

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

the class DefaultBlockServiceApiImpl method updateConsistencyGroup.

/**
 * {@inheritDoc}
 */
@Override
public TaskResourceRep updateConsistencyGroup(StorageSystem device, List<Volume> cgVolumes, BlockConsistencyGroup consistencyGroup, List<URI> addVolumesList, List<URI> removeVolumesList, String task) throws ControllerException {
    Operation op = _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroup.getId(), task, ResourceOperationTypeEnum.UPDATE_CONSISTENCY_GROUP);
    if (!device.getSystemType().equals(DiscoveredDataObject.Type.scaleio.name())) {
        BlockController controller = getController(BlockController.class, device.getSystemType());
        controller.updateConsistencyGroup(device.getId(), consistencyGroup.getId(), addVolumesList, removeVolumesList, task);
        return toTask(consistencyGroup, task, op);
    } else {
        // ScaleIO does not have explicit CGs, so we can just update the database and complete
        Iterator<Volume> addVolumeItr = _dbClient.queryIterativeObjects(Volume.class, addVolumesList);
        List<Volume> addVolumes = new ArrayList<Volume>();
        while (addVolumeItr.hasNext()) {
            Volume volume = addVolumeItr.next();
            volume.setConsistencyGroup(consistencyGroup.getId());
            addVolumes.add(volume);
        }
        Iterator<Volume> removeVolumeItr = _dbClient.queryIterativeObjects(Volume.class, removeVolumesList);
        List<Volume> removeVolumes = new ArrayList<Volume>();
        while (removeVolumeItr.hasNext()) {
            Volume volume = removeVolumeItr.next();
            volume.setConsistencyGroup(consistencyGroup.getId());
            removeVolumes.add(volume);
        }
        _dbClient.updateObject(addVolumes);
        _dbClient.updateObject(removeVolumes);
        return toCompletedTask(consistencyGroup, task, op);
    }
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation)

Example 34 with BlockController

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

the class DefaultBlockServiceApiImpl method updateVolumesInVolumeGroup.

/**
 * {@inheritDoc}
 */
@Override
public void updateVolumesInVolumeGroup(VolumeGroupVolumeList addVolumes, List<Volume> removeVolumes, URI volumeGroupId, String taskId) {
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
    ApplicationAddVolumeList addVolumeList = null;
    if (addVolumes != null && addVolumes.getVolumes() != null && !addVolumes.getVolumes().isEmpty()) {
        addVolumeList = addVolumesToApplication(addVolumes, volumeGroup, taskId);
    }
    if (removeVolumes != null && !removeVolumes.isEmpty()) {
        removeVolumesFromApplication(removeVolumes, volumeGroup, taskId);
    }
    // call controller to handle non application ready CG volumes
    if ((addVolumeList != null && !addVolumeList.getVolumes().isEmpty())) {
        List<URI> vols = addVolumeList.getVolumes();
        Volume firstVolume = _dbClient.queryObject(Volume.class, vols.get(0));
        URI systemURI = firstVolume.getStorageController();
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
        BlockController controller = getController(BlockController.class, system.getSystemType());
        controller.updateApplication(systemURI, addVolumeList, volumeGroup.getId(), taskId);
    } else {
        // No need to call to controller. update the application task
        Operation op = volumeGroup.getOpStatus().get(taskId);
        op.ready();
        volumeGroup.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.updateObject(volumeGroup);
    }
}
Also used : ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) Volume(com.emc.storageos.db.client.model.Volume) BlockController(com.emc.storageos.volumecontroller.BlockController) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 35 with BlockController

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

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