Search in sources :

Example 11 with CIMConnectionFactory

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

the class SmisCreateCGCloneJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMInstance> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            CIMObjectPath replicationGroupPath = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null).next();
            String replicationGroupID = (String) replicationGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
            // VMAX instanceID, e.g., 000196700567+EMC_SMI_RG1414546375042 (8.0.2 provider)
            final String replicationGroupInstance = replicationGroupID.split(Constants.PATH_DELIMITER_REGEX)[storage.getUsingSmis80() ? 1 : 0];
            syncVolumeIter = client.associatorInstances(replicationGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            processCGClones(syncVolumeIter, client, dbClient, clones, replicationGroupInstance, isSyncActive);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create clone");
            for (Volume clone : clones) {
                clone.setInactive(true);
            }
            dbClient.persistObject(clones);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create CG clone job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateCGCloneJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) Volume(com.emc.storageos.db.client.model.Volume) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with CIMConnectionFactory

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

the class SmisCreateMaskingViewJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    _log.info("Updating status of SmisCreateMaskingViewJob");
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            List<CIMObjectPath> maskingViews = new ArrayList<CIMObjectPath>();
            iterator = client.associatorNames(getCimJob(), null, SYMM_LUNMASKINGVIEW, null, null);
            while (iterator.hasNext()) {
                CIMObjectPath cimObjectPath = iterator.next();
                maskingViews.add(cimObjectPath);
                ExportMask mask = dbClient.queryObject(ExportMask.class, _exportMaskURI);
                // necessary for future reference to the MV.
                if (mask != null) {
                    String deviceId = cimObjectPath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                    mask.setNativeId(deviceId);
                    dbClient.persistObject(mask);
                    ExportOperationContext.insertContextOperation(getTaskCompleter(), VmaxExportOperationContext.OPERATION_CREATE_MASKING_VIEW, mask.getMaskName());
                }
            }
            // Now perform RP protection tagging, if required, on the storage group
            if (storageSystem.getUsingSmis80()) {
                _log.info("Set RP tag on all volumes within SG for 8.0.3 Providers");
                enableRecoverPointTagOn803(dbClient, client, storageSystem, jobContext);
            } else {
                _log.info("Set RP tag on SG for 4.6.2 Providers");
                enableRecoverPointTag(dbClient, client, _deviceGroupMaskingPath);
            }
            // Now set the HLU on the volume URIs, if they haven't been set by user.
            ExportMaskOperationsHelper.setHLUFromProtocolControllers(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, maskingViews, getTaskCompleter());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisCreateMaskingViewJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during masking view create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 13 with CIMConnectionFactory

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

the class SmisCreateVmaxCGTargetVolumesJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            _deviceIds = new ArrayList<String>();
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            while (iterator.hasNext()) {
                CIMObjectPath volumePath = iterator.next();
                CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
                String nativeID = deviceID.getValue();
                if (nativeID == null || nativeID.isEmpty()) {
                    throw new IllegalStateException("Could not determine volume native ID from the SMI-S provider");
                }
                _deviceIds.add(nativeID);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create volume: {}", getTaskCompleter().getId());
        }
    } catch (Exception e) {
        setPostProcessingFailedStatus(e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateVmaxCGTargetVolumesJob", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("updateStatus", e.getMessage());
        getTaskCompleter().error(dbClient, error);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMProperty(javax.cim.CIMProperty) WBEMClient(javax.wbem.client.WBEMClient)

Example 14 with CIMConnectionFactory

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

the class SmisVnxCreateCGMirrorJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMInstance> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockMirrorCreateCompleter completer = (BlockMirrorCreateCompleter) getTaskCompleter();
        List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            updatePools(client, dbClient, mirrors);
        }
        if (jobStatus == JobStatus.SUCCESS) {
            syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            processCGMirrors(syncVolumeIter, client, dbClient, storage, mirrors, UUID.randomUUID().toString());
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create group mirrors");
            for (BlockMirror mirror : mirrors) {
                mirror.setInactive(true);
            }
            dbClient.persistObject(mirrors);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create CG mirror job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisVnxCreateCGMirrorJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) CIMInstance(javax.cim.CIMInstance) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 15 with CIMConnectionFactory

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

the class SmisVolumeExpandJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext The job context.
 */
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> associatorIterator = null;
    CloseableIterator<CIMInstance> instanceIterator = null;
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        // from pool's reserved capacity map.
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);
            StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
            StringMap reservationMap = pool.getReservedCapacityMap();
            URI volumeId = getTaskCompleter().getId();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(pool);
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), jobStatus.name(), opId));
        if (jobStatus == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            // set requested capacity
            volume.setCapacity(taskCompleter.getSize());
            // set meta related properties
            volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
            volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
            volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
            volume.setIsComposite(taskCompleter.isComposite());
            volume.setCompositionType(taskCompleter.getMetaVolumeType());
            // set provisioned capacity
            associatorIterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (associatorIterator.hasNext()) {
                CIMObjectPath volumePath = associatorIterator.next();
                CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
                if (volumeInstance != null) {
                    CIMProperty consumableBlocks = volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
                    CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
                    // calculate provisionedCapacity = consumableBlocks * block size
                    Long provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
                    volume.setProvisionedCapacity(provisionedCapacity);
                }
                // set allocated capacity
                instanceIterator = client.referenceInstances(volumePath, SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, SmisConstants.PS_SPACE_CONSUMED);
                if (instanceIterator.hasNext()) {
                    CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
                    CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
                    if (null != spaceConsumed) {
                        volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
                    }
                }
            }
            logMsgBuilder.append(String.format("%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
            if (volume.getIsComposite()) {
                logMsgBuilder.append(String.format("%n   Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
            }
            _log.info(logMsgBuilder.toString());
            // Reset list of meta member volumes in the volume
            if (volume.getMetaVolumeMembers() != null) {
                volume.getMetaVolumeMembers().clear();
            }
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
            // set the RP tag on the volume if the volume is RP protected
            if (volume.checkForRp()) {
                SmisCommandHelper helper = jobContext.getSmisCommandHelper();
                boolean tagSet = helper.doApplyRecoverPointTag(storageSystem, volume, true);
                if (!tagSet) {
                    _log.error("Encountered an error while trying to enable the RecoverPoint tag.");
                    jobStatus = JobStatus.FAILED;
                }
            }
            dbClient.persistObject(volume);
            // Reset list of meta members native ids in WF data (when meta is created meta members are removed from array)
            WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
    } finally {
        _metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
        if (associatorIterator != null) {
            associatorIterator.close();
        }
        if (instanceIterator != null) {
            instanceIterator.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)32 DbClient (com.emc.storageos.db.client.DbClient)28 WBEMClient (javax.wbem.client.WBEMClient)27 CIMObjectPath (javax.cim.CIMObjectPath)18 Volume (com.emc.storageos.db.client.model.Volume)14 CIMInstance (javax.cim.CIMInstance)14 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 URI (java.net.URI)11 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)5 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 CIMProperty (javax.cim.CIMProperty)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 ArrayList (java.util.ArrayList)4 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)3 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)3 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3