mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Closes #4956: Include inventory items on primary device view
This commit is contained in:
parent
52dc80209c
commit
584b076886
@ -7,6 +7,7 @@
|
||||
### New Features
|
||||
|
||||
* [#1692](https://github.com/netbox-community/netbox/issues/1692) - Allow assigment of inventory items to parent items in web UI
|
||||
* [#4956](https://github.com/netbox-community/netbox/issues/4956) - Include inventory items on primary device view
|
||||
* [#5146](https://github.com/netbox-community/netbox/issues/5146) - Add custom fields support for cables, power panels, rack reservations, and virtual chassis
|
||||
|
||||
### Other Changes
|
||||
|
@ -189,7 +189,6 @@ urlpatterns = [
|
||||
path('devices/<int:pk>/delete/', views.DeviceDeleteView.as_view(), name='device_delete'),
|
||||
path('devices/<int:pk>/config-context/', views.DeviceConfigContextView.as_view(), name='device_configcontext'),
|
||||
path('devices/<int:pk>/changelog/', ObjectChangeLogView.as_view(), name='device_changelog', kwargs={'model': Device}),
|
||||
path('devices/<int:pk>/inventory/', views.DeviceInventoryView.as_view(), name='device_inventory'),
|
||||
path('devices/<int:pk>/status/', views.DeviceStatusView.as_view(), name='device_status'),
|
||||
path('devices/<int:pk>/lldp-neighbors/', views.DeviceLLDPNeighborsView.as_view(), name='device_lldp_neighbors'),
|
||||
path('devices/<int:pk>/config/', views.DeviceConfigView.as_view(), name='device_config'),
|
||||
|
@ -1050,6 +1050,11 @@ class DeviceView(ObjectView):
|
||||
'installed_device__device_type__manufacturer',
|
||||
)
|
||||
|
||||
# Inventory items
|
||||
inventoryitems = InventoryItem.objects.restrict(request.user, 'view').filter(
|
||||
device=device
|
||||
).prefetch_related('manufacturer')
|
||||
|
||||
# Services
|
||||
services = Service.objects.restrict(request.user, 'view').filter(device=device)
|
||||
|
||||
@ -1072,9 +1077,10 @@ class DeviceView(ObjectView):
|
||||
'powerports': powerports,
|
||||
'poweroutlets': poweroutlets,
|
||||
'interfaces': interfaces,
|
||||
'devicebays': devicebays,
|
||||
'frontports': frontports,
|
||||
'rearports': rearports,
|
||||
'devicebays': devicebays,
|
||||
'inventoryitems': inventoryitems,
|
||||
'services': services,
|
||||
'secrets': secrets,
|
||||
'vc_members': vc_members,
|
||||
@ -1082,23 +1088,6 @@ class DeviceView(ObjectView):
|
||||
})
|
||||
|
||||
|
||||
class DeviceInventoryView(ObjectView):
|
||||
queryset = Device.objects.all()
|
||||
|
||||
def get(self, request, pk):
|
||||
|
||||
device = get_object_or_404(self.queryset, pk=pk)
|
||||
inventory_items = InventoryItem.objects.restrict(request.user, 'view').filter(
|
||||
device=device
|
||||
).prefetch_related('manufacturer')
|
||||
|
||||
return render(request, 'dcim/device_inventory.html', {
|
||||
'device': device,
|
||||
'inventory_items': inventory_items,
|
||||
'active_tab': 'inventory',
|
||||
})
|
||||
|
||||
|
||||
class DeviceStatusView(ObjectView):
|
||||
additional_permissions = ['dcim.napalm_read_device']
|
||||
queryset = Device.objects.all()
|
||||
|
@ -69,7 +69,7 @@
|
||||
<li><a href="{% url 'dcim:devicebay_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}">Device Bays</a></li>
|
||||
{% endif %}
|
||||
{% if perms.dcim.add_inventoryitem %}
|
||||
<li><a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={% url 'dcim:device_inventory' pk=device.pk %}">Inventory Items</a></li>
|
||||
<li><a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}">Inventory Items</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
@ -93,11 +93,6 @@
|
||||
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
|
||||
<a href="{% url 'dcim:device' pk=device.pk %}">Device</a>
|
||||
</li>
|
||||
<li role="presentation"{% if active_tab == 'inventory' %} class="active"{% endif %}>
|
||||
<a href="{% url 'dcim:device_inventory' pk=device.pk %}">
|
||||
Inventory <span class="badge">{{ device.inventoryitems.unrestricted.count }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% if perms.dcim.napalm_read_device %}
|
||||
{% if device.status != 'active' %}
|
||||
{% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='Device must be in active status' %}
|
||||
@ -123,351 +118,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Device</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<td>Site</td>
|
||||
<td>
|
||||
{% if device.site.region %}
|
||||
<a href="{{ device.site.region.get_absolute_url }}">{{ device.site.region }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rack</td>
|
||||
<td>
|
||||
{% if device.rack %}
|
||||
{% if device.rack.group %}
|
||||
<a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Position</td>
|
||||
<td>
|
||||
{% if device.parent_bay %}
|
||||
{% with device.parent_bay.device as parent %}
|
||||
<a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay }}
|
||||
{% if parent.position %}
|
||||
(U{{ parent.position }} / {{ parent.get_face_display }})
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% elif device.rack and device.position %}
|
||||
<span>U{{ device.position }} / {{ device.get_face_display }}</span>
|
||||
{% elif device.rack and device.device_type.u_height %}
|
||||
<span class="label label-warning">Not racked</span>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tenant</td>
|
||||
<td>
|
||||
{% if device.tenant %}
|
||||
{% if device.tenant.group %}
|
||||
<a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ device.tenant.get_absolute_url }}">{{ device.tenant }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device Type</td>
|
||||
<td>
|
||||
<span><a href="{% url 'dcim:devicetype' pk=device.device_type.pk %}">{{ device.device_type.display_name }}</a> ({{ device.device_type.u_height }}U)</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Serial Number</td>
|
||||
<td><span>{{ device.serial|placeholder }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Asset Tag</td>
|
||||
<td><span>{{ device.asset_tag|placeholder }}</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% if vc_members %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Virtual Chassis</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<th>Device</th>
|
||||
<th>Position</th>
|
||||
<th>Master</th>
|
||||
<th>Priority</th>
|
||||
</tr>
|
||||
{% for vc_member in vc_members %}
|
||||
<tr{% if vc_member == device %} class="info"{% endif %}>
|
||||
<td>
|
||||
<a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
|
||||
</td>
|
||||
<td><span class="badge badge-default">{{ vc_member.vc_position }}</span></td>
|
||||
<td>{% if device.virtual_chassis.master == vc_member %}<i class="fa fa-check"></i>{% endif %}</td>
|
||||
<td>{{ vc_member.vc_priority|default:"" }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{{ device.virtual_chassis.get_absolute_url }}" class="btn btn-primary btn-xs">
|
||||
<span class="fa fa-arrow-right" aria-hidden="true"></span> View Virtual Chassis
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Management</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<td>Role</td>
|
||||
<td>
|
||||
<a href="{% url 'dcim:device_list' %}?role={{ device.device_role.slug }}">{{ device.device_role }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Platform</td>
|
||||
<td>
|
||||
{% if device.platform %}
|
||||
<a href="{{ device.platform.get_absolute_url }}">{{ device.platform }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>
|
||||
<span class="label label-{{ device.get_status_class }}">{{ device.get_status_display }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Primary IPv4</td>
|
||||
<td>
|
||||
{% if device.primary_ip4 %}
|
||||
<a href="{% url 'ipam:ipaddress' pk=device.primary_ip4.pk %}">{{ device.primary_ip4.address.ip }}</a>
|
||||
{% if device.primary_ip4.nat_inside %}
|
||||
<span>(NAT for {{ device.primary_ip4.nat_inside.address.ip }})</span>
|
||||
{% elif device.primary_ip4.nat_outside %}
|
||||
<span>(NAT: {{ device.primary_ip4.nat_outside.address.ip }})</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Primary IPv6</td>
|
||||
<td>
|
||||
{% if device.primary_ip6 %}
|
||||
<a href="{% url 'ipam:ipaddress' pk=device.primary_ip6.pk %}">{{ device.primary_ip6.address.ip }}</a>
|
||||
{% if device.primary_ip6.nat_inside %}
|
||||
<span>(NAT for {{ device.primary_ip6.nat_inside.address.ip }})</span>
|
||||
{% elif device.primary_ip6.nat_outside %}
|
||||
<span>(NAT: {{ device.primary_ip6.nat_outside.address.ip }})</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if device.cluster %}
|
||||
<tr>
|
||||
<td>Cluster</td>
|
||||
<td>
|
||||
{% if device.cluster.group %}
|
||||
<a href="{{ device.cluster.group.get_absolute_url }}">{{ device.cluster.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ device.cluster.get_absolute_url }}">{{ device.cluster }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/custom_fields_panel.html' with obj=device %}
|
||||
{% include 'extras/inc/tags_panel.html' with tags=device.tags.all url='dcim:device_list' %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Comments</strong>
|
||||
</div>
|
||||
<div class="panel-body rendered-markdown">
|
||||
{% if device.comments %}
|
||||
{{ device.comments|render_markdown }}
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% plugin_left_page device %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{% if power_ports and poweroutlets %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Power Utilization</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body">
|
||||
<tr>
|
||||
<th>Input</th>
|
||||
<th>Outlets</th>
|
||||
<th>Allocated</th>
|
||||
<th>Available</th>
|
||||
<th>Utilization</th>
|
||||
</tr>
|
||||
{% for pp in power_ports %}
|
||||
{% with utilization=pp.get_power_draw powerfeed=pp.connected_endpoint %}
|
||||
<tr>
|
||||
<td>{{ pp }}</td>
|
||||
<td>{{ utilization.outlet_count }}</td>
|
||||
<td>{{ utilization.allocated }}VA</td>
|
||||
{% if powerfeed.available_power %}
|
||||
<td>{{ powerfeed.available_power }}VA</td>
|
||||
<td>{% utilization_graph utilization.allocated|percentage:powerfeed.available_power %}</td>
|
||||
{% else %}
|
||||
<td class="text-muted">—</td>
|
||||
<td class="text-muted">—</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% for leg in utilization.legs %}
|
||||
<tr>
|
||||
<td style="padding-left: 20px">Leg {{ leg.name }}</td>
|
||||
<td>{{ leg.outlet_count }}</td>
|
||||
<td>{{ leg.allocated }}</td>
|
||||
<td>{{ powerfeed.available_power|divide:3 }}VA</td>
|
||||
{% with phase_available=powerfeed.available_power|divide:3 %}
|
||||
<td>{% utilization_graph leg.allocated|percentage:phase_available %}</td>
|
||||
{% endwith %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.user.is_authenticated %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Secrets</strong>
|
||||
</div>
|
||||
{% if secrets %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for secret in secrets %}
|
||||
{% include 'secrets/inc/secret_tr.html' %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">
|
||||
None found
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if perms.secrets.add_secret %}
|
||||
<form id="secret_form">
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'secrets:secret_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-xs btn-primary">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
Add secret
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Services</strong>
|
||||
</div>
|
||||
{% if services %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for service in services %}
|
||||
{% include 'ipam/inc/service.html' %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">
|
||||
None
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if perms.ipam.add_service %}
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'dcim:device_service_assign' device=device.pk %}" class="btn btn-xs btn-primary">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Assign service
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Images</strong>
|
||||
</div>
|
||||
{% include 'inc/image_attachments.html' with images=device.images.all %}
|
||||
{% if perms.extras.add_imageattachment %}
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'dcim:device_add_image' object_id=device.pk %}" class="btn btn-primary btn-xs">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
Attach an image
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel panel-default noprint">
|
||||
<div class="panel-heading">
|
||||
<strong>Related Devices</strong>
|
||||
</div>
|
||||
{% if related_devices %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for rd in related_devices %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'dcim:device' pk=rd.pk %}">{{ rd }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if rd.rack %}
|
||||
<a href="{% url 'dcim:rack' pk=rd.rack.pk %}">Rack {{ rd.rack }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ rd.device_type.display_name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">None found</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% plugin_right_page device %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% plugin_full_width_page device %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<ul class="nav nav-pills" role="tablist">
|
||||
<li role="presentation" class="active">
|
||||
<a href="#details" role="tab" data-toggle="tab">Details</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#interfaces" role="tab" data-toggle="tab">Interfaces {% badge interfaces|length %}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
@ -491,8 +148,354 @@
|
||||
<li role="presentation">
|
||||
<a href="#devicebays" role="tab" data-toggle="tab">Device Bays {% badge devicebays|length %}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#inventoryitems" role="tab" data-toggle="tab">Inventory {% badge inventoryitems|length %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="details">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Device</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<td>Site</td>
|
||||
<td>
|
||||
{% if device.site.region %}
|
||||
<a href="{{ device.site.region.get_absolute_url }}">{{ device.site.region }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rack</td>
|
||||
<td>
|
||||
{% if device.rack %}
|
||||
{% if device.rack.group %}
|
||||
<a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Position</td>
|
||||
<td>
|
||||
{% if device.parent_bay %}
|
||||
{% with device.parent_bay.device as parent %}
|
||||
<a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay }}
|
||||
{% if parent.position %}
|
||||
(U{{ parent.position }} / {{ parent.get_face_display }})
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% elif device.rack and device.position %}
|
||||
<span>U{{ device.position }} / {{ device.get_face_display }}</span>
|
||||
{% elif device.rack and device.device_type.u_height %}
|
||||
<span class="label label-warning">Not racked</span>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tenant</td>
|
||||
<td>
|
||||
{% if device.tenant %}
|
||||
{% if device.tenant.group %}
|
||||
<a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ device.tenant.get_absolute_url }}">{{ device.tenant }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device Type</td>
|
||||
<td>
|
||||
<span><a href="{% url 'dcim:devicetype' pk=device.device_type.pk %}">{{ device.device_type.display_name }}</a> ({{ device.device_type.u_height }}U)</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Serial Number</td>
|
||||
<td><span>{{ device.serial|placeholder }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Asset Tag</td>
|
||||
<td><span>{{ device.asset_tag|placeholder }}</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% if vc_members %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Virtual Chassis</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<th>Device</th>
|
||||
<th>Position</th>
|
||||
<th>Master</th>
|
||||
<th>Priority</th>
|
||||
</tr>
|
||||
{% for vc_member in vc_members %}
|
||||
<tr{% if vc_member == device %} class="info"{% endif %}>
|
||||
<td>
|
||||
<a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
|
||||
</td>
|
||||
<td><span class="badge badge-default">{{ vc_member.vc_position }}</span></td>
|
||||
<td>{% if device.virtual_chassis.master == vc_member %}<i class="fa fa-check"></i>{% endif %}</td>
|
||||
<td>{{ vc_member.vc_priority|default:"" }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{{ device.virtual_chassis.get_absolute_url }}" class="btn btn-primary btn-xs">
|
||||
<span class="fa fa-arrow-right" aria-hidden="true"></span> View Virtual Chassis
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Management</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<td>Role</td>
|
||||
<td>
|
||||
<a href="{% url 'dcim:device_list' %}?role={{ device.device_role.slug }}">{{ device.device_role }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Platform</td>
|
||||
<td>
|
||||
{% if device.platform %}
|
||||
<a href="{{ device.platform.get_absolute_url }}">{{ device.platform }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>
|
||||
<span class="label label-{{ device.get_status_class }}">{{ device.get_status_display }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Primary IPv4</td>
|
||||
<td>
|
||||
{% if device.primary_ip4 %}
|
||||
<a href="{% url 'ipam:ipaddress' pk=device.primary_ip4.pk %}">{{ device.primary_ip4.address.ip }}</a>
|
||||
{% if device.primary_ip4.nat_inside %}
|
||||
<span>(NAT for {{ device.primary_ip4.nat_inside.address.ip }})</span>
|
||||
{% elif device.primary_ip4.nat_outside %}
|
||||
<span>(NAT: {{ device.primary_ip4.nat_outside.address.ip }})</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Primary IPv6</td>
|
||||
<td>
|
||||
{% if device.primary_ip6 %}
|
||||
<a href="{% url 'ipam:ipaddress' pk=device.primary_ip6.pk %}">{{ device.primary_ip6.address.ip }}</a>
|
||||
{% if device.primary_ip6.nat_inside %}
|
||||
<span>(NAT for {{ device.primary_ip6.nat_inside.address.ip }})</span>
|
||||
{% elif device.primary_ip6.nat_outside %}
|
||||
<span>(NAT: {{ device.primary_ip6.nat_outside.address.ip }})</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if device.cluster %}
|
||||
<tr>
|
||||
<td>Cluster</td>
|
||||
<td>
|
||||
{% if device.cluster.group %}
|
||||
<a href="{{ device.cluster.group.get_absolute_url }}">{{ device.cluster.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ device.cluster.get_absolute_url }}">{{ device.cluster }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/custom_fields_panel.html' with obj=device %}
|
||||
{% include 'extras/inc/tags_panel.html' with tags=device.tags.all url='dcim:device_list' %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Comments</strong>
|
||||
</div>
|
||||
<div class="panel-body rendered-markdown">
|
||||
{% if device.comments %}
|
||||
{{ device.comments|render_markdown }}
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% plugin_left_page device %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{% if power_ports and poweroutlets %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Power Utilization</strong>
|
||||
</div>
|
||||
<table class="table table-hover panel-body">
|
||||
<tr>
|
||||
<th>Input</th>
|
||||
<th>Outlets</th>
|
||||
<th>Allocated</th>
|
||||
<th>Available</th>
|
||||
<th>Utilization</th>
|
||||
</tr>
|
||||
{% for pp in power_ports %}
|
||||
{% with utilization=pp.get_power_draw powerfeed=pp.connected_endpoint %}
|
||||
<tr>
|
||||
<td>{{ pp }}</td>
|
||||
<td>{{ utilization.outlet_count }}</td>
|
||||
<td>{{ utilization.allocated }}VA</td>
|
||||
{% if powerfeed.available_power %}
|
||||
<td>{{ powerfeed.available_power }}VA</td>
|
||||
<td>{% utilization_graph utilization.allocated|percentage:powerfeed.available_power %}</td>
|
||||
{% else %}
|
||||
<td class="text-muted">—</td>
|
||||
<td class="text-muted">—</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% for leg in utilization.legs %}
|
||||
<tr>
|
||||
<td style="padding-left: 20px">Leg {{ leg.name }}</td>
|
||||
<td>{{ leg.outlet_count }}</td>
|
||||
<td>{{ leg.allocated }}</td>
|
||||
<td>{{ powerfeed.available_power|divide:3 }}VA</td>
|
||||
{% with phase_available=powerfeed.available_power|divide:3 %}
|
||||
<td>{% utilization_graph leg.allocated|percentage:phase_available %}</td>
|
||||
{% endwith %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.user.is_authenticated %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Secrets</strong>
|
||||
</div>
|
||||
{% if secrets %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for secret in secrets %}
|
||||
{% include 'secrets/inc/secret_tr.html' %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">
|
||||
None found
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if perms.secrets.add_secret %}
|
||||
<form id="secret_form">
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'secrets:secret_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-xs btn-primary">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
Add secret
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Services</strong>
|
||||
</div>
|
||||
{% if services %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for service in services %}
|
||||
{% include 'ipam/inc/service.html' %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">
|
||||
None
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if perms.ipam.add_service %}
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'dcim:device_service_assign' device=device.pk %}" class="btn btn-xs btn-primary">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Assign service
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Images</strong>
|
||||
</div>
|
||||
{% include 'inc/image_attachments.html' with images=device.images.all %}
|
||||
{% if perms.extras.add_imageattachment %}
|
||||
<div class="panel-footer text-right noprint">
|
||||
<a href="{% url 'dcim:device_add_image' object_id=device.pk %}" class="btn btn-primary btn-xs">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
Attach an image
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel panel-default noprint">
|
||||
<div class="panel-heading">
|
||||
<strong>Related Devices</strong>
|
||||
</div>
|
||||
{% if related_devices %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for rd in related_devices %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'dcim:device' pk=rd.pk %}">{{ rd }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if rd.rack %}
|
||||
<a href="{% url 'dcim:rack' pk=rd.rack.pk %}">Rack {{ rd.rack }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ rd.device_type.display_name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="panel-body text-muted">None found</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% plugin_right_page device %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% plugin_full_width_page device %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane active" id="interfaces">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
@ -949,6 +952,60 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="inventoryitems">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Inventory Items</strong>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed panel-body" id="hardware">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if perms.dcim.change_inventoryitem or perms.dcim.delete_inventoryitem %}
|
||||
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
|
||||
{% endif %}
|
||||
<th>Name</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Part ID</th>
|
||||
<th>Serial Number</th>
|
||||
<th>Asset Tag</th>
|
||||
<th>Discovered</th>
|
||||
<th>Description</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in inventoryitems %}
|
||||
{% include 'dcim/inc/inventoryitem.html' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-footer noprint">
|
||||
{% if inventoryitems and perms.dcim.change_inventoryitem %}
|
||||
<button type="submit" name="_rename" formaction="{% url 'dcim:inventoryitem_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
|
||||
</button>
|
||||
<button type="submit" name="_edit" formaction="{% url 'dcim:inventoryitem_bulk_edit' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if inventoryitems and perms.dcim.delete_inventoryitem %}
|
||||
<button type="submit" name="_delete" formaction="{% url 'dcim:inventoryitem_bulk_delete' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
|
||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if perms.dcim.add_inventoryitem %}
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-primary btn-xs">
|
||||
<span class="fa fa-plus" aria-hidden="true"></span> Add Inventory Item
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,63 +0,0 @@
|
||||
{% extends 'dcim/device.html' %}
|
||||
{% load helpers %}
|
||||
|
||||
{% block title %}{{ device }} - Inventory{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Inventory Items</strong>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed panel-body" id="hardware">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if perms.dcim.change_inventoryitem or perms.dcim.delete_inventoryitem %}
|
||||
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
|
||||
{% endif %}
|
||||
<th>Name</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Part ID</th>
|
||||
<th>Serial Number</th>
|
||||
<th>Asset Tag</th>
|
||||
<th>Discovered</th>
|
||||
<th>Description</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in inventory_items %}
|
||||
{% include 'dcim/inc/inventoryitem.html' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-footer noprint">
|
||||
{% if inventory_items and perms.dcim.change_inventoryitem %}
|
||||
<button type="submit" name="_rename" formaction="{% url 'dcim:inventoryitem_bulk_rename' %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-warning btn-xs">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
|
||||
</button>
|
||||
<button type="submit" name="_edit" formaction="{% url 'dcim:inventoryitem_bulk_edit' %}?device={{ device.pk }}&return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-warning btn-xs">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if inventory_items and perms.dcim.delete_inventoryitem %}
|
||||
<button type="submit" name="_delete" formaction="{% url 'dcim:inventoryitem_bulk_delete' %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-danger btn-xs">
|
||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if perms.dcim.add_inventoryitem %}
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-primary btn-xs">
|
||||
<span class="fa fa-plus" aria-hidden="true"></span> Add Inventory Item
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -31,10 +31,10 @@
|
||||
<td>{{ item.description|placeholder }}</td>
|
||||
<td class="text-right noprint">
|
||||
{% if perms.dcim.change_inventoryitem %}
|
||||
<a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
|
||||
<a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
|
||||
{% endif %}
|
||||
{% if perms.dcim.delete_inventoryitem %}
|
||||
<a href="{% url 'dcim:inventoryitem_delete' pk=item.pk %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
||||
<a href="{% url 'dcim:inventoryitem_delete' pk=item.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user