Search in sources :

Example 76 with CIMArgument

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

the class XIVSmisCommandHelper method getHidePathsInputArguments.

/**
 * Construct input arguments for hiding paths.
 */
public CIMArgument[] getHidePathsInputArguments(StorageSystem storage, URI exportMask, List<URI> volumeURIList, List<Initiator> initiatorList) throws Exception {
    List<CIMArgument> argsList = new ArrayList<CIMArgument>();
    String[] volumeNames = null;
    String[] initiatorPortIDs = null;
    if (volumeURIList != null && !volumeURIList.isEmpty()) {
        volumeNames = getBlockObjectAlternateNames(volumeURIList);
        argsList.add(_cimArgument.stringArray(CP_LU_NAMES, volumeNames));
    }
    if (initiatorList != null && !initiatorList.isEmpty()) {
        initiatorPortIDs = getInitiatorNames(initiatorList);
        argsList.add(_cimArgument.stringArray(CP_INITIATOR_PORT_IDS, initiatorPortIDs));
    }
    CIMObjectPath protocolController = _cimPath.getSCSIProtocolControllerPath(storage, getExportMaskNativeId(exportMask));
    if (protocolController != null) {
        argsList.add(_cimArgument.referenceArray(CP_PROTOCOL_CONTROLLERS, new CIMObjectPath[] { protocolController }));
    }
    return argsList.toArray(new CIMArgument[argsList.size()]);
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 77 with CIMArgument

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

the class XIVSmisCommandHelper method getHidePathsInputArguments.

/**
 * Construct input arguments for hiding paths.
 */
public CIMArgument[] getHidePathsInputArguments(StorageSystem storage, ExportMask exportMask, String[] volumeNames, String[] initiatorPortIDs) throws Exception {
    List<CIMArgument> argsList = new ArrayList<CIMArgument>();
    if (volumeNames != null && volumeNames.length > 0) {
        argsList.add(_cimArgument.stringArray(CP_LU_NAMES, volumeNames));
    }
    if (initiatorPortIDs != null && initiatorPortIDs.length > 0) {
        argsList.add(_cimArgument.stringArray(CP_INITIATOR_PORT_IDS, initiatorPortIDs));
    }
    CIMObjectPath protocolController = _cimPath.getSCSIProtocolControllerPath(storage, exportMask.getNativeId());
    if (protocolController != null) {
        argsList.add(_cimArgument.referenceArray(CP_PROTOCOL_CONTROLLERS, new CIMObjectPath[] { protocolController }));
    }
    return argsList.toArray(new CIMArgument[argsList.size()]);
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 78 with CIMArgument

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

the class XIVSmisStorageDevice method addVolumesToCG.

private synchronized void addVolumesToCG(StorageSystem storageSystem, URI consistencyGroupId, List<URI> volumeURIs) throws Exception {
    BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    if (null != consistencyGroup) {
        String groupName = _helper.getConsistencyGroupName(consistencyGroup, storageSystem);
        if (groupName.equals(EMPTY_CG_NAME)) {
            // may also check if CG instance exists on array, or not, if not, re-create it here need to create CG group
            // here with member volumes this will ensure the new CG is associated to right pool without member volumes,
            // there is no way to control which pool the CG will be associated to
            CIMArgument[] inArgs = _helper.getCreateReplicationGroupInputArguments(storageSystem, consistencyGroup.getLabel(), volumeURIs);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callReplicationSvc(storageSystem, SmisConstants.CREATE_GROUP, inArgs, outArgs);
            // grab the CG name from the instance ID and store it in the db
            final CIMObjectPath cgPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.CP_REPLICATION_GROUP);
            final String deviceName = _helper.getReplicationGroupName(cgPath);
            // the order of adding and removing system consistency group makes different somehow, removing before adding won't work
            consistencyGroup.addSystemConsistencyGroup(storageSystem.getId().toString(), deviceName);
            consistencyGroup.removeSystemConsistencyGroup(storageSystem.getId().toString(), EMPTY_CG_NAME);
            _dbClient.updateObject(consistencyGroup);
        } else {
            // existing CG, add volumes to the CG
            CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storageSystem, groupName);
            CIMInstance cgPathInstance = _helper.checkExists(storageSystem, cgPath, false, false);
            // if there is no consistency group with the given name, set the operation to error
            if (cgPathInstance == null) {
                throw DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storageSystem.getId()));
            }
            _helper.addVolumesToConsistencyGroup(storageSystem, new ArrayList<URI>(volumeURIs), cgPath);
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) CIMArgument(javax.cim.CIMArgument)

Example 79 with CIMArgument

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

the class XIVSmisStorageDevice 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(final StorageSystem storageSystem, final StoragePool pool, final Volume volume, final Long size, final TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storageSystem.getLabel(), pool.getNativeId(), volume.getLabel(), size));
    try {
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = _helper.getExpandVolumeInputArguments(storageSystem, volume, size);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.CREATE_OR_MODIFY_ELEMENT_FROM_STORAGE_POOL, inArgs, outArgs);
        _smisStorageDevicePostProcessor.processVolumeExpansion(storageSystem, pool.getId(), volume.getId(), outArgs);
        taskCompleter.ready(_dbClient);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (Exception e) {
        _log.error("Problem in doExpandVolume: ", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doExpandVolume", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info(String.format("Expand Volume End - Array: %s, Pool: %s, Volume: %s", storageSystem.getLabel(), pool.getNativeId(), volume.getLabel()));
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) 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 80 with CIMArgument

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

the class XIVSmisStorageDevice method removeVolumesFromCG.

private void removeVolumesFromCG(StorageSystem storage, BlockConsistencyGroup cg, CIMObjectPath cgPath, String[] blockObjectIds) throws Exception {
    CIMObjectPath[] volumePaths = _cimPath.getVolumePaths(storage, blockObjectIds);
    @SuppressWarnings("rawtypes") CIMArgument[] inArgs = null;
    // get all the snapshot groups
    CIMObjectPath[] syncObjectPaths = _helper.getGroupSyncObjectPaths(storage, cgPath);
    if (syncObjectPaths.length > 0) {
        if (isForceSnapshotGroupRemoval) {
            inArgs = _helper.getDeleteListSynchronizationInputArguments(storage, syncObjectPaths);
            // delete snapshot groups
            _helper.callReplicationSvc(storage, IBMSmisConstants.MODIFY_LIST_SYNCHRONIZATION, inArgs, new CIMArgument[5]);
        } else {
            String instanceId = (String) cgPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
            String cgName = _helper.getReplicationGroupName(cgPath);
            throw DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(cgName, instanceId, "Consistency group has snapshot(s)");
        }
    }
    inArgs = _helper.getRemoveMembersInputArguments(cgPath, volumePaths);
    Exception removeMembersException = null;
    try {
        // remove from consistency group
        _helper.callReplicationSvc(storage, SmisConstants.REMOVE_MEMBERS, inArgs, new CIMArgument[5]);
    } catch (Exception e) {
        _log.info("Exception on removeVolumesFromConsistencyGroup: " + e.getMessage());
        removeMembersException = e;
    }
    Set<String> volumeSet = new HashSet<String>(Arrays.asList(blockObjectIds));
    Set<String> members = null;
    try {
        members = _helper.getCGMembers(storage, cgPath, volumeSet);
    } catch (Exception e) {
        _log.info("Exception on getCGMembers: " + e.getMessage());
        if (removeMembersException != null) {
            throw removeMembersException;
        } else {
            throw e;
        }
    }
    String groupName = _helper.getConsistencyGroupName(cg, storage);
    boolean cgExists = true;
    if (members == null) {
        // no CG member on array side, it should have already been deleted
        cgExists = false;
    } else if (members.isEmpty()) {
        // this shouldn't happen, delete CG
        _log.info("Delete CG " + groupName);
        inArgs = _helper.getDeleteReplicationGroupInputArguments(storage, cgPath);
        _helper.callReplicationSvc(storage, IBMSmisConstants.DELETE_GROUP, inArgs, new CIMArgument[5]);
        cgExists = false;
    }
    if (!cgExists) {
        // now remove array association of the CG in ViPR
        // the intention is that the CG can be re-used, and not restricted by previous pool
        _log.info("CG is empty on array. Remove array association from the CG");
        cg.removeSystemConsistencyGroup(storage.getId().toString(), groupName);
        // clear the LOCAL type
        StringSet types = cg.getTypes();
        if (types != null) {
            types.remove(Types.LOCAL.name());
            cg.setTypes(types);
        }
        _dbClient.persistObject(cg);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) 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) HashSet(java.util.HashSet)

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