Search in sources :

Example 16 with ProjectRestRep

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;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Example 17 with ProjectRestRep

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;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Example 18 with ProjectRestRep

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);
}
Also used : TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 19 with ProjectRestRep

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));
    }
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ArrayList(java.util.ArrayList) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI)

Example 20 with ProjectRestRep

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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ArrayList(java.util.ArrayList) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)24 URI (java.net.URI)13 ArrayList (java.util.ArrayList)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 FlashException (controllers.util.FlashException)4 Test (org.junit.Test)4 Asset (com.emc.sa.asset.annotation.Asset)3 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)2 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 HostRestRep (com.emc.storageos.model.host.HostRestRep)2 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)2 ProjectUpdateParam (com.emc.storageos.model.project.ProjectUpdateParam)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1