Minor fixes for actor for linux

This commit is contained in:
Adolfo Gómez García 2017-02-22 10:38:27 +01:00
parent a83e218679
commit bd3d0dd006
3 changed files with 21 additions and 3 deletions

View File

@ -36,6 +36,7 @@ from udsactor import operations
from udsactor.service import CommonService
from udsactor.service import initCfg
from udsactor.service import IPC_PORT
from udsactor import ipc
from udsactor.log import logger
@ -58,6 +59,8 @@ except Exception: # Platform may not include prctl, so in case it's not availab
class UDSActorSvc(Daemon, CommonService):
rebootMachineAfterOp = False
def __init__(self, args=None):
Daemon.__init__(self, '/var/run/udsa.pid')
CommonService.__init__(self)
@ -67,6 +70,12 @@ class UDSActorSvc(Daemon, CommonService):
Renames the computer, and optionally sets a password for an user
before this
'''
hostName = operations.getComputerName()
if hostName.lower() == name.lower():
logger.info('Computer name is now {}'.format(hostName))
self.setReady()
return
# Check for password change request for an user
if user is not None:
@ -80,13 +89,20 @@ class UDSActorSvc(Daemon, CommonService):
'Could not change password for user {} (maybe invalid current password is configured at broker): {} '.format(user, unicode(e)))
renamer.rename(name)
self.setReady()
if self.rebootMachineAfterOp is False:
self.setReady()
else:
logger.info('Rebooting computer to activate new name {}'.format(name))
self.reboot()
def joinDomain(self, name, domain, ou, account, password):
logger.fatal('Join domain is not supported on linux platforms right now')
def run(self):
initCfg()
localCfg = initCfg() # Gets a local copy of config to get "reboot"
self.rebootMachineAfterOp = localCfg.get('reboot', 'false') == 'true'
logger.debug('Running Daemon')
set_proctitle('UDSActorDaemon')

View File

@ -70,6 +70,8 @@ def initCfg():
cfg = None
break
return cfg
class CommonService(object):
def __init__(self):

View File

@ -114,7 +114,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
operations.renameComputer(name)
# Reboot just after renaming
logger.info('Rebooting computer got activate new name {}'.format(name))
logger.info('Rebooting computer to activate new name {}'.format(name))
self.reboot()
def oneStepJoin(self, name, domain, ou, account, password):