blob: 0d8a1fff7fc7204f6c76a2aece178cd716ebe763 [file] [log] [blame]
Scott Bakerc3ce3e72016-06-20 17:35:19 -07001from django.contrib import admin
2
3from django import forms
4from django.utils.safestring import mark_safe
5from django.contrib.auth.admin import UserAdmin
6from django.contrib.admin.widgets import FilteredSelectMultiple
7from django.contrib.auth.forms import ReadOnlyPasswordHashField
8from django.contrib.auth.signals import user_logged_in
9from django.utils import timezone
10from django.contrib.contenttypes import generic
11from suit.widgets import LinkedSelect
Scott Bakerd949b622017-07-18 12:10:35 -070012from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline
Scott Bakerc3ce3e72016-06-20 17:35:19 -070013from core.middleware import get_request
14
15from services.vtn.models import *
16
17from functools import update_wrapper
18from django.contrib.admin.views.main import ChangeList
19from django.core.urlresolvers import reverse
20from django.contrib.admin.utils import quote
21
Scott Bakerc3ce3e72016-06-20 17:35:19 -070022class VTNServiceAdmin(ReadOnlyAwareAdmin):
23 model = VTNService
Scott Bakerc3ce3e72016-06-20 17:35:19 -070024 verbose_name = "VTN Service"
25 verbose_name_plural = "VTN Service"
26 list_display = ("backend_status_icon", "name", "enabled")
27 list_display_links = ('backend_status_icon', 'name', )
28 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber','description',"view_url","icon_url",
Scott Bakerff016682016-11-28 09:53:13 -080029 'privateGatewayMac', 'localManagementIp', 'ovsdbPort', 'sshPort', 'sshUser', 'sshKeyFile', 'mgmtSubnetBits', 'xosEndpoint', 'xosUser', 'xosPassword', 'vtnAPIVersion', 'controllerPort' ], 'classes':['suit-tab suit-tab-general']})]
Scott Bakerc3ce3e72016-06-20 17:35:19 -070030 readonly_fields = ('backend_status_text', )
31 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
32
33 extracontext_registered_admins = True
34
35 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
36
37 suit_form_tabs =(('general', 'VTN Service Details'),
38# ('administration', 'Administration'),
39 ('slices','Slices'),
40 ('serviceattrs','Additional Attributes'),
41 ('serviceprivileges','Privileges'),
42 )
43
44 suit_form_includes = ( # ('vtnadmin.html', 'top', 'administration'),
45 ) #('hpctools.html', 'top', 'tools') )
46
Zack Williamsabe24da2016-06-27 13:09:00 -070047 def get_queryset(self, request):
Scott Bakercd2db8c2017-05-25 09:07:19 -070048 return VTNService.select_by_user(request.user)
Scott Bakerc3ce3e72016-06-20 17:35:19 -070049
50admin.site.register(VTNService, VTNServiceAdmin)