mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
Fixed to use lowercase for uuids (as rfc 4122 says that they will be)
This commit is contained in:
parent
7f049a80de
commit
7a3692cc43
@ -105,7 +105,7 @@ class Tickets(Handler):
|
|||||||
|
|
||||||
# Will raise an exception if no auth found
|
# Will raise an exception if no auth found
|
||||||
if authId is not None:
|
if authId is not None:
|
||||||
auth = Authenticator.objects.get(uuid=authId.upper())
|
auth = Authenticator.objects.get(uuid=authId.lower())
|
||||||
elif authName is not None:
|
elif authName is not None:
|
||||||
auth = Authenticator.objects.get(name=authName)
|
auth = Authenticator.objects.get(name=authName)
|
||||||
else:
|
else:
|
||||||
@ -135,11 +135,11 @@ class Tickets(Handler):
|
|||||||
transport = None
|
transport = None
|
||||||
|
|
||||||
if servicePool is not None:
|
if servicePool is not None:
|
||||||
servicePool = DeployedService.objects.get(uuid=servicePool.upper())
|
servicePool = DeployedService.objects.get(uuid=servicePool.lower())
|
||||||
|
|
||||||
transport = self._params.get('transport', None)
|
transport = self._params.get('transport', None)
|
||||||
if transport is not None:
|
if transport is not None:
|
||||||
transport = Transport.objects.get(uuid=transport.upper())
|
transport = Transport.objects.get(uuid=transport.lower())
|
||||||
try:
|
try:
|
||||||
servicePool.validateTransport(transport)
|
servicePool.validateTransport(transport)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -614,7 +614,7 @@ class ModelHandler(BaseModelHandler):
|
|||||||
if self._args[1] == cm[0]:
|
if self._args[1] == cm[0]:
|
||||||
try:
|
try:
|
||||||
operation = getattr(self, self._args[1])
|
operation = getattr(self, self._args[1])
|
||||||
item = self.model.objects.get(uuid=self._args[0].upper())
|
item = self.model.objects.get(uuid=self._args[0].lower())
|
||||||
except Exception:
|
except Exception:
|
||||||
self.invalidMethodException()
|
self.invalidMethodException()
|
||||||
|
|
||||||
@ -639,7 +639,7 @@ class ModelHandler(BaseModelHandler):
|
|||||||
|
|
||||||
# get item ID
|
# get item ID
|
||||||
try:
|
try:
|
||||||
val = self.model.objects.get(uuid=self._args[0].upper())
|
val = self.model.objects.get(uuid=self._args[0].lower())
|
||||||
res = self.item_as_dict(val)
|
res = self.item_as_dict(val)
|
||||||
self.fillIntanceFields(val, res)
|
self.fillIntanceFields(val, res)
|
||||||
return res
|
return res
|
||||||
@ -664,7 +664,7 @@ class ModelHandler(BaseModelHandler):
|
|||||||
if nArgs != 2:
|
if nArgs != 2:
|
||||||
self.invalidRequestException()
|
self.invalidRequestException()
|
||||||
try:
|
try:
|
||||||
item = self.model.objects.get(uuid=self._args[0].upper()) # DB maybe case sensitive??, anyway, uuids are stored in uppercase
|
item = self.model.objects.get(uuid=self._args[0].lower()) # DB maybe case sensitive??, anyway, uuids are stored in lowercase
|
||||||
except Exception:
|
except Exception:
|
||||||
self.invalidItemException()
|
self.invalidItemException()
|
||||||
return self.getLogs(item)
|
return self.getLogs(item)
|
||||||
@ -708,7 +708,7 @@ class ModelHandler(BaseModelHandler):
|
|||||||
deleteOnError = True
|
deleteOnError = True
|
||||||
else: # Must have 1 arg
|
else: # Must have 1 arg
|
||||||
# We have to take care with this case, update will efectively update records on db
|
# We have to take care with this case, update will efectively update records on db
|
||||||
item = self.model.objects.get(uuid=self._args[0].upper())
|
item = self.model.objects.get(uuid=self._args[0].lower())
|
||||||
for v in self.remove_fields:
|
for v in self.remove_fields:
|
||||||
if v in args:
|
if v in args:
|
||||||
del args[v]
|
del args[v]
|
||||||
@ -759,7 +759,7 @@ class ModelHandler(BaseModelHandler):
|
|||||||
if len(self._args) != 1:
|
if len(self._args) != 1:
|
||||||
raise RequestError('Delete need one and only one argument')
|
raise RequestError('Delete need one and only one argument')
|
||||||
try:
|
try:
|
||||||
item = self.model.objects.get(uuid=self._args[0].upper())
|
item = self.model.objects.get(uuid=self._args[0].lower())
|
||||||
self.checkDelete(item)
|
self.checkDelete(item)
|
||||||
self.deleteItem(item)
|
self.deleteItem(item)
|
||||||
except self.model.DoesNotExist:
|
except self.model.DoesNotExist:
|
||||||
|
@ -128,7 +128,7 @@ class CryptoManager(object):
|
|||||||
|
|
||||||
def uuid(self, obj=None):
|
def uuid(self, obj=None):
|
||||||
'''
|
'''
|
||||||
Generates an uuid from obj.
|
Generates an uuid from obj. (lower case)
|
||||||
If obj is None, returns an uuid based on current datetime + counter
|
If obj is None, returns an uuid based on current datetime + counter
|
||||||
'''
|
'''
|
||||||
if obj is None:
|
if obj is None:
|
||||||
@ -139,4 +139,5 @@ class CryptoManager(object):
|
|||||||
obj = obj.decode('utf-8')
|
obj = obj.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
obj = six. binary_type(obj)
|
obj = six. binary_type(obj)
|
||||||
return six.text_type(uuid.uuid5(self._namespace, six.binary_type(obj)))
|
|
||||||
|
return six.text_type(uuid.uuid5(self._namespace, six.binary_type(obj))).lower() # I believe uuid returns a lowercase uuid always, but in case... :)
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2014-11-02'
|
__updated__ = '2014-11-12'
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
@ -61,8 +61,8 @@ class UUIDModel(models.Model):
|
|||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.uuid is None or self.uuid == '':
|
if self.uuid is None or self.uuid == '':
|
||||||
self.uuid = generateUuid()
|
self.uuid = generateUuid()
|
||||||
elif self.uuid != self.uuid.upper():
|
elif self.uuid != self.uuid.lower():
|
||||||
self.uuid = self.uuid.upper() # If we modify uuid elsewhere, ensure that it's stored in upper case
|
self.uuid = self.uuid.lower() # If we modify uuid elsewhere, ensure that it's stored in lower case
|
||||||
|
|
||||||
return models.Model.save(self, *args, **kwargs)
|
return models.Model.save(self, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2014-11-04'
|
__updated__ = '2014-11-12'
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -41,54 +41,54 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
from uds.models.Util import getSqlDatetime
|
from .Util import getSqlDatetime
|
||||||
from uds.models.Util import optimizeTable
|
from .Util import optimizeTable
|
||||||
from uds.models.Util import NEVER
|
from .Util import NEVER
|
||||||
from uds.models.Util import NEVER_UNIX
|
from .Util import NEVER_UNIX
|
||||||
|
|
||||||
# Services
|
# Services
|
||||||
from uds.models.Provider import Provider
|
from .Provider import Provider
|
||||||
from uds.models.Service import Service
|
from .Service import Service
|
||||||
|
|
||||||
# Os managers
|
# Os managers
|
||||||
from uds.models.OSManager import OSManager
|
from .OSManager import OSManager
|
||||||
|
|
||||||
# Transports
|
# Transports
|
||||||
from uds.models.Transport import Transport
|
from .Transport import Transport
|
||||||
from uds.models.Network import Network
|
from .Network import Network
|
||||||
|
|
||||||
|
|
||||||
# Authenticators
|
# Authenticators
|
||||||
from uds.models.Authenticator import Authenticator
|
from .Authenticator import Authenticator
|
||||||
from uds.models.User import User
|
from .User import User
|
||||||
from uds.models.UserPreference import UserPreference
|
from .UserPreference import UserPreference
|
||||||
from uds.models.Group import Group
|
from .Group import Group
|
||||||
|
|
||||||
|
|
||||||
# Provisioned services
|
# Provisioned services
|
||||||
from uds.models.ServicesPool import DeployedService # Old name, will continue here for a while already
|
from .ServicesPool import DeployedService # Old name, will continue here for a while already
|
||||||
from uds.models.ServicesPool import ServicePool # New name
|
from .ServicesPool import ServicePool # New name
|
||||||
from uds.models.ServicesPoolPublication import DeployedServicePublication
|
from .ServicesPoolPublication import DeployedServicePublication
|
||||||
from uds.models.UserService import UserService
|
from .UserService import UserService
|
||||||
|
|
||||||
# Especific log information for an user service
|
# Especific log information for an user service
|
||||||
from uds.models.Log import Log
|
from .Log import Log
|
||||||
|
|
||||||
# Stats
|
# Stats
|
||||||
from uds.models.StatsCounters import StatsCounters
|
from .StatsCounters import StatsCounters
|
||||||
from uds.models.StatsEvents import StatsEvents
|
from .StatsEvents import StatsEvents
|
||||||
|
|
||||||
|
|
||||||
# General utility models, such as a database cache (for caching remote content of slow connections to external services providers for example)
|
# General utility models, such as a database cache (for caching remote content of slow connections to external services providers for example)
|
||||||
# We could use django cache (and maybe we do it in a near future), but we need to clean up things when objecs owning them are deleted
|
# We could use django cache (and maybe we do it in a near future), but we need to clean up things when objecs owning them are deleted
|
||||||
from uds.models.Cache import Cache
|
from .Cache import Cache
|
||||||
from uds.models.Config import Config
|
from .Config import Config
|
||||||
from uds.models.Storage import Storage
|
from .Storage import Storage
|
||||||
from uds.models.UniqueId import UniqueId
|
from .UniqueId import UniqueId
|
||||||
|
|
||||||
# Workers/Schedulers related
|
# Workers/Schedulers related
|
||||||
from uds.models.Scheduler import Scheduler
|
from .Scheduler import Scheduler
|
||||||
from uds.models.DelayedTask import DelayedTask
|
from .DelayedTask import DelayedTask
|
||||||
|
|
||||||
# Image galery related
|
# Image galery related
|
||||||
from uds.models.Image import Image
|
from .Image import Image
|
Loading…
Reference in New Issue
Block a user