device.html 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. {% extends '_base.html' %}
  2. {% load buttons %}
  3. {% load static %}
  4. {% load helpers %}
  5. {% load custom_links %}
  6. {% block title %}{{ device }}{% endblock %}
  7. {% block header %}
  8. <div class="row noprint">
  9. <div class="col-sm-8 col-md-9">
  10. <ol class="breadcrumb">
  11. <li><a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a></li>
  12. {% if device.rack %}
  13. <li><a href="{% url 'dcim:rack_list' %}?site={{ device.site.slug }}">Racks</a></li>
  14. <li><a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a></li>
  15. {% endif %}
  16. {% if device.parent_bay %}
  17. <li><a href="{% url 'dcim:device' pk=device.parent_bay.device.pk %}">{{ device.parent_bay.device }}</a></li>
  18. <li>{{ device.parent_bay }}</li>
  19. {% endif %}
  20. <li>{{ device }}</li>
  21. </ol>
  22. </div>
  23. <div class="col-sm-4 col-md-3">
  24. <form action="{% url 'dcim:device_list' %}" method="get">
  25. <div class="input-group">
  26. <input type="text" name="q" class="form-control" placeholder="Search devices" />
  27. <span class="input-group-btn">
  28. <button type="submit" class="btn btn-primary">
  29. <span class="fa fa-search" aria-hidden="true"></span>
  30. </button>
  31. </span>
  32. </div>
  33. </form>
  34. </div>
  35. </div>
  36. <div class="pull-right noprint">
  37. {% if show_graphs %}
  38. <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">
  39. <i class="fa fa-signal" aria-hidden="true"></i>
  40. Graphs
  41. </button>
  42. {% endif %}
  43. {% if perms.dcim.change_device %}
  44. <div class="btn-group">
  45. <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  46. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Components <span class="caret"></span>
  47. </button>
  48. <ul class="dropdown-menu">
  49. {% if perms.dcim.add_consoleport %}<li><a href="{% url 'dcim:consoleport_add' pk=device.pk %}">Console Ports</a></li>{% endif %}
  50. {% if perms.dcim.add_consoleserverport %}<li><a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}">Console Server Ports</a></li>{% endif %}
  51. {% if perms.dcim.add_powerport %}<li><a href="{% url 'dcim:powerport_add' pk=device.pk %}">Power Ports</a></li>{% endif %}
  52. {% if perms.dcim.add_poweroutlet %}<li><a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}">Power Outlets</a></li>{% endif %}
  53. {% if perms.dcim.add_interface %}<li><a href="{% url 'dcim:interface_add' pk=device.pk %}">Interfaces</a></li>{% endif %}
  54. {% if perms.dcim.add_frontport %}<li><a href="{% url 'dcim:frontport_add' pk=device.pk %}">Front Ports</a></li>{% endif %}
  55. {% if perms.dcim.add_rearport %}<li><a href="{% url 'dcim:rearport_add' pk=device.pk %}">Rear Ports</a></li>{% endif %}
  56. {% if perms.dcim.add_devicebay %}<li><a href="{% url 'dcim:devicebay_add' pk=device.pk %}">Device Bays</a></li>{% endif %}
  57. </ul>
  58. </div>
  59. {% endif %}
  60. {% if perms.dcim.add_device %}
  61. {% clone_button device %}
  62. {% endif %}
  63. {% if perms.dcim.change_device %}
  64. {% edit_button device %}
  65. {% endif %}
  66. {% if perms.dcim.delete_device %}
  67. {% delete_button device %}
  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 != 'active' %}
  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 class="col-md-2 pull-right noprint">
  557. <input class="form-control interface-filter" type="text" placeholder="Filter" title="RegEx-enabled" style="height: 23px" />
  558. </div>
  559. </div>
  560. <table id="interfaces_table" class="table table-hover table-headings panel-body component-list">
  561. <thead>
  562. <tr>
  563. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  564. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  565. {% endif %}
  566. <th>Name</th>
  567. <th>LAG</th>
  568. <th>Description</th>
  569. <th>MTU</th>
  570. <th>Mode</th>
  571. <th>Cable</th>
  572. <th colspan="2">Connection</th>
  573. <th></th>
  574. </tr>
  575. </thead>
  576. <tbody>
  577. {% for iface in interfaces %}
  578. {% include 'dcim/inc/interface.html' %}
  579. {% endfor %}
  580. </tbody>
  581. </table>
  582. <div class="panel-footer noprint">
  583. {% if interfaces and perms.dcim.change_interface %}
  584. <button type="submit" name="_rename" formaction="{% url 'dcim:interface_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  585. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  586. </button>
  587. <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">
  588. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  589. </button>
  590. {% endif %}
  591. {% if interfaces and perms.dcim.change_interface %}
  592. <button type="submit" name="_disconnect" formaction="{% url 'dcim:interface_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  593. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  594. </button>
  595. {% endif %}
  596. {% if interfaces and perms.dcim.delete_interface %}
  597. <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">
  598. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  599. </button>
  600. {% endif %}
  601. {% if perms.dcim.add_interface %}
  602. <div class="pull-right">
  603. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  604. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  605. </a>
  606. </div>
  607. <div class="clearfix"></div>
  608. {% endif %}
  609. </div>
  610. </div>
  611. {% if perms.dcim.delete_interface %}
  612. </form>
  613. {% endif %}
  614. {% endif %}
  615. {% if consoleserverports %}
  616. {% if perms.dcim.delete_consoleserverport %}
  617. <form method="post">
  618. {% csrf_token %}
  619. {% endif %}
  620. <div class="panel panel-default">
  621. <div class="panel-heading">
  622. <strong>Console Server Ports</strong>
  623. </div>
  624. <table class="table table-hover table-headings panel-body component-list">
  625. <thead>
  626. <tr>
  627. {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %}
  628. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  629. {% endif %}
  630. <th>Name</th>
  631. <th>Type</th>
  632. <th>Description</th>
  633. <th>Cable</th>
  634. <th colspan="2">Connection</th>
  635. <th></th>
  636. </tr>
  637. </thead>
  638. <tbody>
  639. {% for csp in consoleserverports %}
  640. {% include 'dcim/inc/consoleserverport.html' %}
  641. {% endfor %}
  642. </tbody>
  643. </table>
  644. <div class="panel-footer noprint">
  645. {% if consoleserverports and perms.dcim.change_consoleport %}
  646. <button type="submit" name="_rename" formaction="{% url 'dcim:consoleserverport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  647. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  648. </button>
  649. <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">
  650. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  651. </button>
  652. <button type="submit" name="_disconnect" formaction="{% url 'dcim:consoleserverport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  653. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  654. </button>
  655. {% endif %}
  656. {% if consoleserverports and perms.dcim.delete_consoleserverport %}
  657. <button type="submit" formaction="{% url 'dcim:consoleserverport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  658. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  659. </button>
  660. {% endif %}
  661. {% if perms.dcim.add_consoleserverport %}
  662. <div class="pull-right">
  663. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  664. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  665. </a>
  666. </div>
  667. <div class="clearfix"></div>
  668. {% endif %}
  669. </div>
  670. </div>
  671. {% if perms.dcim.delete_consoleserverport %}
  672. </form>
  673. {% endif %}
  674. {% endif %}
  675. {% if poweroutlets %}
  676. {% if perms.dcim.delete_poweroutlet %}
  677. <form method="post">
  678. {% csrf_token %}
  679. {% endif %}
  680. <div class="panel panel-default">
  681. <div class="panel-heading">
  682. <strong>Power Outlets</strong>
  683. </div>
  684. <table class="table table-hover table-headings panel-body component-list">
  685. <thead>
  686. <tr>
  687. {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %}
  688. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  689. {% endif %}
  690. <th>Name</th>
  691. <th>Type</th>
  692. <th>Input/Leg</th>
  693. <th>Description</th>
  694. <th>Cable</th>
  695. <th colspan="3">Connection</th>
  696. <th></th>
  697. </tr>
  698. </thead>
  699. <tbody>
  700. {% for po in poweroutlets %}
  701. {% include 'dcim/inc/poweroutlet.html' %}
  702. {% endfor %}
  703. </tbody>
  704. </table>
  705. <div class="panel-footer noprint">
  706. {% if poweroutlets and perms.dcim.change_powerport %}
  707. <button type="submit" name="_rename" formaction="{% url 'dcim:poweroutlet_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  708. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  709. </button>
  710. <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">
  711. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  712. </button>
  713. <button type="submit" name="_disconnect" formaction="{% url 'dcim:poweroutlet_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  714. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  715. </button>
  716. {% endif %}
  717. {% if poweroutlets and perms.dcim.delete_poweroutlet %}
  718. <button type="submit" formaction="{% url 'dcim:poweroutlet_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  719. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  720. </button>
  721. {% endif %}
  722. {% if perms.dcim.add_poweroutlet %}
  723. <div class="pull-right">
  724. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  725. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  726. </a>
  727. </div>
  728. <div class="clearfix"></div>
  729. {% endif %}
  730. </div>
  731. </div>
  732. {% if perms.dcim.delete_poweroutlet %}
  733. </form>
  734. {% endif %}
  735. {% endif %}
  736. {% if front_ports %}
  737. <form method="post">
  738. {% csrf_token %}
  739. <div class="panel panel-default">
  740. <div class="panel-heading">
  741. <strong>Front Ports</strong>
  742. </div>
  743. <table class="table table-hover table-headings panel-body component-list">
  744. <thead>
  745. <tr>
  746. {% if perms.dcim.change_frontport or perms.dcim.delete_frontport %}
  747. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  748. {% endif %}
  749. <th>Name</th>
  750. <th>Type</th>
  751. <th>Rear Port</th>
  752. <th>Position</th>
  753. <th>Description</th>
  754. <th>Cable</th>
  755. <th colspan="2">Connection</th>
  756. <th></th>
  757. </tr>
  758. </thead>
  759. <tbody>
  760. {% for frontport in front_ports %}
  761. {% include 'dcim/inc/frontport.html' %}
  762. {% endfor %}
  763. </tbody>
  764. </table>
  765. <div class="panel-footer noprint">
  766. {% if front_ports and perms.dcim.change_frontport %}
  767. <button type="submit" name="_rename" formaction="{% url 'dcim:frontport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  768. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  769. </button>
  770. <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">
  771. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  772. </button>
  773. <button type="submit" name="_disconnect" formaction="{% url 'dcim:frontport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  774. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  775. </button>
  776. {% endif %}
  777. {% if front_ports and perms.dcim.delete_frontport %}
  778. <button type="submit" formaction="{% url 'dcim:frontport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  779. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  780. </button>
  781. {% endif %}
  782. {% if perms.dcim.add_frontport %}
  783. <div class="pull-right">
  784. <a href="{% url 'dcim:frontport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  785. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add front ports
  786. </a>
  787. </div>
  788. <div class="clearfix"></div>
  789. {% endif %}
  790. </div>
  791. </div>
  792. </form>
  793. {% endif %}
  794. {% if rear_ports %}
  795. <form method="post">
  796. {% csrf_token %}
  797. <div class="panel panel-default">
  798. <div class="panel-heading">
  799. <strong>Rear Ports</strong>
  800. </div>
  801. <table class="table table-hover table-headings panel-body component-list">
  802. <thead>
  803. <tr>
  804. {% if perms.dcim.change_rearport or perms.dcim.delete_rearport %}
  805. <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
  806. {% endif %}
  807. <th>Name</th>
  808. <th>Type</th>
  809. <th>Positions</th>
  810. <th>Description</th>
  811. <th>Cable</th>
  812. <th colspan="2">Connection</th>
  813. <th></th>
  814. </tr>
  815. </thead>
  816. <tbody>
  817. {% for rearport in rear_ports %}
  818. {% include 'dcim/inc/rearport.html' %}
  819. {% endfor %}
  820. </tbody>
  821. </table>
  822. <div class="panel-footer noprint">
  823. {% if rear_ports and perms.dcim.change_rearport %}
  824. <button type="submit" name="_rename" formaction="{% url 'dcim:rearport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
  825. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
  826. </button>
  827. <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">
  828. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  829. </button>
  830. <button type="submit" name="_disconnect" formaction="{% url 'dcim:rearport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  831. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  832. </button>
  833. {% endif %}
  834. {% if rear_ports and perms.dcim.delete_rearport %}
  835. <button type="submit" formaction="{% url 'dcim:rearport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
  836. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  837. </button>
  838. {% endif %}
  839. {% if perms.dcim.add_rearport %}
  840. <div class="pull-right">
  841. <a href="{% url 'dcim:rearport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  842. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add rear ports
  843. </a>
  844. </div>
  845. <div class="clearfix"></div>
  846. {% endif %}
  847. </div>
  848. </div>
  849. </form>
  850. {% endif %}
  851. </div>
  852. </div>
  853. {% include 'inc/modal.html' with modal_name='graphs' %}
  854. {% include 'secrets/inc/private_key_modal.html' %}
  855. {% endblock %}
  856. {% block javascript %}
  857. <script type="text/javascript">
  858. function toggleConnection(elem) {
  859. var url = netbox_api_path + "dcim/cables/" + elem.attr('data') + "/";
  860. if (elem.hasClass('connected')) {
  861. $.ajax({
  862. url: url,
  863. method: 'PATCH',
  864. dataType: 'json',
  865. beforeSend: function(xhr, settings) {
  866. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  867. },
  868. data: {
  869. 'status': 'False'
  870. },
  871. context: this,
  872. success: function() {
  873. elem.parents('tr').removeClass('success').addClass('info');
  874. elem.removeClass('connected btn-warning').addClass('btn-success');
  875. elem.attr('title', 'Mark installed');
  876. elem.children('i').removeClass('glyphicon glyphicon-ban-circle').addClass('fa fa-plug')
  877. }
  878. });
  879. } else {
  880. $.ajax({
  881. url: url,
  882. method: 'PATCH',
  883. dataType: 'json',
  884. beforeSend: function(xhr, settings) {
  885. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  886. },
  887. data: {
  888. 'status': 'True'
  889. },
  890. context: this,
  891. success: function() {
  892. elem.parents('tr').removeClass('info').addClass('success');
  893. elem.removeClass('btn-success').addClass('connected btn-warning');
  894. elem.attr('title', 'Mark planned');
  895. elem.children('i').removeClass('fa fa-plug').addClass('glyphicon glyphicon-ban-circle')
  896. }
  897. });
  898. }
  899. return false;
  900. }
  901. $(".cable-toggle").click(function() {
  902. return toggleConnection($(this));
  903. });
  904. </script>
  905. <script src="{% static 'js/interface_toggles.js' %}?v{{ settings.VERSION }}"></script>
  906. <script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
  907. <script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
  908. {% endblock %}