interface.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. {% load helpers %}
  2. <tr class="interface{% if not iface.enabled %} danger{% elif iface.cable.status %} success{% elif iface.cable %} info{% elif iface.is_virtual %} warning{% endif %}" id="interface_{{ iface.name }}">
  3. {# Checkbox #}
  4. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  5. <td class="pk">
  6. <input name="pk" type="checkbox" value="{{ iface.pk }}" />
  7. </td>
  8. {% endif %}
  9. {# Icon and name #}
  10. <td class="text-nowrap">
  11. <span title="{{ iface.get_type_display }}">
  12. <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>
  13. <a href="{{ iface.get_absolute_url }}">{{ iface }}</a>
  14. </span>
  15. {% if iface.mac_address %}
  16. <br/><small class="text-muted">{{ iface.mac_address }}</small>
  17. {% endif %}
  18. </td>
  19. {# LAG #}
  20. <td>
  21. {% if iface.lag %}
  22. <a href="#interface_{{ iface.lag }}" class="label label-primary" title="{{ iface.lag.description }}">{{ iface.lag }}</a>
  23. {% endif %}
  24. </td>
  25. {# Description/tags #}
  26. <td>
  27. {% if iface.description %}
  28. {{ iface.description }}<br/>
  29. {% endif %}
  30. {% for tag in iface.tags.all %}
  31. {% tag tag %}
  32. {% empty %}
  33. {% if not iface.description %}&mdash;{% endif %}
  34. {% endfor %}
  35. </td>
  36. {# MTU #}
  37. <td>{{ iface.mtu|default:"&mdash;" }}</td>
  38. {# 802.1Q mode #}
  39. <td>{{ iface.get_mode_display|default:"&mdash;" }}</td>
  40. {# Cable #}
  41. <td class="text-nowrap">
  42. {% if iface.cable %}
  43. <a href="{{ iface.cable.get_absolute_url }}">{{ iface.cable }}</a>
  44. <a href="{% url 'dcim:interface_trace' pk=iface.pk %}" class="btn btn-primary btn-xs" title="Trace">
  45. <i class="fa fa-share-alt" aria-hidden="true"></i>
  46. </a>
  47. {% else %}
  48. <span class="text-muted">&mdash;</span>
  49. {% endif %}
  50. </td>
  51. {# Connection or type #}
  52. {% if iface.is_lag %}
  53. <td colspan="2" class="text-muted">
  54. LAG interface<br />
  55. <small class="text-muted">
  56. {% for member in iface.member_interfaces.all %}
  57. <a href="#interface_{{ member.name }}">{{ member }}</a>{% if not forloop.last %}, {% endif %}
  58. {% empty %}
  59. No members
  60. {% endfor %}
  61. </small>
  62. </td>
  63. {% elif iface.is_virtual %}
  64. <td colspan="2" class="text-muted">Virtual interface</td>
  65. {% elif iface.is_wireless %}
  66. <td colspan="2" class="text-muted">Wireless interface</td>
  67. {% elif iface.connected_endpoint.name %}
  68. {# Connected to an Interface #}
  69. <td>
  70. <a href="{% url 'dcim:device' pk=iface.connected_endpoint.device.pk %}">
  71. {{ iface.connected_endpoint.device }}
  72. </a>
  73. </td>
  74. <td>
  75. <a href="{% url 'dcim:interface' pk=iface.connected_endpoint.pk %}">
  76. <span title="{{ iface.connected_endpoint.get_type_display }}">
  77. {{ iface.connected_endpoint }}
  78. </span>
  79. </a>
  80. </td>
  81. {% elif iface.connected_endpoint.term_side %}
  82. {# Connected to a CircuitTermination #}
  83. {% with iface.connected_endpoint.get_peer_termination as peer_termination %}
  84. {% if peer_termination %}
  85. {% if peer_termination.connected_endpoint %}
  86. <td>
  87. <a href="{% url 'dcim:device' pk=peer_termination.connected_endpoint.device.pk %}">
  88. {{ peer_termination.connected_endpoint.device }}
  89. </a><br/>
  90. <small>via <i class="fa fa-fw fa-globe" title="Circuit"></i>
  91. <a href="{{ iface.connected_endpoint.circuit.get_absolute_url }}">
  92. {{ iface.connected_endpoint.circuit.provider }}
  93. {{ iface.connected_endpoint.circuit }}
  94. </a>
  95. </small>
  96. </td>
  97. <td>
  98. {{ peer_termination.connected_endpoint }}
  99. </td>
  100. {% else %}
  101. <td colspan="2">
  102. <a href="{% url 'dcim:site' slug=peer_termination.site.slug %}">
  103. {{ peer_termination.site }}
  104. </a>
  105. via <i class="fa fa-fw fa-globe" title="Circuit"></i>
  106. <a href="{{ iface.connected_endpoint.circuit.get_absolute_url }}">
  107. {{ iface.connected_endpoint.circuit.provider }}
  108. {{ iface.connected_endpoint.circuit }}
  109. </a>
  110. </td>
  111. {% endif %}
  112. {% else %}
  113. <td colspan="2">
  114. <i class="fa fa-fw fa-globe" title="Circuit"></i>
  115. <a href="{{ iface.connected_endpoint.circuit.get_absolute_url }}">
  116. {{ iface.connected_endpoint.circuit.provider }}
  117. {{ iface.connected_endpoint.circuit }}
  118. </a>
  119. </td>
  120. {% endif %}
  121. {% endwith %}
  122. {% else %}
  123. <td colspan="2">
  124. <span class="text-muted">Not connected</span>
  125. </td>
  126. {% endif %}
  127. {# Buttons #}
  128. <td class="text-right text-nowrap noprint">
  129. {% if show_interface_graphs %}
  130. {% if iface.connected_endpoint %}
  131. <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">
  132. <i class="glyphicon glyphicon-signal" aria-hidden="true"></i>
  133. </button>
  134. {% endif %}
  135. {% endif %}
  136. {% if perms.ipam.add_ipaddress %}
  137. <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">
  138. <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
  139. </a>
  140. {% endif %}
  141. {% if perms.dcim.change_interface %}
  142. {% if iface.cable %}
  143. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=iface.cable %}
  144. {% elif iface.is_connectable and perms.dcim.add_cable %}
  145. <span class="dropdown">
  146. <button type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  147. <span class="glyphicon glyphicon-resize-small" aria-hidden="true"></span>
  148. </button>
  149. <ul class="dropdown-menu dropdown-menu-right">
  150. <li><a href="{% url 'dcim:interface_connect' termination_a_id=iface.pk termination_b_type='interface' %}?return_url={{ device.get_absolute_url }}">Interface</a></li>
  151. <li><a href="{% url 'dcim:interface_connect' termination_a_id=iface.pk termination_b_type='front-port' %}?return_url={{ device.get_absolute_url }}">Front Port</a></li>
  152. <li><a href="{% url 'dcim:interface_connect' termination_a_id=iface.pk termination_b_type='rear-port' %}?return_url={{ device.get_absolute_url }}">Rear Port</a></li>
  153. <li><a href="{% url 'dcim:interface_connect' termination_a_id=iface.pk termination_b_type='circuit-termination' %}?return_url={{ device.get_absolute_url }}">Circuit Termination</a></li>
  154. </ul>
  155. </span>
  156. {% endif %}
  157. <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">
  158. <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
  159. </a>
  160. {% endif %}
  161. {% if perms.dcim.delete_interface %}
  162. {% if iface.connection or iface.circuit_termination %}
  163. <button class="btn btn-danger btn-xs" disabled="disabled">
  164. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  165. </button>
  166. {% else %}
  167. <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">
  168. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  169. </a>
  170. {% endif %}
  171. {% endif %}
  172. </td>
  173. </tr>
  174. {% with ipaddresses=iface.ip_addresses.all %}
  175. {% if ipaddresses %}
  176. <tr class="ipaddresses">
  177. {# Placeholder #}
  178. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  179. <td></td>
  180. {% endif %}
  181. {# IP addresses table #}
  182. <td colspan="9" style="padding: 0">
  183. <table class="table table-condensed interface-ips">
  184. <thead>
  185. <tr class="text-muted">
  186. <th class="col-md-3">IP Address</th>
  187. <th class="col-md-2">Status/Role</th>
  188. <th class="col-md-3">VRF</th>
  189. <th class="col-md-3">Description</th>
  190. <th class="col-md-1"></th>
  191. </tr>
  192. </thead>
  193. {% for ip in iface.ip_addresses.all %}
  194. <tr>
  195. {# IP address #}
  196. <td>
  197. <a href="{% url 'ipam:ipaddress' pk=ip.pk %}">{{ ip }}</a>
  198. </td>
  199. {# Primary/status/role #}
  200. <td>
  201. {% if device.primary_ip4 == ip or device.primary_ip6 == ip %}
  202. <span class="label label-success">Primary</span>
  203. {% endif %}
  204. <span class="label label-{{ ip.get_status_class }}">{{ ip.get_status_display }}</span>
  205. {% if ip.role %}
  206. <span class="label label-{{ ip.get_role_class }}">{{ ip.get_role_display }}</span>
  207. {% endif %}
  208. </td>
  209. {# VRF #}
  210. <td>
  211. {% if ip.vrf %}
  212. <a href="{% url 'ipam:vrf' pk=ip.vrf.pk %}" title="{{ ip.vrf.rd }}">{{ ip.vrf.name }}</a>
  213. {% else %}
  214. <span class="text-muted">Global</span>
  215. {% endif %}
  216. </td>
  217. {# Description #}
  218. <td>
  219. {% if ip.description %}
  220. {{ ip.description }}
  221. {% else %}
  222. <span class="text-muted">&mdash;</span>
  223. {% endif %}
  224. </td>
  225. {# Buttons #}
  226. <td class="text-right text-nowrap noprint">
  227. {% if perms.ipam.change_ipaddress %}
  228. <a href="{% url 'ipam:ipaddress_edit' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-info btn-xs">
  229. <i class="glyphicon glyphicon-pencil" aria-hidden="true" title="Edit IP address"></i>
  230. </a>
  231. {% endif %}
  232. {% if perms.ipam.delete_ipaddress %}
  233. <a href="{% url 'ipam:ipaddress_delete' pk=ip.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  234. <i class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete IP address"></i>
  235. </a>
  236. {% endif %}
  237. </td>
  238. </tr>
  239. {% endfor %}
  240. </table>
  241. </td>
  242. </tr>
  243. {% endif %}
  244. {% endwith %}