use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class ConsistencyGroupProvider method getAllConsistencyGroup.
@Asset("consistencyGroupAll")
public List<AssetOption> getAllConsistencyGroup(AssetOptionsContext ctx) {
List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
for (ProjectRestRep project : projects) {
cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
}
List<AssetOption> options = createBaseResourceOptions(cgs);
return options;
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class ConsistencyGroupProvider method getConsistencyGroupFilters.
@Asset("consistencyGroupFilter")
public List<AssetOption> getConsistencyGroupFilters(AssetOptionsContext ctx) {
List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
for (ProjectRestRep project : projects) {
cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
}
List<AssetOption> options = createBaseResourceOptions(cgs);
options.add(0, new AssetOption("None", "None"));
return options;
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class BlockStorageUtils method getVolumeTagCommand.
/**
* Returns the viprcli command for adding a tag to a block volume
*
* @param blockObjectId the id of the block object
* @param tagName the tag name
* @param tagValue the tag value
* @return viprcli command
*/
public static String getVolumeTagCommand(URI blockObjectId, String tagName, String tagValue) {
BlockObjectRestRep blockObject = getBlockResource(blockObjectId);
URI projectId = getProjectId(blockObject);
ProjectRestRep project = getProject(projectId);
TenantOrgRestRep tenant = getTenant(project.getTenant().getId());
return ExecutionUtils.getMessage("viprcli.volume.tag", blockObject.getName(), tenant.getName(), project.getName(), tagName, tagValue);
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class ViPRClientApp method createBlockVolumeForHost.
public void createBlockVolumeForHost() {
List<HostRestRep> hosts = client.hosts().getByUserTenant(HostTypeFilter.ESX.not());
// User choice
HostRestRep selectedHost = chooseHost(hosts);
List<VirtualArrayRestRep> virtualArrays = client.varrays().findByConnectedHost(selectedHost);
// User choice
VirtualArrayRestRep selectedVirtualArray = chooseVirtualArray(virtualArrays);
List<BlockVirtualPoolRestRep> virtualPools = client.blockVpools().getByVirtualArray(selectedVirtualArray.getId());
// User choice
BlockVirtualPoolRestRep selectedVirtualPool = chooseVirtualPool(virtualPools);
List<ProjectRestRep> projects = client.projects().getByUserTenant();
// User choice
ProjectRestRep selectedProject = chooseProject(projects);
URI volumeId = createVolume(selectedVirtualArray, selectedVirtualPool, selectedProject);
List<ExportGroupRestRep> exports = new ArrayList<>();
if (exports.isEmpty()) {
createExport(volumeId, selectedHost, selectedVirtualArray, selectedProject);
} else {
addVolumeToExport(volumeId, exports.get(0));
}
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method testUserGroupCreateWithProjectAclBACKUP.
@Test
public void testUserGroupCreateWithProjectAclBACKUP() throws NoSuchAlgorithmException {
final String testName = "testUserGroupCreateWithProjectAclBACKUP - ";
createDefaultAuthnProvider(testName + DEFAULT_AUTH_PROVIDER_CREATION);
// Create a test tenant.
URI testTenantId = createTestTenant();
// Remove the group just created tenant user mapping.
// So that, all the users in the domain can be assigned with
// tenant roles. Here getting the ldapGroup(2) as that is the
// one used as default one for creating the tenant.
removeUserMappingGroups(testTenantId, getLDAPGroup(2));
// Create a test project for the just created tenant.
URI projectId = createTestProject(testTenantId);
String aclAssignmentsApi = getProjectACLAssignmentApi(projectId);
boolean isGroup = false;
// Assigning all the project acls BACKUP ldapViPRUser5.
List<String> acls = new ArrayList<String>();
acls.add(getACL(1));
String userNameWithDomain = getUserWithDomain(4);
ACLEntry aclAssignmentEntry1 = getACLAssignmentEntry(userNameWithDomain, acls, isGroup);
ACLAssignmentChanges aclAssignmentChanges = getDefaultACLAssignmentChanges();
aclAssignmentChanges.getAdd().add(aclAssignmentEntry1);
ACLAssignments aclAssignments = rSys.path(aclAssignmentsApi).put(ACLAssignments.class, aclAssignmentChanges);
validateACLAssignmentsSuccess(aclAssignments, userNameWithDomain, isGroup);
// Create a user ldapViPRUser5.
BalancedWebResource ldapViPRUser5 = getHttpsClient(userNameWithDomain, getLDAPUserPassword());
ProjectRestRep ldapViPRUser5ProjectInfo = ldapViPRUser5.path(getProjectApi(projectId)).get(ProjectRestRep.class);
Assert.assertEquals(projectId, ldapViPRUser5ProjectInfo.getId());
UserGroupCreateParam createParam = getDefaultUserGroupCreateParam();
// Try to create a user group by non security admin user (ldapViPRUser5).
ClientResponse clientResponseUserGroupCreate = ldapViPRUser5.path(getTestApi()).post(ClientResponse.class, createParam);
String partialErrorMessage = ERROR_INSUFFICIENT_PERMISSION_FOR_USER;
partialErrorMessage = String.format(partialErrorMessage, userNameWithDomain.toLowerCase());
validateUserGroupBadRequest(HttpStatus.SC_FORBIDDEN, partialErrorMessage, clientResponseUserGroupCreate);
// Only Tenant Admin and Project owner has a readonly access.
clientResponseUserGroupCreate = ldapViPRUser5.path(getTestApi()).get(ClientResponse.class);
validateUserGroupBadRequest(HttpStatus.SC_FORBIDDEN, partialErrorMessage, clientResponseUserGroupCreate);
// Test the bulk api. Here expecting false for get, as ldapViPRUser5
// is not a sysadmin or sysmonitor and expecting false for post, as
// ldapViPRUser5 is tenant admin, project owner, security admin.
testUserGroupBulkApi(ldapViPRUser5, false, false);
// Now remove the user group from the acl assignments.
aclAssignmentChanges.getAdd().clear();
aclAssignmentChanges.getRemove().add(aclAssignmentEntry1);
aclAssignments = rSys.path(aclAssignmentsApi).put(ACLAssignments.class, aclAssignmentChanges);
validateACLAssignmentsRemove(aclAssignments, userNameWithDomain, true);
// Now the user should not have any acls.
ClientResponse clientResponseProjectInfo = ldapViPRUser5.path(getProjectApi(projectId)).get(ClientResponse.class);
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, clientResponseProjectInfo.getStatus());
}
Aggregations