Search in sources :

Example 31 with XtremIOClient

use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doCreateSnapshot.

@Override
public void doCreateSnapshot(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("SnapShot Creation..... Started");
    List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, snapshotList);
    XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
    if (client.isVersion2() && ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, dbClient, taskCompleter)) {
        snapshotOperations.createGroupSnapshots(storage, snapshotList, createInactive, readOnly, taskCompleter);
    } else {
        for (URI snapshotURI : snapshotList) {
            snapshotOperations.createSingleVolumeSnapshot(storage, snapshotURI, createInactive, readOnly, taskCompleter);
        }
    }
    _log.info("SnapShot Creation..... End");
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) URI(java.net.URI)

Example 32 with XtremIOClient

use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doAddToConsistencyGroup.

@Override
public void doAddToConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} doAddToConsistencyGroup START ...", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    try {
        // Check if the consistency group exists
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        if (!client.isVersion2()) {
            _log.info("Nothing to add to consistency group {}", consistencyGroup.getLabel());
            taskCompleter.ready(dbClient);
            return;
        }
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        List<BlockObject> updatedBlockObjects = new ArrayList<BlockObject>();
        for (URI uri : blockObjects) {
            BlockObject blockObject = BlockObject.fetch(dbClient, uri);
            if (blockObject != null) {
                if (blockObject.getClass().isInstance(Volume.class)) {
                    Volume volume = (Volume) blockObject;
                    if (volume.checkForRp() || RPHelper.isAssociatedToRpVplexType(volume, dbClient, PersonalityTypes.METADATA, PersonalityTypes.TARGET)) {
                        // This causes issues with local array snapshots of RP+VPlex volumes.
                        continue;
                    }
                }
                client.addVolumeToConsistencyGroup(blockObject.getLabel(), cgName, clusterName);
                blockObject.setConsistencyGroup(consistencyGroupId);
                updatedBlockObjects.add(blockObject);
            }
        }
        dbClient.updateAndReindexObject(updatedBlockObjects);
        taskCompleter.ready(dbClient);
        _log.info("{} doAddToConsistencyGroup END ...", storage.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Add To Consistency Group operation failed %s", e));
        // Remove any references to the consistency group
        for (URI blockObjectURI : blockObjects) {
            BlockObject blockObject = BlockObject.fetch(dbClient, blockObjectURI);
            if (blockObject != null) {
                blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
            }
            dbClient.persistObject(blockObject);
        }
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToAddMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
    }
}
Also used : XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) Volume(com.emc.storageos.db.client.model.Volume) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) ArrayList(java.util.ArrayList) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 33 with XtremIOClient

use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doCreateConsistencyGroup.

@Override
public void doCreateConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} doCreateConsistencyGroup START ...", storage.getSerialNumber());
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
        boolean isXioV2 = client.isVersion2();
        if (!isXioV2 && consistencyGroup.isProtectedCG()) {
            _log.info("{} Operation createConsistencyGroup not supported for the xtremio array version");
        } else {
            String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
            Project cgProject = dbClient.queryObject(Project.class, consistencyGroup.getProject());
            String cgName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
            client.createConsistencyGroup(cgName, clusterName);
            String cgTagName = XtremIOProvUtils.createTagsForConsistencyGroup(client, cgProject.getLabel(), clusterName);
            consistencyGroup.addSystemConsistencyGroup(storage.getId().toString(), cgName);
            consistencyGroup.addConsistencyGroupTypes(Types.LOCAL.name());
            client.tagObject(cgTagName, XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), cgName, clusterName);
            if (!consistencyGroup.isProtectedCG() && NullColumnValueGetter.isNullURI(consistencyGroup.getStorageController())) {
                consistencyGroup.setStorageController(storage.getId());
            }
        }
        dbClient.updateObject(consistencyGroup);
        taskCompleter.ready(dbClient);
        _log.info("{} doCreateConsistencyGroup END ...", storage.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Create Consistency Group operation failed %s", e));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : Project(com.emc.storageos.db.client.model.Project) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 34 with XtremIOClient

use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doDeleteSnapshot.

@Override
public void doDeleteSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("SnapShot Deletion..... Started");
    List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
    XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
    if (client.isVersion2() && ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, dbClient, taskCompleter)) {
        snapshotOperations.deleteGroupSnapshots(storage, snapshot, taskCompleter);
    } else {
        snapshotOperations.deleteSingleVolumeSnapshot(storage, snapshot, taskCompleter);
    }
    _log.info("SnapShot Deletion..... End");
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient)

Example 35 with XtremIOClient

use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long sizeInBytes, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("Expand Volume..... Started");
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        Long sizeInGB = new Long(sizeInBytes / (1024 * 1024 * 1024));
        // XtremIO Rest API supports only expansion in GBs.
        String capacityInGBStr = String.valueOf(sizeInGB).concat("g");
        client.expandVolume(volume.getDeviceLabel(), capacityInGBStr, clusterName);
        XtremIOVolume createdVolume = client.getVolumeDetails(volume.getDeviceLabel(), clusterName);
        volume.setProvisionedCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
        volume.setAllocatedCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
        volume.setCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
        dbClient.updateObject(volume);
        // update StoragePool capacity
        try {
            XtremIOProvUtils.updateStoragePoolCapacity(client, dbClient, pool);
        } catch (Exception e) {
            _log.warn("Error while updating pool capacity", e);
        }
        taskCompleter.ready(dbClient);
        _log.info("Expand Volume..... End");
    } catch (Exception e) {
        _log.error("Error while expanding volumes", e);
        ServiceError error = DeviceControllerErrors.xtremio.expandVolumeFailure(e);
        taskCompleter.error(dbClient, error);
    }
}
Also used : XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)38 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)27 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)20 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)15 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)13 URI (java.net.URI)13 ArrayList (java.util.ArrayList)12 Initiator (com.emc.storageos.db.client.model.Initiator)11 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)11 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)9 BlockObject (com.emc.storageos.db.client.model.BlockObject)9 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)8 Volume (com.emc.storageos.db.client.model.Volume)7 XtremIOConsistencyGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 ExportOperationContext (com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext)5 List (java.util.List)5