device.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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">GPS Coordinates</th>
  80. <td class="position-relative">
  81. {% if object.latitude and object.longitude %}
  82. {% if config.MAPS_URL %}
  83. <div class="position-absolute top-50 end-0 translate-middle-y noprint">
  84. <a href="{{ config.MAPS_URL }}{{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary btn-sm">
  85. <i class="mdi mdi-map-marker"></i> Map It
  86. </a>
  87. </div>
  88. {% endif %}
  89. <span>{{ object.latitude }}, {{ object.longitude }}</span>
  90. {% else %}
  91. {{ ''|placeholder }}
  92. {% endif %}
  93. </td>
  94. </tr>
  95. <tr>
  96. <th scope="row">Tenant</th>
  97. <td>
  98. {% if object.tenant.group %}
  99. {{ object.tenant.group|linkify }} /
  100. {% endif %}
  101. {{ object.tenant|linkify|placeholder }}
  102. </td>
  103. </tr>
  104. <tr>
  105. <th scope="row">Device Type</th>
  106. <td>
  107. {{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height|floatformat }}U)
  108. </td>
  109. </tr>
  110. <tr>
  111. <th scope="row">Description</th>
  112. <td>{{ object.description|placeholder }}</td>
  113. </tr>
  114. <tr>
  115. <th scope="row">Airflow</th>
  116. <td>
  117. {{ object.get_airflow_display|placeholder }}
  118. </td>
  119. </tr>
  120. <tr>
  121. <th scope="row">Serial Number</th>
  122. <td class="font-monospace">{{ object.serial|placeholder }}</td>
  123. </tr>
  124. <tr>
  125. <th scope="row">Asset Tag</th>
  126. <td class="font-monospace">{{ object.asset_tag|placeholder }}</td>
  127. </tr>
  128. <tr>
  129. <th scope="row">Config Template</th>
  130. <td>{{ object.config_template|linkify|placeholder }}</td>
  131. </tr>
  132. </table>
  133. </div>
  134. </div>
  135. {% if vc_members %}
  136. <div class="card">
  137. <h5 class="card-header">
  138. Virtual Chassis
  139. </h5>
  140. <div class="card-body">
  141. <table class="table table-hover attr-table">
  142. <tr>
  143. <th>Device</th>
  144. <th>Position</th>
  145. <th>Master</th>
  146. <th>Priority</th>
  147. </tr>
  148. {% for vc_member in vc_members %}
  149. <tr{% if vc_member == object %} class="info"{% endif %}>
  150. <td>
  151. {{ vc_member|linkify }}
  152. </td>
  153. <td>
  154. {% badge vc_member.vc_position show_empty=True %}
  155. </td>
  156. <td>
  157. {% if object.virtual_chassis.master == vc_member %}<i class="mdi mdi-check-bold"></i>{% endif %}
  158. </td>
  159. <td>
  160. {{ vc_member.vc_priority|placeholder }}
  161. </td>
  162. </tr>
  163. {% endfor %}
  164. </table>
  165. </div>
  166. <div class="card-footer text-end noprint">
  167. <a href="{{ object.virtual_chassis.get_absolute_url }}" class="btn btn-primary btn-sm">
  168. <span class="mdi mdi-arrow-right-bold" aria-hidden="true"></span> View Virtual Chassis
  169. </a>
  170. </div>
  171. </div>
  172. {% endif %}
  173. {% include 'inc/panels/custom_fields.html' %}
  174. {% include 'inc/panels/tags.html' %}
  175. {% include 'inc/panels/comments.html' %}
  176. <div class="card">
  177. <h5 class="card-header">Virtual Device Contexts</h5>
  178. <div class="card-body htmx-container table-responsive"
  179. hx-get="{% url 'dcim:virtualdevicecontext_list' %}?device_id={{ object.pk }}"
  180. hx-trigger="load"
  181. ></div>
  182. {% if perms.dcim.add_virtualdevicecontext %}
  183. <div class="card-footer text-end noprint">
  184. <a href="{% url 'dcim:virtualdevicecontext_add' %}?device={{ object.pk }}" class="btn btn-sm btn-primary">
  185. <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Create VDC
  186. </a>
  187. </div>
  188. {% endif %}
  189. </div>
  190. {% plugin_left_page object %}
  191. </div>
  192. <div class="col col-12 col-xl-6">
  193. <div class="card">
  194. <h5 class="card-header">Management</h5>
  195. <div class="card-body">
  196. <table class="table table-hover attr-table">
  197. <tr>
  198. <th scope="row">Status</th>
  199. <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
  200. </tr>
  201. <tr>
  202. <th scope="row">Role</th>
  203. <td>{{ object.device_role|linkify }}</td>
  204. </tr>
  205. <tr>
  206. <th scope="row">Platform</th>
  207. <td>{{ object.platform|linkify|placeholder }}</td>
  208. </tr>
  209. <tr>
  210. <th scope="row">Primary IPv4</th>
  211. <td>
  212. {% if object.primary_ip4 %}
  213. <a href="{{ object.primary_ip4.get_absolute_url }}" id="primary_ip4">{{ object.primary_ip4.address.ip }}</a>
  214. {% if object.primary_ip4.nat_inside %}
  215. (NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }}">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
  216. {% elif object.primary_ip4.nat_outside.exists %}
  217. (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 %})
  218. {% endif %}
  219. {% copy_content "primary_ip4" %}
  220. {% else %}
  221. {{ ''|placeholder }}
  222. {% endif %}
  223. </td>
  224. </tr>
  225. <tr>
  226. <th scope="row">Primary IPv6</th>
  227. <td>
  228. {% if object.primary_ip6 %}
  229. <a href="{{ object.primary_ip6.get_absolute_url }}" id="primary_ip6">{{ object.primary_ip6.address.ip }}</a>
  230. {% if object.primary_ip6.nat_inside %}
  231. (NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
  232. {% elif object.primary_ip6.nat_outside.exists %}
  233. (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 %})
  234. {% endif %}
  235. {% copy_content "primary_ip6" %}
  236. {% else %}
  237. {{ ''|placeholder }}
  238. {% endif %}
  239. </td>
  240. </tr>
  241. {% if object.cluster %}
  242. <tr>
  243. <th>Cluster</th>
  244. <td>
  245. {% if object.cluster.group %}
  246. {{ object.cluster.group|linkify }} /
  247. {% endif %}
  248. {{ object.cluster|linkify }}
  249. </td>
  250. </tr>
  251. {% endif %}
  252. </table>
  253. </div>
  254. </div>
  255. {% if object.powerports.exists and object.poweroutlets.exists %}
  256. <div class="card">
  257. <h5 class="card-header">
  258. Power Utilization
  259. </h5>
  260. <div class="card-body">
  261. <table class="table table-hover">
  262. <tr>
  263. <th>Input</th>
  264. <th>Outlets</th>
  265. <th>Allocated</th>
  266. <th>Available</th>
  267. <th>Utilization</th>
  268. </tr>
  269. {% for powerport in object.powerports.all %}
  270. {% with utilization=powerport.get_power_draw powerfeed=powerport.connected_endpoints.0 %}
  271. <tr>
  272. <td>{{ powerport }}</td>
  273. <td>{{ utilization.outlet_count }}</td>
  274. <td>{{ utilization.allocated }}VA</td>
  275. {% if powerfeed.available_power %}
  276. <td>{{ powerfeed.available_power }}VA</td>
  277. <td>{% utilization_graph utilization.allocated|percentage:powerfeed.available_power %}</td>
  278. {% else %}
  279. <td class="text-muted">&mdash;</td>
  280. <td class="text-muted">&mdash;</td>
  281. {% endif %}
  282. </tr>
  283. {% for leg in utilization.legs %}
  284. <tr>
  285. <td style="padding-left: 20px">Leg {{ leg.name }}</td>
  286. <td>{{ leg.outlet_count }}</td>
  287. <td>{{ leg.allocated }}</td>
  288. {% if powerfeed.available_power %}
  289. {% with phase_available=powerfeed.available_power|divide:3 %}
  290. <td>{{ phase_available }}VA</td>
  291. <td>{% utilization_graph leg.allocated|percentage:phase_available %}</td>
  292. {% endwith %}
  293. {% else %}
  294. <td class="text-muted">&mdash;</td>
  295. <td class="text-muted">&mdash;</td>
  296. {% endif %}
  297. </tr>
  298. {% endfor %}
  299. {% endwith %}
  300. {% endfor %}
  301. </table>
  302. </div>
  303. </div>
  304. {% endif %}
  305. <div class="card">
  306. <h5 class="card-header">Services</h5>
  307. <div class="card-body htmx-container table-responsive"
  308. hx-get="{% url 'ipam:service_list' %}?device_id={{ object.pk }}"
  309. hx-trigger="load"
  310. ></div>
  311. {% if perms.ipam.add_service %}
  312. <div class="card-footer text-end noprint">
  313. <a href="{% url 'ipam:service_add' %}?device={{ object.pk }}" class="btn btn-sm btn-primary">
  314. <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add a service
  315. </a>
  316. </div>
  317. {% endif %}
  318. </div>
  319. {% include 'inc/panels/image_attachments.html' %}
  320. <div class="card">
  321. <h5 class="card-header">Dimensions</h5>
  322. <div class="card-body table-responsive">
  323. <table class="table table-hover attr-table">
  324. <tr>
  325. <th scope="row">Height</th>
  326. <td>
  327. {{ object.device_type.u_height }}U
  328. </td>
  329. </tr>
  330. <tr>
  331. <th scope="row">Weight</th>
  332. <td>
  333. {% if object.total_weight %}
  334. {{ object.total_weight|floatformat }} Kilograms
  335. {% else %}
  336. {{ ''|placeholder }}
  337. {% endif %}
  338. </td>
  339. </tr>
  340. </table>
  341. </div>
  342. </div>
  343. {% if object.rack and object.position %}
  344. <div class="row" style="margin-bottom: 20px">
  345. <div class="col col-md-6 col-sm-6 col-xs-12 text-center">
  346. <div style="margin-left: 30px">
  347. <h4>Front</h4>
  348. {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='front' extra_params=svg_extra %}
  349. </div>
  350. </div>
  351. <div class="col col-md-6 col-sm-6 col-xs-12 text-center">
  352. <div style="margin-left: 30px">
  353. <h4>Rear</h4>
  354. {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='rear' extra_params=svg_extra %}
  355. </div>
  356. </div>
  357. </div>
  358. {% endif %}
  359. {% plugin_right_page object %}
  360. </div>
  361. </div>
  362. <div class="row">
  363. <div class="col col-md-12">
  364. {% plugin_full_width_page object %}
  365. </div>
  366. </div>
  367. {% endblock %}