Search in sources :

Example 1 with VirtualPoolChangeList

use of com.emc.storageos.model.vpool.VirtualPoolChangeList in project coprhd-controller by CoprHD.

the class BlockVirtualPoolService method getVirtualPoolForVirtualPoolChange.

/**
 * Returns all potential virtual pools, which supported the given virtual pool change operation
 * for a virtual pool change of the volumes specified in the request
 *
 * @prereq none
 *
 * @param param
 *
 * @brief Show potential virtual pools
 * @return A VirtualPoolChangeList that identifies each potential virtual
 *         pool, whether or not a change is allowed for the virtual pool,
 *         and if not, the reason why.
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/vpool-change/vpool")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public VirtualPoolChangeList getVirtualPoolForVirtualPoolChange(@PathParam("id") URI id, BulkIdParam param) {
    VirtualPool vpool = getVirtualPool(VirtualPool.Type.block, id);
    ArgValidator.checkFieldNotEmpty(param.getIds(), "volume_id");
    // We only need one volume from the current vpool to determine
    // which other vpools we can move to.
    Volume volume = _dbClient.queryObject(Volume.class, param.getIds().get(0));
    VirtualPoolChangeList virtualPoolChangeList = new VirtualPoolChangeList();
    if (volume != null) {
        if (!volume.getVirtualPool().equals(id)) {
            throw APIException.badRequests.volumeNotInVirtualPool(volume.getLabel(), vpool.getLabel());
        }
        // Get the block service implementation for this volume.
        BlockServiceApi blockServiceApi = BlockService.getBlockServiceImpl(volume, _dbClient);
        _log.info("Got BlockServiceApi for volume, now checking for vpool change candidates...");
        // Return the list of candidate VirtualPools for a VirtualPool change for this volume.
        VirtualPoolChangeList volumeVirturalPoolChangeList = blockServiceApi.getVirtualPoolForVirtualPoolChange(volume);
        virtualPoolChangeList.getVirtualPools().addAll(volumeVirturalPoolChangeList.getVirtualPools());
    }
    return virtualPoolChangeList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VirtualPoolChangeList(com.emc.storageos.model.vpool.VirtualPoolChangeList) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with VirtualPoolChangeList

use of com.emc.storageos.model.vpool.VirtualPoolChangeList in project coprhd-controller by CoprHD.

the class AbstractBlockServiceApiImpl method getVirtualPoolChangeListForVolume.

/**
 * Gets all potential vpools to to which the vpool for the passed volume can be
 * changed.
 *
 * @param volume
 *            A reference to the volume.
 *
 * @return A VirtualPoolChangeList specifying each vpool to which the volume's
 *         vpool could potentially be changed and whether or not the change would
 *         be allowed for that vpool.
 */
protected VirtualPoolChangeList getVirtualPoolChangeListForVolume(Volume volume) {
    // Get all potential vpools for this volume based on system
    // connectivity of the volume's storage system. For each
    // vpool determine if a vpool change to that vpool would be
    // allowed for the volume.
    VirtualPoolChangeList vpoolChangeList = new VirtualPoolChangeList();
    VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
    Collection<VirtualPool> allVpools = getVPoolsForVolumeBasedOnSystemConnectivity(volume);
    Iterator<VirtualPool> vpoolIter = allVpools.iterator();
    StringBuffer logMsg = new StringBuffer();
    logMsg.append("Analyzing vpools for change vpool operations:\n");
    while (vpoolIter.hasNext()) {
        StringBuffer notAllowedReason = new StringBuffer();
        VirtualPool targetVpool = vpoolIter.next();
        List<VirtualPoolChangeOperationEnum> allowedOperations = getVirtualPoolChangeAllowedOperationsForVolume(volume, currentVpool, targetVpool, notAllowedReason);
        logMsg.append("\tVpool [" + targetVpool.getLabel() + "]");
        logMsg.append((notAllowedReason.length() > 0) ? " not allowed: " + notAllowedReason.toString() : " allowed but only for: ");
        logMsg.append((allowedOperations != null && !allowedOperations.isEmpty()) ? Joiner.on("\t").join(allowedOperations) : "");
        logMsg.append("\n");
        vpoolChangeList.getVirtualPools().add(toVirtualPoolChangeRep(targetVpool, allowedOperations, notAllowedReason.toString()));
    }
    s_logger.info(logMsg.toString());
    return vpoolChangeList;
}
Also used : VirtualPoolChangeList(com.emc.storageos.model.vpool.VirtualPoolChangeList) VirtualPoolChangeOperationEnum(com.emc.storageos.model.vpool.VirtualPoolChangeOperationEnum) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Aggregations

VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 VirtualPoolChangeList (com.emc.storageos.model.vpool.VirtualPoolChangeList)2 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)1 Volume (com.emc.storageos.db.client.model.Volume)1 VirtualPoolChangeOperationEnum (com.emc.storageos.model.vpool.VirtualPoolChangeOperationEnum)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1