1import django_tables2 as tables 2from django_tables2.utils import Accessor 3 4from utilities.tables import BaseTable, BooleanColumn 5from dcim.models import ConsolePort, Interface, PowerPort 6from .cables import * 7from .devices import * 8from .devicetypes import * 9from .power import * 10from .racks import * 11from .sites import * 12 13 14# 15# Device connections 16# 17 18class ConsoleConnectionTable(BaseTable): 19 console_server = tables.Column( 20 accessor=Accessor('_path__destination__device'), 21 orderable=False, 22 linkify=True, 23 verbose_name='Console Server' 24 ) 25 console_server_port = tables.Column( 26 accessor=Accessor('_path__destination'), 27 orderable=False, 28 linkify=True, 29 verbose_name='Port' 30 ) 31 device = tables.Column( 32 linkify=True 33 ) 34 name = tables.Column( 35 linkify=True, 36 verbose_name='Console Port' 37 ) 38 reachable = BooleanColumn( 39 accessor=Accessor('_path__is_active'), 40 verbose_name='Reachable' 41 ) 42 43 class Meta(BaseTable.Meta): 44 model = ConsolePort 45 fields = ('device', 'name', 'console_server', 'console_server_port', 'reachable') 46 exclude = ('id', ) 47 48 49class PowerConnectionTable(BaseTable): 50 pdu = tables.Column( 51 accessor=Accessor('_path__destination__device'), 52 orderable=False, 53 linkify=True, 54 verbose_name='PDU' 55 ) 56 outlet = tables.Column( 57 accessor=Accessor('_path__destination'), 58 orderable=False, 59 linkify=True, 60 verbose_name='Outlet' 61 ) 62 device = tables.Column( 63 linkify=True 64 ) 65 name = tables.Column( 66 linkify=True, 67 verbose_name='Power Port' 68 ) 69 reachable = BooleanColumn( 70 accessor=Accessor('_path__is_active'), 71 verbose_name='Reachable' 72 ) 73 74 class Meta(BaseTable.Meta): 75 model = PowerPort 76 fields = ('device', 'name', 'pdu', 'outlet', 'reachable') 77 exclude = ('id', ) 78 79 80class InterfaceConnectionTable(BaseTable): 81 device_a = tables.Column( 82 accessor=Accessor('device'), 83 linkify=True, 84 verbose_name='Device A' 85 ) 86 interface_a = tables.Column( 87 accessor=Accessor('name'), 88 linkify=True, 89 verbose_name='Interface A' 90 ) 91 device_b = tables.Column( 92 accessor=Accessor('_path__destination__device'), 93 orderable=False, 94 linkify=True, 95 verbose_name='Device B' 96 ) 97 interface_b = tables.Column( 98 accessor=Accessor('_path__destination'), 99 orderable=False, 100 linkify=True, 101 verbose_name='Interface B' 102 ) 103 reachable = BooleanColumn( 104 accessor=Accessor('_path__is_active'), 105 verbose_name='Reachable' 106 ) 107 108 class Meta(BaseTable.Meta): 109 model = Interface 110 fields = ('device_a', 'interface_a', 'device_b', 'interface_b', 'reachable') 111 exclude = ('id', ) 112