Search in sources :

Example 6 with Pool

use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.

the class HDSCommunicationInterface method processStorageThinPoolResponse.

/**
 * Process the thin pool response received from server.
 *
 * @param system
 * @param thinPoolListFromResponse
 * @param accessProfile
 * @param supportedProtocols
 * @param poolsToMatchWithVpool
 * @throws IOException
 */
private List<StoragePool> processStorageThinPoolResponse(StorageSystem system, List<Pool> thinPoolListFromResponse, AccessProfile accessProfile, Set<String> supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws IOException {
    _logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> updatePools = new ArrayList<StoragePool>();
    List<StoragePool> allPools = new ArrayList<StoragePool>();
    if (null != thinPoolListFromResponse && !thinPoolListFromResponse.isEmpty()) {
        _logger.debug("thinPoolListFromResponse size:{}", thinPoolListFromResponse.size());
        for (Pool poolFromResponse : thinPoolListFromResponse) {
            if (poolFromResponse.getPoolFunction() == 5) {
                boolean isNew = false;
                // indicates whether to add to modified pools list or not
                boolean isModified = false;
                String nativeGuid = NativeGUIDGenerator.generateNativeGuid(system, poolFromResponse.getObjectID(), NativeGUIDGenerator.POOL);
                _logger.debug("nativeGuid :{}", nativeGuid);
                StoragePool pool = checkPoolExistsInDB(nativeGuid);
                if (null == pool) {
                    isNew = true;
                    pool = new StoragePool();
                    pool.setNativeGuid(nativeGuid);
                    pool.setStorageDevice(system.getId());
                    pool.setId(URIUtil.createId(StoragePool.class));
                    pool.setNativeId(poolFromResponse.getPoolID());
                    pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                    // @TODO hard coded for now. Need to see how to get it from API or documentation.
                    pool.setMaximumThinVolumeSize(104857600L);
                    pool.setPoolServiceType(PoolServiceType.block.toString());
                    pool.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
                    StringSet raidLevels = new StringSet();
                    raidLevels.add(poolFromResponse.getRaidType());
                    // 
                    pool.addSupportedRaidLevels(raidLevels);
                    pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
                    _logger.info("pool objectId {}", poolFromResponse.getObjectID());
                    pool.setThinVolumePreAllocationSupported(Boolean.FALSE);
                }
                // Set TieringEnabled flag based on tierControl of the pool.
                if (poolFromResponse.getTierControl() == 1) {
                    pool.setAutoTieringEnabled(Boolean.TRUE);
                } else {
                    pool.setAutoTieringEnabled(Boolean.FALSE);
                }
                StringSet protocols = new StringSet(supportedProtocols);
                if (!isNew && ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), protocols)) {
                    isModified = true;
                }
                pool.setProtocols(protocols);
                StringSet copyTypes = new StringSet();
                copyTypes.add(StoragePool.CopyTypes.UNSYNC_ASSOC.name());
                copyTypes.add(StoragePool.CopyTypes.UNSYNC_UNASSOC.name());
                copyTypes.add(StoragePool.CopyTypes.SYNC.name());
                copyTypes.add(StoragePool.CopyTypes.ASYNC.name());
                pool.setSupportedCopyTypes(copyTypes);
                String label = null;
                if (StringUtils.isBlank(poolFromResponse.getName()) || poolFromResponse.getName().length() <= 2) {
                    label = "DP " + poolFromResponse.getDisplayName();
                } else {
                    label = poolFromResponse.getName();
                }
                pool.setPoolName(label);
                pool.setFreeCapacity(poolFromResponse.getFreeCapacity());
                pool.setTotalCapacity(poolFromResponse.getUsedCapacity());
                pool.setSubscribedCapacity(poolFromResponse.getSubscribedCapacityInKB());
                if (null != poolFromResponse.getDiskType()) {
                    Set<String> driveTypes = new HashSet<String>();
                    driveTypes.add(getPoolSupportedDriveType(poolFromResponse.getDiskType()));
                    pool.addDriveTypes(driveTypes);
                }
                // TODO workaround to display the display name based on the pool name
                pool.setLabel(label);
                if (!isNew && !isModified && (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name()))) {
                    isModified = true;
                }
                pool.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
                pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                if (isNew) {
                    newPools.add(pool);
                    // add new pools to modified pools list to consider them for implicit pool matching.
                    poolsToMatchWithVpool.add(pool);
                } else {
                    updatePools.add(pool);
                    // add to modified pools list if pool's property which is required for vPool matcher, has changed.
                    if (isModified) {
                        poolsToMatchWithVpool.add(pool);
                    }
                }
            }
        }
        StoragePoolAssociationHelper.setStoragePoolVarrays(system.getId(), newPools, _dbClient);
        _logger.info("New pools size: {}", newPools.size());
        _logger.info("updatePools size: {}", updatePools.size());
        _dbClient.createObject(newPools);
        _dbClient.persistObject(updatePools);
        allPools.addAll(newPools);
        allPools.addAll(updatePools);
    }
    _logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    return allPools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePool(com.emc.storageos.db.client.model.StoragePool) Pool(com.emc.storageos.hds.model.Pool) HashSet(java.util.HashSet)

Example 7 with Pool

use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.

the class HDSApiDiscoveryManager method getStoragePoolTierInfo.

/**
 * Returns all storage system information.
 *
 * @return
 * @throws Exception
 */
public Pool getStoragePoolTierInfo(String systemObjectID, String poolObjectID) throws Exception {
    InputStream responseStream = null;
    Pool pool = null;
    URI endpointURI = hdsApiClient.getBaseURI();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray inputStorageArray = new StorageArray(systemObjectID);
    Get getOp = new Get(HDSConstants.STORAGEARRAY);
    attributeMap.put(HDSConstants.STORAGEARRAY, inputStorageArray);
    Pool inputPool = new Pool(poolObjectID);
    attributeMap.put(HDSConstants.JOURNAL_POOL, inputPool);
    attributeMap.put(HDSConstants.GET, getOp);
    String getPoolTieringInfoInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_STORAGE_POOL_TIERING_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    log.info("Get StoragePool Tiering info query payload :{}", getPoolTieringInfoInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getPoolTieringInfoInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        pool = result.getBean(Pool.class);
    } else {
        log.error("Get pool tiering info failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query pool tiering info due to invalid response %1$s from server", response.getStatus()));
    }
    return pool;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) Pool(com.emc.storageos.hds.model.Pool) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 8 with Pool

use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.

the class HDSSnapshotOperations method selectThinImagePoolForPlacement.

private Pool selectThinImagePoolForPlacement(List<Pool> thinImagePoolList, BlockSnapshot snapshot) {
    Pool selectedPool = null;
    for (Pool pool : thinImagePoolList) {
        if (pool.getFreeCapacity() >= snapshot.getAllocatedCapacity()) {
            selectedPool = pool;
            log.info("ThinImage Pool {} has enough space to create snapshot", pool.getObjectID());
            break;
        }
    }
    return selectedPool;
}
Also used : Pool(com.emc.storageos.hds.model.Pool)

Example 9 with Pool

use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.

the class HDSSnapshotOperations method createSingleVolumeSnapshot.

/**
 * Creates ThinImage instance on HDS.
 * 1. Find pair management server.
 * 2. Find ViPR-Snapshot-Group instance from storage system
 * 3. Find ThinImage pool.
 * 4. Create Snapshot instance on ThinImage Pool.
 * 5. Add DummyLunPath into Snapshot.
 * 6. Create ThinImage pair
 */
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("Create Single Volume Snapshot Started");
    boolean isSnapshotCreated = false, isDummyLunPathAdded = false;
    HDSApiClient hdsApiClient = null;
    HDSHost pairMgmtServer = null;
    try {
        hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        log.info("createSingleVolumeSnapshot operation START");
        Volume volume = dbClient.queryObject(Volume.class, snapshotObj.getParent());
        pairMgmtServer = hdsApiClient.getSnapshotGroupPairManagementServer(storage.getSerialNumber());
        if (pairMgmtServer == null) {
            log.error("Unable to find snapshot group information/pair management server for Thin Image");
            throw HDSException.exceptions.snapshotGroupNotAvailable(storage.getNativeGuid());
        }
        String systemObjectId = HDSUtils.getSystemObjectID(storage);
        log.debug("StorageSystem Object Id :{}", systemObjectId);
        List<Pool> thinImagePoolList = hdsApiClient.getThinImagePoolList(systemObjectId);
        if (thinImagePoolList == null || thinImagePoolList.isEmpty()) {
            log.error("ThinImage Pool is not available on Storage System :{}", storage.getNativeGuid());
            throw HDSException.exceptions.thinImagePoolNotAvailable(storage.getNativeGuid());
        }
        Pool selectedThinImagePool = selectThinImagePoolForPlacement(thinImagePoolList, snapshotObj);
        if (selectedThinImagePool == null) {
            log.error("No ThinImage Pool is having enough free capcity to create snapshot on storage system :{}", storage.getNativeGuid());
            throw HDSException.exceptions.notEnoughFreeCapacityOnthinImagePool(storage.getNativeGuid());
        }
        // Create snapshot volume
        hdsProtectionOperations.createSecondaryVolumeForSnapshot(storage, volume, snapshotObj);
        isSnapshotCreated = true;
        snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        // Add Dummy lun path
        hdsProtectionOperations.addDummyLunPath(hdsApiClient, snapshotObj);
        isDummyLunPathAdded = true;
        String snapShotGrpId = getViPRSnapshotGroup(pairMgmtServer, storage.getSerialNumber()).getObjectID();
        // Create Thin Image pair
        hdsApiClient.createThinImagePair(snapShotGrpId, pairMgmtServer.getObjectID(), volume.getNativeId(), snapshotObj.getNativeId(), selectedThinImagePool.getPoolID(), storage.getModel());
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        try {
            rollbackMethodForCreateSnapshot(isSnapshotCreated, isDummyLunPathAdded, hdsApiClient, storage, snapshot);
        } catch (Exception e1) {
            log.error("Exception occured while roll back snap creation", e1);
        }
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, snapshot);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("Create Single Volume Snapshot Completed");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSHost(com.emc.storageos.hds.model.HDSHost) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Pool(com.emc.storageos.hds.model.Pool) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 10 with Pool

use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.

the class HDSUtils method updateStoragePoolCapacity.

public static void updateStoragePoolCapacity(DbClient dbClient, HDSApiClient client, StoragePool storagePool) {
    StorageSystem storageSystem = null;
    try {
        storageSystem = dbClient.queryObject(StorageSystem.class, storagePool.getStorageDevice());
        log.info(String.format("Old storage pool capacity data for %n  pool %s/%s --- %n  free capacity: %s; subscribed capacity: %s", storageSystem.getId(), storagePool.getId(), storagePool.calculateFreeCapacityWithoutReservations(), storagePool.getSubscribedCapacity()));
        String poolObjectId = getPoolObjectID(storagePool);
        String systemObjectId = getSystemObjectID(storageSystem);
        Pool hdsStoragePool = client.getStoragePoolInfo(systemObjectId, poolObjectId);
        // Update storage pool and save to data base
        storagePool.setFreeCapacity(hdsStoragePool.getFreeCapacity());
        // @TODO need to see how to get subscribed capacity of the hds pool
        // storagePool.setSubscribedCapacity(ControllerUtils.convertBytesToKBytes(subscribedCapacity));
        log.info(String.format("New storage pool capacity data for pool %n  %s/%s --- %n  free capacity: %s; subscribed capacity: %s", storageSystem.getId(), storagePool.getId(), storagePool.getFreeCapacity(), storagePool.getSubscribedCapacity()));
        dbClient.persistObject(storagePool);
    } catch (Exception ex) {
        log.error(String.format("Failed to update capacity of storage pool after volume provisioning operation. %n  Storage system: %s, storage pool %s .", storageSystem.getId(), storagePool.getId()), ex);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Pool(com.emc.storageos.hds.model.Pool) URISyntaxException(java.net.URISyntaxException) HDSException(com.emc.storageos.hds.HDSException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

Pool (com.emc.storageos.hds.model.Pool)10 StorageArray (com.emc.storageos.hds.model.StorageArray)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)5 InputStream (java.io.InputStream)5 URI (java.net.URI)5 HashMap (java.util.HashMap)5 JavaResult (org.milyn.payload.JavaResult)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)3 Get (com.emc.storageos.hds.model.Get)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 HDSException (com.emc.storageos.hds.HDSException)2 Add (com.emc.storageos.hds.model.Add)2 EchoCommand (com.emc.storageos.hds.model.EchoCommand)2 Error (com.emc.storageos.hds.model.Error)2 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1