From 7892a196acfecaaadda97cb9d667acc63dd6768f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 10 Oct 2016 07:52:03 +0200 Subject: [PATCH] Adapting v2.1 --- VERSION | 2 +- .../migrations/0023_transport_allowed_oss.py | 20 +++++++++++++++++++ server/src/uds/models/Transport.py | 11 +++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 server/src/uds/migrations/0023_transport_allowed_oss.py diff --git a/VERSION b/VERSION index 227cea215..7ec1d6db4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +2.1.0 diff --git a/server/src/uds/migrations/0023_transport_allowed_oss.py b/server/src/uds/migrations/0023_transport_allowed_oss.py new file mode 100644 index 000000000..b045c06b6 --- /dev/null +++ b/server/src/uds/migrations/0023_transport_allowed_oss.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.9 on 2016-10-10 07:51 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('uds', '0022_dbfile_owner'), + ] + + operations = [ + migrations.AddField( + model_name='transport', + name='allowed_oss', + field=models.CharField(default='', max_length=255), + ), + ] diff --git a/server/src/uds/models/Transport.py b/server/src/uds/models/Transport.py index dc3bd864d..4afcd32de 100644 --- a/server/src/uds/models/Transport.py +++ b/server/src/uds/models/Transport.py @@ -33,7 +33,7 @@ from __future__ import unicode_literals -__updated__ = '2016-02-26' +__updated__ = '2016-08-24' from django.db import models from django.db.models import signals @@ -59,6 +59,9 @@ class Transport(ManagedObjectModel, TaggingMixin): # pylint: disable=model-missing-unicode priority = models.IntegerField(default=0, db_index=True) nets_positive = models.BooleanField(default=False) + # We store allowed oss as a comma-separated list + allowed_oss = models.CharField(max_length=255, default='') + class Meta(ManagedObjectModel.Meta): ''' @@ -113,6 +116,12 @@ class Transport(ManagedObjectModel, TaggingMixin): else: return self.networks.filter(net_start__lte=ip, net_end__gte=ip).count() == 0 + def validForOs(self, os): + logger.debug('Checkin if os "{}" is in "{}"'.format(os, self.allowed_oss)) + if self.allowed_oss == '' or os in self.allowed_oss.split(','): + return True + return False + def __str__(self): return u"{0} of type {1} (id:{2})".format(self.name, self.data_type, self.id)