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
|
||||
if authId is not None:
|
||||
auth = Authenticator.objects.get(uuid=authId.upper())
|
||||
auth = Authenticator.objects.get(uuid=authId.lower())
|
||||
elif authName is not None:
|
||||
auth = Authenticator.objects.get(name=authName)
|
||||
else:
|
||||
@ -135,11 +135,11 @@ class Tickets(Handler):
|
||||
transport = 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)
|
||||
if transport is not None:
|
||||
transport = Transport.objects.get(uuid=transport.upper())
|
||||
transport = Transport.objects.get(uuid=transport.lower())
|
||||
try:
|
||||
servicePool.validateTransport(transport)
|
||||
except Exception:
|
||||
|
@ -614,7 +614,7 @@ class ModelHandler(BaseModelHandler):
|
||||
if self._args[1] == cm[0]:
|
||||
try:
|
||||
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:
|
||||
self.invalidMethodException()
|
||||
|
||||
@ -639,7 +639,7 @@ class ModelHandler(BaseModelHandler):
|
||||
|
||||
# get item ID
|
||||
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)
|
||||
self.fillIntanceFields(val, res)
|
||||
return res
|
||||
@ -664,7 +664,7 @@ class ModelHandler(BaseModelHandler):
|
||||
if nArgs != 2:
|
||||
self.invalidRequestException()
|
||||
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:
|
||||
self.invalidItemException()
|
||||
return self.getLogs(item)
|
||||
@ -708,7 +708,7 @@ class ModelHandler(BaseModelHandler):
|
||||
deleteOnError = True
|
||||
else: # Must have 1 arg
|
||||
# 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:
|
||||
if v in args:
|
||||
del args[v]
|
||||
@ -759,7 +759,7 @@ class ModelHandler(BaseModelHandler):
|
||||
if len(self._args) != 1:
|
||||
raise RequestError('Delete need one and only one argument')
|
||||
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.deleteItem(item)
|
||||
except self.model.DoesNotExist:
|
||||
|
@ -128,7 +128,7 @@ class CryptoManager(object):
|
||||
|
||||
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:
|
||||
@ -139,4 +139,5 @@ class CryptoManager(object):
|
||||
obj = obj.decode('utf-8')
|
||||
else:
|
||||
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
|
||||
|
||||
__updated__ = '2014-11-02'
|
||||
__updated__ = '2014-11-12'
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
@ -61,8 +61,8 @@ class UUIDModel(models.Model):
|
||||
def save(self, *args, **kwargs):
|
||||
if self.uuid is None or self.uuid == '':
|
||||
self.uuid = generateUuid()
|
||||
elif self.uuid != self.uuid.upper():
|
||||
self.uuid = self.uuid.upper() # If we modify uuid elsewhere, ensure that it's stored in upper case
|
||||
elif self.uuid != self.uuid.lower():
|
||||
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)
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2014-11-04'
|
||||
__updated__ = '2014-11-12'
|
||||
|
||||
import logging
|
||||
|
||||
@ -41,54 +41,54 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Utility
|
||||
from uds.models.Util import getSqlDatetime
|
||||
from uds.models.Util import optimizeTable
|
||||
from uds.models.Util import NEVER
|
||||
from uds.models.Util import NEVER_UNIX
|
||||
from .Util import getSqlDatetime
|
||||
from .Util import optimizeTable
|
||||
from .Util import NEVER
|
||||
from .Util import NEVER_UNIX
|
||||
|
||||
# Services
|
||||
from uds.models.Provider import Provider
|
||||
from uds.models.Service import Service
|
||||
from .Provider import Provider
|
||||
from .Service import Service
|
||||
|
||||
# Os managers
|
||||
from uds.models.OSManager import OSManager
|
||||
from .OSManager import OSManager
|
||||
|
||||
# Transports
|
||||
from uds.models.Transport import Transport
|
||||
from uds.models.Network import Network
|
||||
from .Transport import Transport
|
||||
from .Network import Network
|
||||
|
||||
|
||||
# Authenticators
|
||||
from uds.models.Authenticator import Authenticator
|
||||
from uds.models.User import User
|
||||
from uds.models.UserPreference import UserPreference
|
||||
from uds.models.Group import Group
|
||||
from .Authenticator import Authenticator
|
||||
from .User import User
|
||||
from .UserPreference import UserPreference
|
||||
from .Group import Group
|
||||
|
||||
|
||||
# Provisioned services
|
||||
from uds.models.ServicesPool import DeployedService # Old name, will continue here for a while already
|
||||
from uds.models.ServicesPool import ServicePool # New name
|
||||
from uds.models.ServicesPoolPublication import DeployedServicePublication
|
||||
from uds.models.UserService import UserService
|
||||
from .ServicesPool import DeployedService # Old name, will continue here for a while already
|
||||
from .ServicesPool import ServicePool # New name
|
||||
from .ServicesPoolPublication import DeployedServicePublication
|
||||
from .UserService import UserService
|
||||
|
||||
# Especific log information for an user service
|
||||
from uds.models.Log import Log
|
||||
from .Log import Log
|
||||
|
||||
# Stats
|
||||
from uds.models.StatsCounters import StatsCounters
|
||||
from uds.models.StatsEvents import StatsEvents
|
||||
from .StatsCounters import StatsCounters
|
||||
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)
|
||||
# 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 uds.models.Config import Config
|
||||
from uds.models.Storage import Storage
|
||||
from uds.models.UniqueId import UniqueId
|
||||
from .Cache import Cache
|
||||
from .Config import Config
|
||||
from .Storage import Storage
|
||||
from .UniqueId import UniqueId
|
||||
|
||||
# Workers/Schedulers related
|
||||
from uds.models.Scheduler import Scheduler
|
||||
from uds.models.DelayedTask import DelayedTask
|
||||
from .Scheduler import Scheduler
|
||||
from .DelayedTask import DelayedTask
|
||||
|
||||
# Image galery related
|
||||
from uds.models.Image import Image
|
||||
from .Image import Image
|
Loading…
Reference in New Issue
Block a user