Commit 90c0d90e authored by Benjamin Baer's avatar Benjamin Baer
Browse files

new Module logoutuser added

parent b7967ed4
import managementagent.rabbitmodules
import managementagent.utils
import os
import os.path
import logging
import re
import shutil
import subprocess
import pwd
import stat
import deployit.deployitlogging
__author__ = 'Benjamin Baer <benjamin.baer@math.uzh.ch>'
logger = logging.getLogger(deployit.deployitlogging.logger_name )
class LogoutUser(managementagent.RabbitModule):
"""Handling a ping request"""
def __init__(self):
super(LogoutUser, self).__init__('LogoutUser', 'logoutuser', 1)
def process_message(self, message):
instructions = message.body
reply_to = message.header['uuid']
try:
logger.debug('process message: %s', message)
username = instructions['username']
logger.debug('trying to find screensaver for %s', username)
process = subprocess.Popen(['/usr/bin/pkill -u %s' %(username,)])
process.wait()
if process.returncode != 0:
logger.warning("Failed to logout user %s", username)
self.send_reply(reply_to, -1, "Error executing pkill command (%i)" % (process.returncode,))
else:
logger.info("User %s logout succesfull", username)
self.send_reply(reply_to, 0, "Ended sessions for %s" % (username,))
except Exception as ex:
self.send_reply(reply_to, -1, repr(ex))
def initialize():
return LogoutUser().identification()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment