use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class VPlexBlockServiceApiImpl method prepareVolumeForRequest.
/**
* Prepare a new Bourne volume.
*
* TODO: Use existing function (prepareVolume) when VirtualPool capabilities change
* completed by Stalin. Just pass size instead of getting from VolumeCreate
* parameter.
*
* @param size The volume size.
* @param project A reference to the volume's Project.
* @param neighborhood A reference to the volume's varray.
* @param vpool A reference to the volume's VirtualPool.
* @param storageSystemURI The URI of the volume's storage system.
* @param storagePoolURI The URI of the volume's storage pool.
* @param label The volume label.
* @param token The task id for volume creation.
* @param dbClient A reference to a database client.
*
* @return A reference to the new volume.
*/
public static Volume prepareVolumeForRequest(Long size, Project project, VirtualArray neighborhood, VirtualPool vpool, URI storageSystemURI, URI storagePoolURI, String label, ResourceOperationTypeEnum opType, String token, DbClient dbClient) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel(label);
volume.setCapacity(size);
volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
volume.setVirtualPool(vpool.getId());
volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
volume.setVirtualArray(neighborhood.getId());
StoragePool storagePool = null;
if (!NullColumnValueGetter.getNullURI().toString().equals(storagePoolURI.toString())) {
storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
if (null != storagePool) {
volume.setProtocol(new StringSet());
volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), storagePool.getProtocols()));
}
} else {
// Must be preparing a VPLEX volume which does not
// have a storage pool so a null URI is passed. Set
// the volume protocols to FC.
StringSet protocols = new StringSet();
protocols.add(StorageProtocol.Block.FC.name());
volume.setProtocol(protocols);
}
volume.setStorageController(storageSystemURI);
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
volume.setSystemType(systemType);
volume.setPool(storagePoolURI);
volume.setOpStatus(new OpStatusMap());
// Set the auto tiering policy.
if (null != vpool.getAutoTierPolicyName()) {
URI autoTierPolicyUri = StorageScheduler.getAutoTierPolicy(storagePoolURI, vpool.getAutoTierPolicyName(), dbClient);
if (null != autoTierPolicyUri) {
volume.setAutoTieringPolicyUri(autoTierPolicyUri);
}
}
if (opType != null) {
Operation op = new Operation();
op.setResourceType(opType);
volume.getOpStatus().createTaskStatus(token, op);
}
dbClient.createObject(volume);
return volume;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class ReplicaDeviceController method prepareClone.
private Volume prepareClone(Volume volume, String repGroupName, String cloneSetName) {
// create clone for the source
Volume clone = new Volume();
clone.setId(URIUtil.createId(Volume.class));
clone.setLabel(volume.getLabel() + "-" + repGroupName);
clone.setPool(volume.getPool());
clone.setStorageController(volume.getStorageController());
clone.setSystemType(volume.getSystemType());
clone.setProject(new NamedURI(volume.getProject().getURI(), clone.getLabel()));
clone.setTenant(new NamedURI(volume.getTenant().getURI(), clone.getLabel()));
clone.setVirtualPool(volume.getVirtualPool());
clone.setVirtualArray(volume.getVirtualArray());
clone.setProtocol(new StringSet());
clone.getProtocol().addAll(volume.getProtocol());
clone.setThinlyProvisioned(volume.getThinlyProvisioned());
clone.setOpStatus(new OpStatusMap());
clone.setAssociatedSourceVolume(volume.getId());
clone.setReplicationGroupInstance(repGroupName);
// For clones of new volumes added to Application, get the clone set name and set it
if (cloneSetName != null) {
clone.setFullCopySetName(cloneSetName);
}
StringSet fullCopies = volume.getFullCopies();
if (fullCopies == null) {
fullCopies = new StringSet();
volume.setFullCopies(fullCopies);
}
fullCopies.add(clone.getId().toString());
_dbClient.createObject(clone);
_dbClient.updateObject(volume);
return clone;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class StorageScheduler method prepareVolume.
/**
* Prepare Volume for an unprotected traditional block volume.
*
* @param volume pre-created volume (optional)
* @param size volume size
* @param project project requested
* @param neighborhood varray requested
* @param vpool vpool requested
* @param placement recommendation for placement
* @param label volume label
* @param consistencyGroup cg ID
* @param createInactive
*
* @return a persisted volume
*/
public static Volume prepareVolume(DbClient dbClient, Volume volume, long size, long thinVolumePreAllocationSize, Project project, VirtualArray neighborhood, VirtualPool vpool, VolumeRecommendation placement, String label, BlockConsistencyGroup consistencyGroup, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
// In the case of a new volume that wasn't pre-created, make sure that volume doesn't already exist
if (volume == null) {
List<Volume> volumeList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Volume.class, ContainmentPrefixConstraint.Factory.getFullMatchConstraint(Volume.class, "project", project.getId(), label));
if (!volumeList.isEmpty()) {
throw APIException.badRequests.duplicateLabel(label);
}
}
boolean newVolume = false;
StoragePool pool = null;
if (volume == null) {
newVolume = true;
volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setOpStatus(new OpStatusMap());
} else {
// Reload volume object from DB
volume = dbClient.queryObject(Volume.class, volume.getId());
}
volume.setSyncActive(!Boolean.valueOf(createInactive));
volume.setLabel(label);
volume.setCapacity(size);
if (0 != thinVolumePreAllocationSize) {
volume.setThinVolumePreAllocationSize(thinVolumePreAllocationSize);
}
volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
volume.setVirtualPool(vpool.getId());
volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
volume.setVirtualArray(neighborhood.getId());
URI poolId = placement.getCandidatePools().get(0);
if (null != poolId) {
pool = dbClient.queryObject(StoragePool.class, poolId);
if (null != pool) {
volume.setProtocol(new StringSet());
volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
}
}
URI storageControllerUri = placement.getCandidateSystems().get(0);
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageControllerUri);
String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
volume.setSystemType(systemType);
volume.setStorageController(storageControllerUri);
volume.setPool(poolId);
if (consistencyGroup != null) {
volume.setConsistencyGroup(consistencyGroup.getId());
if (!consistencyGroup.isProtectedCG()) {
String rgName = consistencyGroup.getCgNameOnStorageSystem(volume.getStorageController());
if (rgName == null) {
// for new CG
rgName = consistencyGroup.getLabel();
} else {
// if other volumes in the same CG are in an application, add this volume to the same application
VolumeGroup volumeGroup = ControllerUtils.getApplicationForCG(dbClient, consistencyGroup, rgName);
if (volumeGroup != null) {
volume.getVolumeGroupIds().add(volumeGroup.getId().toString());
}
}
volume.setReplicationGroupInstance(rgName);
}
}
if (null != cosCapabilities.getAutoTierPolicyName()) {
URI autoTierPolicyUri = getAutoTierPolicy(poolId, cosCapabilities.getAutoTierPolicyName(), dbClient);
if (null != autoTierPolicyUri) {
volume.setAutoTieringPolicyUri(autoTierPolicyUri);
}
}
if (vpool.getDedupCapable() != null) {
volume.setIsDeduplicated(vpool.getDedupCapable());
}
if (newVolume) {
dbClient.createObject(volume);
} else {
dbClient.updateAndReindexObject(volume);
}
return volume;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class StorageScheduler method prepareEmptyVolume.
/**
* Prepare a new volume object in the database that can be tracked and overridden as the volume goes through the
* placement process.
*
* @param dbClient dbclient
* @param size size of volume
* @param project project
* @param varray virtual array
* @param vpool virtual pool
* @param label base volume label
* @param volNumber a temporary label for this volume to mark which one it is
* @param volumesRequested how many volumes were requested overall
* @return a Volume object
*/
public static Volume prepareEmptyVolume(DbClient dbClient, long size, Project project, VirtualArray varray, VirtualPool vpool, String label, int volNumber, int volumesRequested) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
String volumeLabel = AbstractBlockServiceApiImpl.generateDefaultVolumeLabel(label, volNumber, volumesRequested);
List<Volume> volumeList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Volume.class, ContainmentPrefixConstraint.Factory.getFullMatchConstraint(Volume.class, "project", project.getId(), volumeLabel));
if (!volumeList.isEmpty()) {
throw APIException.badRequests.duplicateLabel(volumeLabel);
}
volume.setLabel(volumeLabel);
volume.setCapacity(size);
volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
volume.setVirtualPool(vpool.getId());
volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
volume.setVirtualArray(varray.getId());
volume.setOpStatus(new OpStatusMap());
if (vpool.getDedupCapable() != null) {
volume.setIsDeduplicated(vpool.getDedupCapable());
}
dbClient.createObject(volume);
return volume;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class DbClientTest method testQueryField.
@Test
public void testQueryField() throws Exception {
DbClient dbClient = _dbClient;
OpStatusMap status = new OpStatusMap();
String taskname = "task1";
Operation op = new Operation(Operation.Status.pending.toString(), "test");
op.setDescription("descr");
status.createTaskStatus(taskname, op);
String label = "test system";
StorageSystem system1 = new StorageSystem();
system1.setId(URIUtil.createId(StorageSystem.class));
system1.setLabel(label);
system1.setInactive(true);
system1.setOpStatus(status);
StorageSystem system2 = new StorageSystem();
system2.setId(URIUtil.createId(StorageSystem.class));
system2.setLabel(label);
system2.setInactive(true);
system2.setOpStatus(status);
dbClient.persistObject(system1, system2);
List<URI> uris = new ArrayList<URI>();
uris.add(system1.getId());
uris.add(system2.getId());
List<StorageSystem> systems = dbClient.queryObjectField(StorageSystem.class, "label", uris);
Assert.assertEquals(2, systems.size());
Assert.assertTrue(systems.get(0).getLabel().equals(label));
Assert.assertTrue(systems.get(1).getLabel().equals(label));
Iterator<StorageSystem> it = dbClient.queryIterativeObjectField(StorageSystem.class, "label", uris);
int count = 0;
while (it.hasNext()) {
count++;
StorageSystem obj = it.next();
Assert.assertTrue(obj.getLabel().equals(label));
}
Assert.assertEquals(2, count);
systems = dbClient.queryObjectField(StorageSystem.class, "inactive", uris);
Assert.assertEquals(2, systems.size());
Assert.assertTrue(systems.get(0).getInactive());
Assert.assertTrue(systems.get(1).getInactive());
systems = dbClient.queryObjectField(StorageSystem.class, "status", uris);
Assert.assertEquals(2, systems.size());
Assert.assertNotNull(systems.get(0).getOpStatus().get(taskname));
Assert.assertNotNull(systems.get(1).getOpStatus().get(taskname));
}
Aggregations