interface.html 9.2 KB

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