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();
}
}
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));
}
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;
}
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());
}
}
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);
}
Aggregations