Rename mark_reserved to mark_populated

This commit is contained in:
Jeremy Stretch 2025-04-02 09:41:03 -04:00
parent 5f548725ee
commit d82040bdc4
9 changed files with 21 additions and 21 deletions

View File

@ -147,7 +147,7 @@ class IPRangeSerializer(NetBoxModelSerializer):
fields = [
'id', 'url', 'display_url', 'display', 'family', 'start_address', 'end_address', 'size', 'vrf', 'tenant',
'status', 'role', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
'mark_reserved', 'mark_utilized', 'description', 'comments', 'tags', 'custom_fields', 'created',
'mark_populated', 'mark_utilized', 'description', 'comments', 'tags', 'custom_fields', 'created',
'last_updated',
]
brief_fields = ('id', 'url', 'display', 'family', 'start_address', 'end_address', 'description')

View File

@ -478,7 +478,7 @@ class IPRangeFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
class Meta:
model = IPRange
fields = ('id', 'mark_reserved', 'mark_utilized', 'size', 'description')
fields = ('id', 'mark_populated', 'mark_utilized', 'size', 'description')
def search(self, queryset, name, value):
if not value.strip():

View File

@ -296,10 +296,10 @@ class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
queryset=Role.objects.all(),
required=False
)
mark_reserved = forms.NullBooleanField(
mark_populated = forms.NullBooleanField(
required=False,
widget=BulkEditNullBooleanSelect(),
label=_('Treat as reserved')
label=_('Treat as populated')
)
mark_utilized = forms.NullBooleanField(
required=False,

View File

@ -268,7 +268,7 @@ class IPRangeImportForm(NetBoxModelImportForm):
class Meta:
model = IPRange
fields = (
'start_address', 'end_address', 'vrf', 'tenant', 'status', 'role', 'mark_reserved', 'mark_utilized',
'start_address', 'end_address', 'vrf', 'tenant', 'status', 'role', 'mark_populated', 'mark_utilized',
'description', 'comments', 'tags',
)

View File

@ -266,7 +266,7 @@ class IPRangeFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
model = IPRange
fieldsets = (
FieldSet('q', 'filter_id', 'tag'),
FieldSet('family', 'vrf_id', 'status', 'role_id', 'mark_reserved', 'mark_utilized', name=_('Attributes')),
FieldSet('family', 'vrf_id', 'status', 'role_id', 'mark_populated', 'mark_utilized', name=_('Attributes')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
)
family = forms.ChoiceField(
@ -291,9 +291,9 @@ class IPRangeFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
null_option='None',
label=_('Role')
)
mark_reserved = forms.NullBooleanField(
mark_populated = forms.NullBooleanField(
required=False,
label=_('Treat as reserved'),
label=_('Treat as populated'),
widget=forms.Select(
choices=BOOLEAN_WITH_BLANK_CHOICES
)

View File

@ -257,7 +257,7 @@ class IPRangeForm(TenancyForm, NetBoxModelForm):
fieldsets = (
FieldSet(
'vrf', 'start_address', 'end_address', 'role', 'status', 'mark_reserved', 'mark_utilized', 'description',
'vrf', 'start_address', 'end_address', 'role', 'status', 'mark_populated', 'mark_utilized', 'description',
'tags', name=_('IP Range')
),
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
@ -266,7 +266,7 @@ class IPRangeForm(TenancyForm, NetBoxModelForm):
class Meta:
model = IPRange
fields = [
'vrf', 'start_address', 'end_address', 'status', 'role', 'tenant_group', 'tenant', 'mark_reserved',
'vrf', 'start_address', 'end_address', 'status', 'role', 'tenant_group', 'tenant', 'mark_populated',
'mark_utilized', 'description', 'comments', 'tags',
]

View File

@ -10,7 +10,7 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name='iprange',
name='mark_reserved',
name='mark_populated',
field=models.BooleanField(default=False),
),
]

View File

@ -407,14 +407,14 @@ class Prefix(ContactsMixin, GetAvailablePrefixesMixin, CachedScopeMixin, Primary
"""
Return all available IPs within this prefix as an IPSet.
"""
# TODO: Add mark_reserved
# TODO: Add mark_populated
prefix = netaddr.IPSet(self.prefix)
child_ips = netaddr.IPSet([
ip.address.ip for ip in self.get_child_ips()
])
child_ranges = netaddr.IPSet([
iprange.range for iprange in self.get_child_ranges().filter(mark_reserved=True)
iprange.range for iprange in self.get_child_ranges().filter(mark_populated=True)
])
available_ips = prefix - child_ips - child_ranges
@ -523,19 +523,19 @@ class IPRange(ContactsMixin, PrimaryModel):
null=True,
help_text=_('The primary function of this range')
)
mark_reserved = models.BooleanField(
verbose_name=_('mark reserved'),
mark_populated = models.BooleanField(
verbose_name=_('mark populated'),
default=False,
help_text=_("Prevent the creation of IP addresses within this range")
)
mark_utilized = models.BooleanField(
verbose_name=_('mark utilized'),
default=False,
help_text=_("Treat as fully utilized")
help_text=_("Report space as 100% utilized")
)
clone_fields = (
'vrf', 'tenant', 'status', 'role', 'description', 'mark_reserved', 'mark_utilized',
'vrf', 'tenant', 'status', 'role', 'description', 'mark_populated', 'mark_utilized',
)
class Meta:
@ -672,7 +672,7 @@ class IPRange(ContactsMixin, PrimaryModel):
"""
Return all available IPs within this range as an IPSet.
"""
if self.mark_reserved:
if self.mark_populated:
return netaddr.IPSet()
range = netaddr.IPRange(self.start_address.ip, self.end_address.ip)

View File

@ -268,8 +268,8 @@ class IPRangeTable(TenancyColumnsMixin, NetBoxTable):
verbose_name=_('Role'),
linkify=True
)
mark_reserved = columns.BooleanColumn(
verbose_name=_('Marked Reserved'),
mark_populated = columns.BooleanColumn(
verbose_name=_('Marked Populated'),
false_mark=None
)
mark_utilized = columns.BooleanColumn(
@ -292,7 +292,7 @@ class IPRangeTable(TenancyColumnsMixin, NetBoxTable):
model = IPRange
fields = (
'pk', 'id', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'tenant_group',
'mark_reserved', 'mark_utilized', 'utilization', 'description', 'comments', 'tags', 'created',
'mark_populated', 'mark_utilized', 'utilization', 'description', 'comments', 'tags', 'created',
'last_updated',
)
default_columns = (