Search in sources :

Example 96 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class XtremioBlockSnapshotDeviceLabelMigrationTest method createXIOSnapshots.

private void createXIOSnapshots() throws Exception {
    log.info("Preparing BlockSnapshot for XtremioBlockSnapshotDeviceLabelMigrationTest");
    StorageSystem xioStorageSystem = new StorageSystem();
    xioStorageSystem.setId(URIUtil.createId(StorageSystem.class));
    xioStorageSystem.setSystemType(DiscoveredDataObject.Type.xtremio.name());
    _dbClient.createObject(xioStorageSystem);
    Volume parentVolume = new Volume();
    URI volumeUri = URIUtil.createId(Volume.class);
    parentVolume.setId(volumeUri);
    parentVolume.setLabel("parentVolume");
    _dbClient.createObject(parentVolume);
    NamedURI parentVolNamedUri = new NamedURI(parentVolume.getId(), parentVolume.getLabel());
    BlockSnapshot snapshot = createSnapshot(SNAPSHOT_LABEL, xioStorageSystem.getId(), parentVolNamedUri);
    _dbClient.createObject(snapshot);
    BlockSnapshot snapshotWithDeviceLabel = createSnapshot("snap-with-device-label", xioStorageSystem.getId(), parentVolNamedUri);
    snapshotWithDeviceLabel.setDeviceLabel("snapshot-device-label");
    _dbClient.createObject(snapshotWithDeviceLabel);
    BlockSnapshot inactiveSnapshot = createSnapshot("inactive-snapshot", xioStorageSystem.getId(), parentVolNamedUri);
    _dbClient.createObject(inactiveSnapshot);
    inactiveSnapshot.setInactive(true);
    _dbClient.updateObject(inactiveSnapshot);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 97 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI 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 98 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class SmisBlockSnapshotSessionUnlinkTargetJob method getBlockConsistencyGroupForPromotedSnapshot.

/**
 * Given a CG snapshot that is to be promoted, create a new BlockConsistencyGroup based on its
 * ReplicationGroup. A group cache parameter is accepted and serves to cache BlockConsistencyGroup
 * instances that have already been created.
 *
 * @param snapshot BlockSnapshot being promoted.
 * @param groupCache Cache mapping of ReplicationGroup name to BlockConsistencyGroup instances.
 * @param dbClient Database client.
 * @return BlockConsistencyGroup URI or null.
 */
private URI getBlockConsistencyGroupForPromotedSnapshot(BlockSnapshot snapshot, Map<String, BlockConsistencyGroup> groupCache, DbClient dbClient) {
    if (!snapshot.hasConsistencyGroup()) {
        return null;
    }
    // Create new BlockConsistencyGroup instances to track the existing target groups.
    String groupInstance = snapshot.getReplicationGroupInstance();
    BlockConsistencyGroup cg = null;
    if (groupCache.containsKey(groupInstance)) {
        cg = groupCache.get(groupInstance);
    } else {
        cg = new BlockConsistencyGroup();
        cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
        Project project = dbClient.queryObject(Project.class, snapshot.getProject().getURI());
        cg.setProject(new NamedURI(project.getId(), project.getLabel()));
        cg.setTenant(new NamedURI(project.getTenantOrg().getURI(), project.getTenantOrg().getName()));
        String repGrpName = groupInstance.substring(groupInstance.indexOf("+") + 1, groupInstance.length());
        cg.setLabel(repGrpName);
        StringSetMap map = new StringSetMap();
        map.put(snapshot.getStorageController().toString(), new StringSet(Arrays.asList(repGrpName)));
        cg.setSystemConsistencyGroups(map);
        StringSet types = new StringSet();
        types.add(BlockConsistencyGroup.Types.LOCAL.name());
        cg.setTypes(types);
        cg.setRequestedTypes(types);
        cg.setStorageController(snapshot.getStorageController());
        s_logger.info("Creating new BlockConsistencyGroup for ReplicationGroup {} with ID: {}", groupInstance, cg.getId());
        dbClient.createObject(cg);
        groupCache.put(groupInstance, cg);
    }
    return cg.getId();
}
Also used : Project(com.emc.storageos.db.client.model.Project) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 99 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class SmisDeleteVolumeJob method updateStatus.

/**
 * Called to update the job status when the volume delete job completes.
 *
 * @param jobContext The job context.
 */
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        // Get list of volumes; get set of storage pool ids to which they belong.
        List<Volume> volumes = new ArrayList<Volume>();
        Set<URI> poolURIs = new HashSet<URI>();
        for (URI id : getTaskCompleter().getIds()) {
            Volume volume = dbClient.queryObject(Volume.class, id);
            if (volume != null && !volume.getInactive()) {
                volumes.add(volume);
                poolURIs.add(volume.getPool());
            }
        }
        // If terminal job state update storage pool capacity
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            // Update capacity of storage pools.
            for (URI poolURI : poolURIs) {
                SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
            }
        }
        StringBuilder logMsgBuilder = new StringBuilder();
        if (jobStatus == JobStatus.SUCCESS) {
            for (Volume volume : volumes) {
                if (logMsgBuilder.length() != 0) {
                    logMsgBuilder.append("\n");
                }
                logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            for (URI id : getTaskCompleter().getIds()) {
                if (logMsgBuilder.length() != 0) {
                    logMsgBuilder.append("\n");
                }
                logMsgBuilder.append(String.format("Failed to delete volume: %s", id));
            }
            // This fix, converts a RDF device to non-rdf device in ViPr, so that this volume is exposed to UI for deletion again.
            for (Volume volume : volumes) {
                if (volume.checkForSRDF()) {
                    volume.setPersonality(NullColumnValueGetter.getNullStr());
                    volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                    volume.setLinkStatus(NullColumnValueGetter.getNullStr());
                    if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent())) {
                        volume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
                        volume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
                        volume.setSrdfGroup(NullColumnValueGetter.getNullURI());
                    } else if (null != volume.getSrdfTargets()) {
                        volume.getSrdfTargets().clear();
                    }
                }
            }
            dbClient.updateObject(volumes);
        }
        if (logMsgBuilder.length() > 0) {
            _log.info(logMsgBuilder.toString());
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during delete volume job status processing: " + e.getMessage());
        _log.error("Caught exception while handling updateStatus for delete volume job.", e);
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) HashSet(java.util.HashSet)

Example 100 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class VNXeBlockRestoreSnapshotJob method getSnapshotFromVol.

private BlockSnapshot getSnapshotFromVol(final Volume volume, final String label) {
    BlockSnapshot createdSnap = new BlockSnapshot();
    createdSnap.setId(URIUtil.createId(BlockSnapshot.class));
    createdSnap.setConsistencyGroup(volume.getConsistencyGroup());
    createdSnap.setSourceNativeId(volume.getNativeId());
    createdSnap.setParent(new NamedURI(volume.getId(), label));
    createdSnap.setLabel(label);
    createdSnap.setStorageController(volume.getStorageController());
    createdSnap.setSystemType(volume.getSystemType());
    createdSnap.setVirtualArray(volume.getVirtualArray());
    createdSnap.setProtocol(new StringSet());
    createdSnap.getProtocol().addAll(volume.getProtocol());
    createdSnap.setProject(new NamedURI(volume.getProject().getURI(), label));
    createdSnap.setSnapsetLabel(ResourceOnlyNameGenerator.removeSpecialCharsForName(label, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH));
    return createdSnap;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)196 URI (java.net.URI)98 Volume (com.emc.storageos.db.client.model.Volume)74 StringSet (com.emc.storageos.db.client.model.StringSet)65 Project (com.emc.storageos.db.client.model.Project)54 ArrayList (java.util.ArrayList)46 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)42 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)36 Test (org.junit.Test)32 StoragePool (com.emc.storageos.db.client.model.StoragePool)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)27 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)26 StringMap (com.emc.storageos.db.client.model.StringMap)26 List (java.util.List)23 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)20 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)20 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)18 FileShare (com.emc.storageos.db.client.model.FileShare)17