device.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. {% extends 'dcim/device/base.html' %}
  2. {% load render_table from django_tables2 %}
  3. {% load buttons %}
  4. {% load static %}
  5. {% load helpers %}
  6. {% load plugins %}
  7. {% block content %}
  8. <div class="row">
  9. <div class="col col-12 col-xl-6">
  10. <div class="card">
  11. <h5 class="card-header">Device</h5>
  12. <div class="card-body">
  13. <table class="table table-hover attr-table">
  14. <tr>
  15. <th scope="row">Region</th>
  16. <td>
  17. {% if object.site.region %}
  18. {% for region in object.site.region.get_ancestors %}
  19. {{ region|linkify }} /
  20. {% endfor %}
  21. {{ object.site.region|linkify }}
  22. {% else %}
  23. {{ ''|placeholder }}
  24. {% endif %}
  25. </td>
  26. </tr>
  27. <tr>
  28. <th scope="row">Site</th>
  29. <td>{{ object.site|linkify }}</td>
  30. </tr>
  31. <tr>
  32. <th scope="row">Location</th>
  33. <td>
  34. {% if object.location %}
  35. {% for location in object.location.get_ancestors %}
  36. {{ location|linkify }} /
  37. {% endfor %}
  38. {{ object.location|linkify }}
  39. {% else %}
  40. {{ ''|placeholder }}
  41. {% endif %}
  42. </td>
  43. </tr>
  44. <tr>
  45. <th scope="row">Rack</th>
  46. <td class="position-relative">
  47. {% if object.rack %}
  48. {{ object.rack|linkify }}
  49. <div class="position-absolute top-50 end-0 translate-middle-y noprint">
  50. <a href="{{ object.rack.get_absolute_url }}?device={{ object.pk }}" class="btn btn-primary btn-sm" title="Highlight device">
  51. <i class="mdi mdi-view-day-outline"></i>
  52. </a>
  53. </div>
  54. {% else %}
  55. {{ ''|placeholder }}
  56. {% endif %}
  57. </td>
  58. </tr>
  59. <tr>
  60. <th scope="row">Position</th>
  61. <td>
  62. {% if object.parent_bay %}
  63. {% with object.parent_bay.device as parent %}
  64. {{ parent|linkify }} / {{ object.parent_bay }}
  65. {% if parent.position %}
  66. (U{{ parent.position|floatformat }} / {{ parent.get_face_display }})
  67. {% endif %}
  68. {% endwith %}
  69. {% elif object.rack and object.position %}
  70. <span>U{{ object.position|floatformat }} / {{ object.get_face_display }}</span>
  71. {% elif object.rack and object.device_type.u_height %}
  72. <span class="badge bg-warning">Not racked</span>
  73. {% else %}
  74. {{ ''|placeholder }}
  75. {% endif %}
  76. </td>
  77. </tr>
  78. <tr>
  79. <th scope="row">Tenant</th>
  80. <td>
  81. {% if object.tenant.group %}
  82. {{ object.tenant.group|linkify }} /
  83. {% endif %}
  84. {{ object.tenant|linkify|placeholder }}
  85. </td>
  86. </tr>
  87. <tr>
  88. <th scope="row">Device Type</th>
  89. <td>
  90. {{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height|floatformat }}U)
  91. </td>
  92. </tr>
  93. <tr>
  94. <th scope="row">Description</th>
  95. <td>{{ object.description|placeholder }}</td>
  96. </tr>
  97. <tr>
  98. <th scope="row">Airflow</th>
  99. <td>
  100. {{ object.get_airflow_display|placeholder }}
  101. </td>
  102. </tr>
  103. <tr>
  104. <th scope="row">Serial Number</th>
  105. <td class="font-monospace">{{ object.serial|placeholder }}</td>
  106. </tr>
  107. <tr>
  108. <th scope="row">Asset Tag</th>
  109. <td class="font-monospace">{{ object.asset_tag|placeholder }}</td>
  110. </tr>
  111. <tr>
  112. <th scope="row">Config Template</th>
  113. <td>{{ object.config_template|linkify|placeholder }}</td>
  114. </tr>
  115. </table>
  116. </div>
  117. </div>
  118. {% if vc_members %}
  119. <div class="card">
  120. <h5 class="card-header">
  121. Virtual Chassis
  122. </h5>
  123. <div class="card-body">
  124. <table class="table table-hover attr-table">
  125. <tr>
  126. <th>Device</th>
  127. <th>Position</th>
  128. <th>Master</th>
  129. <th>Priority</th>
  130. </tr>
  131. {% for vc_member in vc_members %}
  132. <tr{% if vc_member == object %} class="info"{% endif %}>
  133. <td>
  134. {{ vc_member|linkify }}
  135. </td>
  136. <td>
  137. {% badge vc_member.vc_position show_empty=True %}
  138. </td>
  139. <td>
  140. {% if object.virtual_chassis.master == vc_member %}<i class="mdi mdi-check-bold"></i>{% endif %}
  141. </td>
  142. <td>
  143. {{ vc_member.vc_priority|placeholder }}
  144. </td>
  145. </tr>
  146. {% endfor %}
  147. </table>
  148. </div>
  149. <div class="card-footer text-end noprint">
  150. <a href="{{ object.virtual_chassis.get_absolute_url }}" class="btn btn-primary btn-sm">
  151. <span class="mdi mdi-arrow-right-bold" aria-hidden="true"></span> View Virtual Chassis
  152. </a>
  153. </div>
  154. </div>
  155. {% endif %}
  156. {% include 'inc/panels/custom_fields.html' %}
  157. {% include 'inc/panels/tags.html' %}
  158. {% include 'inc/panels/comments.html' %}
  159. <div class="card">
  160. <h5 class="card-header">Virtual Device Contexts</h5>
  161. <div class="card-body htmx-container table-responsive"
  162. hx-get="{% url 'dcim:virtualdevicecontext_list' %}?device_id={{ object.pk }}"
  163. hx-trigger="load"
  164. ></div>
  165. {% if perms.dcim.add_virtualdevicecontext %}
  166. <div class="card-footer text-end noprint">
  167. <a href="{% url 'dcim:virtualdevicecontext_add' %}?device={{ object.pk }}" class="btn btn-sm btn-primary">
  168. <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Create VDC
  169. </a>
  170. </div>
  171. {% endif %}
  172. </div>
  173. {% plugin_left_page object %}
  174. </div>
  175. <div class="col col-12 col-xl-6">
  176. <div class="card">
  177. <h5 class="card-header">Management</h5>
  178. <div class="card-body">
  179. <table class="table table-hover attr-table">
  180. <tr>
  181. <th scope="row">Status</th>
  182. <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
  183. </tr>
  184. <tr>
  185. <th scope="row">Role</th>
  186. <td>{{ object.device_role|linkify }}</td>
  187. </tr>
  188. <tr>
  189. <th scope="row">Platform</th>
  190. <td>{{ object.platform|linkify|placeholder }}</td>
  191. </tr>
  192. <tr>
  193. <th scope="row">Primary IPv4</th>
  194. <td>
  195. {% if object.primary_ip4 %}
  196. <a href="{{ object.primary_ip4.get_absolute_url }}" id="primary_ip4">{{ object.primary_ip4.address.ip }}</a>
  197. {% if object.primary_ip4.nat_inside %}
  198. (NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }}">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
  199. {% elif object.primary_ip4.nat_outside.exists %}
  200. (NAT: {% for nat in object.primary_ip4.nat_outside.all %}<a href="{{ nat.get_absolute_url }}">{{ nat.address.ip }}</a>{% if not forloop.last %}, {% endif %}{% endfor %})
  201. {% endif %}
  202. {% copy_content "primary_ip4" %}
  203. {% else %}
  204. {{ ''|placeholder }}
  205. {% endif %}
  206. </td>
  207. </tr>
  208. <tr>
  209. <th scope="row">Primary IPv6</th>
  210. <td>
  211. {% if object.primary_ip6 %}
  212. <a href="{{ object.primary_ip6.get_absolute_url }}" id="primary_ip6">{{ object.primary_ip6.address.ip }}</a>
  213. {% if object.primary_ip6.nat_inside %}
  214. (NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
  215. {% elif object.primary_ip6.nat_outside.exists %}
  216. (NAT: {% for nat in object.primary_ip6.nat_outside.all %}<a href="{{ nat.get_absolute_url }}">{{ nat.address.ip }}</a>{% if not forloop.last %}, {% endif %}{% endfor %})
  217. {% endif %}
  218. {% copy_content "primary_ip6" %}
  219. {% else %}
  220. {{ ''|placeholder }}
  221. {% endif %}
  222. </td>
  223. </tr>
  224. {% if object.cluster %}
  225. <tr>
  226. <th>Cluster</th>
  227. <td>
  228. {% if object.cluster.group %}
  229. {{ object.cluster.group|linkify }} /
  230. {% endif %}
  231. {{ object.cluster|linkify }}
  232. </td>
  233. </tr>
  234. {% endif %}
  235. </table>
  236. </div>
  237. </div>
  238. {% if object.powerports.exists and object.poweroutlets.exists %}
  239. <div class="card">
  240. <h5 class="card-header">
  241. Power Utilization
  242. </h5>
  243. <div class="card-body">
  244. <table class="table table-hover">
  245. <tr>
  246. <th>Input</th>
  247. <th>Outlets</th>
  248. <th>Allocated</th>
  249. <th>Available</th>
  250. <th>Utilization</th>
  251. </tr>
  252. {% for powerport in object.powerports.all %}
  253. {% with utilization=powerport.get_power_draw powerfeed=powerport.connected_endpoints.0 %}
  254. <tr>
  255. <td>{{ powerport }}</td>
  256. <td>{{ utilization.outlet_count }}</td>
  257. <td>{{ utilization.allocated }}VA</td>
  258. {% if powerfeed.available_power %}
  259. <td>{{ powerfeed.available_power }}VA</td>
  260. <td>{% utilization_graph utilization.allocated|percentage:powerfeed.available_power %}</td>
  261. {% else %}
  262. <td class="text-muted">&mdash;</td>
  263. <td class="text-muted">&mdash;</td>
  264. {% endif %}
  265. </tr>
  266. {% for leg in utilization.legs %}
  267. <tr>
  268. <td style="padding-left: 20px">Leg {{ leg.name }}</td>
  269. <td>{{ leg.outlet_count }}</td>
  270. <td>{{ leg.allocated }}</td>
  271. {% if powerfeed.available_power %}
  272. {% with phase_available=powerfeed.available_power|divide:3 %}
  273. <td>{{ phase_available }}VA</td>
  274. <td>{% utilization_graph leg.allocated|percentage:phase_available %}</td>
  275. {% endwith %}
  276. {% else %}
  277. <td class="text-muted">&mdash;</td>
  278. <td class="text-muted">&mdash;</td>
  279. {% endif %}
  280. </tr>
  281. {% endfor %}
  282. {% endwith %}
  283. {% endfor %}
  284. </table>
  285. </div>
  286. </div>
  287. {% endif %}
  288. <div class="card">
  289. <h5 class="card-header">Services</h5>
  290. <div class="card-body htmx-container table-responsive"
  291. hx-get="{% url 'ipam:service_list' %}?device_id={{ object.pk }}"
  292. hx-trigger="load"
  293. ></div>
  294. {% if perms.ipam.add_service %}
  295. <div class="card-footer text-end noprint">
  296. <a href="{% url 'ipam:service_add' %}?device={{ object.pk }}" class="btn btn-sm btn-primary">
  297. <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add a service
  298. </a>
  299. </div>
  300. {% endif %}
  301. </div>
  302. {% include 'inc/panels/image_attachments.html' %}
  303. <div class="card">
  304. <h5 class="card-header">Dimensions</h5>
  305. <div class="card-body table-responsive">
  306. <table class="table table-hover attr-table">
  307. <tr>
  308. <th scope="row">Height</th>
  309. <td>
  310. {{ object.device_type.u_height }}U
  311. </td>
  312. </tr>
  313. <tr>
  314. <th scope="row">Weight</th>
  315. <td>
  316. {% if object.total_weight %}
  317. {{ object.total_weight|floatformat }} Kilograms
  318. {% else %}
  319. {{ ''|placeholder }}
  320. {% endif %}
  321. </td>
  322. </tr>
  323. </table>
  324. </div>
  325. </div>
  326. {% if object.rack and object.position %}
  327. <div class="row" style="margin-bottom: 20px">
  328. <div class="col col-md-6 col-sm-6 col-xs-12 text-center">
  329. <div style="margin-left: 30px">
  330. <h4>Front</h4>
  331. {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='front' extra_params=svg_extra %}
  332. </div>
  333. </div>
  334. <div class="col col-md-6 col-sm-6 col-xs-12 text-center">
  335. <div style="margin-left: 30px">
  336. <h4>Rear</h4>
  337. {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='rear' extra_params=svg_extra %}
  338. </div>
  339. </div>
  340. </div>
  341. {% endif %}
  342. {% plugin_right_page object %}
  343. </div>
  344. </div>
  345. <div class="row">
  346. <div class="col col-md-12">
  347. {% plugin_full_width_page object %}
  348. </div>
  349. </div>
  350. {% endblock %}