interface.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <tr class="interface{% if not iface.enabled %} danger{% elif iface.connection and iface.connection.connection_status or iface.circuit_termination %} success{% elif iface.connection and not iface.connection.connection_status %} info{% elif iface.is_virtual %} warning{% endif %}" id="iface_{{ iface.name }}">
  2. {# Checkbox #}
  3. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  4. <td class="pk">
  5. <input name="pk" type="checkbox" value="{{ iface.pk }}" />
  6. </td>
  7. {% endif %}
  8. {# Icon and name #}
  9. <td>
  10. <span title="{{ iface.get_form_factor_display }}">
  11. <i class="fa fa-fw fa-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}align-justify{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}exchange{% endif %}"></i>
  12. {{ iface }}
  13. </span>
  14. </td>
  15. {# LAG #}
  16. <td>
  17. {% if iface.lag %}
  18. <a href="#iface_{{ iface.lag }}" class="label label-default">{{ iface.lag }}</a>
  19. {% endif %}
  20. </td>
  21. {# Description #}
  22. <td>{{ iface.description }}</td>
  23. {# MTU #}
  24. <td>{{ iface.mtu|default:"" }}</td>
  25. {# MAC address #}
  26. <td>{{ iface.mac_address|default:"" }}</td>
  27. {# Connection or type #}
  28. {% if iface.is_lag %}
  29. <td colspan="2" class="text-muted">
  30. LAG interface<br />
  31. <small class="text-muted">{{ iface.member_interfaces.all|join:", "|default:"No members" }}</small>
  32. </td>
  33. {% elif iface.is_virtual %}
  34. <td colspan="2" class="text-muted">Virtual interface</td>
  35. {% elif iface.is_wireless %}
  36. <td colspan="2" class="text-muted">Wireless interface</td>
  37. {% elif iface.connection %}
  38. {% with iface.connected_interface as connected_iface %}
  39. <td>
  40. <a href="{% url 'dcim:device' pk=connected_iface.device.pk %}">{{ connected_iface.device }}</a>
  41. </td>
  42. <td>
  43. <span title="{{ connected_iface.get_form_factor_display }}">{{ connected_iface }}</span>
  44. </td>
  45. {% endwith %}
  46. {% elif iface.circuit_termination %}
  47. {% with iface.circuit_termination.get_peer_termination as peer_termination %}
  48. <td colspan="2">
  49. <i class="fa fa-fw fa-globe" title="Circuit"></i>
  50. {% if peer_termination %}
  51. {% if peer_termination.interface %}
  52. <a href="{% url 'dcim:device' pk=peer_termination.interface.device.pk %}">{{ peer_termination.interface.device }}</a>
  53. (<a href="{% url 'dcim:site' slug=peer_termination.site.slug %}">{{ peer_termination.site }}</a>)
  54. {% else %}
  55. <a href="{% url 'dcim:site' slug=peer_termination.site.slug %}">{{ peer_termination.site }}</a>
  56. {% endif %}
  57. via
  58. {% endif %}
  59. <a href="{% url 'circuits:circuit' pk=iface.circuit_termination.circuit_id %}">{{ iface.circuit_termination.circuit }}</a>
  60. </td>
  61. {% endwith %}
  62. {% else %}
  63. <td colspan="2">
  64. <span class="text-muted">Not connected</span>
  65. </td>
  66. {% endif %}
  67. {# Buttons #}
  68. <td class="text-right text-nowrap">
  69. {% if show_graphs %}
  70. {% if iface.circuit_termination or iface.connection %}
  71. <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#graphs_modal" data-obj="{{ device.name }} - {{ iface.name }}" data-url="{% url 'dcim-api:interface-graphs' pk=iface.pk %}" title="Show graphs">
  72. <i class="glyphicon glyphicon-signal" aria-hidden="true"></i>
  73. </button>
  74. {% endif %}
  75. {% endif %}
  76. {% if perms.ipam.add_ipaddress %}
  77. <a href="{% url 'ipam:ipaddress_add' %}?interface={{ iface.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-xs btn-success" title="Add IP address">
  78. <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
  79. </a>
  80. {% endif %}
  81. {% if perms.dcim.change_interface %}
  82. {% if not iface.is_virtual %}
  83. {% if iface.connection %}
  84. {% if iface.connection.connection_status %}
  85. <a href="#" class="btn btn-warning btn-xs interface-toggle connected" data="{{ iface.connection.pk }}" title="Mark planned">
  86. <i class="glyphicon glyphicon-ban-circle" aria-hidden="true"></i>
  87. </a>
  88. {% else %}
  89. <a href="#" class="btn btn-success btn-xs interface-toggle" data="{{ iface.connection.pk }}" title="Mark installed">
  90. <i class="fa fa-plug" aria-hidden="true"></i>
  91. </a>
  92. {% endif %}
  93. <a href="{% url 'dcim:interfaceconnection_delete' pk=iface.connection.pk %}?device={{ device.pk }}" class="btn btn-danger btn-xs" title="Disconnect">
  94. <i class="glyphicon glyphicon-resize-full" aria-hidden="true"></i>
  95. </a>
  96. {% elif iface.circuit_termination and perms.circuits.change_circuittermination %}
  97. <button class="btn btn-warning btn-xs interface-toggle connected" disabled="disabled" title="Circuits cannot be marked as planned or connected">
  98. <i class="glyphicon glyphicon-ban-circle" aria-hidden="true"></i>
  99. </button>
  100. <a href="{% url 'circuits:circuittermination_edit' pk=iface.circuit_termination.pk %}" class="btn btn-danger btn-xs" title="Edit circuit termination">
  101. <i class="glyphicon glyphicon-resize-full" aria-hidden="true"></i>
  102. </a>
  103. {% else %}
  104. <a href="{% url 'dcim:interfaceconnection_add' pk=device.pk %}?interface_a={{ iface.pk }}" class="btn btn-success btn-xs" title="Connect">
  105. <i class="glyphicon glyphicon-resize-small" aria-hidden="true"></i>
  106. </a>
  107. {% endif %}
  108. {% endif %}
  109. <a href="{% if iface.device_id %}{% url 'dcim:interface_edit' pk=iface.pk %}{% else %}{% url 'virtualization:interface_edit' pk=iface.pk %}{% endif %}" class="btn btn-info btn-xs" title="Edit interface">
  110. <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
  111. </a>
  112. {% endif %}
  113. {% if perms.dcim.delete_interface %}
  114. {% if iface.connection or iface.circuit_termination %}
  115. <button class="btn btn-danger btn-xs" disabled="disabled">
  116. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  117. </button>
  118. {% else %}
  119. <a href="{% if iface.device_id %}{% url 'dcim:interface_delete' pk=iface.pk %}{% else %}{% url 'virtualization:interface_delete' pk=iface.pk %}{% endif %}" class="btn btn-danger btn-xs" title="Delete interface">
  120. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  121. </a>
  122. {% endif %}
  123. {% endif %}
  124. </td>
  125. </tr>
  126. {% for ip in iface.ip_addresses.all %}
  127. <tr class="ipaddress">
  128. {# Placeholder #}
  129. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  130. <td></td>
  131. {% endif %}
  132. {# IP address #}
  133. <td colspan="2">
  134. <a href="{% url 'ipam:ipaddress' pk=ip.pk %}">{{ ip }}</a>
  135. </td>
  136. {# Primary, status, role #}
  137. <td>
  138. {% if device.primary_ip4 == ip or device.primary_ip6 == ip %}
  139. <span class="label label-success">Primary</span>
  140. {% endif %}
  141. <span class="label label-{{ ip.get_status_class }}">{{ ip.get_status_display }}</span>
  142. {% if ip.role %}
  143. <span class="label label-{{ ip.get_role_class }}">{{ ip.get_role_display }}</span>
  144. {% endif %}
  145. </td>
  146. {# VRF #}
  147. <td colspan="2">
  148. {% if ip.vrf %}
  149. <a href="{% url 'ipam:vrf' pk=ip.vrf.pk %}" title="{{ ip.vrf.rd }}">{{ ip.vrf.name }}</a>
  150. {% else %}
  151. <span class="text-muted">Global</span>
  152. {% endif %}
  153. </td>
  154. {# Description #}
  155. <td colspan="2">
  156. {{ ip.description }}
  157. </td>
  158. {# Buttons #}
  159. <td class="text-right text-nowrap">
  160. {% if perms.ipam.change_ipaddress %}
  161. <a href="{% url 'ipam:ipaddress_edit' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-info btn-xs">
  162. <i class="glyphicon glyphicon-pencil" aria-hidden="true" title="Edit IP address"></i>
  163. </a>
  164. {% endif %}
  165. {% if perms.ipam.delete_ipaddress %}
  166. <a href="{% url 'ipam:ipaddress_delete' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  167. <i class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete IP address"></i>
  168. </a>
  169. {% endif %}
  170. </td>
  171. </tr>
  172. {% endfor %}