use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class AddFooToProjectTest method verifyPreparedData.
@Override
protected void verifyPreparedData() throws Exception {
// make sure the project is saved
List<URI> ids = dbClient.queryByType(Project.class, true);
Assert.assertEquals(1, TestDBClientUtils.size(ids));
Project project = dbClient.queryObject(Project.class, ids.get(0));
Assert.assertNotNull(project);
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class AddPrefixToProjectOwner method prepareData.
@Override
protected void prepareData() throws Exception {
// prepare a Project object for migration
Project project = new Project();
project.setId(URIUtil.createId(Project.class));
project.setLabel("project1");
project.setOwner("foo1");
dbClient.createObject(project);
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class AddPrefixToProjectOwner method verifyPreparedData.
@Override
protected void verifyPreparedData() throws Exception {
// make sure that the Project object is persisted
List<URI> ids = dbClient.queryByType(Project.class, true);
Project project = null;
int count = 0;
for (URI id : ids) {
project = dbClient.queryObject(Project.class, id);
count++;
}
Assert.assertNotNull(project);
Assert.assertEquals(count, 1);
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class FilePolicyAssignWorkflowCompleter method updatePolicyAssignedResources.
private void updatePolicyAssignedResources(DbClient dbClient, FilePolicy filePolicy, Status status, ServiceCoded coded) {
for (URI resourceURI : assignToResource) {
filePolicy.addAssignedResources(resourceURI);
FilePolicyApplyLevel applyAt = FilePolicyApplyLevel.valueOf(filePolicy.getApplyAt());
switch(applyAt) {
case project:
Project project = dbClient.queryObject(Project.class, resourceURI);
project.addFilePolicy(filePolicy.getId());
dbClient.updateObject(project);
if (projectVPool != null) {
filePolicy.setFilePolicyVpool(projectVPool);
}
break;
case vpool:
VirtualPool vpool = dbClient.queryObject(VirtualPool.class, resourceURI);
vpool.addFilePolicy(filePolicy.getId());
dbClient.updateObject(vpool);
break;
default:
break;
}
}
dbClient.updateObject(filePolicy);
}
use of com.emc.storageos.db.client.model.Project in project coprhd-controller by CoprHD.
the class FilePolicyUnAssignWorkflowCompleter method updatePolicyUnAssignedResources.
protected void updatePolicyUnAssignedResources(DbClient dbClient, FilePolicy filePolicy, Status status, ServiceCoded coded) {
for (URI resourceURI : unassignFromResource) {
filePolicy.removeAssignedResources(resourceURI);
FilePolicyApplyLevel applyLevel = FilePolicyApplyLevel.valueOf(filePolicy.getApplyAt());
switch(applyLevel) {
case vpool:
VirtualPool vpool = dbClient.queryObject(VirtualPool.class, resourceURI);
vpool.removeFilePolicy(filePolicy.getId());
dbClient.updateObject(vpool);
break;
case project:
Project project = dbClient.queryObject(Project.class, resourceURI);
project.removeFilePolicy(project, filePolicy.getId());
dbClient.updateObject(project);
break;
case file_system:
FileShare fs = dbClient.queryObject(FileShare.class, resourceURI);
fs.removeFilePolicy(filePolicy.getId());
dbClient.updateObject(fs);
break;
default:
_log.error("Not a valid policy apply level: " + applyLevel);
}
}
if (filePolicy.getAssignedResources() == null || filePolicy.getAssignedResources().isEmpty()) {
// remove the file policy vpool
if (!NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool())) {
filePolicy.setFilePolicyVpool(NullColumnValueGetter.getNullURI());
}
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, dbClient);
}
dbClient.updateObject(filePolicy);
}
Aggregations