1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +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:
Adolfo Gómez 2013-05-16 10:37:33 +00:00
parent 9642392d7c
commit d47823bbd2
6 changed files with 17 additions and 8 deletions

View File

@ -90,7 +90,7 @@ class InternalDBAuth(Authenticator):
usr.parent = parent
usr.save()
except:
logger.exception('Exception')
pass # User already exists
username = newUsername
return username

View File

@ -86,9 +86,7 @@ class User(object):
else:
# From db
usr = DbUser.objects.get(pk=self._dbUser.id)
self._groups = []
for g in usr.getGroups():
self._groups.append(Group(g))
self._groups = [Group(g) for g in usr.getGroups()]
return self._groups

View File

@ -42,6 +42,8 @@ class UniqueNameGenerator(UniqueIDGenerator):
super(UniqueNameGenerator, self).__init__('name', owner, )
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)
def get(self, baseName, length=5):

View File

@ -1073,7 +1073,7 @@ class DeployedService(models.Model):
# Now get deployed services that DO NOT NEED publication
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)
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):

View File

@ -42,6 +42,8 @@ logger = logging.getLogger(__name__)
opCreate, opStart, opStop, opSuspend, opRemove, opWait, opError, opFinish, opRetry, opChangeMac = range(10)
NO_MORE_NAMES = 'NO-NAME-ERROR'
class OVirtLinkedDeployment(UserDeployment):
'''
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)
'''
if self._name == '':
self._name = self.nameGenerator().get( self.service().getBaseName(), self.service().getLenName() )
try:
self._name = self.nameGenerator().get( self.service().getBaseName(), self.service().getLenName() )
except KeyError:
return NO_MORE_NAMES
return self._name
@ -323,7 +328,11 @@ class OVirtLinkedDeployment(UserDeployment):
Deploys a machine from template for user/cache
'''
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'
self._vmid = self.service().deployFromTemplate(name, comments, templateId)

View File

@ -138,7 +138,7 @@ def modifyUser(credentials, usr):
user.state = usr['state']
user.save()
# Now add/removes groups acordly
if auth.isExternalSource == False:
if auth.isExternalSource == False and user.parent == -1:
newGrps = {}
knownGrps = user.groups.all()
# Add new groups, and keep a dict of all groups selected