Matteo Scandolo | fcf842e | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Rizwan Haider | 30b3379 | 2016-08-18 02:11:18 -0400 | [diff] [blame] | 17 | # admin.py - MetroNetworkService Django Admin |
| 18 | |
| 19 | from core.admin import ReadOnlyAwareAdmin |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 20 | from core.admin import XOSBaseAdmin |
Rizwan Haider | 30b3379 | 2016-08-18 02:11:18 -0400 | [diff] [blame] | 21 | from django.contrib import admin |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 22 | from django import forms |
Rizwan Haider | 30b3379 | 2016-08-18 02:11:18 -0400 | [diff] [blame] | 23 | from services.metronetwork.models import * |
| 24 | |
| 25 | |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 26 | class MetroNetworkSystemAdmin(ReadOnlyAwareAdmin): |
| 27 | model = MetroNetworkSystem |
| 28 | verbose_name = "MetroNetwork System" |
| 29 | verbose_name_plural = "MetroNetwork System" |
Rizwan Haider | 30b3379 | 2016-08-18 02:11:18 -0400 | [diff] [blame] | 30 | list_display = ("name", "administrativeState") |
| 31 | list_display_links = ('name',) |
| 32 | fieldsets = [(None, { |
| 33 | 'fields': ['name', 'administrativeState', 'description'], |
| 34 | 'classes': ['suit-tab suit-tab-general']})] |
| 35 | |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 36 | class NetworkDeviceAdminForm(forms.ModelForm): |
| 37 | |
| 38 | password = forms.CharField(required=False, widget = forms.PasswordInput(render_value=True)) |
| 39 | |
| 40 | class Meta: |
| 41 | model = NetworkDevice |
| 42 | fields = '__all__' |
| 43 | |
| 44 | |
| 45 | class NetworkDeviceAdmin(XOSBaseAdmin): |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 46 | verbose_name = "Network Device" |
| 47 | verbose_name_plural = "Network Devices" |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 48 | form = NetworkDeviceAdminForm |
| 49 | list_display = ('id', 'restCtrlUrl', 'administrativeState', 'username') |
| 50 | list_display_links = ('id', 'restCtrlUrl', 'administrativeState', 'username') |
| 51 | |
| 52 | fields = ('id', 'restCtrlUrl', 'administrativeState', 'username', 'password') |
| 53 | |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 54 | class NetworkEdgePortAdmin(XOSBaseAdmin): |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 55 | verbose_name = "Network Edge Port" |
| 56 | verbose_name_plural = "Network Edge Ports" |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 57 | list_display = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir', 'name', 'location', 'latlng') |
| 58 | list_display_links = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir') |
| 59 | |
| 60 | fields = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir', 'name', 'location', 'latlng') |
| 61 | readonly_fields = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir') |
| 62 | |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 63 | class NetworkEdgeToEdgePointConnectionAdmin(XOSBaseAdmin): |
| 64 | verbose_name = "Metro Network E-Line Service" |
| 65 | verbose_name_plural = "Metro Network E-Line Services" |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 66 | list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate') |
| 67 | list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate') |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 68 | |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 69 | fields = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate', 'backend_status') |
| 70 | readonly_fields = ('id', 'sid', 'backend_status') |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 71 | |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 72 | class NetworkMultipointToMultipointConnectionAdmin(XOSBaseAdmin): |
| 73 | verbose_name = "Metro Network E-LAN Service" |
| 74 | verbose_name_plural = "Metro Network E-LAN Services" |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 75 | list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate') |
| 76 | list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate') |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 77 | |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 78 | fields = ('id', 'name', 'sid', 'type', 'vlanid', 'eps', 'adminstate', 'operstate', 'backend_status') |
| 79 | readonly_fields = ('id', 'sid', 'backend_status') |
Rizwan Haider | 30b3379 | 2016-08-18 02:11:18 -0400 | [diff] [blame] | 80 | |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 81 | class NetworkEdgeToMultipointConnectionAdmin(XOSBaseAdmin): |
| 82 | verbose_name = "Metro Network E-Tree Service" |
| 83 | verbose_name_plural = "Metro Network E-Tree Services" |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 84 | list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate') |
| 85 | list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate') |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 86 | |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 87 | fields = ('id', 'name', 'sid', 'type', 'vlanid', 'root', 'eps', 'adminstate', 'operstate', 'backend_status') |
| 88 | readonly_fields = ('id', 'sid', 'backend_status') |
| 89 | |
| 90 | class RemotePortAdmin(XOSBaseAdmin): |
| 91 | verbose_name = "Remote Port" |
| 92 | verbose_name_plural = "Remote Ports" |
| 93 | list_display = ('name', 'remoteportsite', 'edgeport') |
| 94 | list_display_links = ('name', 'remoteportsite', 'edgeport') |
| 95 | |
| 96 | fields = ('name', 'remoteportsite', 'edgeport') |
| 97 | |
| 98 | class BandwidthProfileAdmin(XOSBaseAdmin): |
| 99 | verbose_name = "Bandwidth Profile" |
| 100 | verbose_name_plural = "Bandwidth Profiles" |
| 101 | list_display = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name') |
| 102 | list_display_links = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name') |
| 103 | |
| 104 | fields = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name') |
| 105 | |
| 106 | class ServiceSpokeAdmin(XOSBaseAdmin): |
| 107 | verbose_name = "Service Spoke" |
| 108 | verbose_name_plural = "Service Spokes" |
| 109 | list_display = ('name','vnodlocalsite', 'remotesubscriber', 'adminstate', 'operstate', 'autoattached') |
| 110 | list_display_links = ('name','vnodlocalsite', 'remotesubscriber', 'adminstate', 'operstate', 'autoattached') |
| 111 | |
| 112 | fields = ('name', 'id','vnodlocalsite', 'vnodlocalport', 'remotesubscriber', 'adminstate', 'operstate', 'backend_status', 'autoattached') |
| 113 | readonly_fields = ('id', 'remotesubscriber', 'adminstate', 'operstate', 'backend_status') |
| 114 | |
| 115 | class VnodGlobalServiceAdmin(XOSBaseAdmin): |
| 116 | verbose_name = "VNOD Global Service" |
| 117 | verbose_name_plural = "VNOD Global Services" |
| 118 | list_display = ('servicehandle', 'vlanid', 'type','operstate', 'adminstate') |
| 119 | list_display_links = ('servicehandle', 'vlanid', 'type','operstate', 'adminstate') |
| 120 | |
| 121 | fields = ( |
| 122 | 'id', 'servicehandle', 'vlanid', 'type', 'metronetworkmultipoint', 'metronetworkpointtopoint', 'metronetworkroottomultipoint', 'operstate', 'adminstate', 'spokes', 'bandwidthProfile') |
| 123 | readonly_fields = ( |
| 124 | 'id', 'operstate', 'backend_status', 'metronetworkmultipoint', 'metronetworkpointtopoint', 'metronetworkroottomultipoint') |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 125 | |
| 126 | admin.site.register(MetroNetworkSystem, MetroNetworkSystemAdmin) |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 127 | admin.site.register(NetworkDevice, NetworkDeviceAdmin) |
Rizwan Haider | eb2cc77 | 2016-09-08 12:14:55 -0400 | [diff] [blame] | 128 | admin.site.register(NetworkEdgePort, NetworkEdgePortAdmin) |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 129 | admin.site.register(NetworkEdgeToEdgePointConnection, NetworkEdgeToEdgePointConnectionAdmin) |
| 130 | admin.site.register(NetworkMultipointToMultipointConnection, NetworkMultipointToMultipointConnectionAdmin) |
| 131 | admin.site.register(NetworkEdgeToMultipointConnection, NetworkEdgeToMultipointConnectionAdmin) |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 132 | admin.site.register(BandwidthProfile, BandwidthProfileAdmin) |
| 133 | admin.site.register(ServiceSpoke, ServiceSpokeAdmin) |
| 134 | admin.site.register(VnodGlobalService, VnodGlobalServiceAdmin) |
| 135 | admin.site.register(RemotePort, RemotePortAdmin) |
| 136 | |
| 137 | |
| 138 | |
| 139 | |