Example #1
0
    def startRemovalOf(self, servicePool: ServicePool):
        if (
                servicePool.service is None
        ):  # Maybe an inconsistent value? (must not, but if no ref integrity in db, maybe someone "touched.. ;)")
            logger.error('Found service pool %s without service',
                         servicePool.name)
            servicePool.delete(
            )  # Just remove it "a las bravas", the best we can do
            return

        # Get publications in course...., that only can be one :)
        logger.debug('Removal process of %s', servicePool)

        publishing = servicePool.publications.filter(state=State.PREPARING)
        for pub in publishing:
            pub.cancel()
        # Now all publishments are canceling, let's try to cancel cache and assigned
        uServices: typing.Iterable[
            UserService] = servicePool.userServices.filter(
                state=State.PREPARING)
        for userService in uServices:
            logger.debug('Canceling %s', userService)
            userService.cancel()
        # Nice start of removal, maybe we need to do some limitation later, but there should not be too much services nor publications cancelable at once
        servicePool.state = State.REMOVING
        servicePool.name += ' (removed)'
        servicePool.save()
Example #2
0
    def setFallbackAccess(self, item: ServicePool):
        self.ensureAccess(item, permissions.PERMISSION_MANAGEMENT)

        fallback = self._params.get('fallbackAccess')
        if fallback != '':
            logger.debug('Setting fallback of %s to %s', item.name, fallback)
            item.fallbackAccess = fallback
            item.save()
        return item.fallbackAccess