Search in sources :

Example 36 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method deleteSecondaryVolumeSnapshot.

public void deleteSecondaryVolumeSnapshot(StorageSystem storageSystem, BlockSnapshot snapshotObj, TaskCompleter taskCompleter) throws Exception {
    log.info("Snapshot deletion operation started");
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    String logicalUnitObjId = HDSUtils.getLogicalUnitObjectId(snapshotObj.getNativeId(), storageSystem);
    asyncTaskMessageId = hdsApiClient.deleteSnapshotVolume(systemObjectID, logicalUnitObjId, storageSystem.getModel());
    if (null != asyncTaskMessageId) {
        HDSJob deleteSnapshotJob = new HDSDeleteSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(deleteSnapshotJob);
        log.info("Snapshot deletion operation completed successfully");
    } else {
        // This path should never be taken as the HDS client should always return
        // the asynchronous task id. If it does not, this will be treated as an
        // error.
        log.error("Unexpected null asynchronous task id from HDS client call to delete volume snapshot.");
        ServiceCoded sc = DeviceControllerExceptions.hds.nullAsyncTaskIdForDeleteSnapshot(snapshotObj.forDisplay());
        taskCompleter.error(dbClient, sc);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSDeleteSnapshotJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSDeleteSnapshotJob) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded)

Example 37 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient 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 38 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSSnapshotOperations method deleteSingleVolumeSnapshot.

/**
 * 1. Delete ThinImage Pair
 * 2. Delete Dummy lun path from snap volume
 * 3. Delete Snapshot
 */
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("Delete Single Volume Snapshot Started");
    try {
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        log.info("deleteSingleVolumeSnapshot operation START");
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        // Get pair management server
        HDSHost pairMgmtServer = hdsApiClient.getSnapshotGroupPairManagementServer(storage.getSerialNumber());
        if (null == pairMgmtServer) {
            log.error("Unable to find snapshot group information/pair management server for Thin Image");
            throw HDSException.exceptions.snapshotGroupNotAvailable(storage.getNativeGuid());
        }
        // Get snapshot group id
        SnapshotGroup snapshotGroup = getViPRSnapshotGroup(pairMgmtServer, storage.getSerialNumber());
        String snapShotGrpId = snapshotGroup.getObjectID();
        // Get replication object ids
        Volume volume = dbClient.queryObject(Volume.class, snapshotObj.getParent());
        ReplicationInfo replicationInfo = getReplicationInfo(snapshotGroup, volume.getNativeId(), snapshotObj.getNativeId());
        if (replicationInfo != null) {
            String replicationInfoObjId = replicationInfo.getObjectID();
            // Delete ThinImage pair between volume and snapshot
            hdsApiClient.deleteThinImagePair(pairMgmtServer.getObjectID(), snapShotGrpId, replicationInfoObjId, storage.getModel());
        } else {
            log.info("Pair has been deleted already on storage system");
        }
        // Remove dummy lun path
        hdsProtectionOperations.removeDummyLunPath(storage, snapshot);
        // Delete snapshot vollume
        hdsProtectionOperations.deleteSecondaryVolumeSnapshot(storage, snapshotObj, taskCompleter);
        log.info("Delete Single Volume Snapshot Completed");
    } catch (Exception e) {
        String errorMsg = String.format(DELETE_ERROR_MSG_FORMAT, snapshot);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
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) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) SnapshotGroup(com.emc.storageos.hds.model.SnapshotGroup) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 39 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSStorageDevice method doCreateVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCreateVolumes(com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool, java.lang.String, java.util.List,
     * com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doCreateVolumes(StorageSystem storageSystem, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    boolean isThinVolume = false;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
        if ((label == null) && (volumes.size() == 1)) {
            String tenantName = "";
            try {
                TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
                tenantName = tenant.getLabel();
            } catch (DatabaseException e) {
                log.error("Error lookup TenantOrb object", e);
            }
            label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
        }
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
        isThinVolume = volume.getThinlyProvisioned();
    }
    log.info(logMsgBuilder.toString());
    try {
        multiVolumeCheckForHitachiModel(volumes, storageSystem);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        String poolObjectID = HDSUtils.getPoolObjectID(storagePool);
        String asyncTaskMessageId = null;
        // isThinVolume = false, creates LogicalUnits
        if (isThinVolume) {
            asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, storagePool.getNativeId(), capacity, volumes.size(), label, QUICK_FORMAT_TYPE, storageSystem.getModel());
        } else if (!isThinVolume) {
            asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, capacity, volumes.size(), label, null, storageSystem.getModel(), null);
        }
        if (asyncTaskMessageId != null) {
            HDSJob createHDSJob = (volumes.size() > 1) ? new HDSCreateMultiVolumeJob(asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), volumes.size(), taskCompleter) : new HDSCreateVolumeJob(asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createHDSJob));
        } else {
            throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
        }
    } catch (final InternalException e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            dbClient.persistObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSCreateVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateVolumeJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) HDSCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateMultiVolumeJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 40 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSStorageDevice method doExpandVolume.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doExpandVolume(com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool, com.emc.storageos.db.client.model.Volume, java.lang.Long,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doExpandVolume(StorageSystem storageSystem, StoragePool storagePool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getLabel(), size));
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        String asyncTaskMessageId = null;
        if (volume.getThinlyProvisioned()) {
            asyncTaskMessageId = hdsApiClient.modifyThinVolume(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storageSystem), size, storageSystem.getModel());
        }
        if (null != asyncTaskMessageId) {
            HDSJob expandVolumeJob = new HDSVolumeExpandJob(asyncTaskMessageId, storageSystem.getId(), storagePool.getId(), taskCompleter, "ExpandVolume");
            ControllerServiceImpl.enqueueJob(new QueueJob(expandVolumeJob));
        } else {
            throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
        }
    } catch (final InternalException e) {
        log.error("Problem in doExpandVolume: ", e);
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doExpandVolume: ", e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doExpandVolume", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info(String.format("Expand Volume End - Array: %s, Pool: %s, Volume: %s", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getLabel()));
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSVolumeExpandJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSVolumeExpandJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)45 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)26 HDSException (com.emc.storageos.hds.HDSException)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)21 Volume (com.emc.storageos.db.client.model.Volume)14 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)13 HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)12 ArrayList (java.util.ArrayList)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 HashSet (java.util.HashSet)11 ExportMask (com.emc.storageos.db.client.model.ExportMask)10 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)10 URI (java.net.URI)10 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)9 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)6