device.html 47 KB

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