Add Site and Deployment to Network object
authorAndy Bavier <acb@cs.princeton.edu>
Thu, 21 Nov 2013 19:11:48 +0000 (14:11 -0500)
committerAndy Bavier <acb@cs.princeton.edu>
Thu, 21 Nov 2013 19:11:48 +0000 (14:11 -0500)
planetstack/core/admin.py
planetstack/core/models/network.py

index dd89024..713dfdd 100644 (file)
@@ -867,14 +867,23 @@ class NetworkSlicesInline(admin.TabularInline):
     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'),
index 72e7a5f..63a4191 100644 (file)
@@ -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 NetworkTemplate(PlCoreBase):
 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)