use of com.emc.storageos.db.client.model.ScopedLabelSet in project coprhd-controller by CoprHD.
the class VolumeBootVolumeMigrationTest method prepareVolumeData.
/**
* Prepares the data for RP volume tests.
*
* @throws Exception When an error occurs preparing the RP volume data.
*/
private void prepareVolumeData() throws Exception {
log.info("Preparing Volumes for VolumeAccessStateLinkStatusMigration");
TenantOrg tenantOrg = new TenantOrg();
URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
tenantOrg.setId(tenantOrgURI);
_dbClient.createObject(tenantOrg);
Project proj = new Project();
URI projectURI = URIUtil.createId(Project.class);
String projectLabel = "project";
proj.setId(projectURI);
proj.setLabel(projectLabel);
proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
_dbClient.createObject(proj);
// Create a boot volume for a host with no tags
Volume vol1 = new Volume();
URI vol1URI = URIUtil.createId(Volume.class);
vol1.setId(vol1URI);
vol1.setLabel("VOL1-ABOOTVOLUME");
vol1.setTenant(new NamedURI(tenantOrgURI, "provider"));
_dbClient.createObject(vol1);
// Create a host object with a boot volume
Host host1 = new Host();
URI host1URI = URIUtil.createId(Host.class);
host1.setId(host1URI);
host1.setHostName("Host1WithBootVol");
host1.setBootVolumeId(vol1URI);
volumeToHostIds.put(vol1URI, host1URI);
_dbClient.createObject(host1);
// Create a boot volume for a host with existing tags
Volume vol2 = new Volume();
URI vol2URI = URIUtil.createId(Volume.class);
vol2.setId(vol2URI);
vol2.setLabel("VOL2-ABOOTVOLUME");
vol2.setTenant(new NamedURI(tenantOrgURI, "provider"));
ScopedLabel label = new ScopedLabel();
label.setScope(tenantOrg.getId().toASCIIString());
label.setLabel("vipr:someothertag=" + vol2URI.toASCIIString());
ScopedLabelSet labelSet = new ScopedLabelSet();
labelSet.add(label);
vol2.setTag(labelSet);
_dbClient.createObject(vol2);
// Create a host object with a boot volume
Host host2 = new Host();
URI host2URI = URIUtil.createId(Host.class);
host2.setId(host2URI);
host2.setHostName("Host2WithBootVol");
host2.setBootVolumeId(vol2URI);
volumeToHostIds.put(vol2URI, host2URI);
_dbClient.createObject(host2);
// Create a volume with no host association
Volume vol3 = new Volume();
URI vol3URI = URIUtil.createId(Volume.class);
vol3.setId(vol3URI);
vol3.setLabel("VOL3-NOTABOOTVOLUME");
vol3.setTenant(new NamedURI(tenantOrgURI, "provider"));
volumeToHostIds.put(vol3URI, null);
_dbClient.createObject(vol3);
}
use of com.emc.storageos.db.client.model.ScopedLabelSet in project coprhd-controller by CoprHD.
the class XIVRestOperationsHelper method setTag.
private void setTag(DataObject object, String scope, String label) {
if (label == null) {
// shouldn't happen
label = "";
}
ScopedLabel newScopedLabel = new ScopedLabel(scope, label);
ScopedLabelSet tagSet = object.getTag();
if (tagSet == null) {
tagSet = new ScopedLabelSet();
tagSet.add(newScopedLabel);
object.setTag(tagSet);
} else if (tagSet.contains(newScopedLabel)) {
return;
} else {
removeLabel(tagSet, scope);
tagSet.add(newScopedLabel);
}
_dbClient.persistObject(object);
}
use of com.emc.storageos.db.client.model.ScopedLabelSet in project coprhd-controller by CoprHD.
the class XIVRestOperationsHelper method unsetTag.
private void unsetTag(DataObject object, String scope) {
ScopedLabelSet tagSet = object.getTag();
if (tagSet == null) {
return;
}
removeLabel(tagSet, scope);
_dbClient.updateObject(object);
}
use of com.emc.storageos.db.client.model.ScopedLabelSet in project coprhd-controller by CoprHD.
the class VolumeBootVolumeMigration method tagBootVolumes.
/**
* For all volumes, fill in the boot volume tag, if certain loose criteria is met
*/
private void tagBootVolumes() {
log.info("Updating volumes to contain boot tag.");
DbClient dbClient = this.getDbClient();
List<URI> hostURIs = dbClient.queryByType(Host.class, false);
Iterator<Host> hosts = dbClient.queryIterativeObjects(Host.class, hostURIs);
while (hosts.hasNext()) {
Host host = hosts.next();
log.info("Examining Host (id={}) for boot volume upgrade", host.getId().toString());
// If there's no boot volume, there's nothing to upgrade.
if (NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
continue;
}
Volume volume = dbClient.queryObject(Volume.class, host.getBootVolumeId());
// if it's not in the DB, set it back to "null" on the host
if (volume == null) {
host.setBootVolumeId(NullColumnValueGetter.getNullURI());
dbClient.updateObject(host);
continue;
}
// If it's already a boot volume, move on
if (isVolumeBootVolume(volume)) {
continue;
}
// Add the tag.
ScopedLabelSet tagSet = volume.getTag();
if (tagSet == null) {
tagSet = new ScopedLabelSet();
volume.setTag(tagSet);
}
// Drop the new tag in the tag list
ScopedLabel tagLabel = new ScopedLabel(volume.getTenant().getURI().toString(), getBootVolumeTagName() + "=" + host.getId());
tagSet.add(tagLabel);
// Update the volume object
dbClient.updateObject(volume);
}
}
use of com.emc.storageos.db.client.model.ScopedLabelSet in project coprhd-controller by CoprHD.
the class VolumeFactory method newInstance.
public static <T extends Volume> Volume newInstance(T from) {
Volume to = new Volume();
to.setId(URIUtil.createId(Volume.class));
// DataObject properties
to.setLabel(from.getLabel());
if (from.getTag() != null && !from.getTag().isEmpty()) {
to.setTag(new ScopedLabelSet(from.getTag()));
}
// BlockObject properties
to.setStorageController(from.getStorageController());
to.setSystemType(from.getSystemType());
to.setProtectionController(from.getProtectionController());
to.setNativeId(from.getNativeId());
to.setNativeGuid(from.getNativeGuid());
if (from.getExtensions() != null && !from.getExtensions().isEmpty()) {
to.setExtensions(new StringMap(from.getExtensions()));
}
to.setConsistencyGroup(from.getConsistencyGroup());
if (from.getProtocol() != null && !from.getProtocol().isEmpty()) {
to.setProtocol(new StringSet(from.getProtocol()));
}
to.setVirtualArray(from.getVirtualArray());
to.setWWN(from.getWWN());
to.setDeviceLabel(from.getDeviceLabel());
to.setAlternateName(from.getAlternateName());
to.setRefreshRequired(from.getRefreshRequired());
to.setProject(from.getProject());
to.setCapacity(from.getCapacity());
to.setThinVolumePreAllocationSize(from.getThinVolumePreAllocationSize());
to.setThinlyProvisioned(from.getThinlyProvisioned());
to.setVirtualPool(from.getVirtualPool());
to.setPool(from.getPool());
to.setTenant(from.getTenant());
to.setProvisionedCapacity(from.getProvisionedCapacity());
to.setAllocatedCapacity(from.getAllocatedCapacity());
if (from.getAssociatedVolumes() != null && !from.getAssociatedVolumes().isEmpty()) {
to.setAssociatedVolumes(new StringSet(from.getAssociatedVolumes()));
}
to.setPersonality(from.getPersonality());
to.setAccessState(from.getAccessState());
to.setProtectionSet(from.getProtectionSet());
to.setRSetName(from.getRSetName());
to.setRpCopyName(from.getRpCopyName());
to.setInternalSiteName(from.getInternalSiteName());
to.setIsComposite(from.getIsComposite());
to.setCompositionType(from.getCompositionType());
to.setMetaMemberSize(from.getMetaMemberSize());
to.setMetaMemberCount(from.getMetaMemberCount());
if (from.getMirrors() != null && !from.getMirrors().isEmpty()) {
to.setMirrors(new StringSet(from.getMirrors()));
}
if (from.getRpTargets() != null && !from.getRpTargets().isEmpty()) {
to.setRpTargets(new StringSet(from.getRpTargets()));
}
to.setTotalMetaMemberCapacity(from.getTotalMetaMemberCapacity());
to.setAutoTieringPolicyUri(from.getAutoTieringPolicyUri());
to.setSyncActive(from.getSyncActive());
if (from.getFullCopies() != null && !from.getFullCopies().isEmpty()) {
to.setFullCopies(new StringSet(from.getFullCopies()));
}
to.setAssociatedSourceVolume(from.getAssociatedSourceVolume());
return to;
}
Aggregations