Search in sources :

Example 76 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockDeleteCGMirrorJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
        List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
        // If terminal state update storage pool capacity
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            Set<URI> poolURIs = new HashSet<URI>();
            for (BlockMirror mirror : mirrors) {
                poolURIs.add(mirror.getPool());
            }
            for (URI poolURI : poolURIs) {
                // Update capacity of storage pools.
                SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
            }
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("Group mirror delete success");
            dbClient.markForDeletion(mirrors);
        } else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
            String msg = String.format("Failed to delete group mirrors");
            _log.error(msg);
            getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
        }
    } catch (Exception e) {
        setFatalErrorStatus("Encountered an internal error during block delete group mirror job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteCGMirrorJob", e);
        getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : BlockMirrorDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorDeleteCompleter) 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) URI(java.net.URI) HashSet(java.util.HashSet)

Example 77 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockDeleteListReplicaJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        List<? extends BlockObject> replicas = BlockObject.fetch(dbClient, getTaskCompleter().getIds());
        // If terminal state update storage pool capacity
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            Set<URI> poolURIs = new HashSet<URI>();
            for (BlockObject replica : replicas) {
                if (replica instanceof Volume)
                    poolURIs.add(((Volume) replica).getPool());
            }
            for (URI poolURI : poolURIs) {
                // Update capacity of storage pools.
                SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
            }
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("List replica delete success");
            dbClient.markForDeletion(replicas);
        } else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
            String msg = String.format("Failed to delete list replica");
            _log.error(msg);
            getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
        }
    } catch (Exception e) {
        setFatalErrorStatus("Encountered an internal error during block delete replica replica job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteListReplicaJob", e);
        getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Example 78 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockDeleteSnapshotJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        BlockSnapshotDeleteCompleter completer = (BlockSnapshotDeleteCompleter) getTaskCompleter();
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, completer.getId());
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        // If terminal state update storage pool capacity
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            NamedURI volumeURI = snapshot.getParent();
            Volume volume = dbClient.queryObject(Volume.class, volumeURI);
            URI poolURI = volume.getPool();
            // Update capacity of storage pools.
            SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("Deleting snapshot job was successful.");
            snapshot.setInactive(true);
            dbClient.persistObject(snapshot);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to delete snapshot: {}", getTaskCompleter().getId());
        }
    } catch (Exception e) {
        setFatalErrorStatus(e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteSnapshotJob", e);
        Operation updateOp = new Operation();
        updateOp.setStatus("Encountered an internal error during block delete snapshot job status processing: " + e.getMessage());
        dbClient.updateTaskOpStatus(BlockSnapshot.class, getTaskCompleter().getId(), getTaskCompleter().getOpId(), updateOp);
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshotDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotDeleteCompleter) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation) WBEMClient(javax.wbem.client.WBEMClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 79 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockSnapshotSessionLinkTargetJob method updateStatus.

/**
 * {@inheritDoc}
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    JobStatus jobStatus = getJobStatus();
    CloseableIterator<CIMObjectPath> volumeIter = null;
    try {
        DbClient dbClient = jobContext.getDbClient();
        TaskCompleter completer = getTaskCompleter();
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, _snapshotURI);
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        if (jobStatus == JobStatus.SUCCESS) {
            s_logger.info("Post-processing successful link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
            // Get the snapshot session to which the target is being linked.
            BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, completer.getId());
            // Get the snapshot device ID and set it against the BlockSnapshot object.
            BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            volumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            while (volumeIter.hasNext()) {
                // Get the sync volume native device id
                CIMObjectPath volumePath = volumeIter.next();
                s_logger.info("volumePath: {}", volumePath.toString());
                CIMInstance volume = client.getInstance(volumePath, false, false, null);
                String volumeDeviceId = volumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                s_logger.info("volumeDeviceId: {}", volumeDeviceId);
                if (volumeDeviceId.equals(sourceObj.getNativeId())) {
                    // Don't want the source, we want the linked target.
                    continue;
                }
                String volumeElementName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
                s_logger.info("volumeElementName: {}", volumeElementName);
                String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
                s_logger.info("volumeWWN: {}", volumeWWN);
                String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
                s_logger.info("volumeAltName: {}", volumeAltName);
                StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
                snapshot.setNativeId(volumeDeviceId);
                snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
                snapshot.setDeviceLabel(volumeElementName);
                snapshot.setInactive(false);
                snapshot.setIsSyncActive(Boolean.TRUE);
                snapshot.setCreationTime(Calendar.getInstance());
                snapshot.setWWN(volumeWWN.toUpperCase());
                snapshot.setAlternateName(volumeAltName);
                snapshot.setSettingsInstance(snapSession.getSessionInstance());
                commonSnapshotUpdate(snapshot, volume, client, system, sourceObj.getNativeId(), volumeDeviceId, false, dbClient);
                s_logger.info(String.format("For target volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", volumePath.toString(), snapshot.getId().toString(), volumeDeviceId, volumeElementName, sourceObj.getNativeId(), sourceObj.getDeviceLabel()));
                dbClient.updateObject(snapshot);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            s_logger.info("Failed to link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
            snapshot.setInactive(true);
            dbClient.updateObject(snapshot);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error in link snapshot session target job status processing: " + e.getMessage());
        s_logger.error("Encountered an internal error in link snapshot session target job status processing", e);
    } finally {
        if (volumeIter != null) {
            volumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WBEMClient(javax.wbem.client.WBEMClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 80 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisCreateListReplicaJob 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;
        }
        List<? extends BlockObject> replicas = BlockObject.fetch(dbClient, getTaskCompleter().getIds());
        if (jobStatus == JobStatus.SUCCESS) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            if (_syncType == SmisConstants.MIRROR_VALUE || _syncType == SmisConstants.CLONE_VALUE) {
                updatePools(client, dbClient, (List<? extends Volume>) replicas);
            }
            syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            processListReplica(syncVolumeIter, client, dbClient, jobContext.getSmisCommandHelper(), storage, replicas, _syncType, _isSyncActive);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create list relica");
            for (BlockObject replica : replicas) {
                replica.setInactive(true);
            }
            dbClient.persistObject(replicas);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create list replica job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateListReplicaJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

WBEMClient (javax.wbem.client.WBEMClient)110 CIMObjectPath (javax.cim.CIMObjectPath)75 CIMInstance (javax.cim.CIMInstance)69 WBEMException (javax.wbem.WBEMException)42 ArrayList (java.util.ArrayList)39 URI (java.net.URI)35 DbClient (com.emc.storageos.db.client.DbClient)29 Volume (com.emc.storageos.db.client.model.Volume)29 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)27 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)25 HashSet (java.util.HashSet)25 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)24 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)18 HashMap (java.util.HashMap)17 ExportMask (com.emc.storageos.db.client.model.ExportMask)16 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 CIMProperty (javax.cim.CIMProperty)14 UnsignedInteger32 (javax.cim.UnsignedInteger32)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)13