Search in sources :

Example 6 with ResourcesManagerBl

use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.

the class urn_perun_group_attribute_def_def_adName_o365muTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_group_attribute_def_def_adName_o365mu();
    attributeToCheck = new Attribute();
    sess = mock(PerunSessionImpl.class);
    reqAttribute1 = new Attribute();
    reqAttribute2 = new Attribute();
    // perunBl
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    // managers
    attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(perunBl.getResourcesManagerBl()).thenReturn(resourcesManagerBl);
    // specific methods
    when(attributesManagerBl.getAttribute(sess, resource1, AttributesManager.NS_RESOURCE_ATTR_DEF + ":adOuName")).thenReturn(reqAttribute1);
    when(attributesManagerBl.getAttribute(sess, resource2, AttributesManager.NS_RESOURCE_ATTR_DEF + ":adOuName")).thenReturn(reqAttribute2);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 7 with ResourcesManagerBl

use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.

the class ServicesManagerBlImpl method deleteService.

/*
	 * Tables with reference to service:
	 *   - service_required_attrs
	 *   - service_denials
	 *   - resource_services
	 *   - facility_service_destinations
	 *   - service_service_packages
	 *   - tasks
	 *   - authz
	 */
@Override
public void deleteService(PerunSession perunSession, Service service, boolean forceFlag) throws RelationExistsException, ServiceAlreadyRemovedException {
    List<Resource> assignedResources = this.getAssignedResources(perunSession, service);
    if (forceFlag) {
        // Remove all denials for this service
        getServicesManagerImpl().unblockService(service.getId());
        // Remove from assigned resources
        ResourcesManagerBl resourcesManager = getPerunBl().getResourcesManagerBl();
        for (Resource resource : assignedResources) {
            try {
                resourcesManager.removeService(perunSession, resource, service);
                // Remove from facility_service_destinations
                Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityById(perunSession, resource.getFacilityId());
                removeAllDestinations(perunSession, service, facility);
            } catch (ServiceNotAssignedException | FacilityNotExistsException e) {
                // should not happen
                throw new InternalErrorException("Error removing service", e);
            }
        }
        // Remove from service packages
        getServicesManagerImpl().removeServiceFromAllServicesPackages(perunSession, service);
        // Remove all related tasks
        getPerunBl().getTasksManagerBl().removeAllTasksForService(perunSession, service);
    } else {
        if (assignedResources.size() > 0) {
            throw new RelationExistsException("Service is defined on some resource");
        }
    }
    getServicesManagerImpl().removeAllRequiredAttributes(perunSession, service);
    getServicesManagerImpl().deleteService(perunSession, service);
    getPerunBl().getAuditer().log(perunSession, new ServiceDeleted(service));
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) RelationExistsException(cz.metacentrum.perun.core.api.exceptions.RelationExistsException) Resource(cz.metacentrum.perun.core.api.Resource) FacilityNotExistsException(cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException) DestinationAddedToServiceAndFacility(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility) Facility(cz.metacentrum.perun.core.api.Facility) BanServiceOnFacility(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnFacility) FreeAllDenialsOnFacility(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeAllDenialsOnFacility) FreeDenialServiceOnFacility(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeDenialServiceOnFacility) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) ServiceDeleted(cz.metacentrum.perun.audit.events.ServicesManagerEvents.ServiceDeleted) ServiceNotAssignedException(cz.metacentrum.perun.core.api.exceptions.ServiceNotAssignedException)

Example 8 with ResourcesManagerBl

use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.

the class urn_perun_resource_attribute_def_def_unixGroupName_namespaceTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_resource_attribute_def_def_unixGroupName_namespace();
    attributeToCheck = new Attribute();
    attributeToCheck.setFriendlyName("unixGID-namespace");
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(attributeToCheck);
    GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
    when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
    ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 9 with ResourcesManagerBl

use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.

the class urn_perun_resource_attribute_def_def_homeMountPointsTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_resource_attribute_def_def_homeMountPoints();
    attributeToCheck = new Attribute();
    reqAttribute = new Attribute();
    sess = mock(PerunSessionImpl.class);
    Facility facility = new Facility();
    List<String> value = new ArrayList<>();
    value.add("/example");
    attributeToCheck.setValue(value);
    reqAttribute.setValue(value);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":homeMountPoints")).thenReturn(reqAttribute);
    ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(perunBl.getResourcesManagerBl()).thenReturn(resourcesManagerBl);
    when(resourcesManagerBl.getFacility(sess, resource)).thenReturn(facility);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Aggregations

ResourcesManagerBl (cz.metacentrum.perun.core.bl.ResourcesManagerBl)9 Attribute (cz.metacentrum.perun.core.api.Attribute)8 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)8 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)8 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)8 Before (org.junit.Before)8 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)5 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)4 Facility (cz.metacentrum.perun.core.api.Facility)3 Resource (cz.metacentrum.perun.core.api.Resource)2 FacilitiesManagerBl (cz.metacentrum.perun.core.bl.FacilitiesManagerBl)2 ArrayList (java.util.ArrayList)2 BanServiceOnFacility (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnFacility)1 FreeAllDenialsOnFacility (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeAllDenialsOnFacility)1 FreeDenialServiceOnFacility (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeDenialServiceOnFacility)1 DestinationAddedToServiceAndFacility (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)1 ServiceDeleted (cz.metacentrum.perun.audit.events.ServicesManagerEvents.ServiceDeleted)1 FacilityNotExistsException (cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 RelationExistsException (cz.metacentrum.perun.core.api.exceptions.RelationExistsException)1