Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 1 | from django.contrib import admin |
| 2 | |
Srikanth Vavilapalli | d84b7b7 | 2016-06-28 00:19:07 +0000 | [diff] [blame] | 3 | from services.monitoring.models import * |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 4 | from django import forms |
| 5 | from django.utils.safestring import mark_safe |
| 6 | from django.contrib.auth.admin import UserAdmin |
| 7 | from django.contrib.admin.widgets import FilteredSelectMultiple |
| 8 | from django.contrib.auth.forms import ReadOnlyPasswordHashField |
| 9 | from django.contrib.auth.signals import user_logged_in |
| 10 | from django.utils import timezone |
| 11 | from django.contrib.contenttypes import generic |
| 12 | from suit.widgets import LinkedSelect |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 13 | from core.admin import XOSBaseAdmin,ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline, TenantAttrAsTabInline, UploadTextareaWidget |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 14 | from core.middleware import get_request |
| 15 | |
| 16 | from functools import update_wrapper |
| 17 | from django.contrib.admin.views.main import ChangeList |
| 18 | from django.core.urlresolvers import reverse |
| 19 | from django.contrib.admin.utils import quote |
| 20 | |
| 21 | class CeilometerServiceForm(forms.ModelForm): |
| 22 | ceilometer_pub_sub_url = forms.CharField(required=False, max_length=1024, help_text="REST URL of ceilometer PUB/SUB component in http://IP:port/ format") |
| 23 | |
| 24 | def __init__(self,*args,**kwargs): |
| 25 | super (CeilometerServiceForm,self ).__init__(*args,**kwargs) |
| 26 | if self.instance: |
| 27 | # fields for the attributes |
| 28 | self.fields['ceilometer_pub_sub_url'].initial = self.instance.ceilometer_pub_sub_url |
| 29 | |
| 30 | def save(self, commit=True): |
| 31 | self.instance.ceilometer_pub_sub_url = self.cleaned_data.get("ceilometer_pub_sub_url") |
| 32 | return super(CeilometerServiceForm, self).save(commit=commit) |
| 33 | |
| 34 | class Meta: |
| 35 | model = CeilometerService |
Zack Williams | 1861b52 | 2016-06-27 08:25:33 -0700 | [diff] [blame] | 36 | fields = '__all__' |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 37 | |
| 38 | class CeilometerServiceAdmin(ReadOnlyAwareAdmin): |
| 39 | model = CeilometerService |
| 40 | verbose_name = "Ceilometer Service" |
| 41 | verbose_name_plural = "Ceilometer Service" |
| 42 | list_display = ("backend_status_icon", "name", "enabled") |
| 43 | list_display_links = ('backend_status_icon', 'name', ) |
| 44 | fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description','ceilometer_pub_sub_url', "view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})] |
| 45 | readonly_fields = ('backend_status_text', ) |
| 46 | inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline] |
| 47 | form = CeilometerServiceForm |
| 48 | |
| 49 | extracontext_registered_admins = True |
| 50 | |
| 51 | user_readonly_fields = ["name", "enabled", "versionNumber", "description"] |
| 52 | |
| 53 | suit_form_tabs =(('general', 'Ceilometer Service Details'), |
| 54 | ('administration', 'Administration'), |
| 55 | ('slices','Slices'), |
| 56 | ('serviceattrs','Additional Attributes'), |
| 57 | ('serviceprivileges','Privileges'), |
| 58 | ) |
| 59 | |
| 60 | suit_form_includes = (('ceilometeradmin.html', 'top', 'administration'), |
| 61 | ) |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 62 | #actions=['delete_selected_objects'] |
| 63 | |
| 64 | #def get_actions(self, request): |
| 65 | # actions = super(CeilometerServiceAdmin, self).get_actions(request) |
| 66 | # if 'delete_selected' in actions: |
| 67 | # del actions['delete_selected'] |
| 68 | # return actions |
| 69 | |
| 70 | #def delete_selected_objects(self, request, queryset): |
| 71 | # for obj in queryset: |
| 72 | # obj.delete() |
| 73 | #delete_selected_objects.short_description = "Delete Selected Ceilometer Service Objects" |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 74 | |
Zack Williams | 031e1b6 | 2016-06-27 13:19:50 -0700 | [diff] [blame] | 75 | def get_queryset(self, request): |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 76 | return CeilometerService.get_service_objects_by_user(request.user) |
| 77 | |
| 78 | class MonitoringChannelForm(forms.ModelForm): |
| 79 | creator = forms.ModelChoiceField(queryset=User.objects.all()) |
| 80 | |
| 81 | def __init__(self,*args,**kwargs): |
| 82 | super (MonitoringChannelForm,self ).__init__(*args,**kwargs) |
| 83 | self.fields['kind'].widget.attrs['readonly'] = True |
| 84 | self.fields['provider_service'].queryset = CeilometerService.get_service_objects().all() |
| 85 | if self.instance: |
| 86 | # fields for the attributes |
| 87 | self.fields['creator'].initial = self.instance.creator |
| 88 | if (not self.instance) or (not self.instance.pk): |
| 89 | # default fields for an 'add' form |
| 90 | self.fields['kind'].initial = CEILOMETER_KIND |
| 91 | self.fields['creator'].initial = get_request().user |
| 92 | if CeilometerService.get_service_objects().exists(): |
| 93 | self.fields["provider_service"].initial = CeilometerService.get_service_objects().all()[0] |
| 94 | |
| 95 | |
| 96 | def save(self, commit=True): |
| 97 | self.instance.creator = self.cleaned_data.get("creator") |
| 98 | return super(MonitoringChannelForm, self).save(commit=commit) |
| 99 | |
| 100 | class Meta: |
| 101 | model = MonitoringChannel |
Zack Williams | 1861b52 | 2016-06-27 08:25:33 -0700 | [diff] [blame] | 102 | fields = '__all__' |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 103 | |
| 104 | class MonitoringChannelAdmin(ReadOnlyAwareAdmin): |
| 105 | list_display = ('backend_status_icon', 'id', ) |
| 106 | list_display_links = ('backend_status_icon', 'id') |
| 107 | fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute', |
| 108 | 'ceilometer_url', 'tenant_list_str', |
| 109 | 'instance', 'creator'], |
| 110 | 'classes':['suit-tab suit-tab-general']})] |
| 111 | readonly_fields = ('backend_status_text', 'instance', 'service_specific_attribute', 'ceilometer_url', 'tenant_list_str') |
| 112 | form = MonitoringChannelForm |
| 113 | |
| 114 | suit_form_tabs = (('general','Details'),) |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 115 | #actions=['delete_selected_objects'] |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 116 | |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 117 | #def get_actions(self, request): |
| 118 | # actions = super(MonitoringChannelAdmin, self).get_actions(request) |
| 119 | # if 'delete_selected' in actions: |
| 120 | # del actions['delete_selected'] |
| 121 | # return actions |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 122 | |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 123 | #def delete_selected_objects(self, request, queryset): |
| 124 | # for obj in queryset: |
| 125 | # obj.delete() |
| 126 | #delete_selected_objects.short_description = "Delete Selected MonitoringChannel Objects" |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 127 | |
Zack Williams | 031e1b6 | 2016-06-27 13:19:50 -0700 | [diff] [blame] | 128 | def get_queryset(self, request): |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 129 | return MonitoringChannel.get_tenant_objects_by_user(request.user) |
| 130 | |
| 131 | class SFlowServiceForm(forms.ModelForm): |
| 132 | sflow_port = forms.IntegerField(required=False) |
| 133 | sflow_api_port = forms.IntegerField(required=False) |
| 134 | |
| 135 | def __init__(self,*args,**kwargs): |
| 136 | super (SFlowServiceForm,self ).__init__(*args,**kwargs) |
| 137 | if self.instance: |
| 138 | # fields for the attributes |
| 139 | self.fields['sflow_port'].initial = self.instance.sflow_port |
| 140 | self.fields['sflow_api_port'].initial = self.instance.sflow_api_port |
| 141 | if (not self.instance) or (not self.instance.pk): |
| 142 | # default fields for an 'add' form |
| 143 | self.fields['sflow_port'].initial = SFLOW_PORT |
| 144 | self.fields['sflow_api_port'].initial = SFLOW_API_PORT |
| 145 | |
| 146 | def save(self, commit=True): |
| 147 | self.instance.sflow_port = self.cleaned_data.get("sflow_port") |
| 148 | self.instance.sflow_api_port = self.cleaned_data.get("sflow_api_port") |
| 149 | return super(SFlowServiceForm, self).save(commit=commit) |
| 150 | |
| 151 | class Meta: |
| 152 | model = SFlowService |
Zack Williams | 1861b52 | 2016-06-27 08:25:33 -0700 | [diff] [blame] | 153 | fields = '__all__' |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 154 | |
| 155 | class SFlowServiceAdmin(ReadOnlyAwareAdmin): |
| 156 | model = SFlowService |
| 157 | verbose_name = "SFlow Service" |
| 158 | verbose_name_plural = "SFlow Service" |
| 159 | list_display = ("backend_status_icon", "name", "enabled") |
| 160 | list_display_links = ('backend_status_icon', 'name', ) |
| 161 | fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","sflow_port","sflow_api_port","icon_url" ], 'classes':['suit-tab suit-tab-general']})] |
| 162 | readonly_fields = ('backend_status_text', ) |
| 163 | inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline] |
| 164 | form = SFlowServiceForm |
| 165 | |
| 166 | extracontext_registered_admins = True |
| 167 | |
| 168 | user_readonly_fields = ["name", "enabled", "versionNumber", "description"] |
| 169 | |
| 170 | suit_form_tabs =(('general', 'SFlow Service Details'), |
| 171 | ('administration', 'Administration'), |
| 172 | ('slices','Slices'), |
| 173 | ('serviceattrs','Additional Attributes'), |
| 174 | ('serviceprivileges','Privileges'), |
| 175 | ) |
| 176 | |
| 177 | suit_form_includes = (('sflowadmin.html', 'top', 'administration'), |
| 178 | ) |
| 179 | |
Zack Williams | 031e1b6 | 2016-06-27 13:19:50 -0700 | [diff] [blame] | 180 | def get_queryset(self, request): |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 181 | return SFlowService.get_service_objects_by_user(request.user) |
| 182 | |
| 183 | class SFlowTenantForm(forms.ModelForm): |
| 184 | creator = forms.ModelChoiceField(queryset=User.objects.all()) |
| 185 | listening_endpoint = forms.CharField(max_length=1024, help_text="sFlow listening endpoint in udp://IP:port format") |
| 186 | |
| 187 | def __init__(self,*args,**kwargs): |
| 188 | super (SFlowTenantForm,self ).__init__(*args,**kwargs) |
| 189 | self.fields['kind'].widget.attrs['readonly'] = True |
| 190 | self.fields['provider_service'].queryset = SFlowService.get_service_objects().all() |
| 191 | if self.instance: |
| 192 | # fields for the attributes |
| 193 | self.fields['creator'].initial = self.instance.creator |
| 194 | self.fields['listening_endpoint'].initial = self.instance.listening_endpoint |
| 195 | if (not self.instance) or (not self.instance.pk): |
| 196 | # default fields for an 'add' form |
| 197 | self.fields['kind'].initial = SFLOW_KIND |
| 198 | self.fields['creator'].initial = get_request().user |
| 199 | if SFlowService.get_service_objects().exists(): |
| 200 | self.fields["provider_service"].initial = SFlowService.get_service_objects().all()[0] |
| 201 | |
| 202 | def save(self, commit=True): |
| 203 | self.instance.creator = self.cleaned_data.get("creator") |
| 204 | self.instance.listening_endpoint = self.cleaned_data.get("listening_endpoint") |
| 205 | return super(SFlowTenantForm, self).save(commit=commit) |
| 206 | |
| 207 | class Meta: |
| 208 | model = SFlowTenant |
Zack Williams | 1861b52 | 2016-06-27 08:25:33 -0700 | [diff] [blame] | 209 | fields = '__all__' |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 210 | |
| 211 | class SFlowTenantAdmin(ReadOnlyAwareAdmin): |
| 212 | list_display = ('backend_status_icon', 'creator', 'listening_endpoint' ) |
| 213 | list_display_links = ('backend_status_icon', 'listening_endpoint') |
| 214 | fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_service', 'service_specific_attribute', 'listening_endpoint', |
| 215 | 'creator'], |
| 216 | 'classes':['suit-tab suit-tab-general']})] |
| 217 | readonly_fields = ('backend_status_text', 'instance', 'service_specific_attribute') |
| 218 | inlines = [TenantAttrAsTabInline] |
| 219 | form = SFlowTenantForm |
| 220 | |
| 221 | suit_form_tabs = (('general','Details'), ('tenantattrs', 'Attributes')) |
| 222 | |
Zack Williams | 031e1b6 | 2016-06-27 13:19:50 -0700 | [diff] [blame] | 223 | def get_queryset(self, request): |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 224 | return SFlowTenant.get_tenant_objects_by_user(request.user) |
| 225 | |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 226 | class OpenStackServiceMonitoringPublisherForm(forms.ModelForm): |
| 227 | creator = forms.ModelChoiceField(queryset=User.objects.all()) |
| 228 | |
| 229 | def __init__(self,*args,**kwargs): |
| 230 | super (OpenStackServiceMonitoringPublisherForm,self ).__init__(*args,**kwargs) |
| 231 | self.fields['kind'].widget.attrs['readonly'] = True |
| 232 | self.fields['provider_service'].queryset = CeilometerService.get_service_objects().all() |
| 233 | if self.instance: |
| 234 | # fields for the attributes |
| 235 | self.fields['creator'].initial = self.instance.creator |
| 236 | if (not self.instance) or (not self.instance.pk): |
| 237 | # default fields for an 'add' form |
| 238 | self.fields['kind'].initial = CEILOMETER_PUBLISH_TENANT_OS_KIND |
| 239 | self.fields['creator'].initial = get_request().user |
| 240 | if CeilometerService.get_service_objects().exists(): |
| 241 | self.fields["provider_service"].initial = CeilometerService.get_service_objects().all()[0] |
| 242 | |
| 243 | def save(self, commit=True): |
| 244 | self.instance.creator = self.cleaned_data.get("creator") |
| 245 | return super(OpenStackServiceMonitoringPublisherForm, self).save(commit=commit) |
| 246 | |
| 247 | class Meta: |
| 248 | model = OpenStackServiceMonitoringPublisher |
| 249 | fields = '__all__' |
| 250 | |
| 251 | class OpenStackServiceMonitoringPublisherAdmin(ReadOnlyAwareAdmin): |
| 252 | list_display = ('backend_status_icon', 'id', ) |
| 253 | list_display_links = ('backend_status_icon', 'id') |
| 254 | fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute', 'creator'], |
| 255 | 'classes':['suit-tab suit-tab-general']})] |
| 256 | readonly_fields = ('backend_status_text', 'service_specific_attribute' ) |
| 257 | form = OpenStackServiceMonitoringPublisherForm |
| 258 | |
| 259 | suit_form_tabs = (('general','Details'),) |
| 260 | actions=['delete_selected_objects'] |
| 261 | |
| 262 | def get_actions(self, request): |
| 263 | actions = super(OpenStackServiceMonitoringPublisherAdmin, self).get_actions(request) |
| 264 | if 'delete_selected' in actions: |
| 265 | del actions['delete_selected'] |
| 266 | return actions |
| 267 | |
| 268 | def delete_selected_objects(self, request, queryset): |
| 269 | for obj in queryset: |
| 270 | obj.delete() |
| 271 | delete_selected_objects.short_description = "Delete Selected OpenStackServiceMonitoringPublisher Objects" |
| 272 | |
| 273 | def get_queryset(self, request): |
| 274 | return OpenStackServiceMonitoringPublisher.get_tenant_objects_by_user(request.user) |
| 275 | |
| 276 | class ONOSServiceMonitoringPublisherForm(forms.ModelForm): |
| 277 | creator = forms.ModelChoiceField(queryset=User.objects.all()) |
| 278 | onos_service_endpoints = forms.CharField(max_length=1024, help_text="IP addresses of all the ONOS services to be monitored") |
| 279 | |
| 280 | def __init__(self,*args,**kwargs): |
| 281 | super (ONOSServiceMonitoringPublisherForm,self ).__init__(*args,**kwargs) |
| 282 | self.fields['kind'].widget.attrs['readonly'] = True |
| 283 | self.fields['provider_service'].queryset = CeilometerService.get_service_objects().all() |
| 284 | if self.instance: |
| 285 | # fields for the attributes |
| 286 | self.fields['creator'].initial = self.instance.creator |
| 287 | self.fields['onos_service_endpoints'].initial = self.instance.onos_service_endpoints |
| 288 | if (not self.instance) or (not self.instance.pk): |
| 289 | # default fields for an 'add' form |
| 290 | self.fields['kind'].initial = CEILOMETER_PUBLISH_TENANT_ONOS_KIND |
| 291 | self.fields['creator'].initial = get_request().user |
| 292 | if CeilometerService.get_service_objects().exists(): |
| 293 | self.fields["provider_service"].initial = CeilometerService.get_service_objects().all()[0] |
| 294 | |
| 295 | def save(self, commit=True): |
| 296 | self.instance.creator = self.cleaned_data.get("creator") |
| 297 | self.instance.onos_service_endpoints = self.cleaned_data.get("onos_service_endpoints") |
| 298 | return super(ONOSServiceMonitoringPublisherForm, self).save(commit=commit) |
| 299 | |
| 300 | class Meta: |
| 301 | model = ONOSServiceMonitoringPublisher |
| 302 | fields = '__all__' |
| 303 | |
| 304 | class ONOSServiceMonitoringPublisherAdmin(ReadOnlyAwareAdmin): |
| 305 | list_display = ('backend_status_icon', 'id', ) |
| 306 | list_display_links = ('backend_status_icon', 'id') |
| 307 | fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute', 'creator', 'onos_service_endpoints'], |
| 308 | 'classes':['suit-tab suit-tab-general']})] |
| 309 | readonly_fields = ('backend_status_text', 'service_specific_attribute' ) |
| 310 | form = ONOSServiceMonitoringPublisherForm |
| 311 | |
| 312 | suit_form_tabs = (('general','Details'),) |
| 313 | actions=['delete_selected_objects'] |
| 314 | |
| 315 | def get_actions(self, request): |
| 316 | actions = super(ONOSServiceMonitoringPublisherAdmin, self).get_actions(request) |
| 317 | if 'delete_selected' in actions: |
| 318 | del actions['delete_selected'] |
| 319 | return actions |
| 320 | |
| 321 | def delete_selected_objects(self, request, queryset): |
| 322 | for obj in queryset: |
| 323 | obj.delete() |
| 324 | delete_selected_objects.short_description = "Delete Selected OpenStackServiceMonitoringPublisher Objects" |
| 325 | |
| 326 | def get_queryset(self, request): |
| 327 | return ONOSServiceMonitoringPublisher.get_tenant_objects_by_user(request.user) |
| 328 | |
| 329 | class UserServiceMonitoringPublisherForm(forms.ModelForm): |
| 330 | creator = forms.ModelChoiceField(queryset=User.objects.all()) |
| 331 | exclude_service_list = ['ceilometer', 'onos', 'VTN', 'vROUTER', 'vOLT', 'vTR'] |
| 332 | target_service = forms.ModelChoiceField(queryset=Service.objects.all().exclude(kind__in=exclude_service_list)) |
| 333 | |
| 334 | def __init__(self,*args,**kwargs): |
| 335 | super (UserServiceMonitoringPublisherForm,self ).__init__(*args,**kwargs) |
| 336 | self.fields['kind'].widget.attrs['readonly'] = True |
| 337 | self.fields['provider_service'].queryset = CeilometerService.get_service_objects().all() |
| 338 | if self.instance: |
| 339 | # fields for the attributes |
| 340 | self.fields['creator'].initial = self.instance.creator |
| 341 | self.fields['target_service'].initial = self.instance.target_service |
| 342 | if (not self.instance) or (not self.instance.pk): |
| 343 | # default fields for an 'add' form |
| 344 | self.fields['kind'].initial = CEILOMETER_PUBLISH_TENANT_USER_KIND |
| 345 | self.fields['creator'].initial = get_request().user |
| 346 | if CeilometerService.get_service_objects().exists(): |
| 347 | self.fields["provider_service"].initial = CeilometerService.get_service_objects().all()[0] |
| 348 | |
| 349 | def save(self, commit=True): |
| 350 | self.instance.creator = self.cleaned_data.get("creator") |
| 351 | self.instance.target_service = self.cleaned_data.get("target_service") |
| 352 | return super(UserServiceMonitoringPublisherForm, self).save(commit=commit) |
| 353 | |
| 354 | class Meta: |
| 355 | model = UserServiceMonitoringPublisher |
| 356 | fields = '__all__' |
| 357 | |
| 358 | class UserServiceMonitoringPublisherAdmin(ReadOnlyAwareAdmin): |
| 359 | list_display = ('backend_status_icon', 'id', ) |
| 360 | list_display_links = ('backend_status_icon', 'id') |
| 361 | fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute', 'creator', 'target_service'], |
| 362 | 'classes':['suit-tab suit-tab-general']})] |
| 363 | readonly_fields = ('backend_status_text', 'service_specific_attribute' ) |
| 364 | form = UserServiceMonitoringPublisherForm |
| 365 | |
| 366 | suit_form_tabs = (('general','Details'),) |
| 367 | actions=['delete_selected_objects'] |
| 368 | |
| 369 | def get_actions(self, request): |
| 370 | actions = super(UserServiceMonitoringPublisherAdmin, self).get_actions(request) |
| 371 | if 'delete_selected' in actions: |
| 372 | del actions['delete_selected'] |
| 373 | return actions |
| 374 | |
| 375 | def delete_selected_objects(self, request, queryset): |
| 376 | for obj in queryset: |
| 377 | obj.delete() |
| 378 | delete_selected_objects.short_description = "Delete Selected UserServiceMonitoringPublisher Objects" |
| 379 | |
| 380 | def get_queryset(self, request): |
| 381 | return UserServiceMonitoringPublisher.get_tenant_objects_by_user(request.user) |
| 382 | |
| 383 | class InfraMonitoringAgentInfoForm(forms.ModelForm): |
| 384 | class Meta: |
| 385 | model = InfraMonitoringAgentInfo |
| 386 | widgets = { |
| 387 | 'start_url_json_data': UploadTextareaWidget(attrs={'rows': 5, 'cols': 80, 'class': "input-xxlarge"}), |
| 388 | } |
| 389 | fields = '__all__' |
| 390 | |
| 391 | class InfraMonitoringAgentInfoAdmin(XOSBaseAdmin): |
| 392 | list_display = ('backend_status_icon', 'name', 'id', ) |
| 393 | list_display_links = ('backend_status_icon', 'name', 'id') |
| 394 | fieldsets = [ (None, {'fields': ['name', 'start_url', 'start_url_json_data', 'stop_url', 'monitoring_publisher'], |
| 395 | 'classes':['suit-tab suit-tab-general']})] |
| 396 | form = InfraMonitoringAgentInfoForm |
| 397 | |
| 398 | suit_form_tabs = (('general','Details'),) |
| 399 | |
| 400 | class MonitoringCollectorPluginInfoForm(forms.ModelForm): |
| 401 | class Meta: |
| 402 | model = MonitoringCollectorPluginInfo |
| 403 | #widgets = { |
| 404 | # 'plugin_notification_handlers_json': UploadTextareaWidget(attrs={'rows': 5, 'cols': 80, 'class': "input-xxlarge"}), |
| 405 | #} |
| 406 | fields = '__all__' |
| 407 | |
| 408 | class MonitoringCollectorPluginInfoAdmin(XOSBaseAdmin): |
| 409 | list_display = ('backend_status_icon', 'name', 'id', ) |
| 410 | list_display_links = ('backend_status_icon', 'name', 'id') |
| 411 | fieldsets = [ (None, {'fields': ['name', 'plugin_folder_path', 'plugin_rabbit_exchange', 'monitoring_publisher'], |
| 412 | 'classes':['suit-tab suit-tab-general']})] |
| 413 | form = MonitoringCollectorPluginInfoForm |
| 414 | |
| 415 | suit_form_tabs = (('general','Details'),) |
| 416 | |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 417 | admin.site.register(CeilometerService, CeilometerServiceAdmin) |
| 418 | admin.site.register(SFlowService, SFlowServiceAdmin) |
| 419 | admin.site.register(MonitoringChannel, MonitoringChannelAdmin) |
| 420 | admin.site.register(SFlowTenant, SFlowTenantAdmin) |
rdudyala | 996d70b | 2016-10-13 17:40:55 +0000 | [diff] [blame] | 421 | admin.site.register(OpenStackServiceMonitoringPublisher, OpenStackServiceMonitoringPublisherAdmin) |
| 422 | admin.site.register(ONOSServiceMonitoringPublisher, ONOSServiceMonitoringPublisherAdmin) |
| 423 | admin.site.register(UserServiceMonitoringPublisher, UserServiceMonitoringPublisherAdmin) |
| 424 | admin.site.register(InfraMonitoringAgentInfo, InfraMonitoringAgentInfoAdmin) |
| 425 | admin.site.register(MonitoringCollectorPluginInfo, MonitoringCollectorPluginInfoAdmin) |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 426 | |