interface.html 11 KB

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