Search in sources :

Example 31 with CIMArgument

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

the class VnxExportOperations method deleteStorageHWIDs.

/**
 * Method invokes the SMI-S operation to remove the initiator hardware ID from the
 * array. This should be called whenever the initiator is removed from an export or
 * when the export is deleted.
 *
 * @param storage
 *            [in] - StorageSystem representing the array
 * @param initiators
 *            [in] - An array Initiator objects, whose representation will
 *            be removed from the array.
 * @throws Exception
 */
private void deleteStorageHWIDs(StorageSystem storage, List<Initiator> initiators) throws Exception {
    if (initiators == null || initiators.isEmpty()) {
        _log.debug("No initiators ...");
        return;
    }
    CIMObjectPath hwIdManagementSvc = _cimPath.getStorageHardwareIDManagementService(storage);
    for (Initiator initiator : initiators) {
        try {
            CIMArgument[] createHwIdIn = _helper.getDeleteStorageHardwareIDArgs(storage, initiator);
            CIMArgument[] createHwIdOut = new CIMArgument[5];
            _helper.invokeMethod(storage, hwIdManagementSvc, SmisConstants.DELETE_STORAGE_HARDWARE_ID, createHwIdIn, createHwIdOut);
        } catch (WBEMException e) {
            _log.error("deleteStorageHWIDs -- WBEMException: " + e.getMessage());
            throw e;
        } catch (Exception e) {
            _log.error("deleteStorageHWIDs -- Exception: " + e.getMessage());
            throw e;
        }
    }
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) CIMArgument(javax.cim.CIMArgument)

Example 32 with CIMArgument

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

the class VnxExportOperations method getEMCTargetEndpoints.

/**
 * Looks up the targets that are associated with the initiator (if any).
 *
 * @param idMgmtSvcPath
 *            [in] - Clar_StorageHardwareIDManagementService CIMObjectPath
 * @param storage
 *            [in] - StorageSystem object representing the array
 * @param initiator
 *            [in] - CIMObjectPath representing initiator to lookup target endpoints (StoragePorts) for
 * @return List or StoragePort URIs that were found to be end points for the initiator
 * @throws Exception
 */
private List<String> getEMCTargetEndpoints(CIMObjectPath idMgmtSvcPath, StorageSystem storage, CIMObjectPath initiator) throws Exception {
    List<String> endpoints = new ArrayList<>();
    try {
        CIMArgument[] input = _helper.getEMCGetConnectedTargetEndpoints(initiator);
        CIMArgument[] output = new CIMArgument[5];
        _helper.invokeMethod(storage, idMgmtSvcPath, SmisConstants.EMC_GET_TARGET_ENDPOINTS, input, output);
        CIMObjectPath[] tePaths = (CIMObjectPath[]) _cimPath.getFromOutputArgs(output, SmisConstants.CP_TARGET_ENDPOINTS);
        if (tePaths != null) {
            for (CIMObjectPath tePath : tePaths) {
                CIMInstance teInstance = _helper.getInstance(storage, tePath, false, false, SmisConstants.PS_NAME);
                String tePortNetworkId = CIMPropertyFactory.getPropertyValue(teInstance, SmisConstants.CP_NAME);
                List<StoragePort> storagePorts = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StoragePort.class, "portNetworkId", WWNUtility.getWWNWithColons(tePortNetworkId));
                for (StoragePort port : storagePorts) {
                    endpoints.add(port.getNativeGuid());
                }
            }
        }
        _log.info(String.format("Initiator %s has these target endpoints: [ %s ]", initiator.toString(), Joiner.on(',').join(endpoints)));
    } catch (WBEMException e) {
        // The initiator CIMObjectPath passed into this function was determined by getting
        // the associators to the StorageHardwareIDManagementService. When we call
        // getEMCTargetEndpoints, it is done based on seeing that the initiator is in this
        // associator list. Sometimes, the provider is returing initiator CIMObjectPaths
        // that actually do not exist on the array. In this case, there will be WBEMException
        // thrown when we try to get the targets storage ports using this CIMObject reference.
        // So, here we're trying to protect against this possibility.
        _log.info(String.format("Could not get TargetEndPoints for %s - %s", initiator, e.getMessage()));
    }
    return endpoints;
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) StoragePort(com.emc.storageos.db.client.model.StoragePort) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) CIMArgument(javax.cim.CIMArgument)

Example 33 with CIMArgument

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

the class VnxMirrorOperations method createGroupMirrors.

/**
 * Should implement create of a mirror 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 clones. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group clone operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param mirrorList [required] - mirror URI list
 * @param createInactive whether the mirror needs to to be created with sync_active=true/false
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createGroupMirrors operation START");
    List<BlockMirror> mirrors = null;
    List<String> targetDeviceIds = null;
    try {
        mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        BlockMirror firstMirror = mirrors.get(0);
        Volume sourceVolume = _dbClient.queryObject(Volume.class, firstMirror.getSource());
        String sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVolume, _dbClient);
        if (!ControllerUtils.isNotInRealVNXRG(sourceVolume, _dbClient)) {
            // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
            ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        }
        List<String> sourceIds = new ArrayList<String>();
        targetDeviceIds = new ArrayList<String>();
        Map<String, String> tgtToSrcMap = new HashMap<String, String>();
        for (BlockMirror mirror : mirrors) {
            final URI poolId = mirror.getPool();
            final Volume source = _dbClient.queryObject(Volume.class, mirror.getSource());
            sourceIds.add(source.getNativeId());
            // Create target devices
            final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, mirror.getLabel(), createInactive, 1, poolId, mirror.getCapacity(), source.getThinlyProvisioned(), null, taskCompleter, _dbClient, _helper, _cimPath);
            targetDeviceIds.addAll(newDeviceIds);
            tgtToSrcMap.put(newDeviceIds.get(0), source.getNativeId());
        }
        CIMObjectPath[] targetDevicePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
        CIMObjectPath[] sourceDevicePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
        // Create list replica
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceDevicePaths, targetDevicePaths);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGMirrorJob(job, storage.getId(), tgtToSrcMap, taskCompleter)));
        for (BlockMirror mirror : mirrors) {
            mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
        }
        _dbClient.persistObject(mirrors);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        // Roll back changes
        ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
        if (mirrors != null && !mirrors.isEmpty()) {
            for (BlockMirror mirror : mirrors) {
                mirror.setInactive(true);
            }
        }
        _dbClient.persistObject(mirrors);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupMirrors", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("createGroupMirrors operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) SmisVnxCreateCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGMirrorJob) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 34 with CIMArgument

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

the class VnxSnapshotOperations method internalGroupSnapCopyToTarget.

/**
 * Internal function to call SMI-S to run Copy-to-Target for CG snapshot
 *
 * @param storage [in] - StorageSystem object
 * @param snapshot [in] - BlockSnapshot object. One of the snaps in the CG
 * @param snapshotList [in] - List of BlockSnapshot URIs. These are all the snaps in
 *            CG snap set.
 * @throws Exception
 */
private void internalGroupSnapCopyToTarget(StorageSystem storage, BlockSnapshot snapshot, List<URI> snapshotList) throws Exception {
    String snapGroupName = snapshot.getReplicationGroupInstance();
    CIMObjectPath targetGroup = _cimPath.getReplicationGroupPath(storage, snapGroupName);
    CIMObjectPath settingsState = _helper.getSettingsDefineStateForSourceGroup(storage, snapshot.getSettingsGroupInstance());
    CIMArgument[] inArgs = _helper.getVNXCopyToTargetGroupInputArguments(settingsState, targetGroup);
    CIMArgument[] outArgs = new CIMArgument[5];
    _helper.callModifySettingsDefineState(storage, inArgs, outArgs);
    List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, snapshotList);
    for (BlockSnapshot it : snapshots) {
        it.setNeedsCopyToTarget(false);
    }
    _dbClient.persistObject(snapshots);
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMArgument(javax.cim.CIMArgument)

Example 35 with CIMArgument

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

the class VnxSnapshotOperations method deleteSingleVolumeSnapshot.

/**
 * Should implement deletion of single volume snapshot. That is, deleting a snap that was
 * created independent of other volumes.
 *
 * @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 deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snap);
        if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storage, _helper.getDeleteSnapshotSynchronousInputArguments(syncObjectPath), outArgs);
            snap.setInactive(true);
            snap.setIsSyncActive(false);
            _dbClient.updateObject(snap);
            taskCompleter.ready(_dbClient);
        } else {
            // Perhaps, it's already been deleted or was deleted on the array.
            // In that case, we'll just say all is well, so that this operation
            // is idempotent.
            snap.setInactive(true);
            snap.setIsSyncActive(false);
            _dbClient.updateObject(snap);
            taskCompleter.ready(_dbClient);
        }
    } catch (WBEMException e) {
        String message = String.format("Error encountered during delete snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (Exception e) {
        String message = String.format("Generic exception when trying to delete snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("deleteSingleVolumeSnapshot", 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) WBEMException(javax.wbem.WBEMException) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) 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