mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
* Fixed a bug that made deployed services from services that do not need publication appear as much times as valid groups for that deployed service
* Removed annoying exception logging (user creation for internaldb when user already exists, but error is managed so it do no have to be logged) * Minor aesthetic fix on User class * Fixed name generators so if it consumes all range, an exception is generated * Fixed ovirt linked vm so it treats no more names error * Fixed user modify operation, so if user is derived Groups are not saved (they will be got from parent user)
This commit is contained in:
parent
9642392d7c
commit
d47823bbd2
@ -90,7 +90,7 @@ class InternalDBAuth(Authenticator):
|
|||||||
usr.parent = parent
|
usr.parent = parent
|
||||||
usr.save()
|
usr.save()
|
||||||
except:
|
except:
|
||||||
logger.exception('Exception')
|
pass # User already exists
|
||||||
username = newUsername
|
username = newUsername
|
||||||
|
|
||||||
return username
|
return username
|
||||||
|
@ -86,9 +86,7 @@ class User(object):
|
|||||||
else:
|
else:
|
||||||
# From db
|
# From db
|
||||||
usr = DbUser.objects.get(pk=self._dbUser.id)
|
usr = DbUser.objects.get(pk=self._dbUser.id)
|
||||||
self._groups = []
|
self._groups = [Group(g) for g in usr.getGroups()]
|
||||||
for g in usr.getGroups():
|
|
||||||
self._groups.append(Group(g))
|
|
||||||
return self._groups
|
return self._groups
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ class UniqueNameGenerator(UniqueIDGenerator):
|
|||||||
super(UniqueNameGenerator, self).__init__('name', owner, )
|
super(UniqueNameGenerator, self).__init__('name', owner, )
|
||||||
|
|
||||||
def __toName(self, seq, length):
|
def __toName(self, seq, length):
|
||||||
|
if seq == -1:
|
||||||
|
raise KeyError('No more names available. Please, increase service digits.')
|
||||||
return "%s%0*d" % (self._baseName, length, seq)
|
return "%s%0*d" % (self._baseName, length, seq)
|
||||||
|
|
||||||
def get(self, baseName, length=5):
|
def get(self, baseName, length=5):
|
||||||
|
@ -1073,7 +1073,7 @@ class DeployedService(models.Model):
|
|||||||
# Now get deployed services that DO NOT NEED publication
|
# Now get deployed services that DO NOT NEED publication
|
||||||
doNotNeedPublishing = [ t.type() for t in services.factory().servicesThatDoNotNeedPublication() ]
|
doNotNeedPublishing = [ t.type() for t in services.factory().servicesThatDoNotNeedPublication() ]
|
||||||
list2 = DeployedService.objects.filter(assignedGroups__in=groups, assignedGroups__state__exact=State.ACTIVE, service__data_type__in=doNotNeedPublishing, state = State.ACTIVE)
|
list2 = DeployedService.objects.filter(assignedGroups__in=groups, assignedGroups__state__exact=State.ACTIVE, service__data_type__in=doNotNeedPublishing, state = State.ACTIVE)
|
||||||
return [ r for r in list1 ] + [ r for r in list2 ]
|
return list(set([ r for r in list1 ] + [ r for r in list2 ]))
|
||||||
|
|
||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
|
@ -42,6 +42,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
opCreate, opStart, opStop, opSuspend, opRemove, opWait, opError, opFinish, opRetry, opChangeMac = range(10)
|
opCreate, opStart, opStop, opSuspend, opRemove, opWait, opError, opFinish, opRetry, opChangeMac = range(10)
|
||||||
|
|
||||||
|
NO_MORE_NAMES = 'NO-NAME-ERROR'
|
||||||
|
|
||||||
class OVirtLinkedDeployment(UserDeployment):
|
class OVirtLinkedDeployment(UserDeployment):
|
||||||
'''
|
'''
|
||||||
This class generates the user consumable elements of the service tree.
|
This class generates the user consumable elements of the service tree.
|
||||||
@ -103,7 +105,10 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
generate more names. (Generator are simple utility classes)
|
generate more names. (Generator are simple utility classes)
|
||||||
'''
|
'''
|
||||||
if self._name == '':
|
if self._name == '':
|
||||||
|
try:
|
||||||
self._name = self.nameGenerator().get( self.service().getBaseName(), self.service().getLenName() )
|
self._name = self.nameGenerator().get( self.service().getBaseName(), self.service().getLenName() )
|
||||||
|
except KeyError:
|
||||||
|
return NO_MORE_NAMES
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
||||||
@ -323,7 +328,11 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
Deploys a machine from template for user/cache
|
Deploys a machine from template for user/cache
|
||||||
'''
|
'''
|
||||||
templateId = self.publication().getTemplateId()
|
templateId = self.publication().getTemplateId()
|
||||||
name = self.service().sanitizeVmName(self.getName()) # oVirt don't let us to create machines with more than 15 chars!!!
|
name = self.getName()
|
||||||
|
if name == NO_MORE_NAMES:
|
||||||
|
raise Exception('No more names available for this service. (Increase digits for this service to fix)')
|
||||||
|
|
||||||
|
name = self.service().sanitizeVmName(name) # oVirt don't let us to create machines with more than 15 chars!!!
|
||||||
comments = 'UDS Linked clone'
|
comments = 'UDS Linked clone'
|
||||||
|
|
||||||
self._vmid = self.service().deployFromTemplate(name, comments, templateId)
|
self._vmid = self.service().deployFromTemplate(name, comments, templateId)
|
||||||
|
@ -138,7 +138,7 @@ def modifyUser(credentials, usr):
|
|||||||
user.state = usr['state']
|
user.state = usr['state']
|
||||||
user.save()
|
user.save()
|
||||||
# Now add/removes groups acordly
|
# Now add/removes groups acordly
|
||||||
if auth.isExternalSource == False:
|
if auth.isExternalSource == False and user.parent == -1:
|
||||||
newGrps = {}
|
newGrps = {}
|
||||||
knownGrps = user.groups.all()
|
knownGrps = user.groups.all()
|
||||||
# Add new groups, and keep a dict of all groups selected
|
# Add new groups, and keep a dict of all groups selected
|
||||||
|
Loading…
Reference in New Issue
Block a user