Search in sources :

Example 11 with ProjectRestRep

use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.

the class Projects method edit.

@FlashException(value = "list", keep = true)
public static void edit(String id) {
    ProjectRestRep viprProject = ProjectUtils.getProject(id);
    if (viprProject == null) {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        list();
    }
    QuotaInfo quota = null;
    if (Security.isTenantAdmin()) {
        quota = ProjectUtils.getQuota(id);
    }
    if (viprProject != null) {
        ProjectForm project = new ProjectForm().from(viprProject, quota);
        project.aclEntries = AclEntryForm.loadAclEntryForms(ProjectUtils.getACLs(id));
        addRenderArgs();
        render(project);
    } else {
        flash.error(MessagesUtils.get("projects.unknown", id));
        list();
    }
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 12 with ProjectRestRep

use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.

the class Projects method listJson.

@FlashException(value = "list", keep = true)
public static void listJson() {
    String userId = Security.getUserInfo().getIdentifier();
    List<ProjectRestRep> viprProjects = ProjectUtils.getProjects(Models.currentAdminTenant());
    List<ProjectsDataTable.Project> projects = Lists.newArrayList();
    for (ProjectRestRep viprProject : viprProjects) {
        if (Security.isTenantAdmin() || (Security.isProjectAdmin() && StringUtils.equalsIgnoreCase(userId, viprProject.getOwner()))) {
            projects.add(new ProjectsDataTable.Project(viprProject));
        }
    }
    renderJSON(DataTablesSupport.createJSON(projects, params));
}
Also used : ProjectsDataTable(models.datatable.ProjectsDataTable) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 13 with ProjectRestRep

use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.

the class TestBlockStorageUtils method prepare.

static List<URI> prepare(ViPRCoreClient client) throws URISyntaxException {
    List<URI> returnList = new ArrayList<>();
    ProjectRestRep project = client.projects().get(new URI("urn:storageos:Project:3e1ef32b-3091-4a83-9fac-4a2a3bc30413:global"));
    for (BlockSnapshotRestRep r : client.blockSnapshots().findByProject(project)) {
        returnList.add(r.getId());
    }
    for (VolumeRestRep r : client.blockVolumes().findByProject(project)) {
        returnList.add(r.getId());
    }
    return returnList;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ArrayList(java.util.ArrayList) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 14 with ProjectRestRep

use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.

the class ViPRClientHelper method deactiveAllTenants.

public void deactiveAllTenants() {
    URI rootTenantID = viPRCoreClient.getUserTenantId();
    List<String> roles = new ArrayList<String>();
    roles.add("TENANT_ADMIN");
    RoleAssignmentEntry roleAssignmentEntry = new RoleAssignmentEntry();
    roleAssignmentEntry.setSubjectId("root");
    roleAssignmentEntry.setRoles(roles);
    List<RoleAssignmentEntry> add = new ArrayList<RoleAssignmentEntry>();
    add.add(roleAssignmentEntry);
    RoleAssignmentChanges roleChanges = new RoleAssignmentChanges();
    roleChanges.setAdd(add);
    // grant TenantAdmin to root on provider tenant
    viPRCoreClient.tenants().updateRoleAssignments(rootTenantID, roleChanges);
    List<TenantOrgRestRep> tenantList = viPRCoreClient.tenants().getAllSubtenants(rootTenantID);
    for (TenantOrgRestRep tenantOrgRestRep : tenantList) {
        // grant TenantAdmin to root on the Tenant
        viPRCoreClient.tenants().updateRoleAssignments(tenantOrgRestRep.getId(), roleChanges);
        List<ProjectRestRep> projectList = viPRCoreClient.projects().getByTenant(tenantOrgRestRep.getId());
        for (ProjectRestRep projectRestRep : projectList) {
            viPRCoreClient.projects().deactivate(projectRestRep.getId());
        }
        viPRCoreClient.tenants().deactivate(tenantOrgRestRep.getId());
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI)

Example 15 with ProjectRestRep

use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSourceVolumes.

@Asset("sourceBlockVolumeForAddToApplication")
@AssetDependencies({ "consistencyGroupAll" })
public List<AssetOption> getApplicationSourceVolumes(AssetOptionsContext ctx, URI cg) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupList applications = client.application().getApplications();
    List<URI> applicationIds = new ArrayList<URI>();
    for (NamedRelatedResourceRep volumeGroup : applications.getVolumeGroups()) {
        VolumeGroupRestRep vg = client.application().getApplication(volumeGroup.getId());
        if (vg.getRoles().contains("COPY")) {
            applicationIds.add(volumeGroup.getId());
        }
    }
    ResourceFilter<VolumeRestRep> cgFilter = new BlockVolumeConsistencyGroupFilter(cg, false);
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<VolumeRestRep> volumes = new ArrayList<VolumeRestRep>();
    for (ProjectRestRep project : projects) {
        volumes.addAll(listSourceVolumes(api(ctx), project.getId(), cgFilter));
    }
    List<VolumeRestRep> volumesNotInApplication = new ArrayList<VolumeRestRep>();
    for (VolumeRestRep volume : volumes) {
        if (volume.getVolumeGroups() != null && !volume.getVolumeGroups().isEmpty()) {
            boolean volumeIsInApplication = false;
            for (RelatedResourceRep rep : volume.getVolumeGroups()) {
                if (applicationIds.contains(rep.getId())) {
                    volumeIsInApplication = true;
                    break;
                }
            }
            if (!volumeIsInApplication) {
                volumesNotInApplication.add(volume);
            }
        } else {
            volumesNotInApplication.add(volume);
        }
    }
    return createVolumeOptions(null, volumesNotInApplication);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) BlockVolumeConsistencyGroupFilter(com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

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