Search in sources :

Example 91 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method restoreGroupSnapshots.

/**
 * Implementation should restore the set of snapshots that were taken for a set of
 * volumes in a consistency group. That is, at some time there was a consistency
 * group of volumes created and snapshot was taken of these; these snapshots would
 * belong to a "snap-set". This restore operation, will restore the volumes in the
 * consistency group from this snap-set. Any snapshot from the snap-set can be
 * provided to restore the whole snap-set.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshot [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        // Check if the consistency group exists
        String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
        storage = findProviderFactory.withGroup(storage, consistencyGroupName).find();
        if (storage == null) {
            ServiceError error = DeviceControllerErrors.smis.noConsistencyGroupWithGivenName();
            taskCompleter.error(_dbClient, error);
            return;
        }
        String snapshotGroupName = snapshotObj.getReplicationGroupInstance();
        CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, snapshotGroupName);
        if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
            CIMObjectPath cimJob = null;
            if (storage.checkIfVmax3()) {
                if (snapshotObj.getSettingsInstance() == null) {
                    throw DeviceControllerException.exceptions.snapSettingsInstanceNull(snapshotObj.getSnapsetLabel(), snapshotObj.getId().toString());
                }
                // there could only be one restored snapshot per device at a time
                // terminate any pre-existing one in favor of the new one
                terminateAnyRestoreSessions(storage, snapshotObj, snapshot, taskCompleter);
                CIMObjectPath settingsPath = _cimPath.getGroupSynchronizedSettingsPath(storage, consistencyGroupName, snapshotObj.getSettingsInstance());
                cimJob = _helper.callModifySettingsDefineState(storage, _helper.getRestoreFromSettingsStateInputArguments(settingsPath, false));
            } else {
                CIMArgument[] restoreCGSnapInput = _helper.getRestoreFromReplicaInputArguments(groupSynchronized);
                cimJob = _helper.callModifyReplica(storage, restoreCGSnapInput);
            }
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(consistencyGroupName);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String message = String.format("Generic exception when trying to restoring snapshots from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupSnapshots", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 92 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method createStorageSetting.

/**
 * In order to create VDEV targets for snapshots, we need to have a StorageSetting
 * with a parameter set to enable it. This method will create an instance of this.
 * We will try to maintain a single StorageSetting for this purpose, per pool. To
 * that end, we'll first check for the existence of the setting (based on a
 * special name).
 *
 * @param storage - StorageSystem where the pool exists
 * @param poolPath - CIMObject representing the pool to allocate targets from
 * @return CIMInstance - null => error. Otherwise, will be the StorageSetting
 *         instance for creating VDEVs against the pool.
 * @throws DeviceControllerException
 */
private CIMInstance createStorageSetting(StorageSystem storage, CIMObjectPath poolPath) throws Exception {
    CloseableIterator<CIMObjectPath> capabilities = null;
    CloseableIterator<CIMObjectPath> poolSettings = null;
    CIMInstance instance = null;
    try {
        // From the storage pool, get its capability (assuming there is only
        // one per pool). Get associated storage settings from the capability,
        // loop through each and find one that has the special name. If it
        // doesn't exist, create it and modify the StorageExtentInitialUsage
        // and ElementName.
        capabilities = _helper.getAssociatorNames(storage, poolPath, null, SYMM_STORAGE_POOL_CAPABILITIES, null, null);
        if (capabilities != null && capabilities.hasNext()) {
            CIMObjectPath poolCapabilities = capabilities.next();
            poolSettings = _helper.getAssociatorNames(storage, poolCapabilities, null, SYMM_STORAGE_POOL_SETTING, null, null);
            CIMInstance foundVdevSettingForThisPool = null;
            while (poolSettings != null && poolSettings.hasNext()) {
                CIMInstance it = _helper.getInstance(storage, poolSettings.next(), false, false, PL_STORAGE_EXTENT_INITIAL_USAGE);
                int storageExtentInitialUsage = Integer.valueOf(CIMPropertyFactory.getPropertyValue(it, CP_STORAGE_EXTENT_INITIAL_USAGE));
                if (storageExtentInitialUsage == DELTA_REPLICA_TARGET_VALUE) {
                    // We found a setting that has the "Delta Replica Target" value
                    // for the StorageExtentInitialUsage attribute
                    foundVdevSettingForThisPool = it;
                    break;
                }
            }
            if (foundVdevSettingForThisPool != null) {
                instance = foundVdevSettingForThisPool;
                _log.info(String.format("Found existing StorageSetting for VDEV %s", instance.toString()));
            } else {
                // It wasn't found ==> create it
                // TODO: How do we prevent concurrent operations from creating duplicates?
                _log.info("Could not find existing StorageSetting for VDEV, going to create it and modify it...");
                CIMArgument[] inArgs = _helper.getCreateDefaultStoragePoolSettingsArguments();
                CIMArgument[] outArgs = new CIMArgument[5];
                _helper.invokeMethod(storage, poolCapabilities, CREATE_SETTING, inArgs, outArgs);
                CIMObjectPath newSetting = _cimPath.getCimObjectPathFromOutputArgs(outArgs, NEW_SETTING);
                instance = _cimPath.getStoragePoolVdevSettings(newSetting);
                _helper.modifyInstance(storage, instance, PL_STORAGE_EXTENT_INITIAL_USAGE);
                // Get the unique ID for display
                CIMInstance newSettingInstance = _helper.getInstance(storage, newSetting, false, false, PL_ONLY_EMC_UNIQUE_ID);
                String emcUniqueId = CIMPropertyFactory.getPropertyValue(newSettingInstance, CP_EMC_UNIQUE_ID);
                _log.info(String.format("Created StorageSetting for VDEV %s (EMCUniqueID = %s)", instance.toString(), emcUniqueId));
            }
        } else {
            String message = String.format("Could not find any %s instances for StoragePool %s. Will not be able to create a StorageSetting.", SYMM_STORAGE_POOL_CAPABILITIES, poolPath.toString());
            _log.error(message);
            throw DeviceControllerExceptions.smis.noStoragePoolInstances(message, null);
        }
    } finally {
        if (capabilities != null) {
            capabilities.close();
        }
        if (poolSettings != null) {
            poolSettings.close();
        }
    }
    return instance;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) Factory.getLinkedTargetSnapshotSessionConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint.Factory.getLinkedTargetSnapshotSessionConstraint) CIMArgument(javax.cim.CIMArgument)

Example 93 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method deleteTargetGroup.

/**
 * Method will invoke the SMI-S operation to delete the ReplicationGroup.
 *
 * @param system StorageSystem where the pool and volume exist
 * @param replicationGroupInstance InstanceID of the SMI-S ReplicationGroup
 * @throws Exception
 */
private void deleteTargetGroup(StorageSystem system, String replicationGroupInstance) throws Exception {
    /*
         * FIXME Inconsistencies with BlockSnapshot#getReplicationGroupInstance format
         *
         * CoprHD-created linked targets will have this field value in the format "<system-serial>+<instance>".
         *
         * Ingested linked targets will have this field value in the more simple format, "<instance>"
         */
    if (system.getUsingSmis80()) {
        if (!replicationGroupInstance.contains("+")) {
            replicationGroupInstance = String.format("%s+%s", system.getSerialNumber(), replicationGroupInstance);
        }
    }
    CIMObjectPath groupPath = _cimPath.getReplicationGroupObjectPath(system, replicationGroupInstance);
    CIMArgument[] outArgs = new CIMArgument[5];
    CIMArgument[] deleteGroupInArgs = _helper.getDeleteReplicationGroupInputArguments(system, groupPath, true);
    _helper.invokeMethod(system, _cimPath.getControllerReplicationSvcPath(system), DELETE_GROUP, deleteGroupInArgs, outArgs);
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 94 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method findSnapStoragePoolOrNull.

/**
 * Method will search through the snap pools for the specified array
 * and return the CIMObjectPath for it. This will be the pool where
 * the target devices will be created for snapshot operation.
 *
 * @param storage - StorageSystem representing the array
 * @return CIMObjectPath - CIM Reference to SnapStoragePool to be used for
 *         the target devices.
 * @throws WBEMException
 */
private CIMObjectPath findSnapStoragePoolOrNull(StorageSystem storage) throws WBEMException {
    CIMObjectPath snapPoolPath = null;
    CloseableIterator<CIMObjectPath> snapPools = null;
    try {
        CIMObjectPath systemPath = _cimPath.getStorageSystem(storage);
        snapPools = _helper.getAssociatorNames(storage, systemPath, null, storage.checkIfVmax3() ? StoragePool.PoolClassNames.Symm_SRPStoragePool.name() : SYMM_SNAP_STORAGE_POOL, null, null);
        // TODO: Get the first one for now, but could there be more than one? If so, what to do?
        if (snapPools.hasNext()) {
            snapPoolPath = snapPools.next();
            _log.info(String.format("Found Symm_SnapStoragePool to use -> %s", snapPoolPath.toString()));
        }
    } finally {
        if (snapPools != null) {
            snapPools.close();
        }
    }
    return snapPoolPath;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath)

Example 95 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method createGroupSnapshots.

/**
 * Should implement create of a snapshot from a source volume that is part of a
 * consistency group.
 *
 * Implementation note: In this method we will kick of the asynchronous creation
 * of the target devices required for the CG snaps. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group snapshot operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshotList [required] - BlockSnapshot URI list representing the previously created
 *            snap for the volume
 * @param createInactive whether the snapshot needs to to be created with sync_active=true/false
 * @param readOnly - Indicates if the snapshot should be read only.
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START createGroupSnapshots");
    // Target group CIM Path
    CIMObjectPath targetGroupPath = null;
    // List of target device ids
    List<String> targetDeviceIds = null;
    // The source consistency group name
    String sourceGroupName = null;
    try {
        final BlockSnapshot first = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
        sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(first, _dbClient);
        Volume snapVolume = _dbClient.queryObject(Volume.class, first.getParent());
        boolean thinProvisioning = snapVolume.getThinlyProvisioned() != null && snapVolume.getThinlyProvisioned();
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, snapVolume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        final String snapLabelToUse = _nameGenerator.generate(tenantName, first.getLabel(), snapshotList.get(0).toString(), '-', storage.getUsingSmis80() ? SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH : SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, first, _dbClient, _helper, _cimPath);
        final Map<String, List<Volume>> volumesBySizeMap = new HashMap<String, List<Volume>>();
        // Group volumes by pool and size
        for (URI uri : snapshotList) {
            final BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
            final Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
            final String key = volume.getPool() + "-" + volume.getCapacity();
            final List<Volume> currentVolumes = volumesBySizeMap.containsKey(key) ? volumesBySizeMap.get(key) : new ArrayList<Volume>();
            currentVolumes.add(volume);
            volumesBySizeMap.put(key, currentVolumes);
        }
        // For VMAX3, we need the target group to tag the setting instance
        if (storage.checkIfVmax3() || !storage.getUsingSmis80()) {
            targetDeviceIds = new ArrayList<String>();
            for (Entry<String, List<Volume>> entry : volumesBySizeMap.entrySet()) {
                final List<Volume> volumes = entry.getValue();
                final Volume volume = volumes.get(0);
                final URI poolId = volume.getPool();
                CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, volume, null);
                // Create target devices based on the array model
                final List<String> newDeviceIds = kickOffTargetDevicesCreation(storage, volumeGroupPath, sourceGroupName, snapLabelToUse, createInactive, thinProvisioning, volumes.size(), poolId, volume.getCapacity(), taskCompleter);
                targetDeviceIds.addAll(newDeviceIds);
            }
            // Create target device group
            targetGroupPath = ReplicationUtils.createTargetDeviceGroup(storage, sourceGroupName, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath, SYNC_TYPE.SNAPSHOT);
        }
        // Create CG snapshot
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, snapLabelToUse, targetGroupPath, createInactive, thinProvisioning, taskCompleter, SYNC_TYPE.SNAPSHOT, _dbClient, _helper, _cimPath);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, sourceGroupName, taskCompleter)));
        }
    } catch (Exception e) {
        final String errMsg = format("An exception occurred when trying to create snapshots for consistency group {0} on storage system {1}", sourceGroupName, storage.getId());
        _log.error(errMsg, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupSnapshots", e.getMessage());
        taskCompleter.error(_dbClient, error);
        // Roll back changes
        rollbackCreateSnapshot(storage, targetGroupPath, targetDeviceIds, taskCompleter);
        throw new SmisException(errMsg, e);
    }
}
Also used : SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) ArrayList(java.util.ArrayList) List(java.util.List) SmisBlockCreateCGSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

CIMObjectPath (javax.cim.CIMObjectPath)582 CIMInstance (javax.cim.CIMInstance)254 WBEMException (javax.wbem.WBEMException)236 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)208 CIMArgument (javax.cim.CIMArgument)190 ArrayList (java.util.ArrayList)139 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)118 Volume (com.emc.storageos.db.client.model.Volume)108 URI (java.net.URI)108 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)82 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)76 WBEMClient (javax.wbem.client.WBEMClient)75 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)72 HashSet (java.util.HashSet)68 HashMap (java.util.HashMap)63 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)57 CIMProperty (javax.cim.CIMProperty)57 IOException (java.io.IOException)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)52 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)52