Search in sources :

Example 1 with SmisJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisJob in project coprhd-controller by CoprHD.

the class SmisStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    Long thinVolumePreAllocationSize = null;
    CIMInstance poolSetting = null;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volumes.get(0));
    // volumeGroupObjectPath is required for VMAX3
    CIMObjectPath volumeGroupObjectPath = _helper.getVolumeGroupPath(forProvider, storageSystem, volumes.get(0), storagePool);
    List<String> volumeLabels = new ArrayList<>();
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
        String tenantName = "";
        try {
            TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
            tenantName = tenant.getLabel();
        } catch (DatabaseException e) {
            _log.error("Error lookup TenantOrb object", e);
        }
        label = _nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
        volumeLabels.add(label);
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
        if (thinVolumePreAllocationSize == null && volume.getThinVolumePreAllocationSize() > 0) {
            thinVolumePreAllocationSize = volume.getThinVolumePreAllocationSize();
        }
    }
    _log.info(logMsgBuilder.toString());
    boolean isThinlyProvisioned = volumes.get(0).getThinlyProvisioned();
    try {
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = null;
        // I didn't find any ways to add this branching logic based on device Types.
        if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
            String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volumes.get(0).getId(), _dbClient);
            if (autoTierPolicyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            }
            inArgs = _helper.getCreateVolumesInputArgumentsOnFastEnabledPool(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, autoTierPolicyName);
        } else {
            if (!storageSystem.checkIfVmax3() && isThinlyProvisioned && null != thinVolumePreAllocationSize) {
                poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, thinVolumePreAllocationSize);
            }
            if (storageSystem.checkIfVmax3()) {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, true, volumeGroupObjectPath, (null != thinVolumePreAllocationSize));
            } else {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, poolSetting, true);
            }
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(forProvider, configSvcPath, _helper.createVolumesMethodName(forProvider), inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            SmisJob createSmisJob = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(job, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter) : new SmisCreateVolumeJob(job, forProvider.getId(), storagePool.getId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createSmisJob));
        }
    } catch (final InternalException e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(_dbClient, e);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.updateObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) 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) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) SmisCreateVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateVolumeJob) Volume(com.emc.storageos.db.client.model.Volume) SmisCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 2 with SmisJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisJob in project coprhd-controller by CoprHD.

the class SmisCommandHelper method waitForAsyncSmisJob.

private void waitForAsyncSmisJob(StorageSystem storageDevice, CIMObjectPath cimJobPath, SmisJob job) throws SmisException {
    if (job == null) {
        TaskCompleter taskCompleter = new TaskCompleter() {

            @Override
            public void ready(DbClient dbClient) throws DeviceControllerException {
            }

            @Override
            public void error(DbClient dbClient, ServiceCoded serviceCoded) throws DeviceControllerException {
            }

            @Override
            protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
            }
        };
        job = new SmisJob(cimJobPath, storageDevice.getId(), taskCompleter, "");
    } else {
        job.setCimJob(cimJobPath);
    }
    JobContext jobContext = new JobContext(_dbClient, _cimConnection, null, null, null, null, this);
    long startTime = System.currentTimeMillis();
    int sync_wrapper_time_out = InvokeTestFailure.internalOnlyOverrideSyncWrapperTimeOut(SYNC_WRAPPER_TIME_OUT);
    while (true) {
        JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
        if (!result.isJobInTerminalState()) {
            if (System.currentTimeMillis() - startTime > sync_wrapper_time_out) {
                throw new SmisException("Timed out waiting on smis job to complete after " + (System.currentTimeMillis() - startTime) + " milliseconds");
            } else {
                try {
                    Thread.sleep(SYNC_WRAPPER_WAIT);
                } catch (InterruptedException e) {
                    _log.error("Thread waiting for smis job to complete was interrupted and " + "will be resumed");
                }
            }
        } else {
            if (result.isJobInTerminalFailedState()) {
                throw new SmisException("Smis job failed: " + result.getErrorDescription());
            }
            break;
        }
    }
}
Also used : LinkStatus(com.emc.storageos.db.client.model.Volume.LinkStatus) DbClient(com.emc.storageos.db.client.DbClient) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) JobContext(com.emc.storageos.volumecontroller.JobContext) JobPollResult(com.emc.storageos.volumecontroller.impl.JobPollResult) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 3 with SmisJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method addVolumesToParkingStorageGroup.

/**
 * This method is used for VMAX3 to add volumes to parking storage group
 * once volumes are unexported.
 * For volumes which are still part of another export and if they already
 * belong to FAST managed storage group, they won't be added to parking storage group.
 *
 * @param storage
 * @param policyName
 * @param volumeDeviceIds
 * @throws Exception
 */
private void addVolumesToParkingStorageGroup(StorageSystem storage, String policyName, Set<String> volumeDeviceIds) throws Exception {
    // Don't add volumes to parking SLO which are already part of a FAST managed storage group
    volumeDeviceIds = _helper.filterVolumesPartOfAnyFASTStorageGroup(storage, volumeDeviceIds);
    if (!volumeDeviceIds.isEmpty() && !Constants.NONE.equalsIgnoreCase(policyName)) {
        String[] tokens = policyName.split(Constants.SMIS_PLUS_REGEX);
        CIMObjectPath groupPath = _helper.getVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        if (groupPath == null) {
            groupPath = _helper.createVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        }
        CIMArgument[] inArgs = _helper.getAddVolumesToMaskingGroupInputArguments(storage, groupPath, volumeDeviceIds);
        CIMArgument[] outArgs = new CIMArgument[5];
        SmisJob addVolumesToSGJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.ADD_MEMBERS);
        _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "AddMembers", inArgs, outArgs, addVolumesToSGJob);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) CIMArgument(javax.cim.CIMArgument)

Example 4 with SmisJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method deleteInitiatorGroup.

/**
 * Function will delete the IG specified by the CIMObjectPath from the array.
 *
 * @param storage
 *            [in] - StorageSystem object
 * @param igPath
 *            [in] - CIMObjectPath object to be query
 * @throws WBEMException
 * @throws Exception
 */
private boolean deleteInitiatorGroup(StorageSystem storage, CIMObjectPath igPath) throws Exception {
    CIMArgument[] deleteIn = _helper.getDeleteInitiatorMaskingGroup(storage, igPath);
    CIMArgument[] deleteOut = new CIMArgument[5];
    SmisJob deleteIgJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.DELETE_GROUP);
    _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), SmisConstants.DELETE_GROUP, deleteIn, deleteOut, deleteIgJob);
    return deleteIgJob.isSuccess();
}
Also used : SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) CIMArgument(javax.cim.CIMArgument)

Example 5 with SmisJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisJob in project coprhd-controller by CoprHD.

the class SmisCommandHelper method setRecoverPointTagInternal.

/**
 * Method will add or remove the EMCRecoverPointEnabled flag from the device masking group for
 * VMAX.
 *
 * @param deviceGroupPath
 *            [in] - CIMObjectPath referencing the volume
 */
private boolean setRecoverPointTagInternal(StorageSystem storage, List<CIMObjectPath> volumeMemberList, boolean tag) throws Exception {
    boolean tagSet = false;
    try {
        _log.info("Attempting to {} RecoverPoint tag on Volume: {}", tag ? "enable" : "disable", Joiner.on(",").join(volumeMemberList));
        CimConnection connection = _cimConnection.getConnection(storage);
        WBEMClient client = connection.getCimClient();
        if (storage.getUsingSmis80()) {
            CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storage);
            CIMArgument[] inArgs = getRecoverPointInputArguments(storage, volumeMemberList, tag);
            CIMArgument[] outArgs = new CIMArgument[5];
            SmisJob job = null;
            invokeMethodSynchronously(storage, configSvcPath, EMC_SETUNSET_RECOVERPOINT, inArgs, outArgs, job);
        } else {
            for (CIMObjectPath volumeMember : volumeMemberList) {
                CIMInstance toUpdate = new CIMInstance(volumeMember, new CIMProperty[] { _cimProperty.bool(EMC_RECOVERPOINT_ENABLED, tag) });
                _log.debug("Params: " + toUpdate.toString());
                client.modifyInstance(toUpdate, CP_EMC_RECOVERPOINT_ENABLED);
            }
        }
        _log.info(String.format("RecoverPoint tag has been successfully %s Volume", tag ? "applied to" : "removed from"));
        tagSet = true;
    } catch (WBEMException e) {
        if (e.getMessage().contains("is already set to the requested state")) {
            _log.info("Found the volume was already in the proper RecoverPoint tag state");
            tagSet = true;
        } else {
            _log.error(String.format("Encountered an error while trying to %s the RecoverPoint tag", tag ? "enable" : "disable"), e);
        }
    }
    return tagSet;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) CIMArgument(javax.cim.CIMArgument)

Aggregations

SmisJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisJob)10 CIMArgument (javax.cim.CIMArgument)8 CIMObjectPath (javax.cim.CIMObjectPath)8 WBEMException (javax.wbem.WBEMException)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 CIMInstance (javax.cim.CIMInstance)4 SmisSynchSubTaskJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob)3 SmisCreateMetaVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMetaVolumeJob)2 SmisVolumeExpandJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisVolumeExpandJob)2 ArrayList (java.util.ArrayList)2 WBEMClient (javax.wbem.client.WBEMClient)2 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)1 DbClient (com.emc.storageos.db.client.DbClient)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1