Add Site and Deployment to Network object
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index dd89024..713dfdd 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -867,14 +867,23 @@
verbose_name = "Slice"
suit_classes = 'suit-tab suit-tab-networkslices'
+class NetworkForm(forms.ModelForm):
+ class Meta:
+ widgets = {
+ 'deployment': LinkedSelect,
+ 'site': LinkedSelect,
+ }
+
class NetworkAdmin(admin.ModelAdmin):
+ form = NetworkForm
list_display = ("name", "subnet", "ports", "labels")
+ list_filter = ('deployment', )
readonly_fields = ("subnet", )
inlines = [NetworkParameterInline, NetworkSliversInline, NetworkSlicesInline, RouterInline]
fieldsets = [
- (None, {'fields': ['name','template','ports','labels','owner','guaranteedBandwidth', 'permitAllSlices','permittedSlices','network_id','router_id','subnet_id','subnet'], 'classes':['suit-tab suit-tab-general']}),]
+ (None, {'fields': ['name','template','ports','labels','owner','guaranteedBandwidth', 'permitAllSlices','permittedSlices','site','deployment','network_id','router_id','subnet_id','subnet'], 'classes':['suit-tab suit-tab-general']}),]
suit_form_tabs =(
('general','Network Details'),
diff --git a/planetstack/core/models/network.py b/planetstack/core/models/network.py
index 72e7a5f..63a4191 100644
--- a/planetstack/core/models/network.py
+++ b/planetstack/core/models/network.py
@@ -1,7 +1,7 @@
import os
import socket
from django.db import models
-from core.models import PlCoreBase, Site, Slice, Sliver
+from core.models import PlCoreBase, Site, Slice, Sliver, Deployment
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
@@ -26,6 +26,8 @@
class Network(PlCoreBase):
name = models.CharField(max_length=32)
template = models.ForeignKey(NetworkTemplate)
+ deployment = models.ForeignKey(Deployment, related_name="networks", help_text="Deployment this Network belongs to")
+ site = models.ForeignKey(Site, blank=True, null=True, default=None, related_name="networks", help_text="Is this an infrastructure Network at a single Site?")
subnet = models.CharField(max_length=32, blank=True)
ports = models.CharField(max_length=1024, blank=True, null=True)
labels = models.CharField(max_length=1024, blank=True, null=True)