mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Update custom napalm_read, napalm_write permissions
This commit is contained in:
parent
85e932bfc1
commit
110bad7041
@ -395,7 +395,7 @@ class DeviceViewSet(CustomFieldModelViewSet):
|
|||||||
))
|
))
|
||||||
|
|
||||||
# Verify user permission
|
# Verify user permission
|
||||||
if not request.user.has_perm('dcim.napalm_read'):
|
if not request.user.has_perm('dcim.napalm_read_device'):
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
# Connect to the device
|
# Connect to the device
|
||||||
|
@ -22,7 +22,7 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='device',
|
name='device',
|
||||||
options={'ordering': ['name'], 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))},
|
options={'ordering': ['name']},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='platform',
|
model_name='platform',
|
||||||
|
@ -12,7 +12,7 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='device',
|
name='device',
|
||||||
options={'ordering': ('name', 'pk'), 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))},
|
options={'ordering': ('name', 'pk')},
|
||||||
),
|
),
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='rack',
|
name='rack',
|
||||||
|
@ -30,7 +30,7 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='device',
|
name='device',
|
||||||
options={'ordering': ('_name', 'pk'), 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))},
|
options={'ordering': ('_name', 'pk')},
|
||||||
),
|
),
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='rack',
|
name='rack',
|
||||||
|
@ -1477,10 +1477,6 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
|||||||
('rack', 'position', 'face'),
|
('rack', 'position', 'face'),
|
||||||
('virtual_chassis', 'vc_position'),
|
('virtual_chassis', 'vc_position'),
|
||||||
)
|
)
|
||||||
permissions = (
|
|
||||||
('napalm_read', 'Read-only access to devices via NAPALM'),
|
|
||||||
('napalm_write', 'Read/write access to devices via NAPALM'),
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.display_name or super().__str__()
|
return self.display_name or super().__str__()
|
||||||
|
@ -1099,7 +1099,7 @@ class DeviceInventoryView(ObjectView):
|
|||||||
|
|
||||||
|
|
||||||
class DeviceStatusView(ObjectView):
|
class DeviceStatusView(ObjectView):
|
||||||
additional_permissions = ['dcim.napalm_read']
|
additional_permissions = ['dcim.napalm_read_device']
|
||||||
queryset = Device.objects.all()
|
queryset = Device.objects.all()
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
@ -1113,7 +1113,7 @@ class DeviceStatusView(ObjectView):
|
|||||||
|
|
||||||
|
|
||||||
class DeviceLLDPNeighborsView(ObjectView):
|
class DeviceLLDPNeighborsView(ObjectView):
|
||||||
additional_permissions = ['dcim.napalm_read']
|
additional_permissions = ['dcim.napalm_read_device']
|
||||||
queryset = Device.objects.all()
|
queryset = Device.objects.all()
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
@ -1133,7 +1133,7 @@ class DeviceLLDPNeighborsView(ObjectView):
|
|||||||
|
|
||||||
|
|
||||||
class DeviceConfigView(ObjectView):
|
class DeviceConfigView(ObjectView):
|
||||||
additional_permissions = ['dcim.napalm_read']
|
additional_permissions = ['dcim.napalm_read_device']
|
||||||
queryset = Device.objects.all()
|
queryset = Device.objects.all()
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
Inventory <span class="badge">{{ device.inventory_items.count }}</span>
|
Inventory <span class="badge">{{ device.inventory_items.count }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if perms.dcim.napalm_read %}
|
{% if perms.dcim.napalm_read_device %}
|
||||||
{% if device.status != 'active' %}
|
{% if device.status != 'active' %}
|
||||||
{% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='Device must be in active status' %}
|
{% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='Device must be in active status' %}
|
||||||
{% elif not device.platform %}
|
{% elif not device.platform %}
|
||||||
|
Loading…
Reference in New Issue
Block a user