mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
8356 virtual machine tab
This commit is contained in:
parent
42068090f0
commit
b2bb6f68a2
59
netbox/templates/virtualization/virtualdisk.html
Normal file
59
netbox/templates/virtualization/virtualdisk.html
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{% extends 'generic/object.html' %}
|
||||||
|
{% load helpers %}
|
||||||
|
{% load plugins %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
{{ block.super }}
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
{% comment %}
|
||||||
|
<a href="{% url 'virtualization:virtualmachine_virtualdisks' pk=object.virtual_machine.pk %}">{{ object.virtual_machine }}</a>
|
||||||
|
{% endcomment %}
|
||||||
|
</li>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<h5 class="card-header">
|
||||||
|
{% trans "Virtual Disk" %}
|
||||||
|
</h5>
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-hover attr-table">
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Virtual Machine" %}</th>
|
||||||
|
<td>{{ object.virtual_machine|linkify }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Name" %}</th>
|
||||||
|
<td>{{ object.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><i class="mdi mdi-harddisk"></i> {% trans "Disk Space" %}</th>
|
||||||
|
<td>
|
||||||
|
{% if object.size %}
|
||||||
|
{{ object.size }} {% trans "GB" context "Abbreviation for gigabyte" %}
|
||||||
|
{% else %}
|
||||||
|
{{ ''|placeholder }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% include 'inc/panels/tags.html' %}
|
||||||
|
{% plugin_left_page object %}
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-6">
|
||||||
|
{% include 'inc/panels/custom_fields.html' %}
|
||||||
|
{% plugin_right_page object %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col col-md-12">
|
||||||
|
{% plugin_full_width_page object %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -84,6 +84,7 @@ class VirtualMachineSerializer(NetBoxModelSerializer):
|
|||||||
|
|
||||||
# Counter fields
|
# Counter fields
|
||||||
interface_count = serializers.IntegerField(read_only=True)
|
interface_count = serializers.IntegerField(read_only=True)
|
||||||
|
virtual_disk_count = serializers.IntegerField(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VirtualMachine
|
model = VirtualMachine
|
||||||
@ -91,7 +92,7 @@ class VirtualMachineSerializer(NetBoxModelSerializer):
|
|||||||
'id', 'url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'platform',
|
'id', 'url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'platform',
|
||||||
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
||||||
'config_template', 'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
|
'config_template', 'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
|
||||||
'interface_count',
|
'interface_count', 'virtual_disk_count',
|
||||||
]
|
]
|
||||||
validators = []
|
validators = []
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ class VirtualMachineWithConfigContextSerializer(VirtualMachineSerializer):
|
|||||||
'id', 'url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'platform',
|
'id', 'url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'platform',
|
||||||
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
||||||
'local_context_data', 'tags', 'custom_fields', 'config_context', 'created', 'last_updated',
|
'local_context_data', 'tags', 'custom_fields', 'config_context', 'created', 'last_updated',
|
||||||
'interface_count',
|
'interface_count', 'virtual_disk_count',
|
||||||
]
|
]
|
||||||
|
|
||||||
@extend_schema_field(serializers.JSONField(allow_null=True))
|
@extend_schema_field(serializers.JSONField(allow_null=True))
|
||||||
|
@ -131,6 +131,10 @@ class VirtualMachine(ContactsMixin, RenderConfigMixin, ConfigContextModel, Prima
|
|||||||
to_model='virtualization.VMInterface',
|
to_model='virtualization.VMInterface',
|
||||||
to_field='virtual_machine'
|
to_field='virtual_machine'
|
||||||
)
|
)
|
||||||
|
virtual_disk_count = CounterCacheField(
|
||||||
|
to_model='virtualization.VirtualDisk',
|
||||||
|
to_field='virtual_machine'
|
||||||
|
)
|
||||||
|
|
||||||
objects = ConfigContextModelQuerySet.as_manager()
|
objects = ConfigContextModelQuerySet.as_manager()
|
||||||
|
|
||||||
|
@ -85,6 +85,9 @@ class VirtualMachineTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable)
|
|||||||
interface_count = tables.Column(
|
interface_count = tables.Column(
|
||||||
verbose_name=_('Interfaces')
|
verbose_name=_('Interfaces')
|
||||||
)
|
)
|
||||||
|
virtual_disk_count = tables.Column(
|
||||||
|
verbose_name=_('Virtual Disks')
|
||||||
|
)
|
||||||
config_template = tables.Column(
|
config_template = tables.Column(
|
||||||
verbose_name=_('Config Template'),
|
verbose_name=_('Config Template'),
|
||||||
linkify=True
|
linkify=True
|
||||||
|
@ -365,6 +365,12 @@ class VirtualMachineInterfacesView(generic.ObjectChildrenView):
|
|||||||
permission='virtualization.view_vminterface',
|
permission='virtualization.view_vminterface',
|
||||||
weight=500
|
weight=500
|
||||||
)
|
)
|
||||||
|
tab = ViewTab(
|
||||||
|
label=_('Disks'),
|
||||||
|
badge=lambda obj: obj.virtual_disk_count,
|
||||||
|
permission='virtualization.view_virtual_disk',
|
||||||
|
weight=500
|
||||||
|
)
|
||||||
actions = ('add', 'import', 'export', 'bulk_edit', 'bulk_delete', 'bulk_rename')
|
actions = ('add', 'import', 'export', 'bulk_edit', 'bulk_delete', 'bulk_rename')
|
||||||
action_perms = defaultdict(set, **{
|
action_perms = defaultdict(set, **{
|
||||||
'add': {'add'},
|
'add': {'add'},
|
||||||
|
Loading…
Reference in New Issue
Block a user