interface.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <tr class="interface{% if not iface.enabled %} danger{% elif iface.connected_endpoint %} {% if iface.connection_status %}success{% else %}info{% endif %}{% elif iface.circuit_termination %} success{% 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. <a href="{{ iface.get_absolute_url }}">{{ iface }}</a>
  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|default:"&mdash;" }}</td>
  23. {# 802.1Q mode #}
  24. <td>{{ iface.get_mode_display }}</td>
  25. {# Connection or type #}
  26. {% if iface.is_lag %}
  27. <td colspan="2" class="text-muted">
  28. LAG interface<br />
  29. <small class="text-muted">{{ iface.member_interfaces.all|join:", "|default:"No members" }}</small>
  30. </td>
  31. {% elif iface.is_virtual %}
  32. <td colspan="2" class="text-muted">Virtual interface</td>
  33. {% elif iface.is_wireless %}
  34. <td colspan="2" class="text-muted">Wireless interface</td>
  35. {% elif iface.connected_endpoint %}
  36. {% with connected_iface=iface.connected_endpoint %}
  37. <td>
  38. <a href="{% url 'dcim:device' pk=connected_iface.device.pk %}">{{ connected_iface.device }}</a>
  39. </td>
  40. <td>
  41. <a href="{% url 'dcim:interface' pk=connected_iface.pk %}"><span title="{{ connected_iface.get_form_factor_display }}">{{ connected_iface }}</span></a>
  42. </td>
  43. {% endwith %}
  44. {% elif iface.circuit_termination %}
  45. {% with iface.circuit_termination.get_peer_termination as peer_termination %}
  46. <td colspan="2">
  47. <i class="fa fa-fw fa-globe" title="Circuit"></i>
  48. {% if peer_termination %}
  49. {% if peer_termination.interface %}
  50. <a href="{% url 'dcim:device' pk=peer_termination.interface.device.pk %}">{{ peer_termination.interface.device }}</a>
  51. (<a href="{% url 'dcim:site' slug=peer_termination.site.slug %}">{{ peer_termination.site }}</a>)
  52. {% else %}
  53. <a href="{% url 'dcim:site' slug=peer_termination.site.slug %}">{{ peer_termination.site }}</a>
  54. {% endif %}
  55. via
  56. {% endif %}
  57. <a href="{% url 'circuits:circuit' pk=iface.circuit_termination.circuit_id %}">{{ iface.circuit_termination.circuit }}</a>
  58. </td>
  59. {% endwith %}
  60. {% else %}
  61. <td colspan="2">
  62. <span class="text-muted">Not connected</span>
  63. </td>
  64. {% endif %}
  65. {# Buttons #}
  66. <td class="text-right text-nowrap">
  67. {% if show_graphs %}
  68. {% if iface.circuit_termination or iface.connection %}
  69. <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">
  70. <i class="glyphicon glyphicon-signal" aria-hidden="true"></i>
  71. </button>
  72. {% endif %}
  73. {% endif %}
  74. {% if perms.ipam.add_ipaddress %}
  75. <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">
  76. <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
  77. </a>
  78. {% endif %}
  79. {% if perms.dcim.change_interface %}
  80. {% if not iface.is_virtual %}
  81. {% if iface.connection %}
  82. {% if iface.connection.connection_status %}
  83. <a href="#" class="btn btn-warning btn-xs interface-toggle connected" data="{{ iface.connection.pk }}" title="Mark planned">
  84. <i class="glyphicon glyphicon-ban-circle" aria-hidden="true"></i>
  85. </a>
  86. {% else %}
  87. <a href="#" class="btn btn-success btn-xs interface-toggle" data="{{ iface.connection.pk }}" title="Mark installed">
  88. <i class="fa fa-plug" aria-hidden="true"></i>
  89. </a>
  90. {% endif %}
  91. <a href="{% url 'dcim:interfaceconnection_delete' pk=iface.connection.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs" title="Disconnect">
  92. <i class="glyphicon glyphicon-resize-full" aria-hidden="true"></i>
  93. </a>
  94. {% elif iface.circuit_termination and perms.circuits.change_circuittermination %}
  95. <button class="btn btn-warning btn-xs interface-toggle connected" disabled="disabled" title="Circuits cannot be marked as planned or connected">
  96. <i class="glyphicon glyphicon-ban-circle" aria-hidden="true"></i>
  97. </button>
  98. <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">
  99. <i class="glyphicon glyphicon-resize-full" aria-hidden="true"></i>
  100. </a>
  101. {% else %}
  102. <a href="{% url 'dcim:interface_connect' termination_a_id=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-success btn-xs" title="Connect">
  103. <i class="glyphicon glyphicon-resize-small" aria-hidden="true"></i>
  104. </a>
  105. {% endif %}
  106. {% endif %}
  107. <a href="{% if iface.device_id %}{% url 'dcim:interface_edit' pk=iface.pk %}{% else %}{% url 'virtualization:interface_edit' pk=iface.pk %}{% endif %}?return_url={{ device.get_absolute_url }}" class="btn btn-info btn-xs" title="Edit interface">
  108. <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
  109. </a>
  110. {% endif %}
  111. {% if perms.dcim.delete_interface %}
  112. {% if iface.connection or iface.circuit_termination %}
  113. <button class="btn btn-danger btn-xs" disabled="disabled">
  114. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  115. </button>
  116. {% else %}
  117. <a href="{% if iface.device_id %}{% url 'dcim:interface_delete' pk=iface.pk %}{% else %}{% url 'virtualization:interface_delete' pk=iface.pk %}{% endif %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs" title="Delete interface">
  118. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  119. </a>
  120. {% endif %}
  121. {% endif %}
  122. </td>
  123. </tr>
  124. {% with ipaddresses=iface.ip_addresses.all %}
  125. {% if ipaddresses %}
  126. <tr class="ipaddresses">
  127. {# Placeholder #}
  128. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  129. <td></td>
  130. {% endif %}
  131. {# IP addresses table #}
  132. <td colspan="7" style="padding: 0">
  133. <table class="table table-condensed interface-ips">
  134. <thead>
  135. <tr class="text-muted">
  136. <th class="col-md-3">IP Address</th>
  137. <th class="col-md-2">Status/Role</th>
  138. <th class="col-md-3">VRF</th>
  139. <th class="col-md-3">Description</th>
  140. <th class="col-md-1"></th>
  141. </tr>
  142. </thead>
  143. {% for ip in iface.ip_addresses.all %}
  144. <tr>
  145. {# IP address #}
  146. <td>
  147. <a href="{% url 'ipam:ipaddress' pk=ip.pk %}">{{ ip }}</a>
  148. </td>
  149. {# Primary/status/role #}
  150. <td>
  151. {% if device.primary_ip4 == ip or device.primary_ip6 == ip %}
  152. <span class="label label-success">Primary</span>
  153. {% endif %}
  154. <span class="label label-{{ ip.get_status_class }}">{{ ip.get_status_display }}</span>
  155. {% if ip.role %}
  156. <span class="label label-{{ ip.get_role_class }}">{{ ip.get_role_display }}</span>
  157. {% endif %}
  158. </td>
  159. {# VRF #}
  160. <td>
  161. {% if ip.vrf %}
  162. <a href="{% url 'ipam:vrf' pk=ip.vrf.pk %}" title="{{ ip.vrf.rd }}">{{ ip.vrf.name }}</a>
  163. {% else %}
  164. <span class="text-muted">Global</span>
  165. {% endif %}
  166. </td>
  167. {# Description #}
  168. <td>
  169. {% if ip.description %}
  170. {{ ip.description }}
  171. {% else %}
  172. <span class="text-muted">&mdash;</span>
  173. {% endif %}
  174. </td>
  175. {# Buttons #}
  176. <td class="text-right text-nowrap">
  177. {% if perms.ipam.change_ipaddress %}
  178. <a href="{% url 'ipam:ipaddress_edit' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-info btn-xs">
  179. <i class="glyphicon glyphicon-pencil" aria-hidden="true" title="Edit IP address"></i>
  180. </a>
  181. {% endif %}
  182. {% if perms.ipam.delete_ipaddress %}
  183. <a href="{% url 'ipam:ipaddress_delete' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  184. <i class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete IP address"></i>
  185. </a>
  186. {% endif %}
  187. </td>
  188. </tr>
  189. {% endfor %}
  190. </table>
  191. </td>
  192. </tr>
  193. {% endif %}
  194. {% endwith %}