use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class WorkflowTest method createVolumeResource.
/**
* creates a volume resource
*
* @return
*/
private Volume createVolumeResource() {
TenantOrg tenant = new TenantOrg();
tenant.setId(URIUtil.createId(TenantOrg.class));
dbClient.createObject(tenant);
Project project = new Project();
project.setId(URIUtil.createId(Project.class));
project.setLabel("project1");
project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
dbClient.createObject(project);
Volume vol = new Volume();
vol.setId(URIUtil.createId(Volume.class));
vol.setLabel("volumeObject");
vol.setProject(new NamedURI(project.getId(), vol.getLabel()));
vol.setTenant(new NamedURI(tenant.getId(), vol.getLabel()));
dbClient.createObject(vol);
return vol;
}
use of com.emc.storageos.db.client.model.Project 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.Project in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method getVolumeFolderName.
private String getVolumeFolderName(URI projectURI, StorageSystem storage) {
String volumeGroupFolderName = "";
Project project = dbClient.queryObject(Project.class, projectURI);
DataSource dataSource = dataSourceFactory.createXtremIOVolumeFolderNameDataSource(project, storage);
volumeGroupFolderName = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.XTREMIO_VOLUME_FOLDER_NAME, storage.getSystemType(), dataSource);
return volumeGroupFolderName;
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doDeleteConsistencyGroup.
@Override
public void doDeleteConsistencyGroup(StorageSystem storage, final URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, final TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} doDeleteConsistencyGroup START ...", storage.getSerialNumber());
ServiceError serviceError = null;
try {
// Check if the consistency group exists
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
URI systemURI = storage.getId();
if (consistencyGroup == null || consistencyGroup.getInactive()) {
_log.info(String.format("%s is inactive or deleted", consistencyGroupId));
return;
}
String groupName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
// This will be null, if consistencyGroup references no system CG's for storage.
if (groupName == null) {
_log.info(String.format("%s contains no system CG for %s. Assuming it has already been deleted.", consistencyGroupId, systemURI));
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
return;
}
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
// We still need throw exception for standard CG.
if (!client.isVersion2() && consistencyGroup.isProtectedCG()) {
StringSet cgTypes = consistencyGroup.getTypes();
cgTypes.remove(BlockConsistencyGroup.Types.LOCAL.name());
consistencyGroup.setTypes(cgTypes);
_log.info("{} Operation deleteConsistencyGroup not supported for the xtremio array version");
} else {
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
Project cgProject = dbClient.queryObject(Project.class, consistencyGroup.getProject());
XtremIOTag tagDetails = XtremIOProvUtils.isTagAvailableInArray(client, cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
// If the tag has no references, delete the tag completely
if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) == 0) {
_log.info("Deleting the CG tag {} as no references found.", cgProject.getLabel());
client.deleteTag(cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
} else if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) > 0) {
deleteEntityTag(client, cgProject.getLabel(), groupName, clusterName);
}
// Finally remove the CG.
if (null != XtremIOProvUtils.isCGAvailableInArray(client, groupName, clusterName)) {
client.removeConsistencyGroup(groupName, clusterName);
}
if (keepRGName) {
return;
}
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCG(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
}
dbClient.updateObject(consistencyGroup);
_log.info("{} doDeleteConsistencyGroup END ...", storage.getSerialNumber());
} catch (Exception e) {
_log.error(String.format("Delete Consistency Group operation failed %s", e));
serviceError = DeviceControllerException.errors.jobFailed(e);
} finally {
if (serviceError != null) {
taskCompleter.error(dbClient, serviceError);
} else {
taskCompleter.ready(dbClient);
}
}
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class DbClientTest method testDeactivate.
@Test
public void testDeactivate() {
List<TenantOrg> tenants = createTenants(1, "tenant", "tenantIndex");
List<Project> projects = createProjects(1, tenants.iterator().next());
Project project = projects.iterator().next();
String msg = checkForDelete(project);
_logger.info(msg);
Assert.assertNull(msg);
_dbClient.markForDeletion(project);
List<URI> projectIds = new ArrayList<URI>();
projectIds.add(project.getId());
List<Project> queriedProjects = _dbClient.queryObject(Project.class, projectIds, true);
Assert.assertFalse(queriedProjects.iterator().hasNext());
}
Aggregations