device.html 19 KB

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