__init__.py 2.8 KB

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