Search in sources :

Example 46 with Service

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

the class ServicesManagerEntryIntegrationTest method getServiceByName.

@Test
public void getServiceByName() throws Exception {
    System.out.println(CLASS_NAME + "getServiceByName");
    service = setUpService();
    assertNotNull("unable to create service", service);
    Service returnedService = perun.getServicesManager().getServiceByName(sess, service.getName());
    assertEquals("cannot get service by Name", returnedService, service);
}
Also used : Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 47 with Service

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

the class ServicesManagerEntryIntegrationTest method removeRequiredAttributesWhenServiceNotExists.

@Test(expected = ServiceNotExistsException.class)
public void removeRequiredAttributesWhenServiceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "removeRequiredAttributesWhenServiceNotExists");
    List<AttributeDefinition> attributes = setUpRequiredAttribute();
    perun.getServicesManager().removeRequiredAttributes(sess, new Service(), attributes);
// shouldn't find service
}
Also used : AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 48 with Service

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

the class ServicesManagerBlImpl method addDestination.

public Destination addDestination(PerunSession perunSession, List<Service> services, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
    if (!getServicesManagerImpl().destinationExists(perunSession, destination)) {
        try {
            //Try to get the destination without id
            destination = getServicesManagerImpl().getDestination(perunSession, destination.getDestination(), destination.getType());
        } catch (DestinationNotExistsException ex) {
            try {
                destination = createDestination(perunSession, destination);
            } catch (DestinationExistsException e) {
                throw new ConsistencyErrorException(e);
            }
        }
    }
    for (Service s : services) {
        if (!getServicesManagerImpl().destinationExists(perunSession, s, facility, destination)) {
            getServicesManagerImpl().addDestination(perunSession, s, facility, destination);
            getPerunBl().getAuditer().log(perunSession, "{} added to {} and {}.", destination, s, facility);
        }
    }
    return destination;
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) DestinationNotExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException) Service(cz.metacentrum.perun.core.api.Service) DestinationExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationExistsException)

Example 49 with Service

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

the class ServicesManagerBlImpl method addDestinationsForAllServicesOnFacility.

@Override
public List<Destination> addDestinationsForAllServicesOnFacility(PerunSession sess, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
    List<Service> services = this.getAssignedServices(sess, facility);
    List<Destination> destinations = new ArrayList<Destination>();
    for (Service service : services) {
        destinations.add(this.addDestination(sess, service, facility, destination));
    }
    return destinations;
}
Also used : RichDestination(cz.metacentrum.perun.core.api.RichDestination) Destination(cz.metacentrum.perun.core.api.Destination) ArrayList(java.util.ArrayList) Service(cz.metacentrum.perun.core.api.Service)

Example 50 with Service

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

the class ExecServiceDependencyDaoTest method beforeClass.

@Before
public void beforeClass() {
    try {
        perunSession = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
    } catch (InternalErrorException e) {
        log.error(e.toString());
    }
    jdbcTemplate = new JdbcPerunTemplate(dataSource);
    // Test Owner
    int newOwnerId = 0;
    try {
        newOwnerId = Utils.getNewId(jdbcTemplate, "owners_id_seq");
    } catch (InternalErrorException e) {
        log.error(e.toString(), e);
    }
    testOwner = new Owner();
    testOwner.setContact("Call me babe");
    testOwner.setType(OwnerType.technical);
    testOwner.setName("Tester-" + Long.toHexString(System.currentTimeMillis()));
    testOwner.setId(newOwnerId);
    jdbcTemplate.update("insert into owners(id, name, contact, type) values (?,?,?,?)", newOwnerId, testOwner.getName(), testOwner.getContact(), testOwner.getType().toString());
    // Test Service #1
    testService1 = new Service();
    testService1.setName("Test_service_1_" + Long.toHexString(System.currentTimeMillis()));
    // Test Service #2
    testService2 = new Service();
    testService2.setName("Test_service_2_" + Long.toHexString(System.currentTimeMillis()));
    try {
        testService1.setId(servicesManager.createService(perunSession, testService1).getId());
        testService2.setId(servicesManager.createService(perunSession, testService2).getId());
    } catch (InternalErrorException e) {
        log.error(e.toString());
    } catch (PrivilegeException e) {
        log.error(e.toString());
    } catch (ServiceExistsException e) {
        log.error(e.toString());
    }
    // Test ExecService #1 (Parent:testService1)
    testExecService1 = new ExecService();
    testExecService1.setDefaultDelay(1);
    testExecService1.setDefaultRecurrence(1);
    testExecService1.setEnabled(true);
    testExecService1.setService(testService1);
    testExecService1.setScript("/hellish/test/script");
    testExecService1.setExecServiceType(ExecServiceType.GENERATE);
    try {
        testExecService1.setId(execServiceDao.insertExecService(testExecService1));
    } catch (InternalErrorException e) {
        log.error(e.toString(), e);
    }
    // Test ExecService #2 (Parent:testService1)
    testExecService2 = new ExecService();
    testExecService2.setDefaultDelay(2);
    testExecService2.setDefaultRecurrence(2);
    testExecService2.setEnabled(true);
    testExecService2.setService(testService1);
    testExecService2.setScript("/hellish/test/script2");
    testExecService2.setExecServiceType(ExecServiceType.SEND);
    try {
        testExecService2.setId(execServiceDao.insertExecService(testExecService2));
    } catch (InternalErrorException e) {
        log.error(e.toString(), e);
    }
    // Test ExecService #3 (Parent:testService2)
    testExecService3 = new ExecService();
    testExecService3.setDefaultDelay(3);
    testExecService3.setDefaultRecurrence(3);
    testExecService3.setEnabled(true);
    testExecService3.setService(testService2);
    testExecService3.setScript("/hellish/test/script3");
    testExecService3.setExecServiceType(ExecServiceType.SEND);
    try {
        testExecService3.setId(execServiceDao.insertExecService(testExecService3));
    } catch (InternalErrorException e) {
        log.error(e.toString(), e);
    }
}
Also used : JdbcPerunTemplate(org.springframework.jdbc.core.JdbcPerunTemplate) Owner(cz.metacentrum.perun.core.api.Owner) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) PerunClient(cz.metacentrum.perun.core.api.PerunClient) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) Service(cz.metacentrum.perun.core.api.Service) ServiceExistsException(cz.metacentrum.perun.core.api.exceptions.ServiceExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Before(org.junit.Before)

Aggregations

Service (cz.metacentrum.perun.core.api.Service)66 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)44 Test (org.junit.Test)44 ArrayList (java.util.ArrayList)11 Facility (cz.metacentrum.perun.core.api.Facility)10 Destination (cz.metacentrum.perun.core.api.Destination)9 Member (cz.metacentrum.perun.core.api.Member)8 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)8 User (cz.metacentrum.perun.core.api.User)6 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)6 Attribute (cz.metacentrum.perun.core.api.Attribute)5 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)5 Group (cz.metacentrum.perun.core.api.Group)5 Host (cz.metacentrum.perun.core.api.Host)5 Resource (cz.metacentrum.perun.core.api.Resource)5 RichDestination (cz.metacentrum.perun.core.api.RichDestination)5 RichUser (cz.metacentrum.perun.core.api.RichUser)5 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)4 PerunClient (cz.metacentrum.perun.core.api.PerunClient)4 PerunPrincipal (cz.metacentrum.perun.core.api.PerunPrincipal)4