def reserve_hosts(host_filter_data, username=None): """ :param host_filter_data: Filters out which hosts to reserve. :param username: login of the user reserving hosts :type username: str """ hosts = models.Host.query_objects(host_filter_data) reservations.create(hosts_to_reserve=[h.hostname for h in hosts], username=username)
def _create_basic_reservation_data(self): ''' Creates the basic data used on tests ''' self.reservation_hosts = [] for hostname in ('reshost1', 'reshost2', 'reshost3', 'reshost4'): host = models.Host.objects.create(hostname=hostname) self.reservation_hosts.append(host) self.user1 = models.User.objects.create(login='******') self.user2 = models.User.objects.create(login='******') reservations.create(['reshost4'], self.user2.login)
def _create_basic_reservation_data(self): ''' Creates the basic data used on tests ''' self.reservation_hosts = [] for hostname in ('reshost1', 'reshost2', 'reshost3', 'reshost4'): host = models.Host.objects.create(hostname=hostname) self.reservation_hosts.append(host) self.user1 = models.User.objects.create(login='******') self.user2 = models.User.objects.create(login='******') reservations.create(['reshost4'], self.user2.login)
def reserve_hosts(host_filter_data, username=None): """ Reserve some hosts. :param host_filter_data: Filters out which hosts to reserve. :param username: login of the user reserving hosts :type username: str :return: None. """ hosts = models.Host.query_objects(host_filter_data) reservations.create(hosts_to_reserve=[h.hostname for h in hosts], username=username)
def test_normal_reserve_lifecycle(self): ''' Tests the normal reservation lifecycle A few hosts will be reserved for a given user, and then a second user tries to access the host. ''' # reserve few hosts host_names = [h.hostname for h in self.reservation_hosts[0:2]] reservations.create(host_names, self.user1.login) # second user cannot access it self.assertRaises(models.AclAccessViolation, models.AclGroup.check_for_acl_violation_hosts, self.reservation_hosts[0:2], self.user2.login) reservations.release(host_names, self.user1.login) models.AclGroup.check_for_acl_violation_hosts( self.reservation_hosts[0:2], self.user2.login)
def test_normal_reserve_lifecycle(self): ''' Tests the normal reservation lifecycle A few hosts will be reserved for a given user, and then a second user tries to access the host. ''' #reserve few hosts host_names = [h.hostname for h in self.reservation_hosts[0:2]] reservations.create(host_names, self.user1.login) #second user cannot access it self.assertRaises(models.AclAccessViolation, models.AclGroup.check_for_acl_violation_hosts, self.reservation_hosts[0:2], self.user2.login) reservations.release(host_names, self.user1.login) models.AclGroup.check_for_acl_violation_hosts( self.reservation_hosts[0:2], self.user2.login)