|
@@ -19,13 +19,13 @@
|
|
|
#
|
|
|
|
|
|
|
|
|
# Django imports.
|
|
|
from django.contrib.admin.utils import NestedObjects
|
|
|
from django.core.exceptions import ValidationError
|
|
|
from django.core.urlresolvers import reverse
|
|
|
from django.urls import reverse
|
|
|
from django.db import models
|
|
|
from django.db.models.query_utils import Q
|
|
|
|
|
|
# Application imports.
|
|
|
from .utils import list_formatter_callback, get_distinct_colors
|
|
|
|
|
@@ -245,14 +245,14 @@ class Entity(RelatedCollectorMixin, mode
|
|
|
location - Foreign key pointing to the location at which the entity is
|
|
|
located.
|
|
|
"""
|
|
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
description = models.TextField(blank=True)
|
|
|
project = models.ForeignKey(Project)
|
|
|
location = models.ForeignKey(Location)
|
|
|
project = models.ForeignKey(Project, on_delete = models.CASCADE)
|
|
|
location = models.ForeignKey(Location, on_delete = models.CASCADE)
|
|
|
objects = SearchManager()
|
|
|
|
|
|
class Meta:
|
|
|
# Fix the plural form used by Django.
|
|
|
verbose_name_plural = 'entities'
|
|
|
# Enforce uniqueness of entity name in a project.
|
|
@@ -342,13 +342,13 @@ class Interface(RelatedCollectorMixin, m
|
|
|
(255.255.255.255), but in case of subnet entities this can be used for
|
|
|
denoting the network netmask.
|
|
|
"""
|
|
|
|
|
|
name = models.CharField(max_length=100, default='eth0')
|
|
|
description = models.TextField(blank=True, default='Main network interface.')
|
|
|
entity = models.ForeignKey(Entity)
|
|
|
entity = models.ForeignKey(Entity, on_delete = models.CASCADE)
|
|
|
address = models.GenericIPAddressField()
|
|
|
netmask = models.GenericIPAddressField(default='255.255.255.255')
|
|
|
|
|
|
class Meta:
|
|
|
# Enforce uniqueness of interface name in an entity. Enforce uniqueness
|
|
|
# of IP address in a subnet for an entity.
|
|
@@ -404,14 +404,14 @@ class Communication(RelatedCollectorMixi
|
|
|
PROTOCOL_CHOICES = (
|
|
|
('TCP', 'TCP'),
|
|
|
('UDP', 'UDP'),
|
|
|
('ICMP', 'ICMP'),
|
|
|
)
|
|
|
|
|
|
source = models.ForeignKey(Interface, related_name='source_set')
|
|
|
destination = models.ForeignKey(Interface, related_name='destination_set')
|
|
|
source = models.ForeignKey(Interface, related_name='source_set', on_delete = models.CASCADE)
|
|
|
destination = models.ForeignKey(Interface, related_name='destination_set', on_delete = models.CASCADE)
|
|
|
protocol = models.CharField(max_length=10, choices=PROTOCOL_CHOICES)
|
|
|
port = models.IntegerField(default=0)
|
|
|
description = models.TextField(blank=True)
|
|
|
|
|
|
class Meta:
|
|
|
# Enforce uniqueness of communication.
|