Skip to content

Commit

Permalink
Closes #1824: Add virtual machine count to platforms list
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Jan 19, 2018
1 parent d5ecfe7 commit 7ac27b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions netbox/dcim/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,17 @@ class PlatformTable(BaseTable):
pk = ToggleColumn()
name = tables.LinkColumn(verbose_name='Name')
device_count = tables.Column(verbose_name='Devices')
vm_count = tables.Column(verbose_name='VMs')
slug = tables.Column(verbose_name='Slug')
actions = tables.TemplateColumn(template_code=PLATFORM_ACTIONS, attrs={'td': {'class': 'text-right'}},
verbose_name='')
actions = tables.TemplateColumn(
template_code=PLATFORM_ACTIONS,
attrs={'td': {'class': 'text-right'}},
verbose_name=''
)

class Meta(BaseTable.Meta):
model = Platform
fields = ('pk', 'name', 'device_count', 'slug', 'napalm_driver', 'actions')
fields = ('pk', 'name', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'actions')


#
Expand Down
5 changes: 4 additions & 1 deletion netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,10 @@ class DeviceRoleBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
#

class PlatformListView(ObjectListView):
queryset = Platform.objects.annotate(device_count=Count('devices'))
queryset = Platform.objects.annotate(
device_count=Count('devices', distinct=True),
vm_count=Count('virtual_machines', distinct=True)
)
table = tables.PlatformTable
template_name = 'dcim/platform_list.html'

Expand Down

0 comments on commit 7ac27b5

Please sign in to comment.