device.html 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. {% extends '_base.html' %}
  2. {% load static %}
  3. {% load helpers %}
  4. {% load custom_links %}
  5. {% block title %}{{ device }}{% endblock %}
  6. {% block header %}
  7. <div class="row noprint">
  8. <div class="col-sm-8 col-md-9">
  9. <ol class="breadcrumb">
  10. <li><a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a></li>
  11. {% if device.rack %}
  12. <li><a href="{% url 'dcim:rack_list' %}?site={{ device.site.slug }}">Racks</a></li>
  13. <li><a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a></li>
  14. {% endif %}
  15. {% if device.parent_bay %}
  16. <li><a href="{% url 'dcim:device' pk=device.parent_bay.device.pk %}">{{ device.parent_bay.device }}</a></li>
  17. <li>{{ device.parent_bay }}</li>
  18. {% endif %}
  19. <li>{{ device }}</li>
  20. </ol>
  21. </div>
  22. <div class="col-sm-4 col-md-3">
  23. <form action="{% url 'dcim:device_list' %}" method="get">
  24. <div class="input-group">
  25. <input type="text" name="q" class="form-control" placeholder="Search devices" />
  26. <span class="input-group-btn">
  27. <button type="submit" class="btn btn-primary">
  28. <span class="fa fa-search" aria-hidden="true"></span>
  29. </button>
  30. </span>
  31. </div>
  32. </form>
  33. </div>
  34. </div>
  35. <div class="pull-right noprint">
  36. {% if show_graphs %}
  37. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#graphs_modal" data-obj="{{ device.name }}" data-url="{% url 'dcim-api:device-graphs' pk=device.pk %}" title="Show graphs">
  38. <i class="fa fa-signal" aria-hidden="true"></i>
  39. Graphs
  40. </button>
  41. {% endif %}
  42. {% if perms.dcim.change_device %}
  43. <div class="btn-group">
  44. <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  45. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Components <span class="caret"></span>
  46. </button>
  47. <ul class="dropdown-menu">
  48. {% if perms.dcim.add_consoleport %}<li><a href="{% url 'dcim:consoleport_add' pk=device.pk %}">Console Ports</a></li>{% endif %}
  49. {% if perms.dcim.add_consoleserverport %}<li><a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}">Console Server Ports</a></li>{% endif %}
  50. {% if perms.dcim.add_powerport %}<li><a href="{% url 'dcim:powerport_add' pk=device.pk %}">Power Ports</a></li>{% endif %}
  51. {% if perms.dcim.add_poweroutlet %}<li><a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}">Power Outlets</a></li>{% endif %}
  52. {% if perms.dcim.add_interface %}<li><a href="{% url 'dcim:interface_add' pk=device.pk %}">Interfaces</a></li>{% endif %}
  53. {% if perms.dcim.add_frontport %}<li><a href="{% url 'dcim:frontport_add' pk=device.pk %}">Front Ports</a></li>{% endif %}
  54. {% if perms.dcim.add_rearport %}<li><a href="{% url 'dcim:rearport_add' pk=device.pk %}">Rear Ports</a></li>{% endif %}
  55. {% if perms.dcim.add_devicebay %}<li><a href="{% url 'dcim:devicebay_add' pk=device.pk %}">Device Bays</a></li>{% endif %}
  56. </ul>
  57. </div>
  58. <a href="{% url 'dcim:device_edit' pk=device.pk %}" class="btn btn-warning">
  59. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
  60. Edit this device
  61. </a>
  62. {% endif %}
  63. {% if perms.dcim.delete_device %}
  64. <a href="{% url 'dcim:device_delete' pk=device.pk %}" class="btn btn-danger">
  65. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
  66. Delete this device
  67. </a>
  68. {% endif %}
  69. </div>
  70. <h1>{{ device }}</h1>
  71. {% include 'inc/created_updated.html' with obj=device %}
  72. <div class="pull-right noprint">
  73. {% custom_links device %}
  74. </div>
  75. <ul class="nav nav-tabs">
  76. <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
  77. <a href="{% url 'dcim:device' pk=device.pk %}">Device</a>
  78. </li>
  79. <li role="presentation"{% if active_tab == 'inventory' %} class="active"{% endif %}>
  80. <a href="{% url 'dcim:device_inventory' pk=device.pk %}">
  81. Inventory <span class="badge">{{ device.inventory_items.count }}</span>
  82. </a>
  83. </li>
  84. {% if perms.dcim.napalm_read %}
  85. {% if device.status != 1 %}
  86. {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='Device must be in active status' %}
  87. {% elif not device.platform %}
  88. {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='No platform assigned to this device' %}
  89. {% elif not device.platform.napalm_driver %}
  90. {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='No NAPALM driver assigned for this platform' %}
  91. {% elif not device.primary_ip %}
  92. {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='No primary IP address assigned to this device' %}
  93. {% else %}
  94. {% include 'dcim/inc/device_napalm_tabs.html' %}
  95. {% endif %}
  96. {% endif %}
  97. {% if perms.extras.view_configcontext %}
  98. <li role="presentation"{% if active_tab == 'config-context' %} class="active"{% endif %}>
  99. <a href="{% url 'dcim:device_configcontext' pk=device.pk %}">Config Context</a>
  100. </li>
  101. {% endif %}
  102. {% if perms.extras.view_objectchange %}
  103. <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
  104. <a href="{% url 'dcim:device_changelog' pk=device.pk %}">Changelog</a>
  105. </li>
  106. {% endif %}
  107. </ul>
  108. {% endblock %}
  109. {% block content %}
  110. <div class="row">
  111. <div class="col-md-6">
  112. <div class="panel panel-default">
  113. <div class="panel-heading">
  114. <strong>Device</strong>
  115. </div>
  116. <table class="table table-hover panel-body attr-table">
  117. <tr>
  118. <td>Site</td>
  119. <td>
  120. {% if device.site.region %}
  121. <a href="{{ device.site.region.get_absolute_url }}">{{ device.site.region }}</a>
  122. <i class="fa fa-angle-right"></i>
  123. {% endif %}
  124. <a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td>Rack</td>
  129. <td>
  130. {% if device.rack %}
  131. {% if device.rack.group %}
  132. <a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group }}</a>
  133. <i class="fa fa-angle-right"></i>
  134. {% endif %}
  135. <a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a>
  136. {% else %}
  137. <span class="text-muted">None</span>
  138. {% endif %}
  139. </td>
  140. </tr>
  141. <tr>
  142. <td>Position</td>
  143. <td>
  144. {% if device.parent_bay %}
  145. {% with device.parent_bay.device as parent %}
  146. <a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay }}
  147. {% if parent.position %}
  148. (U{{ parent.position }} / {{ parent.get_face_display }})
  149. {% endif %}
  150. {% endwith %}
  151. {% elif device.rack and device.position %}
  152. <span>U{{ device.position }} / {{ device.get_face_display }}</span>
  153. {% elif device.rack and device.device_type.u_height %}
  154. <span class="label label-warning">Not racked</span>
  155. {% else %}
  156. <span class="text-muted">&mdash;</span>
  157. {% endif %}
  158. </td>
  159. </tr>
  160. <tr>
  161. <td>Tenant</td>
  162. <td>
  163. {% if device.tenant %}
  164. {% if device.tenant.group %}
  165. <a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group }}</a>
  166. <i class="fa fa-angle-right"></i>
  167. {% endif %}
  168. <a href="{{ device.tenant.get_absolute_url }}">{{ device.tenant }}</a>
  169. {% else %}
  170. <span class="text-muted">None</span>
  171. {% endif %}
  172. </td>
  173. </tr>
  174. <tr>
  175. <td>Device Type</td>
  176. <td>
  177. <span><a href="{% url 'dcim:devicetype' pk=device.device_type.pk %}">{{ device.device_type.display_name }}</a> ({{ device.device_type.u_height }}U)</span>
  178. </td>
  179. </tr>
  180. <tr>
  181. <td>Serial Number</td>
  182. <td><span>{{ device.serial|placeholder }}</span></td>
  183. </tr>
  184. <tr>
  185. <td>Asset Tag</td>
  186. <td><span>{{ device.asset_tag|placeholder }}</span></td>
  187. </tr>
  188. </table>
  189. </div>
  190. {% if vc_members %}
  191. <div class="panel panel-default">
  192. <div class="panel-heading">
  193. <strong>Virtual Chassis</strong>
  194. </div>
  195. <table class="table table-hover panel-body attr-table">
  196. <tr>
  197. <th>Device</th>
  198. <th>Position</th>
  199. <th>Master</th>
  200. <th>Priority</th>
  201. </tr>
  202. {% for vc_member in vc_members %}
  203. <tr{% if vc_member == device %} class="info"{% endif %}>
  204. <td>
  205. <a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
  206. </td>
  207. <td><span class="badge badge-default">{{ vc_member.vc_position }}</span></td>
  208. <td>{% if device.virtual_chassis.master == vc_member %}<i class="fa fa-check"></i>{% endif %}</td>
  209. <td>{{ vc_member.vc_priority|default:"" }}</td>
  210. </tr>
  211. {% endfor %}
  212. </table>
  213. <div class="panel-footer text-right noprint">
  214. {% if perms.dcim.change_virtualchassis %}
  215. <a href="{% url 'dcim:virtualchassis_add_member' pk=device.virtual_chassis.pk %}?site={{ device.site.pk }}&rack={{ device.rack.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-primary btn-xs">
  216. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Member
  217. </a>
  218. <a href="{% url 'dcim:virtualchassis_edit' pk=device.virtual_chassis.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  219. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit Virtual Chassis
  220. </a>
  221. {% endif %}
  222. {% if perms.dcim.delete_virtualchassis %}
  223. <a href="{% url 'dcim:virtualchassis_delete' pk=device.virtual_chassis.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  224. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete Virtual Chassis
  225. </a>
  226. {% endif %}
  227. </div>
  228. </div>
  229. {% endif %}
  230. <div class="panel panel-default">
  231. <div class="panel-heading">
  232. <strong>Management</strong>
  233. </div>
  234. <table class="table table-hover panel-body attr-table">
  235. <tr>
  236. <td>Role</td>
  237. <td>
  238. <a href="{% url 'dcim:device_list' %}?role={{ device.device_role.slug }}">{{ device.device_role }}</a>
  239. </td>
  240. </tr>
  241. <tr>
  242. <td>Platform</td>
  243. <td>
  244. {% if device.platform %}
  245. <a href="{{ device.platform.get_absolute_url }}">{{ device.platform }}</a>
  246. {% else %}
  247. <span class="text-muted">None</span>
  248. {% endif %}
  249. </td>
  250. </tr>
  251. <tr>
  252. <td>Status</td>
  253. <td>
  254. <span class="label label-{{ device.get_status_class }}">{{ device.get_status_display }}</span>
  255. </td>
  256. </tr>
  257. <tr>
  258. <td>Primary IPv4</td>
  259. <td>
  260. {% if device.primary_ip4 %}
  261. <a href="{% url 'ipam:ipaddress' pk=device.primary_ip4.pk %}">{{ device.primary_ip4.address.ip }}</a>
  262. {% if device.primary_ip4.nat_inside %}
  263. <span>(NAT for {{ device.primary_ip4.nat_inside.address.ip }})</span>
  264. {% elif device.primary_ip4.nat_outside %}
  265. <span>(NAT: {{ device.primary_ip4.nat_outside.address.ip }})</span>
  266. {% endif %}
  267. {% else %}
  268. <span class="text-muted">&mdash;</span>
  269. {% endif %}
  270. </td>
  271. </tr>
  272. <tr>
  273. <td>Primary IPv6</td>
  274. <td>
  275. {% if device.primary_ip6 %}
  276. <a href="{% url 'ipam:ipaddress' pk=device.primary_ip6.pk %}">{{ device.primary_ip6.address.ip }}</a>
  277. {% if device.primary_ip6.nat_inside %}
  278. <span>(NAT for {{ device.primary_ip6.nat_inside.address.ip }})</span>
  279. {% elif device.primary_ip6.nat_outside %}
  280. <span>(NAT: {{ device.primary_ip6.nat_outside.address.ip }})</span>
  281. {% endif %}
  282. {% else %}
  283. <span class="text-muted">&mdash;</span>
  284. {% endif %}
  285. </td>
  286. </tr>
  287. {% if device.cluster %}
  288. <tr>
  289. <td>Cluster</td>
  290. <td>
  291. {% if device.cluster.group %}
  292. <a href="{{ device.cluster.group.get_absolute_url }}">{{ device.cluster.group }}</a>
  293. <i class="fa fa-angle-right"></i>
  294. {% endif %}
  295. <a href="{{ device.cluster.get_absolute_url }}">{{ device.cluster }}</a>
  296. </td>
  297. </tr>
  298. {% endif %}
  299. </table>
  300. </div>
  301. {% include 'inc/custom_fields_panel.html' with obj=device %}
  302. {% include 'extras/inc/tags_panel.html' with tags=device.tags.all url='dcim:device_list' %}
  303. <div class="panel panel-default">
  304. <div class="panel-heading">
  305. <strong>Comments</strong>
  306. </div>
  307. <div class="panel-body rendered-markdown">
  308. {% if device.comments %}
  309. {{ device.comments|gfm }}
  310. {% else %}
  311. <span class="text-muted">None</span>
  312. {% endif %}
  313. </div>
  314. </div>
  315. </div>
  316. <div class="col-md-6">
  317. {% if console_ports or power_ports %}
  318. <div class="panel panel-default">
  319. <div class="panel-heading">
  320. <strong>Console / Power</strong>
  321. </div>
  322. <table class="table table-hover panel-body component-list">
  323. {% for cp in console_ports %}
  324. {% include 'dcim/inc/consoleport.html' %}
  325. {% endfor %}
  326. {% for pp in power_ports %}
  327. {% include 'dcim/inc/powerport.html' %}
  328. {% endfor %}
  329. </table>
  330. {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %}
  331. <div class="panel-footer text-right noprint">
  332. {% if perms.dcim.add_consoleport %}
  333. <a href="{% url 'dcim:consoleport_add' pk=device.pk %}" class="btn btn-xs btn-primary">
  334. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console port
  335. </a>
  336. {% endif %}
  337. {% if perms.dcim.add_powerport %}
  338. <a href="{% url 'dcim:powerport_add' pk=device.pk %}" class="btn btn-xs btn-primary">
  339. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power port
  340. </a>
  341. {% endif %}
  342. </div>
  343. {% endif %}
  344. </div>
  345. {% endif %}
  346. {% if power_ports and poweroutlets %}
  347. <div class="panel panel-default">
  348. <div class="panel-heading">
  349. <strong>Power Utilization</strong>
  350. </div>
  351. <table class="table table-hover panel-body">
  352. <tr>
  353. <th>Input</th>
  354. <th>Outlets</th>
  355. <th>Allocated</th>
  356. <th>Available</th>
  357. <th>Utilization</th>
  358. </tr>
  359. {% for pp in power_ports %}
  360. {% with utilization=pp.get_power_draw powerfeed=pp.connected_endpoint %}
  361. <tr>
  362. <td>{{ pp }}</td>
  363. <td>{{ utilization.outlet_count }}</td>
  364. <td>{{ utilization.allocated }}VA</td>
  365. {% if powerfeed.available_power %}
  366. <td>{{ powerfeed.available_power }}VA</td>
  367. <td>{% utilization_graph utilization.allocated|percentage:powerfeed.available_power %}</td>
  368. {% else %}
  369. <td class="text-muted">&mdash;</td>
  370. <td class="text-muted">&mdash;</td>
  371. {% endif %}
  372. </tr>
  373. {% for leg in utilization.legs %}
  374. <tr>
  375. <td style="padding-left: 20px">Leg {{ leg.name }}</td>
  376. <td>{{ leg.outlet_count }}</td>
  377. <td>{{ leg.allocated }}</td>
  378. <td>{{ powerfeed.available_power|divide:3 }}VA</td>
  379. {% with phase_available=powerfeed.available_power|divide:3 %}
  380. <td>{% utilization_graph leg.allocated|percentage:phase_available %}</td>
  381. {% endwith %}
  382. </tr>
  383. {% endfor %}
  384. {% endwith %}
  385. {% endfor %}
  386. </table>
  387. </div>
  388. {% endif %}
  389. {% if request.user.is_authenticated %}
  390. <div class="panel panel-default">
  391. <div class="panel-heading">
  392. <strong>Secrets</strong>
  393. </div>
  394. {% if secrets %}
  395. <table class="table table-hover panel-body">
  396. {% for secret in secrets %}
  397. {% include 'secrets/inc/secret_tr.html' %}
  398. {% endfor %}
  399. </table>
  400. {% else %}
  401. <div class="panel-body text-muted">
  402. None found
  403. </div>
  404. {% endif %}
  405. {% if perms.secrets.add_secret %}
  406. <form id="secret_form">
  407. {% csrf_token %}
  408. </form>
  409. <div class="panel-footer text-right noprint">
  410. <a href="{% url 'dcim:device_addsecret' pk=device.pk %}" class="btn btn-xs btn-primary">
  411. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
  412. Add secret
  413. </a>
  414. </div>
  415. {% endif %}
  416. </div>
  417. {% endif %}
  418. <div class="panel panel-default">
  419. <div class="panel-heading">
  420. <strong>Services</strong>
  421. </div>
  422. {% if services %}
  423. <table class="table table-hover panel-body">
  424. {% for service in services %}
  425. {% include 'ipam/inc/service.html' %}
  426. {% endfor %}
  427. </table>
  428. {% else %}
  429. <div class="panel-body text-muted">
  430. None
  431. </div>
  432. {% endif %}
  433. {% if perms.ipam.add_service %}
  434. <div class="panel-footer text-right noprint">
  435. <a href="{% url 'dcim:device_service_assign' device=device.pk %}" class="btn btn-xs btn-primary">
  436. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Assign service
  437. </a>
  438. </div>
  439. {% endif %}
  440. </div>
  441. <div class="panel panel-default">
  442. <div class="panel-heading">
  443. <strong>Images</strong>
  444. </div>
  445. {% include 'inc/image_attachments.html' with images=device.images.all %}
  446. {% if perms.extras.add_imageattachment %}
  447. <div class="panel-footer text-right noprint">
  448. <a href="{% url 'dcim:device_add_image' object_id=device.pk %}" class="btn btn-primary btn-xs">
  449. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
  450. Attach an image
  451. </a>
  452. </div>
  453. {% endif %}
  454. </div>
  455. <div class="panel panel-default noprint">
  456. <div class="panel-heading">
  457. <strong>Related Devices</strong>
  458. </div>
  459. {% if related_devices %}
  460. <table class="table table-hover panel-body">
  461. {% for rd in related_devices %}
  462. <tr>
  463. <td>
  464. <a href="{% url 'dcim:device' pk=rd.pk %}">{{ rd }}</a>
  465. </td>
  466. <td>
  467. {% if rd.rack %}
  468. <a href="{% url 'dcim:rack' pk=rd.rack.pk %}">Rack {{ rd.rack }}</a>
  469. {% else %}
  470. <span class="text-muted">&mdash;</span>
  471. {% endif %}
  472. </td>
  473. <td>{{ rd.device_type.display_name }}</td>
  474. </tr>
  475. {% endfor %}
  476. </table>
  477. {% else %}
  478. <div class="panel-body text-muted">None found</div>
  479. {% endif %}
  480. </div>
  481. </div>
  482. </div>
  483. <div class="row">
  484. <div class="col-md-12">
  485. {% if device_bays or device.device_type.is_parent_device %}
  486. {% if perms.dcim.delete_devicebay %}
  487. <form method="post">
  488. {% csrf_token %}
  489. {% endif %}
  490. <div class="panel panel-default">
  491. <div class="panel-heading">
  492. <strong>Device Bays</strong>
  493. </div>
  494. <table class="table table-hover table-headings panel-body component-list">
  495. <thead>
  496. <tr>
  497. {% if perms.dcim.change_devicebay or perms.dcim.delete_devicebay %}
  498. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  499. {% endif %}
  500. <th>Name</th>
  501. <th>Status</th>
  502. <th>Description</th>
  503. <th colspan="2">Installed Device</th>
  504. <th></th>
  505. </tr>
  506. </thead>
  507. <tbody>
  508. {% for devicebay in device_bays %}
  509. {% include 'dcim/inc/devicebay.html' %}
  510. {% empty %}
  511. <tr>
  512. <td colspan="5" class="text-center text-muted">&mdash; No device bays defined &mdash;</td>
  513. </tr>
  514. {% endfor %}
  515. </tbody>
  516. </table>
  517. <div class="panel-footer noprint">
  518. {% if device_bays and perms.dcim.change_devicebay %}
  519. <button type="submit" name="_rename" formaction="{% url 'dcim:devicebay_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  520. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  521. </button>
  522. {% endif %}
  523. {% if device_bays and perms.dcim.delete_devicebay %}
  524. <button type="submit" formaction="{% url 'dcim:devicebay_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  525. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  526. </button>
  527. {% endif %}
  528. {% if perms.dcim.add_devicebay %}
  529. <div class="pull-right">
  530. <a href="{% url 'dcim:devicebay_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  531. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add device bays
  532. </a>
  533. </div>
  534. <div class="clearfix"></div>
  535. {% endif %}
  536. </div>
  537. </div>
  538. {% if perms.dcim.delete_devicebay %}
  539. </form>
  540. {% endif %}
  541. {% endif %}
  542. {% if interfaces %}
  543. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  544. <form method="post">
  545. {% csrf_token %}
  546. <input type="hidden" name="device" value="{{ device.pk }}" />
  547. {% endif %}
  548. <div class="panel panel-default">
  549. <div class="panel-heading">
  550. <strong>Interfaces</strong>
  551. <div class="pull-right noprint">
  552. <button class="btn btn-default btn-xs toggle-ips" selected="selected">
  553. <span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
  554. </button>
  555. </div>
  556. </div>
  557. <table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
  558. <thead>
  559. <tr>
  560. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  561. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  562. {% endif %}
  563. <th>Name</th>
  564. <th>LAG</th>
  565. <th>Description</th>
  566. <th>MTU</th>
  567. <th>Mode</th>
  568. <th>Cable</th>
  569. <th colspan="2">Connection</th>
  570. <th></th>
  571. </tr>
  572. </thead>
  573. <tbody>
  574. {% for iface in interfaces %}
  575. {% include 'dcim/inc/interface.html' %}
  576. {% endfor %}
  577. </tbody>
  578. </table>
  579. <div class="panel-footer noprint">
  580. {% if interfaces and perms.dcim.change_interface %}
  581. <button type="submit" name="_rename" formaction="{% url 'dcim:interface_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  582. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  583. </button>
  584. <button type="submit" name="_edit" formaction="{% url 'dcim:interface_bulk_edit' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  585. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  586. </button>
  587. {% endif %}
  588. {% if interfaces and perms.dcim.change_interface %}
  589. <button type="submit" name="_disconnect" formaction="{% url 'dcim:interface_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  590. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  591. </button>
  592. {% endif %}
  593. {% if interfaces and perms.dcim.delete_interface %}
  594. <button type="submit" name="_delete" formaction="{% url 'dcim:interface_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  595. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  596. </button>
  597. {% endif %}
  598. {% if perms.dcim.add_interface %}
  599. <div class="pull-right">
  600. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  601. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  602. </a>
  603. </div>
  604. <div class="clearfix"></div>
  605. {% endif %}
  606. </div>
  607. </div>
  608. {% if perms.dcim.delete_interface %}
  609. </form>
  610. {% endif %}
  611. {% endif %}
  612. {% if consoleserverports %}
  613. {% if perms.dcim.delete_consoleserverport %}
  614. <form method="post">
  615. {% csrf_token %}
  616. {% endif %}
  617. <div class="panel panel-default">
  618. <div class="panel-heading">
  619. <strong>Console Server Ports</strong>
  620. </div>
  621. <table class="table table-hover table-headings panel-body component-list">
  622. <thead>
  623. <tr>
  624. {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %}
  625. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  626. {% endif %}
  627. <th>Name</th>
  628. <th>Description</th>
  629. <th>Cable</th>
  630. <th colspan="2">Connection</th>
  631. <th></th>
  632. </tr>
  633. </thead>
  634. <tbody>
  635. {% for csp in consoleserverports %}
  636. {% include 'dcim/inc/consoleserverport.html' %}
  637. {% endfor %}
  638. </tbody>
  639. </table>
  640. <div class="panel-footer noprint">
  641. {% if consoleserverports and perms.dcim.change_consoleport %}
  642. <button type="submit" name="_rename" formaction="{% url 'dcim:consoleserverport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  643. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  644. </button>
  645. <button type="submit" name="_edit" formaction="{% url 'dcim:consoleserverport_bulk_edit' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  646. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  647. </button>
  648. <button type="submit" name="_disconnect" formaction="{% url 'dcim:consoleserverport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  649. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  650. </button>
  651. {% endif %}
  652. {% if consoleserverports and perms.dcim.delete_consoleserverport %}
  653. <button type="submit" formaction="{% url 'dcim:consoleserverport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  654. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  655. </button>
  656. {% endif %}
  657. {% if perms.dcim.add_consoleserverport %}
  658. <div class="pull-right">
  659. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  660. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  661. </a>
  662. </div>
  663. <div class="clearfix"></div>
  664. {% endif %}
  665. </div>
  666. </div>
  667. {% if perms.dcim.delete_consoleserverport %}
  668. </form>
  669. {% endif %}
  670. {% endif %}
  671. {% if poweroutlets %}
  672. {% if perms.dcim.delete_poweroutlet %}
  673. <form method="post">
  674. {% csrf_token %}
  675. {% endif %}
  676. <div class="panel panel-default">
  677. <div class="panel-heading">
  678. <strong>Power Outlets</strong>
  679. </div>
  680. <table class="table table-hover table-headings panel-body component-list">
  681. <thead>
  682. <tr>
  683. {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %}
  684. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  685. {% endif %}
  686. <th>Name</th>
  687. <th>Input/Leg</th>
  688. <th>Description</th>
  689. <th>Cable</th>
  690. <th colspan="3">Connection</th>
  691. <th></th>
  692. </tr>
  693. </thead>
  694. <tbody>
  695. {% for po in poweroutlets %}
  696. {% include 'dcim/inc/poweroutlet.html' %}
  697. {% endfor %}
  698. </tbody>
  699. </table>
  700. <div class="panel-footer noprint">
  701. {% if poweroutlets and perms.dcim.change_powerport %}
  702. <button type="submit" name="_rename" formaction="{% url 'dcim:poweroutlet_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  703. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  704. </button>
  705. <button type="submit" name="_edit" formaction="{% url 'dcim:poweroutlet_bulk_edit' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  706. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  707. </button>
  708. <button type="submit" name="_disconnect" formaction="{% url 'dcim:poweroutlet_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  709. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  710. </button>
  711. {% endif %}
  712. {% if poweroutlets and perms.dcim.delete_poweroutlet %}
  713. <button type="submit" formaction="{% url 'dcim:poweroutlet_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  714. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  715. </button>
  716. {% endif %}
  717. {% if perms.dcim.add_poweroutlet %}
  718. <div class="pull-right">
  719. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  720. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  721. </a>
  722. </div>
  723. <div class="clearfix"></div>
  724. {% endif %}
  725. </div>
  726. </div>
  727. {% if perms.dcim.delete_poweroutlet %}
  728. </form>
  729. {% endif %}
  730. {% endif %}
  731. {% if front_ports %}
  732. <form method="post">
  733. {% csrf_token %}
  734. <div class="panel panel-default">
  735. <div class="panel-heading">
  736. <strong>Front Ports</strong>
  737. </div>
  738. <table class="table table-hover table-headings panel-body component-list">
  739. <thead>
  740. <tr>
  741. {% if perms.dcim.change_frontport or perms.dcim.delete_frontport %}
  742. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  743. {% endif %}
  744. <th>Name</th>
  745. <th>Type</th>
  746. <th>Rear Port</th>
  747. <th>Position</th>
  748. <th>Description</th>
  749. <th>Cable</th>
  750. <th colspan="2">Connection</th>
  751. <th></th>
  752. </tr>
  753. </thead>
  754. <tbody>
  755. {% for frontport in front_ports %}
  756. {% include 'dcim/inc/frontport.html' %}
  757. {% endfor %}
  758. </tbody>
  759. </table>
  760. <div class="panel-footer noprint">
  761. {% if front_ports and perms.dcim.change_frontport %}
  762. <button type="submit" name="_rename" formaction="{% url 'dcim:frontport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  763. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  764. </button>
  765. <button type="submit" name="_edit" formaction="{% url 'dcim:frontport_bulk_edit' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  766. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  767. </button>
  768. <button type="submit" name="_disconnect" formaction="{% url 'dcim:frontport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  769. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  770. </button>
  771. {% endif %}
  772. {% if front_ports and perms.dcim.delete_frontport %}
  773. <button type="submit" formaction="{% url 'dcim:frontport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  774. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  775. </button>
  776. {% endif %}
  777. {% if perms.dcim.add_frontport %}
  778. <div class="pull-right">
  779. <a href="{% url 'dcim:frontport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  780. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add front ports
  781. </a>
  782. </div>
  783. <div class="clearfix"></div>
  784. {% endif %}
  785. </div>
  786. </div>
  787. </form>
  788. {% endif %}
  789. {% if rear_ports %}
  790. <form method="post">
  791. {% csrf_token %}
  792. <div class="panel panel-default">
  793. <div class="panel-heading">
  794. <strong>Rear Ports</strong>
  795. </div>
  796. <table class="table table-hover table-headings panel-body component-list">
  797. <thead>
  798. <tr>
  799. {% if perms.dcim.change_rearport or perms.dcim.delete_rearport %}
  800. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  801. {% endif %}
  802. <th>Name</th>
  803. <th>Type</th>
  804. <th>Positions</th>
  805. <th>Description</th>
  806. <th>Cable</th>
  807. <th colspan="2">Connection</th>
  808. <th></th>
  809. </tr>
  810. </thead>
  811. <tbody>
  812. {% for rearport in rear_ports %}
  813. {% include 'dcim/inc/rearport.html' %}
  814. {% endfor %}
  815. </tbody>
  816. </table>
  817. <div class="panel-footer noprint">
  818. {% if rear_ports and perms.dcim.change_rearport %}
  819. <button type="submit" name="_rename" formaction="{% url 'dcim:rearport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  820. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  821. </button>
  822. <button type="submit" name="_edit" formaction="{% url 'dcim:rearport_bulk_edit' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  823. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  824. </button>
  825. <button type="submit" name="_disconnect" formaction="{% url 'dcim:rearport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  826. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  827. </button>
  828. {% endif %}
  829. {% if rear_ports and perms.dcim.delete_rearport %}
  830. <button type="submit" formaction="{% url 'dcim:rearport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  831. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  832. </button>
  833. {% endif %}
  834. {% if perms.dcim.add_rearport %}
  835. <div class="pull-right">
  836. <a href="{% url 'dcim:rearport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  837. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add rear ports
  838. </a>
  839. </div>
  840. <div class="clearfix"></div>
  841. {% endif %}
  842. </div>
  843. </div>
  844. </form>
  845. {% endif %}
  846. </div>
  847. </div>
  848. {% include 'inc/modal.html' with modal_name='graphs' %}
  849. {% include 'secrets/inc/private_key_modal.html' %}
  850. {% endblock %}
  851. {% block javascript %}
  852. <script type="text/javascript">
  853. function toggleConnection(elem) {
  854. var url = netbox_api_path + "dcim/cables/" + elem.attr('data') + "/";
  855. if (elem.hasClass('connected')) {
  856. $.ajax({
  857. url: url,
  858. method: 'PATCH',
  859. dataType: 'json',
  860. beforeSend: function(xhr, settings) {
  861. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  862. },
  863. data: {
  864. 'status': 'False'
  865. },
  866. context: this,
  867. success: function() {
  868. elem.parents('tr').removeClass('success').addClass('info');
  869. elem.removeClass('connected btn-warning').addClass('btn-success');
  870. elem.attr('title', 'Mark installed');
  871. elem.children('i').removeClass('glyphicon glyphicon-ban-circle').addClass('fa fa-plug')
  872. }
  873. });
  874. } else {
  875. $.ajax({
  876. url: url,
  877. method: 'PATCH',
  878. dataType: 'json',
  879. beforeSend: function(xhr, settings) {
  880. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  881. },
  882. data: {
  883. 'status': 'True'
  884. },
  885. context: this,
  886. success: function() {
  887. elem.parents('tr').removeClass('info').addClass('success');
  888. elem.removeClass('btn-success').addClass('connected btn-warning');
  889. elem.attr('title', 'Mark planned');
  890. elem.children('i').removeClass('fa fa-plug').addClass('glyphicon glyphicon-ban-circle')
  891. }
  892. });
  893. }
  894. return false;
  895. }
  896. $(".cable-toggle").click(function() {
  897. return toggleConnection($(this));
  898. });
  899. // Toggle the display of IP addresses under interfaces
  900. $('button.toggle-ips').click(function() {
  901. var selected = $(this).attr('selected');
  902. if (selected) {
  903. $('#interfaces_table tr.ipaddresses').hide();
  904. } else {
  905. $('#interfaces_table tr.ipaddresses').show();
  906. }
  907. $(this).attr('selected', !selected);
  908. $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
  909. return false;
  910. });
  911. </script>
  912. <script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
  913. <script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
  914. {% endblock %}