mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
added trace file for connections checking tracing
This commit is contained in:
parent
32b5354a15
commit
047eac18a7
@ -122,7 +122,7 @@ def getComputerName():
|
||||
def getNetworkInfo():
|
||||
for ifname in _getInterfaces():
|
||||
ip, mac = _getIpAndMac(ifname)
|
||||
if mac != '00:00:00:00:00:00': # Skips local interfaces
|
||||
if mac != '00:00:00:00:00:00' and ip.startswith('169.254') is False: # Skips local interfaces & interfaces with no dhcp IPs
|
||||
yield utils.Bunch(name=ifname, mac=mac, ip=ip)
|
||||
|
||||
|
||||
|
@ -218,8 +218,10 @@ if DEBUG:
|
||||
LOGDIR = BASE_DIR + '/' + 'log'
|
||||
LOGFILE = 'uds.log'
|
||||
SERVICESFILE = 'services.log'
|
||||
WORKERSFILE = 'workers.log'
|
||||
AUTHFILE = 'auth.log'
|
||||
USEFILE = 'use.log'
|
||||
TRACEFILE = 'trace.log'
|
||||
LOGLEVEL = DEBUG and 'DEBUG' or 'INFO'
|
||||
ROTATINGSIZE = 32 * 1024 * 1024 # 32 Megabytes before rotating files
|
||||
|
||||
@ -230,16 +232,16 @@ LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse',
|
||||
}
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse',
|
||||
}
|
||||
},
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
|
||||
'format': '%(levelname)s %(asctime)s %(module)s %(funcName)s %(lineno)d %(message)s'
|
||||
},
|
||||
'database': {
|
||||
'format': '%(levelname)s %(asctime)s Database %(message)s'
|
||||
@ -249,17 +251,20 @@ LOGGING = {
|
||||
},
|
||||
'use': {
|
||||
'format': '%(asctime)s %(message)s'
|
||||
},
|
||||
'trace': {
|
||||
'format': '%(levelname)s %(asctime)s %(message)s'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'null': {
|
||||
'level':'DEBUG',
|
||||
'class':'logging.NullHandler',
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
},
|
||||
|
||||
'file':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
|
||||
'file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'simple',
|
||||
'filename': LOGDIR + '/' + LOGFILE,
|
||||
'mode': 'a',
|
||||
@ -268,20 +273,20 @@ LOGGING = {
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'database':{
|
||||
'level':'ERROR',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'database': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'simple',
|
||||
'filename': LOGDIR + '/' + 'db.log',
|
||||
'filename': LOGDIR + '/' + 'sql.log',
|
||||
'mode': 'a',
|
||||
'maxBytes': ROTATINGSIZE,
|
||||
'backupCount': 3,
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'servicesFile':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
|
||||
'servicesFile': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'simple',
|
||||
'filename': LOGDIR + '/' + SERVICESFILE,
|
||||
'mode': 'a',
|
||||
@ -290,9 +295,20 @@ LOGGING = {
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'authFile':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'workersFile': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'simple',
|
||||
'filename': LOGDIR + '/' + WORKERSFILE,
|
||||
'mode': 'a',
|
||||
'maxBytes': ROTATINGSIZE,
|
||||
'backupCount': 3,
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'authFile': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'auth',
|
||||
'filename': LOGDIR + '/' + AUTHFILE,
|
||||
'mode': 'a',
|
||||
@ -301,9 +317,9 @@ LOGGING = {
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'useFile':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'useFile': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'use',
|
||||
'filename': LOGDIR + '/' + USEFILE,
|
||||
'mode': 'a',
|
||||
@ -311,10 +327,21 @@ LOGGING = {
|
||||
'backupCount': 3,
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'console':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.StreamHandler',
|
||||
|
||||
'traceFile': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'formatter': 'trace',
|
||||
'filename': LOGDIR + '/' + TRACEFILE,
|
||||
'mode': 'a',
|
||||
'maxBytes': ROTATINGSIZE,
|
||||
'backupCount': 3,
|
||||
'encoding': 'utf-8'
|
||||
},
|
||||
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple'
|
||||
},
|
||||
'mail_admins': {
|
||||
@ -325,9 +352,9 @@ LOGGING = {
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers':['null'],
|
||||
'handlers': ['null'],
|
||||
'propagate': True,
|
||||
'level':'INFO',
|
||||
'level': 'INFO',
|
||||
},
|
||||
'django.request': {
|
||||
'handlers': ['file'],
|
||||
@ -336,15 +363,26 @@ LOGGING = {
|
||||
},
|
||||
'django.db.backends': {
|
||||
'handlers': ['database'],
|
||||
'level': 'ERROR',
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
},
|
||||
|
||||
|
||||
'uds': {
|
||||
'handlers': ['file'],
|
||||
'level': LOGLEVEL,
|
||||
},
|
||||
|
||||
|
||||
'uds.core.workers': {
|
||||
'handlers': ['workersFile'],
|
||||
'level': LOGLEVEL,
|
||||
'propagate': False,
|
||||
},
|
||||
'uds.core.jobs': {
|
||||
'handlers': ['workersFile'],
|
||||
'level': LOGLEVEL,
|
||||
'propagate': False,
|
||||
},
|
||||
|
||||
'uds.services': {
|
||||
'handlers': ['servicesFile'],
|
||||
'level': LOGLEVEL,
|
||||
@ -352,16 +390,22 @@ LOGGING = {
|
||||
},
|
||||
# Custom Auth log
|
||||
'authLog': {
|
||||
'handlers' : ['authFile'],
|
||||
'handlers': ['authFile'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
# Custom Services use log
|
||||
'useLog': {
|
||||
'handlers' : ['useFile'],
|
||||
'handlers': ['useFile'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
# Custom tracing
|
||||
'traceLog': {
|
||||
'handlers': ['traceFile'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,10 @@ import requests
|
||||
import json
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-11-04'
|
||||
__updated__ = '2017-01-26'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
traceLogger = logging.getLogger('traceLog')
|
||||
|
||||
|
||||
class UserServiceManager(object):
|
||||
@ -498,11 +499,17 @@ class UserServiceManager(object):
|
||||
if trans.validForIp(srcIp) is False:
|
||||
raise InvalidServiceException()
|
||||
|
||||
if user is not None:
|
||||
userName = user.name
|
||||
|
||||
|
||||
if doTest is False:
|
||||
# traceLogger.info('GOT service "{}" for user "{}" with transport "{}" (NOT TESTED)'.format(userService.name, userName, trans.name))
|
||||
return (None, userService, None, trans, None)
|
||||
|
||||
serviceNotReadyCode = 0x0001
|
||||
|
||||
serviceNotReadyCode = 0x0001
|
||||
ip = 'unknown'
|
||||
# Test if the service is ready
|
||||
if userService.isReady():
|
||||
serviceNotReadyCode = 0x0002
|
||||
@ -516,7 +523,7 @@ class UserServiceManager(object):
|
||||
log.doLog(userService, log.WARN, "User service is not accessible (ip {0})".format(ip), log.TRANSPORT)
|
||||
logger.debug('Transport is not ready for user service {0}'.format(userService))
|
||||
else:
|
||||
events.addEvent(userService.deployed_service, events.ET_ACCESS, username=user.name, srcip=srcIp, dstip=ip, uniqueid=userService.unique_id)
|
||||
events.addEvent(userService.deployed_service, events.ET_ACCESS, username=userName, srcip=srcIp, dstip=ip, uniqueid=userService.unique_id)
|
||||
if ip is not None:
|
||||
serviceNotReadyCode = 0x0003
|
||||
itrans = trans.getInstance()
|
||||
@ -524,6 +531,7 @@ class UserServiceManager(object):
|
||||
userService.setConnectionSource(srcIp, 'unknown')
|
||||
log.doLog(userService, log.INFO, "User service ready", log.WEB)
|
||||
self.notifyPreconnect(userService, itrans.processedUser(userService, user), itrans.protocol)
|
||||
traceLogger.info('READY on service "{}" for user "{}" with transport "{}" (ip:{})'.format(userService.name, userName, trans.name, ip))
|
||||
return (ip, userService, iads, trans, itrans)
|
||||
else:
|
||||
log.doLog(userService, log.WARN, "User service is not accessible (ip {0})".format(ip), log.TRANSPORT)
|
||||
@ -533,4 +541,5 @@ class UserServiceManager(object):
|
||||
else:
|
||||
log.doLog(userService, log.WARN, "User {0} from {1} tried to access, but service was not ready".format(user.name, srcIp), log.WEB)
|
||||
|
||||
traceLogger.error('ERROR {} on service "{}" for user "{}" with transport "{}" (ip:{})'.format(serviceNotReadyCode, userService.name, userName, trans.name, ip))
|
||||
raise ServiceNotReadyError(code=serviceNotReadyCode, service=userService, transport=trans)
|
||||
|
@ -55,7 +55,7 @@ from uds.models.Util import getSqlDatetime
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-04-26'
|
||||
__updated__ = '2017-01-26'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -111,6 +111,13 @@ class UserService(UUIDModel):
|
||||
'state'
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
'''
|
||||
Simple accessor to deployed service name plus unique name
|
||||
'''
|
||||
return "{}\\{}".format(self.deployed_service.name, self.friendly_name)
|
||||
|
||||
def getEnvironment(self):
|
||||
'''
|
||||
Returns an environment valid for the record this object represents.
|
||||
|
@ -39,7 +39,7 @@ from defusedxml import minidom
|
||||
# Python bindings for OpenNebula
|
||||
from .common import VmState
|
||||
|
||||
__updated__ = '2016-11-24'
|
||||
__updated__ = '2017-01-26'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -127,7 +127,8 @@ def removeMachine(api, machineId):
|
||||
# vm.delete()
|
||||
api.deleteVM(machineId)
|
||||
except Exception as e:
|
||||
logger.error('Error removing machine {} on opennebula: {}'.format(machineId, e))
|
||||
logger.exception('Error removing machine {} on opennebula: {}'.format(machineId, e))
|
||||
raise 'Error removing machine {} on opennebula: {}'.format(machineId, e)
|
||||
|
||||
|
||||
def enumerateMachines(api):
|
||||
|
Loading…
Reference in New Issue
Block a user