Search in sources :

Example 1 with GroupResourceAssignment

use of cz.metacentrum.perun.core.api.GroupResourceAssignment in project perun by CESNET.

the class ResourceAssignmentActivator method activateGroupResourceAssignments.

/**
 * Tries to activate all group-resource assignments in PROCESSING or FAILED state.
 * The activations run synchronously in one thread.
 */
private void activateGroupResourceAssignments() {
    if (perunBl.isPerunReadOnly()) {
        log.warn("This instance is just read only so skip activation of group-resource assignments.");
        return;
    }
    try {
        log.debug("ResourceAssignmentActivator starting to activate group-resource assignments in PROCESSING or FAILED state.");
        List<GroupResourceAssignment> assignments = perunBl.getResourcesManagerBl().getGroupResourceAssignments(sess, List.of(GroupResourceStatus.PROCESSING, GroupResourceStatus.FAILED));
        for (GroupResourceAssignment assignment : assignments) {
            perunBl.getResourceAssignmentActivator().tryActivateAssignment(assignment);
        }
    } catch (Exception e) {
        log.error("Error during activating group-resource assignments: ", e);
    }
}
Also used : GroupResourceAssignment(cz.metacentrum.perun.core.api.GroupResourceAssignment)

Example 2 with GroupResourceAssignment

use of cz.metacentrum.perun.core.api.GroupResourceAssignment in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getGroupResourceAssignmentsWithAllStatuses.

@Test
public void getGroupResourceAssignmentsWithAllStatuses() throws Exception {
    System.out.println(CLASS_NAME + "getGroupResourceAssignmentsWithAllStatuses");
    vo = setUpVo();
    member = setUpMember(vo);
    group = setUpGroup(vo, member);
    facility = setUpFacility();
    resource = setUpResource();
    Resource resource2 = setUpResource2();
    resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
    resourcesManager.assignGroupToResource(sess, group, resource2, false, false, false);
    resourcesManager.deactivateGroupResourceAssignment(sess, group, resource2);
    GroupResourceAssignment expectedAssignment = new GroupResourceAssignment(group, resource, GroupResourceStatus.ACTIVE, null);
    GroupResourceAssignment expectedAssignment2 = new GroupResourceAssignment(group, resource2, GroupResourceStatus.INACTIVE, null);
    List<GroupResourceAssignment> assignments = perun.getResourcesManagerBl().getGroupResourceAssignments(sess, null);
    assertThat(assignments).containsExactlyInAnyOrder(expectedAssignment, expectedAssignment2);
    assignments = perun.getResourcesManagerBl().getGroupResourceAssignments(sess, Collections.emptyList());
    assertThat(assignments).containsExactlyInAnyOrder(expectedAssignment, expectedAssignment2);
    assignments = perun.getResourcesManagerBl().getGroupResourceAssignments(sess, Arrays.asList(GroupResourceStatus.values()));
    assertThat(assignments).containsExactlyInAnyOrder(expectedAssignment, expectedAssignment2);
}
Also used : GroupResourceAssignment(cz.metacentrum.perun.core.api.GroupResourceAssignment) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) Resource(cz.metacentrum.perun.core.api.Resource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) RichResource(cz.metacentrum.perun.core.api.RichResource) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 3 with GroupResourceAssignment

use of cz.metacentrum.perun.core.api.GroupResourceAssignment in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getGroupResourceAssignmentsWithGivenStatus.

@Test
public void getGroupResourceAssignmentsWithGivenStatus() throws Exception {
    System.out.println(CLASS_NAME + "getGroupResourceAssignmentsWithGivenStatus");
    vo = setUpVo();
    member = setUpMember(vo);
    group = setUpGroup(vo, member);
    facility = setUpFacility();
    resource = setUpResource();
    Resource resource2 = setUpResource2();
    List<GroupResourceAssignment> assignments = perun.getResourcesManagerBl().getGroupResourceAssignments(sess, List.of(GroupResourceStatus.ACTIVE));
    assertThat(assignments).isEmpty();
    resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
    resourcesManager.assignGroupToResource(sess, group, resource2, false, false, false);
    resourcesManager.deactivateGroupResourceAssignment(sess, group, resource2);
    GroupResourceAssignment expectedAssignment = new GroupResourceAssignment(group, resource, GroupResourceStatus.ACTIVE, null);
    assignments = perun.getResourcesManagerBl().getGroupResourceAssignments(sess, List.of(GroupResourceStatus.ACTIVE));
    assertThat(assignments).containsExactly(expectedAssignment);
}
Also used : GroupResourceAssignment(cz.metacentrum.perun.core.api.GroupResourceAssignment) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) Resource(cz.metacentrum.perun.core.api.Resource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) RichResource(cz.metacentrum.perun.core.api.RichResource) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

GroupResourceAssignment (cz.metacentrum.perun.core.api.GroupResourceAssignment)3 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)2 AssignedResource (cz.metacentrum.perun.core.api.AssignedResource)2 BanOnResource (cz.metacentrum.perun.core.api.BanOnResource)2 EnrichedResource (cz.metacentrum.perun.core.api.EnrichedResource)2 Resource (cz.metacentrum.perun.core.api.Resource)2 RichResource (cz.metacentrum.perun.core.api.RichResource)2 Test (org.junit.Test)2