mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Linux actor seems to start working, a bit to go anyway to finish debian
package (fix init scripts, create a couple of shell scripts to "easy" management, etc..)
This commit is contained in:
parent
15ef761d47
commit
dca366b334
@ -26,8 +26,8 @@ case "$1" in
|
||||
|
||||
echo "[uds]" > /etc/udsactor/udsactor.cfg
|
||||
echo "host = $host" >> /etc/udsactor/udsactor.cfg
|
||||
echo "logLevel = 20000" >> /etc/udsactor/udsactor.cfg
|
||||
echo "ssl = ssl" >> /etc/udsactor/udsactor.cfg
|
||||
echo "logLevel = 30000" >> /etc/udsactor/udsactor.cfg
|
||||
echo "ssl = $ssl" >> /etc/udsactor/udsactor.cfg
|
||||
echo "masterKey = $masterKey" >> /etc/udsactor/udsactor.cfg
|
||||
|
||||
fi
|
||||
|
@ -2,7 +2,7 @@ Package: udsactor
|
||||
Version: 1.7.0
|
||||
Architecture: all
|
||||
Maintainer: Adolfo Gómez García <agomez@virtualcable.es>
|
||||
Installed-Size: 205
|
||||
Installed-Size: 206
|
||||
Depends: python-requests (>= 0.8.2), python-qt4 (>= 4.9), python-six (>= 1.1), python (>= 2.7), debconf (>= 0.5) | debconf-2.0
|
||||
Section: admin
|
||||
Priority: optional
|
||||
|
@ -5,22 +5,22 @@ fc4e41285d388d33b5f149ebe4b93236 usr/share/doc/udsactor/readme.txt
|
||||
86020414868d2ede37e76a911aa211c5 usr/share/pyshared/UDSActor/UDSActorConfig.py
|
||||
b14dee09070d95cac6321a13442f15b8 usr/share/pyshared/UDSActor/UDSActorUser.py
|
||||
db1be7dd5fec00a3c31587fe8ce8e56f usr/share/pyshared/UDSActor/setup_dialog_ui.py
|
||||
d677aa5ec15d9497b654a04f3d671958 usr/share/pyshared/UDSActor/udsactor/REST.py
|
||||
5317be4587c15ce790bfa55399f4d601 usr/share/pyshared/UDSActor/udsactor/REST.py
|
||||
68b329da9893e34099c7d8ad5cb9c940 usr/share/pyshared/UDSActor/udsactor/__init__.py
|
||||
976710a766859591a543eebdf351537b usr/share/pyshared/UDSActor/udsactor/certs.py
|
||||
bcfca2062d45ec44b77b1e65d611bcc1 usr/share/pyshared/UDSActor/udsactor/httpserver.py
|
||||
0350137ae586a7babe54a75e68fa1fe7 usr/share/pyshared/UDSActor/udsactor/ipc.py
|
||||
73082793d61ef3ce40736de43c9b3314 usr/share/pyshared/UDSActor/udsactor/linux/UDSActorService.py
|
||||
6b7afab1321512cf7884df70f86041e8 usr/share/pyshared/UDSActor/udsactor/linux/UDSActorService.py
|
||||
3ef55d64ebda86651c3d882c5c649389 usr/share/pyshared/UDSActor/udsactor/linux/__init__.py
|
||||
fee6ea5f27ec7aa294c2c0741b22c5e6 usr/share/pyshared/UDSActor/udsactor/linux/daemon.py
|
||||
7322c53041ef99b982a6bbdb9d510c70 usr/share/pyshared/UDSActor/udsactor/linux/daemon.py
|
||||
c599495230cbd3f6495ba4a6edc169d9 usr/share/pyshared/UDSActor/udsactor/linux/log.py
|
||||
49dccc874df32d0dbeaf7ffcbc9cc176 usr/share/pyshared/UDSActor/udsactor/linux/operations.py
|
||||
fe28aef338eacc56f8e76a33ac33ac2a usr/share/pyshared/UDSActor/udsactor/linux/operations.py
|
||||
1234f7f854901dc53a6d67105e72404d usr/share/pyshared/UDSActor/udsactor/linux/renamer/__init__.py
|
||||
e958b3a317d41f350a412992f5016e4d usr/share/pyshared/UDSActor/udsactor/linux/renamer/debian.py
|
||||
93e6a3d18c34fda4a42d96b42407e52b usr/share/pyshared/UDSActor/udsactor/linux/store.py
|
||||
28b691cb635888d496598bedf184cdb0 usr/share/pyshared/UDSActor/udsactor/log.py
|
||||
3351055d556c481e7fb61b132ab96f90 usr/share/pyshared/UDSActor/udsactor/log.py
|
||||
9bfbf09895f4319c4a5ebef858ff9faa usr/share/pyshared/UDSActor/udsactor/operations.py
|
||||
d284d7b4f544b0d7efe27188e843a783 usr/share/pyshared/UDSActor/udsactor/service.py
|
||||
8f5c4a4db6d42dbd2effd760f960b598 usr/share/pyshared/UDSActor/udsactor/service.py
|
||||
c88b37b89a88734788e23b2f71a7fcd5 usr/share/pyshared/UDSActor/udsactor/store.py
|
||||
68b513e35d67d3e783947ec35b60cfa7 usr/share/pyshared/UDSActor/udsactor/utils.py
|
||||
517440806336069b121ea587ec0ed80f usr/share/pyshared/UDSActor/udsactor/windows/SENS.py
|
||||
|
@ -26,8 +26,8 @@ case "$1" in
|
||||
|
||||
echo "[uds]" > /etc/udsactor/udsactor.cfg
|
||||
echo "host = $host" >> /etc/udsactor/udsactor.cfg
|
||||
echo "logLevel = 20000" >> /etc/udsactor/udsactor.cfg
|
||||
echo "ssl = ssl" >> /etc/udsactor/udsactor.cfg
|
||||
echo "logLevel = 30000" >> /etc/udsactor/udsactor.cfg
|
||||
echo "ssl = $ssl" >> /etc/udsactor/udsactor.cfg
|
||||
echo "masterKey = $masterKey" >> /etc/udsactor/udsactor.cfg
|
||||
|
||||
fi
|
||||
|
@ -119,6 +119,7 @@ class Api(object):
|
||||
self.useSSL = ssl
|
||||
self.scrambledResponses = scrambledResponses
|
||||
self.uuid = None
|
||||
self.mac = None
|
||||
self.url = "{}://{}/rest/actor/".format(('http', 'https')[ssl], self.host)
|
||||
self.secretKey = six.text_type(uuid.uuid4())
|
||||
self.newerRequestLib = 'verify' in requests.sessions.Session.__attrs__
|
||||
|
@ -119,8 +119,8 @@ def usage():
|
||||
|
||||
if __name__ == '__main__':
|
||||
initCfg()
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
client = None
|
||||
try:
|
||||
client = ipc.ClientIPC(IPC_PORT)
|
||||
client.start()
|
||||
@ -135,7 +135,8 @@ if __name__ == '__main__':
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
finally:
|
||||
client.stop()
|
||||
if client is not None:
|
||||
client.stop()
|
||||
usage()
|
||||
|
||||
logger.debug('Executing actor')
|
||||
|
@ -35,7 +35,7 @@ import sys
|
||||
import os
|
||||
import time
|
||||
import atexit
|
||||
|
||||
from udsactor.log import logger
|
||||
|
||||
from signal import SIGTERM
|
||||
|
||||
@ -64,7 +64,8 @@ class Daemon:
|
||||
# exit first parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
sys.stderr.write("fork #1 failed: {} ({})\n".format(e.errno, e.strerror))
|
||||
logger.error("fork #1 error: {}".format(e))
|
||||
sys.stderr.write("fork #1 failed: {}\n".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
# decouple from parent environment
|
||||
@ -79,7 +80,8 @@ class Daemon:
|
||||
# exit from second parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
sys.stderr.write("fork #2 failed: {} ({})\n".format(e.errno, e.strerror))
|
||||
logger.error("fork #2 error: {}".format(e))
|
||||
sys.stderr.write("fork #2 failed: {}\n".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
# redirect standard file descriptors
|
||||
@ -105,22 +107,27 @@ class Daemon:
|
||||
"""
|
||||
Start the daemon
|
||||
"""
|
||||
logger.debug('Starting daemon')
|
||||
# Check for a pidfile to see if the daemon already runs
|
||||
try:
|
||||
pf = file(self.pidfile, 'r')
|
||||
pf = open(self.pidfile, 'r')
|
||||
pid = int(pf.read().strip())
|
||||
pf.close()
|
||||
except IOError:
|
||||
pid = None
|
||||
|
||||
if pid:
|
||||
message = "pidfile %s already exist. Daemon already running?\n"
|
||||
sys.stderr.write(message % self.pidfile)
|
||||
message = "pidfile {} already exist. Daemon already running?\n".format(pid)
|
||||
logger.error(message)
|
||||
sys.stderr.write(message)
|
||||
sys.exit(1)
|
||||
|
||||
# Start the daemon
|
||||
self.daemonize()
|
||||
self.run()
|
||||
try:
|
||||
self.run()
|
||||
except Exception as e:
|
||||
logger.error('Exception running process: {}'.format(e))
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
@ -135,7 +142,9 @@ class Daemon:
|
||||
pid = None
|
||||
|
||||
if pid is None:
|
||||
sys.stderr.write("pidfile {} does not exist. Daemon not running?\n".format(self.pidfile))
|
||||
message = "pidfile {} does not exist. Daemon not running?\n".format(self.pidfile)
|
||||
logger.error(message)
|
||||
sys.stderr.write(message)
|
||||
return # not an error in a restart
|
||||
|
||||
# Try killing the daemon process
|
||||
|
@ -52,7 +52,7 @@ def _getMacAddr(ifname):
|
||||
ifname = ifname.encode('utf-8') # If unicode, convert to bytes (or str in python 2.7)
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15])))
|
||||
info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack(str('256s'), ifname[:15])))
|
||||
return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1])
|
||||
except Exception:
|
||||
return None
|
||||
@ -72,7 +72,7 @@ def _getIpAddr(ifname):
|
||||
return six.text_type(socket.inet_ntoa(fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8915, # SIOCGIFADDR
|
||||
struct.pack('256s', ifname[:15])
|
||||
struct.pack(str('256s'), ifname[:15])
|
||||
)[20:24]))
|
||||
except Exception:
|
||||
return None
|
||||
@ -93,10 +93,10 @@ def _getInterfaces():
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
names = array.array(str('B'), b'\0' * space)
|
||||
outbytes = struct.unpack('iL', fcntl.ioctl(
|
||||
outbytes = struct.unpack(str('iL'), fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8912, # SIOCGIFCONF
|
||||
struct.pack('iL', space, names.buffer_info()[0])
|
||||
struct.pack(str('iL'), space, names.buffer_info()[0])
|
||||
))[0]
|
||||
namestr = names.tostring()
|
||||
# return namestr, outbytes
|
||||
@ -118,7 +118,8 @@ def getComputerName():
|
||||
def getNetworkInfo():
|
||||
for ifname in _getInterfaces():
|
||||
ip, mac = _getIpAndMac(ifname)
|
||||
yield utils.Bunch(name=ifname, mac=mac, ip=ip)
|
||||
if mac != '00:00:00:00:00:00': # Skips local interfaces
|
||||
yield utils.Bunch(name=ifname, mac=mac, ip=ip)
|
||||
|
||||
|
||||
def getDomainName():
|
||||
|
@ -50,7 +50,7 @@ class Logger(object):
|
||||
self.remoteLogger = None
|
||||
|
||||
def setLevel(self, level):
|
||||
self.logLevel = level
|
||||
self.logLevel = int(level) # Ensures level is an integer or fails
|
||||
self.logger.log(INFO, 'Setting LogLevel to {}'.format(level))
|
||||
|
||||
def setRemoteLogger(self, remoteLogger):
|
||||
|
@ -116,7 +116,7 @@ class CommonService(object):
|
||||
# Right now, we thing that the interface connected to broker is
|
||||
# the interface that broker will know, let's see how this works
|
||||
logger.fatal('This host is not managed by UDS Broker (ids: {})'.format(ids))
|
||||
return False
|
||||
return False # On unmanaged hosts, there is no reason right now to continue running
|
||||
except Exception as e:
|
||||
logger.debug('Exception caugh: {}, retrying'.format(exceptionToMessage(e)))
|
||||
# Any other error is expectable and recoverable, so let's wait a bit and retry again
|
||||
@ -185,6 +185,8 @@ class CommonService(object):
|
||||
return True
|
||||
|
||||
def checkIpsChanged(self):
|
||||
if self.api.uuid is None:
|
||||
return # Not connected
|
||||
netInfo = tuple(operations.getNetworkInfo())
|
||||
for i in netInfo:
|
||||
# If at least one ip has changed
|
||||
|
@ -119,6 +119,7 @@ class Api(object):
|
||||
self.useSSL = ssl
|
||||
self.scrambledResponses = scrambledResponses
|
||||
self.uuid = None
|
||||
self.mac = None
|
||||
self.url = "{}://{}/rest/actor/".format(('http', 'https')[ssl], self.host)
|
||||
self.secretKey = six.text_type(uuid.uuid4())
|
||||
self.newerRequestLib = 'verify' in requests.sessions.Session.__attrs__
|
||||
|
@ -119,8 +119,8 @@ def usage():
|
||||
|
||||
if __name__ == '__main__':
|
||||
initCfg()
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
client = None
|
||||
try:
|
||||
client = ipc.ClientIPC(IPC_PORT)
|
||||
client.start()
|
||||
@ -135,7 +135,8 @@ if __name__ == '__main__':
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
finally:
|
||||
client.stop()
|
||||
if client is not None:
|
||||
client.stop()
|
||||
usage()
|
||||
|
||||
logger.debug('Executing actor')
|
||||
|
@ -35,7 +35,7 @@ import sys
|
||||
import os
|
||||
import time
|
||||
import atexit
|
||||
|
||||
from udsactor.log import logger
|
||||
|
||||
from signal import SIGTERM
|
||||
|
||||
@ -64,7 +64,8 @@ class Daemon:
|
||||
# exit first parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
sys.stderr.write("fork #1 failed: {} ({})\n".format(e.errno, e.strerror))
|
||||
logger.error("fork #1 error: {}".format(e))
|
||||
sys.stderr.write("fork #1 failed: {}\n".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
# decouple from parent environment
|
||||
@ -79,7 +80,8 @@ class Daemon:
|
||||
# exit from second parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
sys.stderr.write("fork #2 failed: {} ({})\n".format(e.errno, e.strerror))
|
||||
logger.error("fork #2 error: {}".format(e))
|
||||
sys.stderr.write("fork #2 failed: {}\n".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
# redirect standard file descriptors
|
||||
@ -105,22 +107,27 @@ class Daemon:
|
||||
"""
|
||||
Start the daemon
|
||||
"""
|
||||
logger.debug('Starting daemon')
|
||||
# Check for a pidfile to see if the daemon already runs
|
||||
try:
|
||||
pf = file(self.pidfile, 'r')
|
||||
pf = open(self.pidfile, 'r')
|
||||
pid = int(pf.read().strip())
|
||||
pf.close()
|
||||
except IOError:
|
||||
pid = None
|
||||
|
||||
if pid:
|
||||
message = "pidfile %s already exist. Daemon already running?\n"
|
||||
sys.stderr.write(message % self.pidfile)
|
||||
message = "pidfile {} already exist. Daemon already running?\n".format(pid)
|
||||
logger.error(message)
|
||||
sys.stderr.write(message)
|
||||
sys.exit(1)
|
||||
|
||||
# Start the daemon
|
||||
self.daemonize()
|
||||
self.run()
|
||||
try:
|
||||
self.run()
|
||||
except Exception as e:
|
||||
logger.error('Exception running process: {}'.format(e))
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
@ -135,7 +142,9 @@ class Daemon:
|
||||
pid = None
|
||||
|
||||
if pid is None:
|
||||
sys.stderr.write("pidfile {} does not exist. Daemon not running?\n".format(self.pidfile))
|
||||
message = "pidfile {} does not exist. Daemon not running?\n".format(self.pidfile)
|
||||
logger.error(message)
|
||||
sys.stderr.write(message)
|
||||
return # not an error in a restart
|
||||
|
||||
# Try killing the daemon process
|
||||
|
@ -52,7 +52,7 @@ def _getMacAddr(ifname):
|
||||
ifname = ifname.encode('utf-8') # If unicode, convert to bytes (or str in python 2.7)
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15])))
|
||||
info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack(str('256s'), ifname[:15])))
|
||||
return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1])
|
||||
except Exception:
|
||||
return None
|
||||
@ -72,7 +72,7 @@ def _getIpAddr(ifname):
|
||||
return six.text_type(socket.inet_ntoa(fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8915, # SIOCGIFADDR
|
||||
struct.pack('256s', ifname[:15])
|
||||
struct.pack(str('256s'), ifname[:15])
|
||||
)[20:24]))
|
||||
except Exception:
|
||||
return None
|
||||
@ -93,10 +93,10 @@ def _getInterfaces():
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
names = array.array(str('B'), b'\0' * space)
|
||||
outbytes = struct.unpack('iL', fcntl.ioctl(
|
||||
outbytes = struct.unpack(str('iL'), fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8912, # SIOCGIFCONF
|
||||
struct.pack('iL', space, names.buffer_info()[0])
|
||||
struct.pack(str('iL'), space, names.buffer_info()[0])
|
||||
))[0]
|
||||
namestr = names.tostring()
|
||||
# return namestr, outbytes
|
||||
@ -118,7 +118,8 @@ def getComputerName():
|
||||
def getNetworkInfo():
|
||||
for ifname in _getInterfaces():
|
||||
ip, mac = _getIpAndMac(ifname)
|
||||
yield utils.Bunch(name=ifname, mac=mac, ip=ip)
|
||||
if mac != '00:00:00:00:00:00': # Skips local interfaces
|
||||
yield utils.Bunch(name=ifname, mac=mac, ip=ip)
|
||||
|
||||
|
||||
def getDomainName():
|
||||
|
@ -50,7 +50,7 @@ class Logger(object):
|
||||
self.remoteLogger = None
|
||||
|
||||
def setLevel(self, level):
|
||||
self.logLevel = level
|
||||
self.logLevel = int(level) # Ensures level is an integer or fails
|
||||
self.logger.log(INFO, 'Setting LogLevel to {}'.format(level))
|
||||
|
||||
def setRemoteLogger(self, remoteLogger):
|
||||
|
@ -116,7 +116,7 @@ class CommonService(object):
|
||||
# Right now, we thing that the interface connected to broker is
|
||||
# the interface that broker will know, let's see how this works
|
||||
logger.fatal('This host is not managed by UDS Broker (ids: {})'.format(ids))
|
||||
return False
|
||||
return False # On unmanaged hosts, there is no reason right now to continue running
|
||||
except Exception as e:
|
||||
logger.debug('Exception caugh: {}, retrying'.format(exceptionToMessage(e)))
|
||||
# Any other error is expectable and recoverable, so let's wait a bit and retry again
|
||||
@ -185,6 +185,8 @@ class CommonService(object):
|
||||
return True
|
||||
|
||||
def checkIpsChanged(self):
|
||||
if self.api.uuid is None:
|
||||
return # Not connected
|
||||
netInfo = tuple(operations.getNetworkInfo())
|
||||
for i in netInfo:
|
||||
# If at least one ip has changed
|
||||
|
Loading…
Reference in New Issue
Block a user