def checkForRemoval(self, userService: UserService) -> None: """ This method is used by UserService when a request for setInUse(False) is made This checks that the service can continue existing or not """ osManager = userService.deployed_service.osmanager # If os manager says "machine is persistent", do not try to delete "previous version" assigned machines doPublicationCleanup = True if not osManager else not osManager.getInstance( ).isPersistent() if doPublicationCleanup: remove = False with transaction.atomic(): userService = UserService.objects.select_for_update().get( id=userService.id) activePublication = userService.deployed_service.activePublication( ) if userService.publication and activePublication and userService.publication.id != activePublication.id: logger.debug( 'Old revision of user service, marking as removable: %s', userService) remove = True if remove: userService.remove()
def process_logout(userService: UserService, username: str) -> None: """ This method is static so can be invoked from elsewhere """ osManager: typing.Optional[ osmanagers.OSManager] = userService.getOsManagerInstance() if userService.in_use: # If already logged out, do not add a second logout (windows does this i.e.) osmanagers.OSManager.loggedOut(userService, username) if osManager: if osManager.isRemovableOnLogout(userService): logger.debug('Removable on logout: %s', osManager) userService.remove() else: userService.remove()