mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-31 17:17:53 +03:00
* Added a "needed" comment on USerServiceManager
* Cached "modfinder" results * Added "early" loading of dispatchers, so they can register (for example) Configuration Parameters, etc..
This commit is contained in:
parent
63d0f6e470
commit
d75422c96f
@ -91,10 +91,12 @@ encoding//src/uds/core/workers/DeployedServiceCleaner.py=utf-8
|
||||
encoding//src/uds/core/workers/PublicationCleaner.py=utf-8
|
||||
encoding//src/uds/core/workers/ServiceCacheUpdater.py=utf-8
|
||||
encoding//src/uds/core/workers/UserServiceCleaner.py=utf-8
|
||||
encoding//src/uds/dispatchers/__init__.py=utf-8
|
||||
encoding//src/uds/dispatchers/pam/urls.py=utf-8
|
||||
encoding//src/uds/dispatchers/pam/views.py=utf-8
|
||||
encoding//src/uds/dispatchers/test/urls.py=utf-8
|
||||
encoding//src/uds/dispatchers/test/views.py=utf-8
|
||||
encoding//src/uds/dispatchers/wyse_enterprise/__init__.py=utf-8
|
||||
encoding//src/uds/dispatchers/wyse_enterprise/urls.py=utf-8
|
||||
encoding//src/uds/dispatchers/wyse_enterprise/views.py=utf-8
|
||||
encoding//src/uds/management/commands/config.py=utf-8
|
||||
|
@ -41,6 +41,7 @@ import services # to make sure that the packages are initialized at this point
|
||||
import auths # To make sure that the packages are initialized at this point
|
||||
import osmanagers # To make sure that packages are initialized at this point
|
||||
import transports # To make sure that packages are initialized at this point
|
||||
import dispatchers
|
||||
import models
|
||||
|
||||
|
||||
|
@ -216,6 +216,11 @@ class UserServiceManager(object):
|
||||
state_date=now, creation_date=now, data='', deployed_service=deployedServicePublication.deployed_service, user=user, in_use=False)
|
||||
|
||||
def __createAssignedAtDbForNoPublication(self, deployedService, user):
|
||||
'''
|
||||
__createCacheAtDb and __createAssignedAtDb uses a publication for create the UserService.
|
||||
There is cases where deployed services do not have publications (do not need them), so we need this method to create
|
||||
an UserService with no publications, and create them from an DeployedService
|
||||
'''
|
||||
self.__checkMaxDeployedReached(deployedService)
|
||||
now = getSqlDatetime()
|
||||
return deployedService.userServices.create(cache_level=0, state=State.PREPARING, os_state=State.PREPARING,
|
||||
|
@ -39,16 +39,22 @@ import uds.dispatchers
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
patterns = []
|
||||
|
||||
def loadModulesUrls():
|
||||
patterns = []
|
||||
try:
|
||||
modName = 'uds.dispatchers'
|
||||
pkgpath = os.path.dirname(sys.modules[modName].__file__)
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
fullModName = '%s.%s.urls' % (modName, name)
|
||||
mod = __import__(fullModName, globals(), locals(), ['urlpatterns'], -1)
|
||||
patterns += mod.urlpatterns
|
||||
except Exception, e:
|
||||
logger.debug(e)
|
||||
pass
|
||||
return patterns
|
||||
logger.debug('Looking for dispatching modules')
|
||||
global patterns
|
||||
if len(patterns) == 0:
|
||||
try:
|
||||
modName = 'uds.dispatchers'
|
||||
pkgpath = os.path.dirname(sys.modules[modName].__file__)
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
fullModName = '%s.%s.urls' % (modName, name)
|
||||
mod = __import__(fullModName, globals(), locals(), ['urlpatterns'], -1)
|
||||
patterns += mod.urlpatterns
|
||||
except Exception, e:
|
||||
logger.debug(e)
|
||||
pass
|
||||
|
||||
return patterns
|
||||
|
@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
'''
|
||||
Service modules for uds are contained inside this package.
|
||||
To create a new service module, you will need to follow this steps:
|
||||
1.- Create the service module, probably based on an existing one
|
||||
2.- Insert the module package as child of this package
|
||||
3.- Import the class of your service module at __init__. For example::
|
||||
from Service import SimpleService
|
||||
4.- Done. At Server restart, the module will be recognized, loaded and treated
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.auths.Authentication`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
def __init__():
|
||||
'''
|
||||
This imports all packages that are descendant of this package, and, after that,
|
||||
it register all subclases of service provider as
|
||||
'''
|
||||
import os.path, pkgutil
|
||||
import sys
|
||||
|
||||
# Dinamycally import children of this package. The __init__.py files must register, if needed, inside ServiceProviderFactory
|
||||
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
__import__(name, globals(), locals(), [], -1)
|
||||
|
||||
|
||||
logger.debug('Dispatchers initialized')
|
||||
|
||||
__init__()
|
@ -1678,24 +1678,28 @@ class Network(models.Model):
|
||||
'''
|
||||
convert decimal dotted quad string to long integer
|
||||
'''
|
||||
|
||||
hexn = ''.join(["%02X" % long(i) for i in ip.split('.')])
|
||||
return long(hexn, 16)
|
||||
try:
|
||||
hexn = ''.join(["%02X" % long(i) for i in ip.split('.')])
|
||||
return long(hexn, 16)
|
||||
except:
|
||||
return 0 # Invalid values will map to "0.0.0.0" --> 0
|
||||
|
||||
@staticmethod
|
||||
def longToIp(n):
|
||||
'''
|
||||
convert long int to dotted quad string
|
||||
'''
|
||||
|
||||
d = 256 * 256 * 256
|
||||
q = []
|
||||
while d > 0:
|
||||
m,n = divmod(n,d)
|
||||
q.append(str(m))
|
||||
d = d/256
|
||||
|
||||
return '.'.join(q)
|
||||
try:
|
||||
d = 256 * 256 * 256
|
||||
q = []
|
||||
while d > 0:
|
||||
m,n = divmod(n,d)
|
||||
q.append(str(m))
|
||||
d = d/256
|
||||
|
||||
return '.'.join(q)
|
||||
except:
|
||||
return '0.0.0.0' # Invalid values will map to "0.0.0.0"
|
||||
|
||||
@staticmethod
|
||||
def networksFor(ip):
|
||||
|
Loading…
Reference in New Issue
Block a user