Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/cord/admin.py b/xos/cord/admin.py
new file mode 100644
index 0000000..caf5d08
--- /dev/null
+++ b/xos/cord/admin.py
@@ -0,0 +1,185 @@
+from django.contrib import admin
+
+from cord.models import *
+from django import forms
+from django.utils.safestring import mark_safe
+from django.contrib.auth.admin import UserAdmin
+from django.contrib.admin.widgets import FilteredSelectMultiple
+from django.contrib.auth.forms import ReadOnlyPasswordHashField
+from django.contrib.auth.signals import user_logged_in
+from django.utils import timezone
+from django.contrib.contenttypes import generic
+from suit.widgets import LinkedSelect
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline
+
+from functools import update_wrapper
+from django.contrib.admin.views.main import ChangeList
+from django.core.urlresolvers import reverse
+from django.contrib.admin.utils import quote
+
+#-----------------------------------------------------------------------------
+# vOLT
+#-----------------------------------------------------------------------------
+
+class VOLTServiceAdmin(ReadOnlyAwareAdmin):
+ model = VOLTService
+ verbose_name = "vOLT Service"
+ verbose_name_plural = "vOLT Service"
+ list_display = ("backend_status_icon", "name", "enabled")
+ list_display_links = ('backend_status_icon', 'name', )
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ inlines = [SliceInline,ServiceAttrAsTabInline]
+
+ extracontext_registered_admins = True
+
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+ suit_form_tabs =(('general', 'vOLT Service Details'),
+ ('administration', 'Administration'),
+ #('tools', 'Tools'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ )
+
+ suit_form_includes = (('voltadmin.html', 'top', 'administration'),
+ ) #('hpctools.html', 'top', 'tools') )
+
+ def queryset(self, request):
+ return VOLTService.get_service_objects()
+
+class VOLTTenantForm(forms.ModelForm):
+ def __init__(self,*args,**kwargs):
+ super (VOLTTenantForm,self ).__init__(*args,**kwargs)
+ self.fields['kind'].default = "vOLT"
+ self.fields['kind'].widget.attrs['readonly'] = True
+ self.fields['provider_service'].queryset = VOLTService.get_service_objects().all()
+
+ class Meta:
+ model = VOLTTenant
+
+class VOLTTenantAdmin(ReadOnlyAwareAdmin):
+ list_display = ('backend_status_icon', 'id', 'service_specific_id', 'vlan_id' )
+ list_display_links = ('backend_status_icon', 'id')
+ fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ form = VOLTTenantForm
+
+ suit_form_tabs = (('general','Details'),)
+
+ def queryset(self, request):
+ return VOLTTenant.get_tenant_objects()
+
+#-----------------------------------------------------------------------------
+# vCPE
+#-----------------------------------------------------------------------------
+
+class VCPEServiceAdmin(ReadOnlyAwareAdmin):
+ model = VCPEService
+ verbose_name = "vCPE Service"
+ verbose_name_plural = "vCPE Service"
+ list_display = ("backend_status_icon", "name", "enabled")
+ list_display_links = ('backend_status_icon', 'name', )
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ inlines = [SliceInline,ServiceAttrAsTabInline]
+
+ extracontext_registered_admins = True
+
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+ suit_form_tabs =(('general', 'vCPE Service Details'),
+ ('administration', 'Administration'),
+ #('tools', 'Tools'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ )
+
+ suit_form_includes = (('vcpeadmin.html', 'top', 'administration'),
+ ) #('hpctools.html', 'top', 'tools') )
+
+ def queryset(self, request):
+ return VCPEService.get_service_objects()
+
+class VCPETenantForm(forms.ModelForm):
+ def __init__(self,*args,**kwargs):
+ super (VCPETenantForm,self ).__init__(*args,**kwargs)
+ self.fields['kind'].default = "vCPE"
+ self.fields['kind'].widget.attrs['readonly'] = True
+ self.fields['provider_service'].queryset = VCPEService.get_service_objects().all()
+
+ class Meta:
+ model = VCPETenant
+
+class VCPETenantAdmin(ReadOnlyAwareAdmin):
+ list_display = ('backend_status_icon', 'id' )
+ list_display_links = ('backend_status_icon', 'id')
+ fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ form = VCPETenantForm
+
+ suit_form_tabs = (('general','Details'),)
+
+ def queryset(self, request):
+ return VCPETenant.get_tenant_objects()
+
+#-----------------------------------------------------------------------------
+# vBNG
+#-----------------------------------------------------------------------------
+
+class VBNGServiceAdmin(ReadOnlyAwareAdmin):
+ model = VBNGService
+ verbose_name = "vBNG Service"
+ verbose_name_plural = "vBNG Service"
+ list_display = ("backend_status_icon", "name", "enabled")
+ list_display_links = ('backend_status_icon', 'name', )
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ inlines = [SliceInline,ServiceAttrAsTabInline]
+
+ extracontext_registered_admins = True
+
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+ suit_form_tabs =(('general', 'vBNG Service Details'),
+ ('administration', 'Administration'),
+ #('tools', 'Tools'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ )
+
+ suit_form_includes = (('vbngadmin.html', 'top', 'administration'),
+ ) #('hpctools.html', 'top', 'tools') )
+
+ def queryset(self, request):
+ return VBNGService.get_service_objects()
+
+class VBNGTenantForm(forms.ModelForm):
+ def __init__(self,*args,**kwargs):
+ super (VBNGTenantForm,self ).__init__(*args,**kwargs)
+ self.fields['kind'].default = "vBNG"
+ self.fields['kind'].widget.attrs['readonly'] = True
+ self.fields['provider_service'].queryset = VBNGService.get_service_objects().all()
+
+ class Meta:
+ model = VBNGTenant
+
+class VBNGTenantAdmin(ReadOnlyAwareAdmin):
+ list_display = ('backend_status_icon', 'id' )
+ list_display_links = ('backend_status_icon', 'id')
+ fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ form = VBNGTenantForm
+
+ suit_form_tabs = (('general','Details'),)
+
+ def queryset(self, request):
+ return VBNGTenant.get_tenant_objects()
+
+admin.site.register(VOLTService, VOLTServiceAdmin)
+admin.site.register(VOLTTenant, VOLTTenantAdmin)
+admin.site.register(VCPEService, VCPEServiceAdmin)
+admin.site.register(VCPETenant, VCPETenantAdmin)
+admin.site.register(VBNGService, VBNGServiceAdmin)
+admin.site.register(VBNGTenant, VBNGTenantAdmin)
+
diff --git a/xos/cord/templates/voltadmin.html b/xos/cord/templates/voltadmin.html
new file mode 100644
index 0000000..6a583d6
--- /dev/null
+++ b/xos/cord/templates/voltadmin.html
@@ -0,0 +1,8 @@
+<div class = "left-nav">
+<ul>
+{% for admin in registered_admins %}
+ <li><a href="{{ admin.url }}">{{ admin.name }}</a></li>
+{% endfor %}
+</ul>
+</div>
+
diff --git a/xos/core/xoslib/dashboards/xosHpc.html b/xos/core/xoslib/dashboards/xosHpc.html
index bdb964d..85c0cbc 100644
--- a/xos/core/xoslib/dashboards/xosHpc.html
+++ b/xos/core/xoslib/dashboards/xosHpc.html
@@ -22,6 +22,8 @@
<div id="contentInner">
+<dic id="warnings"></div>
+
<h2>Request Routers</h2>
<div id="xos-hpc-dns"></div>
diff --git a/xos/core/xoslib/methods/hpcview.py b/xos/core/xoslib/methods/hpcview.py
index 850e29e..7c4baa9 100644
--- a/xos/core/xoslib/methods/hpcview.py
+++ b/xos/core/xoslib/methods/hpcview.py
@@ -11,8 +11,16 @@
from syndicate_storage.models import Volume
from django.core.exceptions import PermissionDenied
from django.contrib.contenttypes.models import ContentType
+import socket
import time
+NAMESERVERS = ["cdnrr1.opencloud.us",
+ "cdnrr2.opencloud.us",
+ "cdnrr3.opencloud.us",
+ "cdnrr4.opencloud.us",
+ "cdnrr5.opencloud.us",
+ "cdnrr6.opencloud.us"]
+
# This REST API endpoint contains a bunch of misc information that the
# tenant view needs to display
@@ -61,12 +69,39 @@
dnsdemux_service = rr
dnsdemux_slice = slice
+ dnsdemux_has_public_network = False
+ for network in dnsdemux_slice.networks.all():
+ if (network.template) and (network.template.visibility=="public") and (network.template.translation=="none"):
+ dnsdemux_has_public_network = True
+
+ nameservers = {}
+ for nameserver in NAMESERVERS:
+ try:
+ nameservers[nameserver] = {"name": nameserver, "ip": socket.gethostbyname(nameserver), "hit": False}
+ except:
+ nameservers[nameserver] = {"name": nameserver, "ip": "exception", "hit": False}
+
dnsdemux=[]
for sliver in dnsdemux_slice.slivers.all():
+ if dnsdemux_has_public_network:
+ ip = sliver.get_public_ip()
+ else:
+ try:
+ ip = socket.gethostbyname(sliver.node.name)
+ except:
+ ip = "??? " + sliver.node.name
+
+ sliver_nameservers = []
+ for ns in nameservers.values():
+ if ns["ip"]==ip:
+ sliver_nameservers.append(ns["name"])
+ ns["hit"]=True
+
dnsdemux.append( {"name": sliver.node.name,
"watcher.DNS.msg": lookup_tag(dnsdemux_service, sliver, "watcher.DNS.msg"),
"watcher.DNS.time": lookup_time(dnsdemux_service, sliver, "watcher.DNS.time"),
- "ip": sliver.get_public_ip() })
+ "ip": ip,
+ "nameservers": sliver_nameservers })
hpc=[]
for sliver in hpc_slice.slivers.all():
@@ -80,7 +115,8 @@
return { "id": pk,
"dnsdemux": dnsdemux,
- "hpc": hpc }
+ "hpc": hpc,
+ "nameservers": nameservers }
class HpcList(APIView):
diff --git a/xos/core/xoslib/static/js/xosHpc.js b/xos/core/xoslib/static/js/xosHpc.js
index 15dc404..220b1d5 100644
--- a/xos/core/xoslib/static/js/xosHpc.js
+++ b/xos/core/xoslib/static/js/xosHpc.js
@@ -18,12 +18,12 @@
$('#xos-hpc-dns').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamic_dnsdemux"></table>' );
var actualEntries = [];
- console.log(dnsdemux);
+ //console.log(dnsdemux);
for (rowkey in dnsdemux) {
row = dnsdemux[rowkey];
- actualEntries.push( [row.name, row.ip, staleCheck(row, "watcher.DNS.time", "watcher.DNS.msg", SC_RR)] );
+ actualEntries.push( [row.name, row.ip, staleCheck(row, "watcher.DNS.time", "watcher.DNS.msg", SC_RR), row.nameservers.join(",")] );
}
console.log(actualEntries);
oTable = $('#dynamic_dnsdemux').dataTable( {
@@ -36,6 +36,7 @@
{ "sTitle": "Node" },
{ "sTitle": "IP Address" },
{ "sTitle": "Record Checker" },
+ { "sTitle": "Nameservers" },
]
} );
}
@@ -44,7 +45,7 @@
$('#xos-hpc-hpc').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamic_hpc"></table>' );
var actualEntries = [];
- console.log(dnsdemux);
+ //console.log(dnsdemux);
for (rowkey in dnsdemux) {
row = dnsdemux[rowkey];
@@ -66,10 +67,26 @@
} );
}
+function updateWarnings(data) {
+ nameservers = data.attributes.nameservers;
+ warnings = [];
+ for (rowKey in nameservers) {
+ nameserver = nameservers[rowKey]
+ if (!nameserver.hit) {
+ warnings.push("<B>WARNING:</B> nameserver " + nameserver.name + " does not map to a request router");
+ }
+ }
+
+ console.log(warnings);
+
+ $("#warnings").html(warnings.join("<BR>"));
+}
+
function updateHpcView(data) {
data = data[0];
updateDnsDemuxTable( data.attributes.dnsdemux );
updateHpcTable( data.attributes.hpc );
+ updateWarnings( data );
}
$(document).ready(function(){
diff --git a/xos/nginx/xos.conf b/xos/nginx/xos.conf
index 7910d84..9b5d996 100644
--- a/xos/nginx/xos.conf
+++ b/xos/nginx/xos.conf
@@ -15,6 +15,10 @@
access_log off;
}
+ location /files/ {
+ alias /var/www/html/files/;
+ }
+
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass backend;