Search in sources :

Example 41 with CIMArgument

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

the class SmisStorageDevice method cleanupAnyGroupBackupSnapshots.

/**
 * Method will look up backup snapshots that were created when a snapshot restore operation was
 * performed, then clean them up. This would be required in order to do the volume delete.
 *
 * @param storage
 *            [required] - StorageSystem object representing the array
 * @param volume
 *            [required] - Volume object representing the volume that has a snapshot created for
 *            it
 */
private void cleanupAnyGroupBackupSnapshots(final StorageSystem storage, final Volume volume) {
    CloseableIterator<CIMObjectPath> settingsIterator = null;
    _log.info(String.format("cleanupAnyGroupBackupSnapshots for volume [%s](%s)...", volume.getLabel(), volume.getId()));
    try {
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volume, _dbClient);
        CIMObjectPath cgPath = null;
        if (groupName != null) {
            cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
            if (cgPath == null) {
                _log.info("Replication Group {} not found. Skipping cleanup of group backup snapsots step.", groupName);
                return;
            }
        } else {
            _log.info(String.format("No Replication Group found for volume [%s](%s). Skipping cleanup of group backup snapsots step.", volume.getLabel(), volume.getId()));
            return;
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        CIMInstance cgPathInstance = _helper.checkExists(storage, cgPath, false, false);
        if (cgPathInstance != null) {
            settingsIterator = _helper.getAssociatorNames(storage, cgPath, null, SmisConstants.CLAR_SYNCHRONIZATION_ASPECT_FOR_SOURCE_GROUP, null, null);
            while (settingsIterator.hasNext()) {
                CIMObjectPath aspectPath = settingsIterator.next();
                CIMObjectPath settingsPath = _cimPath.getGroupSynchronizedSettingsPath(storage, groupName, (String) aspectPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue());
                CIMArgument[] deleteSettingsInput = _helper.getDeleteSettingsForSnapshotInputArguments(settingsPath, true);
                _helper.callModifySettingsDefineState(storage, deleteSettingsInput, outArgs);
            }
        }
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
    } finally {
        if (settingsIterator != null) {
            settingsIterator.close();
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 42 with CIMArgument

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

the class SmisStorageDevice method doRemoveFromConsistencyGroup.

@Override
public void doRemoveFromConsistencyGroup(StorageSystem storage, final URI consistencyGroupId, final List<URI> blockObjects, final TaskCompleter taskCompleter) throws DeviceControllerException {
    Set<String> groupNames = new HashSet<String>();
    String grpName = null;
    try {
        // get the group name from one of the block objects; we expect all of them to be the same group
        Iterator<URI> itr = blockObjects.iterator();
        while (itr.hasNext()) {
            BlockObject blockObject = BlockObject.fetch(_dbClient, itr.next());
            if (blockObject != null && !blockObject.getInactive() && !NullColumnValueGetter.isNullValue(blockObject.getReplicationGroupInstance())) {
                groupNames.add(blockObject.getReplicationGroupInstance());
            }
        }
        // Check if the replication group exists
        for (String groupName : groupNames) {
            grpName = groupName;
            storage = findProviderFactory.withGroup(storage, groupName).find();
            if (storage == null) {
                ServiceError error = DeviceControllerErrors.smis.noConsistencyGroupWithGivenName();
                taskCompleter.error(_dbClient, error);
                return;
            }
            String[] blockObjectNames = _helper.getBlockObjectAlternateNames(blockObjects);
            CIMObjectPath[] members = _cimPath.getVolumePaths(storage, blockObjectNames);
            CIMArgument[] output = new CIMArgument[5];
            BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
            if (!storage.deviceIsType(Type.vnxblock) && ControllerUtils.checkCGHasGroupRelationship(storage, consistencyGroupId, _dbClient)) {
                // remove from DeviceMaskingGroup
                CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, groupName, SmisConstants.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                _log.info("Removing volumes {} from device masking group {}", blockObjectNames, maskingGroupPath.toString());
                CIMArgument[] inArgs = _helper.getRemoveAndUnmapMaskingGroupMembersInputArguments(maskingGroupPath, members, storage, true);
                _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), SmisConstants.REMOVE_MEMBERS, inArgs, output, null);
            } else {
                CIMObjectPath cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
                CIMInstance cgPathInstance = _helper.checkExists(storage, cgPath, false, false);
                // If there is no replication group with the given name, return success
                if (cgPathInstance == null) {
                    _log.info(String.format("no replication group with name %s exists on storage system %s", groupName, storage.getLabel()));
                } else {
                    CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
                    CIMArgument[] removeMembersInput = _helper.getRemoveMembersInputArguments(cgPath, members);
                    _helper.invokeMethod(storage, replicationSvc, SmisConstants.REMOVE_MEMBERS, removeMembersInput, output);
                }
            }
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
        _log.error("Problem while removing volume from CG :{}", consistencyGroupId, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup((consistencyGroup == null ? "unknown cg" : consistencyGroup.getLabel()), (grpName == null ? "unknown replication group" : grpName), e.getMessage()));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) CIMArgument(javax.cim.CIMArgument)

Example 43 with CIMArgument

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

the class SmisStorageDevice method doCreateConsistencyGroup.

@Override
public void doCreateConsistencyGroup(final StorageSystem storage, final URI consistencyGroupId, String groupName, final TaskCompleter taskCompleter) throws DeviceControllerException {
    BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    try {
        CIMArgument[] inArgs;
        CIMArgument[] outArgs = new CIMArgument[5];
        boolean srdfCG = false;
        String deviceName = groupName;
        // create target CG on source provider
        StorageSystem forProvider = storage;
        if (consistencyGroup.getRequestedTypes().contains(Types.SRDF.name())) {
            srdfCG = true;
            if (NullColumnValueGetter.isNotNullValue(consistencyGroup.getAlternateLabel())) {
                forProvider = getSRDFSourceProvider(consistencyGroup);
                _log.debug("Creating target Consistency Group on source provider");
            }
        }
        if (forProvider.deviceIsType(Type.vnxblock) && !consistencyGroup.getArrayConsistency()) {
            // nothing need to be done on array side
            _log.info("No array operation needed for VNX replication group {}", groupName);
        } else {
            inArgs = _helper.getCreateReplicationGroupInputArguments(groupName);
            CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
            _helper.invokeMethod(forProvider, replicationSvc, SmisConstants.CREATE_GROUP, inArgs, outArgs);
            // Grab the generated name from the instance ID and store it in the db
            final String instanceID = (String) _cimPath.getCimObjectPathFromOutputArgs(outArgs, CP_REPLICATION_GROUP).getKey(CP_INSTANCE_ID).getValue();
            // VMAX instanceID, e.g., 000196700567+EMC_SMI_RG1414546375042 (8.0.2 provider)
            deviceName = instanceID.split(Constants.PATH_DELIMITER_REGEX)[storage.getUsingSmis80() ? 1 : 0];
        }
        consistencyGroup.addSystemConsistencyGroup(storage.getId().toString(), deviceName);
        if (srdfCG) {
            consistencyGroup.addConsistencyGroupTypes(Types.SRDF.name());
        } else {
            consistencyGroup.addConsistencyGroupTypes(Types.LOCAL.name());
        }
        if (!consistencyGroup.isProtectedCG() && NullColumnValueGetter.isNullURI(consistencyGroup.getStorageController())) {
            consistencyGroup.setStorageController(storage.getId());
        }
        _dbClient.updateObject(consistencyGroup);
        // This function could be called from doAddToConsistencyGroup() with a null taskCompleter.
        if (taskCompleter != null) {
            // Set task to ready.
            taskCompleter.ready(_dbClient);
        }
    } catch (Exception e) {
        _log.error("Failed to create consistency group: ", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doCreateConsistencyGroup", e.getMessage());
        // Set task to error
        if (taskCompleter != null) {
            taskCompleter.error(_dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) CIMArgument(javax.cim.CIMArgument) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 44 with CIMArgument

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

the class SmisStorageDevice method doAddStorageSystem.

@Override
public String doAddStorageSystem(final StorageSystem storage) throws DeviceControllerException {
    try {
        String system = "";
        CIMObjectPath seSystemRegistrationSvc = _helper.getRegistrationService(storage);
        CIMArgument[] inArgs = _helper.getAddStorageCIMArguments(storage);
        CIMArgument[] outArgs = new CIMArgument[5];
        Object result = _helper.invokeMethod(storage, seSystemRegistrationSvc, SmisConstants.EMC_ADD_SYSTEM, inArgs, outArgs);
        javax.cim.UnsignedInteger32 status = (javax.cim.UnsignedInteger32) result;
        if (status.intValue() == 0 && outArgs[0] != null) {
            outArgs[0].getName();
            CIMObjectPath objPath = (CIMObjectPath) outArgs[0].getValue();
            system = objPath.getKey(Constants._Name).getValue().toString();
        }
        return system;
    } catch (WBEMException ex) {
        _log.debug("Failed to add storage system to SMI-S Provider : " + ex.getMessage());
        throw new DeviceControllerException(ex);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 45 with CIMArgument

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

the class SmisStorageDevice method cleanupAnyBackupSnapshots.

/**
 * Method will make synchronous SMI-S calls to clean up any backup snapshots that may exist for
 * the volume. Typically, on VNX arrays, if there's a restore operation against an 'advanced'
 * snap, there will be backup snapshot created. There isn't any easy way to get to this backup
 * using the SMI-S API, so we'll have to clean them all up when we go to delete the volume.
 *
 * @param storage
 *            [required] - StorageSystem object
 * @param volume
 *            [required] - Volume object
 * @throws Exception
 */
private void cleanupAnyBackupSnapshots(final StorageSystem storage, final Volume volume) throws Exception {
    _log.info(String.format("cleanupAnyBackupSnapshots for volume [%s](%s)...", volume.getLabel(), volume.getId()));
    CIMObjectPath volumePath = _cimPath.getBlockObjectPath(storage, volume);
    if (_helper.checkExists(storage, volumePath, false, false) == null) {
        _log.info(String.format("cleanupAnyBackupSnapshots(%s, %s) -- volumePath does not exist, perhaps it has already been deleted?", storage.getSerialNumber(), volume.getLabel()));
        return;
    }
    CloseableIterator<CIMObjectPath> settingsIterator = null;
    try {
        settingsIterator = _helper.getReference(storage, volumePath, SmisConstants.CIM_SETTINGS_DEFINE_STATE, null);
        if (settingsIterator != null) {
            while (settingsIterator.hasNext()) {
                CIMObjectPath settingsPath = settingsIterator.next();
                CIMArgument[] outArgs = new CIMArgument[5];
                _helper.callModifySettingsDefineState(storage, _helper.getDeleteSettingsForSnapshotInputArguments(settingsPath, true), outArgs);
            }
        }
    } finally {
        if (settingsIterator != null) {
            settingsIterator.close();
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMArgument (javax.cim.CIMArgument)234 CIMObjectPath (javax.cim.CIMObjectPath)190 WBEMException (javax.wbem.WBEMException)129 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)127 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)80 ArrayList (java.util.ArrayList)74 CIMInstance (javax.cim.CIMInstance)71 Volume (com.emc.storageos.db.client.model.Volume)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 URI (java.net.URI)39 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)36 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)32 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)26 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)23 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 HashSet (java.util.HashSet)16 List (java.util.List)16 CIMProperty (javax.cim.CIMProperty)16