1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-08 21:18:00 +03:00

Added tagging capability to most entities

This commit is contained in:
Adolfo Gómez García 2016-02-10 01:51:05 +01:00
parent ec93e5c9cc
commit 134f2059dd
11 changed files with 164 additions and 17 deletions

View File

@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('uds', '0018_auto_20151005_1305'),
]
operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('uuid', models.CharField(default=None, max_length=50, unique=True, null=True)),
('tag', models.CharField(unique=True, max_length=32, db_index=True)),
],
options={
'db_table': 'uds_tag',
},
),
migrations.AddField(
model_name='authenticator',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='calendar',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='deployedservice',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='network',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='osmanager',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='provider',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='service',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
migrations.AddField(
model_name='transport',
name='tags',
field=models.ManyToManyField(to='uds.Tag'),
),
]

View File

@ -40,6 +40,7 @@ from django.db.models import signals
from uds.core.util import log
from uds.core.util.State import State
from uds.models.ManagedObjectModel import ManagedObjectModel
from uds.models.Tag import TaggingMixin
from uds.models.Util import NEVER
@ -47,10 +48,10 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-04-27'
__updated__ = '2016-02-10'
@python_2_unicode_compatible
class Authenticator(ManagedObjectModel):
class Authenticator(ManagedObjectModel, TaggingMixin):
'''
This class represents an Authenticator inside the platform.
Sample authenticators are LDAP, Active Directory, SAML, ...

View File

@ -34,12 +34,13 @@
from __future__ import unicode_literals
__updated__ = '2015-09-12'
__updated__ = '2016-02-10'
from django.db import models
from uds.models.UUIDModel import UUIDModel
from django.utils.encoding import python_2_unicode_compatible
# from django.utils.translation import ugettext_lazy as _, ugettext
from uds.models.Tag import TaggingMixin
import logging
@ -47,7 +48,7 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Calendar(UUIDModel):
class Calendar(UUIDModel, TaggingMixin):
name = models.CharField(max_length=128, default='')
comments = models.CharField(max_length=256, default='')

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
__updated__ = '2015-03-02'
__updated__ = '2016-02-10'
from django.db import models
from django.db.models import signals
@ -42,6 +42,7 @@ from django.utils.encoding import python_2_unicode_compatible
from uds.models.Transport import Transport
from uds.core.util import net
from uds.models.UUIDModel import UUIDModel
from uds.models.Tag import TaggingMixin
import logging
@ -49,7 +50,7 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Network(UUIDModel):
class Network(UUIDModel, TaggingMixin):
'''
This model is used for keeping information of networks associated with transports (right now, just transports..)
'''

View File

@ -33,13 +33,14 @@
from __future__ import unicode_literals
__updated__ = '2014-10-31'
__updated__ = '2016-02-10'
from django.utils.encoding import python_2_unicode_compatible
from django.db import IntegrityError
from django.db.models import signals
from uds.models.ManagedObjectModel import ManagedObjectModel
from uds.models.Tag import TaggingMixin
import logging
@ -47,7 +48,7 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class OSManager(ManagedObjectModel):
class OSManager(ManagedObjectModel, TaggingMixin):
'''
An OS Manager represents a manager for responding requests for agents inside services.
'''

View File

@ -39,18 +39,19 @@ from django.db.models import signals
from uds.core.util import log
from uds.models.ManagedObjectModel import ManagedObjectModel
from uds.models.Tag import TaggingMixin
import logging
__updated__ = '2015-11-16'
__updated__ = '2016-02-10'
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Provider(ManagedObjectModel):
class Provider(ManagedObjectModel, TaggingMixin):
'''
A Provider represents the Service provider itself, (i.e. a KVM Server or a Terminal Server)
'''

View File

@ -41,20 +41,21 @@ from uds.core.Environment import Environment
from uds.core.util import log
from uds.core.util import unique
from uds.models.ManagedObjectModel import ManagedObjectModel
from uds.models.Tag import TaggingMixin
from uds.models.Provider import Provider
import logging
__updated__ = '2015-11-16'
__updated__ = '2016-02-10'
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Service(ManagedObjectModel):
class Service(ManagedObjectModel, TaggingMixin):
'''
A Service represents an specidied type of service offered to final users, with it configuration (i.e. a KVM Base Machine for cloning
or a Terminal Server configuration).

View File

@ -42,6 +42,7 @@ from uds.core.util import log
from uds.core.util.State import State
from uds.core.services.Exceptions import InvalidServiceException
from uds.models.UUIDModel import UUIDModel
from uds.models.Tag import TaggingMixin
from uds.models.OSManager import OSManager
from uds.models.Service import Service
@ -55,14 +56,14 @@ from uds.models.Util import getSqlDatetime
from datetime import timedelta
import logging
__updated__ = '2015-11-18'
__updated__ = '2016-02-10'
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class DeployedService(UUIDModel):
class DeployedService(UUIDModel, TaggingMixin):
'''
A deployed service is the Service produced element that is assigned finally to an user (i.e. a Virtual Machine, etc..)
'''

View File

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
'''
from __future__ import unicode_literals
__updated__ = '2016-02-10'
from django.db import models
from uds.models.UUIDModel import UUIDModel
import logging
logger = logging.getLogger(__name__)
class Tag(UUIDModel):
'''
Log model associated with an object.
This log is mainly used to keep track of log relative to objects
(such as when a user access a machine, or information related to user logins/logout, errors, ...)
'''
tag = models.CharField(max_length=32, db_index=True, unique=True)
class Meta:
'''
Meta class to declare db table
'''
db_table = 'uds_tag'
app_label = 'uds'
def __unicode__(self):
return 'Tag: {} {}'.format(self.uuid, self.tag)
class TaggingMixin(models.Model):
tags = models.ManyToManyField(Tag)
class Meta:
abstract = True

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
__updated__ = '2015-03-02'
__updated__ = '2016-02-10'
from django.db import models
from django.db.models import signals
@ -42,6 +42,7 @@ from django.utils.encoding import python_2_unicode_compatible
from uds.core.util import net
from uds.models.ManagedObjectModel import ManagedObjectModel
from uds.models.Tag import TaggingMixin
import logging
@ -49,7 +50,7 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Transport(ManagedObjectModel):
class Transport(ManagedObjectModel, TaggingMixin):
'''
A Transport represents a way of connecting the user with the service.

View File

@ -98,7 +98,10 @@ from .TicketStore import TicketStore
from .Calendar import Calendar
from .CalendarRule import CalendarRule
__updated__ = '2015-09-08'
# Tagging
from .Tag import Tag
__updated__ = '2016-02-10'
logger = logging.getLogger(__name__)