Search in sources :

Example 66 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 67 with CIMArgument

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

the class MetaVolumeMembersProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
        if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
            _logger.info(String.format("There are no meta members to process"));
        } else {
            _logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
            // Get volume from db
            _logger.debug(String.format("Args size: %s", _args.size()));
            Object[] arguments = (Object[]) _args.get(0);
            CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
            _logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
            CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(theElementPath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
                _logger.debug("Volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            Integer membersCount = metaMembersPaths.length;
            // get meta member size. use second member --- the first member will show size of meta volume itself.
            CIMObjectPath metaMemberPath = metaMembersPaths[1];
            CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
            CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate size = consumableBlocks * block size
            Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
            // set meta member count and meta members size for meta volume (required for volume expansion)
            if (null != preExistingVolume) {
                StringSet metaMembersCount = new StringSet();
                metaMembersCount.add(membersCount.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
                StringSet metaMemberSize = new StringSet();
                metaMemberSize.add(size.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
                // persist unmanaged volume in db
                dbClient.persistObject(preExistingVolume);
            } else {
                storageVolume.setMetaMemberCount(membersCount);
                storageVolume.setMetaMemberSize(size);
                storageVolume.setTotalMetaMemberCapacity(membersCount * size);
                // persist volume in db
                dbClient.persistObject(storageVolume);
            }
            _logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume  information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) CIMArgument(javax.cim.CIMArgument)

Example 68 with CIMArgument

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

the class FEPortStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
    try {
        CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_FEPORT_MANIFEST);
        String[] feportsMetricValues = ((String[]) outputArguments[0].getValue())[0].split("\n");
        List<StoragePort> systemPorts = ControllerUtils.getSystemPortsOfSystem(dbClient, profile.getSystemId());
        _logger.debug("FEPort metricNames Sequence {}", metricSequence);
        // process the results.
        if (null != metricSequence && !metricSequence.isEmpty()) {
            // Step2: For each feport metric record
            for (String fePortMetricValue : feportsMetricValues) {
                if (fePortMetricValue.isEmpty()) {
                    _logger.debug("Empty FEPort stats returned as part of Statistics Response");
                    continue;
                }
                String[] metrics = fePortMetricValue.split(Constants.SEMI_COLON);
                // Step 3: For each port in db for a given system.
                for (StoragePort port : systemPorts) {
                    // Step 4: if port in db is null just continue.
                    if (null == port) {
                        continue;
                    } else if (!port.getInactive() && metrics[0].endsWith(port.getPortName())) {
                        // Step 5: Check whether provider returned port
                        // exists in db or not. if port exists in db,
                        // then create a PortStat object for it.
                        _logger.debug("found FEPort in db for {}", port.getPortName());
                        createPortStatMetric(metricSequence, port, keyMap, metricsObjList, metrics);
                    }
                }
            }
            // 
            // compute port metric to trigger if any port allocation qualification changed. If there is
            // changes, run vpool matcher
            // 
            portMetricsProcessor.triggerVpoolMatcherIfPortAllocationQualificationChanged(profile.getSystemId(), systemPorts);
            // 
            // compute storage system's average of port metrics. Then, persist it into storage system object.
            // 
            portMetricsProcessor.computeStorageSystemAvgPortMetrics(profile.getSystemId());
            // Compute port group's port metrics for vmax only
            portMetricsProcessor.computePortGroupMetrics(profile.getSystemId());
        } else {
            _logger.error("failed processing FEPOrt Metric values as metric sequence is null.");
        }
    } catch (Exception e) {
        _logger.error("Failed while extracting stats for FEPorts: ", e);
    }
    resultObj = null;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) Stat(com.emc.storageos.db.client.model.Stat) List(java.util.List) CIMArgument(javax.cim.CIMArgument)

Example 69 with CIMArgument

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

the class XIVSnapshotOperations method createGroupSnapshots.

/**
 * Should implement create of a snapshot from a source volume that is part
 * of a consistency group.
 *
 * @param storage
 *            [required] - StorageSystem object representing the array
 * @param taskCompleter
 *            - TaskCompleter object used for the updating operation status.
 * @param snapshot
 *            [required] - BlockSnapshot URI representing the previously
 *            created snap for the volume
 * @throws DeviceControllerException
 */
@SuppressWarnings("rawtypes")
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        URI snapshot = snapshotList.get(0);
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getSnapsetLabel(), snapshot.toString(), '-', IBMSmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        // check if the snapshot group name is used on array, return if the name is used to avoid unnecessary CIM call
        // snapshot group name has to be unique on array
        CIMObjectPath sgPath = _cimPath.getSnapshotGroupPath(storage, snapLabelToUse);
        if (sgPath != null) {
            _log.error("Failed to create group snapshots: " + IBMSmisConstants.DUPLICATED_SG_NAME_ERROR);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupSnapshots", IBMSmisConstants.DUPLICATED_SG_NAME_ERROR);
            taskCompleter.error(_dbClient, error);
            setInactive(snapshotList, true);
            return;
        }
        String groupName = _helper.getConsistencyGroupName(snapshotObj, storage);
        CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storage, groupName);
        CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArguments(storage, cgPath, createInactive, snapLabelToUse);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callReplicationSvc(storage, IBMSmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
        _smisStorageDevicePostProcessor.processCGSnapshotCreation(storage, snapshotList, !createInactive, snapLabelToUse, (BlockSnapshotCreateCompleter) taskCompleter);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
        setInactive(snapshotList, true);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 70 with CIMArgument

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

the class XIVCloneOperations method createSingleClone.

@SuppressWarnings("rawtypes")
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceVolume, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
    _log.info("START createSingleClone operation");
    SmisException serviceCode = null;
    CIMArgument[] outArgs = new CIMArgument[5];
    try {
        BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceVolume);
        URI tenantUri = null;
        if (sourceObj instanceof BlockSnapshot) {
            // In case of snapshot, get the tenant from its parent volume
            NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
            Volume parentVolume = _dbClient.queryObject(Volume.class, parentVolUri);
            tenantUri = parentVolume.getTenant().getURI();
        } else {
            tenantUri = ((Volume) sourceObj).getTenant().getURI();
        }
        Volume cloneObj = _dbClient.queryObject(Volume.class, cloneVolume);
        StoragePool targetPool = _dbClient.queryObject(StoragePool.class, cloneObj.getPool());
        TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, tenantUri);
        String cloneLabel = _nameGenerator.generate(tenantOrg.getLabel(), cloneObj.getLabel(), cloneObj.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
        CIMObjectPath sourceVolumePath = _cimPath.getBlockObjectPath(storageSystem, sourceObj);
        CIMArgument[] inArgs = _helper.getCloneInputArguments(cloneLabel, sourceVolumePath, storageSystem, targetPool, createInactive);
        _helper.callReplicationSvc(storageSystem, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolume, cloneVolume);
        _log.error(errorMsg, e);
        serviceCode = DeviceControllerExceptions.smis.createFullCopyFailure(errorMsg, e);
    } finally {
        try {
            // update clone and pool
            // clone will be set to inactive if no return from provider
            _smisStorageDevicePostProcessor.processCloneCreation(storageSystem, cloneVolume, outArgs, (CloneCreateCompleter) taskCompleter);
        } catch (Exception e) {
            String errorMsg = "Exception on creating clone of " + sourceVolume;
            _log.error(errorMsg, e);
            // set serviceCode only if no previous exception
            if (serviceCode == null) {
                serviceCode = DeviceControllerExceptions.smis.createFullCopyFailure(errorMsg, e);
            }
        }
        if (serviceCode != null) {
            taskCompleter.error(_dbClient, serviceCode);
            throw serviceCode;
        }
    }
}
Also used : SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) BlockObject(com.emc.storageos.db.client.model.BlockObject) 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