Search in sources :

Example 61 with NamedURI

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

the class DbClientTest method testTaskCleanup.

@Test
public void testTaskCleanup() throws Exception {
    _logger.info("Starting testTaskCleanup");
    int taskCount = 100;
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URIUtil.createId(TenantOrg.class));
    tenant.setLabel("tenant-unit-test");
    _dbClient.createObject(tenant);
    List<Project> projects = createProjects(1, tenant);
    List<Volume> volumes = createVolumes(1, "foobar", projects.get(0));
    Volume volume = volumes.get(0);
    volume.setTenant(new NamedURI(tenant.getId(), tenant.getLabel()));
    DbClient dbClient = _dbClient;
    Calendar twoWeeksAgo = Calendar.getInstance();
    twoWeeksAgo.setTime(Date.from(LocalDateTime.now().minusWeeks(2).atZone(ZoneId.systemDefault()).toInstant()));
    Calendar sixWeeksAgo = Calendar.getInstance();
    sixWeeksAgo.setTime(Date.from(LocalDateTime.now().minusWeeks(6).atZone(ZoneId.systemDefault()).toInstant()));
    Calendar sixMonthsAgo = Calendar.getInstance();
    sixMonthsAgo.setTime(Date.from(LocalDateTime.now().minusMonths(6).atZone(ZoneId.systemDefault()).toInstant()));
    for (int i = 0; i < taskCount; i++) {
        Task task = new Task();
        task.setId(URIUtil.createId(Task.class));
        task.setCompletedFlag(false);
        task.setDescription("test task");
        task.setLabel("TEST TASK");
        task.setMessage("test task");
        task.setProgress(0);
        task.setRequestId(UUID.randomUUID().toString());
        task.setResource(new NamedURI(volume.getId(), volume.getLabel()));
        task.setStartTime(sixWeeksAgo);
        task.setStatus(Task.Status.pending.toString());
        task.setTenant(volume.getTenant().getURI());
        dbClient.createObject(task);
    }
    Iterator<Task> pendingTaskItr = TaskUtils.findPendingTasksForResource(dbClient, volume.getId(), volume.getTenant().getURI());
    Assert.assertEquals(iteratorCount(pendingTaskItr), taskCount);
    TaskUtils.cleanupPendingTasks(dbClient, volume.getId(), "TEST TASK", volume.getTenant().getURI(), sixMonthsAgo);
    pendingTaskItr = TaskUtils.findPendingTasksForResource(dbClient, volume.getId(), volume.getTenant().getURI());
    Assert.assertEquals(iteratorCount(pendingTaskItr), taskCount);
    TaskUtils.cleanupPendingTasks(dbClient, volume.getId(), "TEST TASK", volume.getTenant().getURI(), twoWeeksAgo);
    pendingTaskItr = TaskUtils.findPendingTasksForResource(dbClient, volume.getId(), volume.getTenant().getURI());
    Assert.assertEquals(iteratorCount(pendingTaskItr), 0);
    for (int i = 0; i < taskCount; i++) {
        Task task = new Task();
        task.setId(URIUtil.createId(Task.class));
        task.setCompletedFlag(false);
        task.setDescription("test task");
        task.setLabel("TEST TASK");
        task.setMessage("test task");
        task.setProgress(0);
        task.setRequestId(UUID.randomUUID().toString());
        task.setResource(new NamedURI(volume.getId(), volume.getLabel()));
        task.setStartTime(sixWeeksAgo);
        task.setStatus(Task.Status.pending.toString());
        task.setTenant(volume.getTenant().getURI());
        dbClient.createObject(task);
    }
    pendingTaskItr = TaskUtils.findPendingTasksForResource(dbClient, volume.getId(), volume.getTenant().getURI());
    Assert.assertEquals(iteratorCount(pendingTaskItr), taskCount);
    TaskUtils.cleanupPendingTasks(dbClient, volume.getId(), "TEST TASK", volume.getTenant().getURI());
    pendingTaskItr = TaskUtils.findPendingTasksForResource(dbClient, volume.getId(), volume.getTenant().getURI());
    Assert.assertEquals(iteratorCount(pendingTaskItr), 0);
}
Also used : Project(com.emc.storageos.db.client.model.Project) Task(com.emc.storageos.db.client.model.Task) DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) Calendar(java.util.Calendar) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Example 62 with NamedURI

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

the class BlockObjectConsistencyGroupMigrationTest method createBlockSnapshotData.

/**
 * Creates the BlockObject BlockSnapshot data.
 *
 * @param name
 * @param numSnapshots
 * @throws Exception
 */
private void createBlockSnapshotData(String name, int numSnapshots) throws Exception {
    // Create the volume for the snapshots
    Volume volume = new Volume();
    URI volumeURI = URIUtil.createId(Volume.class);
    testVolumeURIs.add(volumeURI);
    volume.setId(volumeURI);
    String volName = "snapVolume";
    volume.setLabel(volName);
    URI cgUri = createBlockConsistencyGroup(volName + "-cg");
    volume.setConsistencyGroup(cgUri);
    _dbClient.createObject(volume);
    for (int i = 1; i <= numSnapshots; i++) {
        BlockSnapshot blockSnapshot = new BlockSnapshot();
        URI blockSnapshotURI = URIUtil.createId(BlockSnapshot.class);
        testBlockSnapshotURIs.add(blockSnapshotURI);
        blockSnapshot.setId(blockSnapshotURI);
        blockSnapshot.setLabel(name + i);
        blockSnapshot.setSnapsetLabel(name + i);
        blockSnapshot.setParent(new NamedURI(volume.getId(), name + i));
        blockSnapshot.setConsistencyGroup(cgUri);
        _dbClient.createObject(blockSnapshot);
        BlockSnapshot querySnap = _dbClient.queryObject(BlockSnapshot.class, blockSnapshotURI);
    }
}
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)

Example 63 with NamedURI

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

the class BlockObjectMultipleConsistencyGroupsMigrationTest method createRpVolumes.

/**
 * Creates the RP source volume/journal and the specified number of
 * target/journal volumes.
 *
 * @param volumeName
 * @param numTargets
 */
private List<Volume> createRpVolumes(String volumeName, int numTargets, ProtectionSet protectionSet, boolean isRpVPlex) {
    List<Volume> volumes = new ArrayList<Volume>();
    StringSet associatedVolumes = new StringSet();
    associatedVolumes.add("associatedVol1");
    StorageSystem storageSystem = null;
    if (isRpVPlex) {
        storageSystem = createStorageSystem(true);
    } else {
        storageSystem = createStorageSystem(false);
    }
    String rsetName = "RSet-" + volumeName;
    Volume sourceVolume = new Volume();
    URI sourceVolumeURI = URIUtil.createId(Volume.class);
    volumes.add(sourceVolume);
    sourceVolume.setId(sourceVolumeURI);
    sourceVolume.setLabel(volumeName);
    sourceVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
    sourceVolume.setRSetName(rsetName);
    sourceVolume.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
    sourceVolume.setStorageController(storageSystem.getId());
    if (isRpVPlex) {
        sourceVolume.setAssociatedVolumes(associatedVolumes);
        sourceVolume.setNativeId("/clusters/cluster-1/virtual-volumes/device_V000195701573-01E7A_vol");
        // Create a VPLEX ViPR BlockConsistencyGroup for the source volume
        BlockConsistencyGroup sourceVolumeCg = createBlockConsistencyGroup(sourceVolume.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true);
        addVolumeToBlockConsistencyGroup(sourceVolumeCg.getId(), sourceVolume);
        rpVplexVolumeToCgMapping.put(sourceVolumeURI, sourceVolumeCg.getId());
    } else {
        rpVolumeURIs.add(sourceVolumeURI);
    }
    _dbClient.createObject(sourceVolume);
    Volume sourceVolumeJournal = new Volume();
    URI sourceVolumeJournalURI = URIUtil.createId(Volume.class);
    volumes.add(sourceVolumeJournal);
    sourceVolumeJournal.setId(sourceVolumeJournalURI);
    sourceVolumeJournal.setLabel(volumeName + RP_SRC_JOURNAL_APPEND);
    sourceVolumeJournal.setPersonality(Volume.PersonalityTypes.METADATA.toString());
    sourceVolumeJournal.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
    sourceVolumeJournal.setStorageController(storageSystem.getId());
    if (isRpVPlex) {
        sourceVolumeJournal.setAssociatedVolumes(associatedVolumes);
        sourceVolumeJournal.setNativeId("/clusters/cluster-1/virtual-volumes/device_V000195701573-01E7B_vol");
        // Create a VPLEX ViPR BlockConsistencyGroup for the source journal volume
        BlockConsistencyGroup sourceVolumeJournalCg = createBlockConsistencyGroup(sourceVolumeJournal.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true);
        addVolumeToBlockConsistencyGroup(sourceVolumeJournalCg.getId(), sourceVolumeJournal);
        rpVplexVolumeToCgMapping.put(sourceVolumeJournalURI, sourceVolumeJournalCg.getId());
    } else {
        rpVolumeURIs.add(sourceVolumeJournalURI);
    }
    _dbClient.createObject(sourceVolumeJournal);
    for (int i = 1; i <= numTargets; i++) {
        Volume sourceVolumeTarget = new Volume();
        URI sourceVolumeTargetURI = URIUtil.createId(Volume.class);
        volumes.add(sourceVolumeTarget);
        sourceVolumeTarget.setId(sourceVolumeTargetURI);
        sourceVolumeTarget.setLabel(volumeName + RP_TGT_APPEND + "vArray" + i);
        sourceVolumeTarget.setPersonality(Volume.PersonalityTypes.TARGET.toString());
        sourceVolumeTarget.setRSetName(rsetName);
        sourceVolumeTarget.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
        sourceVolumeTarget.setStorageController(storageSystem.getId());
        if (isRpVPlex) {
            sourceVolumeTarget.setAssociatedVolumes(associatedVolumes);
            sourceVolumeTarget.setNativeId("/clusters/cluster-2/virtual-volumes/device_V000195701573-01E7C_vol" + i);
            // Create a VPLEX ViPR BlockConsistencyGroup for the target volume
            BlockConsistencyGroup sourceVolumeTargetCg = createBlockConsistencyGroup(sourceVolumeTarget.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true);
            addVolumeToBlockConsistencyGroup(sourceVolumeTargetCg.getId(), sourceVolumeTarget);
            rpVplexVolumeToCgMapping.put(sourceVolumeTargetURI, sourceVolumeTargetCg.getId());
        } else {
            rpVolumeURIs.add(sourceVolumeTargetURI);
        }
        _dbClient.createObject(sourceVolumeTarget);
        Volume sourceVolumeTargetJournal = new Volume();
        URI sourceVolumeTargetJournalURI = URIUtil.createId(Volume.class);
        volumes.add(sourceVolumeTargetJournal);
        sourceVolumeTargetJournal.setId(sourceVolumeTargetJournalURI);
        sourceVolumeTargetJournal.setLabel(volumeName + RP_TGT_JOURNAL_APPEND + "vArray" + i);
        sourceVolumeTargetJournal.setPersonality(Volume.PersonalityTypes.METADATA.toString());
        sourceVolumeTargetJournal.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
        sourceVolumeTargetJournal.setStorageController(storageSystem.getId());
        if (isRpVPlex) {
            sourceVolumeTargetJournal.setAssociatedVolumes(associatedVolumes);
            sourceVolumeTargetJournal.setNativeId("/clusters/cluster-2/virtual-volumes/device_V000195701573-01ED_vol" + i);
            // Create a VPLEX ViPR BlockConsistencyGroup for the source target journal volume
            BlockConsistencyGroup sourceVolumeTargetJournalCg = createBlockConsistencyGroup(sourceVolumeTargetJournal.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true);
            addVolumeToBlockConsistencyGroup(sourceVolumeTargetJournalCg.getId(), sourceVolumeTargetJournal);
            rpVplexVolumeToCgMapping.put(sourceVolumeTargetJournalURI, sourceVolumeTargetJournalCg.getId());
        } else {
            rpVolumeURIs.add(sourceVolumeTargetJournalURI);
        }
        _dbClient.createObject(sourceVolumeTargetJournal);
    }
    return volumes;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 64 with NamedURI

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

the class BlockSnapshotSessionMigrationTest method prepareSingleSnapshotData.

/**
 * Prepares single volume test data.
 */
private void prepareSingleSnapshotData() {
    // A list of database object instances to be created.
    ArrayList<DataObject> newObjectsToBeCreated = new ArrayList<DataObject>();
    // Create some snapshots on a storage system that does not support
    // snapshot sessions. Snapshots on VNX do not currently support
    // snapshot sessions.
    StorageSystem system = new StorageSystem();
    URI systemURI = URIUtil.createId(StorageSystem.class);
    system.setId(systemURI);
    system.setSystemType(DiscoveredDataObject.Type.vnxblock.name());
    newObjectsToBeCreated.add(system);
    for (int i = 0; i < SNAPSHOT_COUNT; i++) {
        BlockSnapshot snapshot = new BlockSnapshot();
        URI snapshotURI = URIUtil.createId(BlockSnapshot.class);
        snapshot.setId(snapshotURI);
        snapshot.setLabel(BASE_SNAPSHOT_NAME + i);
        snapshot.setSnapsetLabel(snapshot.getLabel());
        URI projectURI = URIUtil.createId(Project.class);
        snapshot.setProject(new NamedURI(projectURI, PROJECT_NAME));
        URI parentURI = URIUtil.createId(Volume.class);
        snapshot.setParent(new NamedURI(parentURI, PARENT_NAME + i));
        snapshot.setSettingsInstance(BASE_SETTINGS_INSTANCE + i);
        snapshot.setStorageController(systemURI);
        newObjectsToBeCreated.add(snapshot);
    }
    // Now create some BlockSnapshot instances on a storage system
    // that does support snapshot sessions. VMAX3 is the only storage
    // system for which we currently support snapshot sessions. We
    // set up the system so that the method on StorageSystem
    // "checkIfVmax3" returns true.
    system = new StorageSystem();
    systemURI = URIUtil.createId(StorageSystem.class);
    system.setId(systemURI);
    system.setSystemType(DiscoveredDataObject.Type.vmax.name());
    system.setFirmwareVersion(VMAX3_SYSTEM_FW_VERSION);
    newObjectsToBeCreated.add(system);
    for (int i = 0; i < SNAPVX_SNAPSHOT_COUNT; i++) {
        BlockSnapshot snapshot = new BlockSnapshot();
        URI snapshotURI = URIUtil.createId(BlockSnapshot.class);
        snapshot.setId(snapshotURI);
        snapshot.setLabel(BASE_SNAPVX_SNAPSHOT_NAME + i);
        snapshot.setSnapsetLabel(snapshot.getLabel());
        URI projectURI = URIUtil.createId(Project.class);
        snapshot.setProject(new NamedURI(projectURI, PROJECT_NAME));
        URI parentURI = URIUtil.createId(Volume.class);
        snapshot.setParent(new NamedURI(parentURI, PARENT_NAME + i));
        snapshot.setSettingsInstance(BASE_SETTINGS_INSTANCE + i);
        snapshot.setStorageController(systemURI);
        newObjectsToBeCreated.add(snapshot);
        _linkedTargetsMap.put(snapshotURI.toString(), snapshot);
    }
    // Create the database objects.
    _dbClient.createObject(newObjectsToBeCreated);
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) 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 65 with NamedURI

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

the class DbObjInternalFlagsMigrationTest method prepareFileShareData.

private void prepareFileShareData() throws Exception {
    String currentLabel = "onePublic";
    // create a couple of public FileShares that should be ignored by the migration callback
    FileShare fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel(currentLabel);
    fs.setProject(new NamedURI(URI.create("urn:" + currentLabel), currentLabel));
    _dbClient.createObject(fs);
    currentLabel = "twoPublic";
    fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel(currentLabel);
    fs.setProject(new NamedURI(URI.create("urn:" + currentLabel), currentLabel));
    _dbClient.createObject(fs);
    // create a couple of internal (project==null) FileShares that should be migrated
    currentLabel = "oneInternal";
    fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel(currentLabel);
    fs.setProject(null);
    _dbClient.createObject(fs);
    currentLabel = "twoInternal";
    fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel(currentLabel);
    fs.setProject(null);
    _dbClient.createObject(fs);
    // make sure our test data made it into the database as expected
    List<URI> fileShareKeys = _dbClient.queryByType(FileShare.class, false);
    int count = 0;
    for (@SuppressWarnings("unused") URI ignore : fileShareKeys) {
        count++;
    }
    Assert.assertTrue("expected 4 prepared FileShares, found only " + count, count == 4);
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) FileShare(com.emc.storageos.db.client.model.FileShare) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

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