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