diff --git a/.github/stale.yaml b/.github/stale.yml similarity index 100% rename from .github/stale.yaml rename to .github/stale.yml diff --git a/docs/release-notes/version-2.6.md b/docs/release-notes/version-2.6.md index 575d23822..dbeefe2af 100644 --- a/docs/release-notes/version-2.6.md +++ b/docs/release-notes/version-2.6.md @@ -1,4 +1,4 @@ -# v2.6.8 (FUTURE) +# v2.6.8 (2019-12-10) ## Enhancements @@ -6,12 +6,21 @@ * [#3457](https://github.com/netbox-community/netbox/issues/3457) - Display cable colors on device view * [#3329](https://github.com/netbox-community/netbox/issues/3329) - Remove obsolete P3P policy header * [#3663](https://github.com/netbox-community/netbox/issues/3663) - Add query filters for `created` and `last_updated` fields +* [#3722](https://github.com/netbox-community/netbox/issues/3722) - Allow the underscore character in IPAddress DNS names ## Bug Fixes +* [#3312](https://github.com/netbox-community/netbox/issues/3312) - Fix validation error when editing power cables in bulk +* [#3644](https://github.com/netbox-community/netbox/issues/3644) - Fix exception when connecting a cable to a RearPort with no corresponding FrontPort * [#3669](https://github.com/netbox-community/netbox/issues/3669) - Include `weight` field in prefix/VLAN role form * [#3674](https://github.com/netbox-community/netbox/issues/3674) - Include comments on PowerFeed view * [#3679](https://github.com/netbox-community/netbox/issues/3679) - Fix link for assigned ipaddress in interface page +* [#3709](https://github.com/netbox-community/netbox/issues/3709) - Prevent exception when importing an invalid cable definition +* [#3720](https://github.com/netbox-community/netbox/issues/3720) - Correctly indicate power feed terminations on cable list +* [#3724](https://github.com/netbox-community/netbox/issues/3724) - Fix API filtering of interfaces by more than one device name +* [#3725](https://github.com/netbox-community/netbox/issues/3725) - Enforce client validation for minimum service port number + +--- # v2.6.7 (2019-11-01) diff --git a/mkdocs.yml b/mkdocs.yml index b03f357fe..cc44921b6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -31,6 +31,7 @@ pages: - Change Logging: 'additional-features/change-logging.md' - Context Data: 'additional-features/context-data.md' - Custom Fields: 'additional-features/custom-fields.md' + - Custom Links: 'additional-features/custom-links.md' - Custom Scripts: 'additional-features/custom-scripts.md' - Export Templates: 'additional-features/export-templates.md' - Graphs: 'additional-features/graphs.md' diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index 8dacd68f5..af009f481 100644 --- a/netbox/dcim/constants.py +++ b/netbox/dcim/constants.py @@ -31,7 +31,7 @@ CONNECTION_STATUS_CHOICES = [ # Cable endpoint types CABLE_TERMINATION_TYPES = [ 'consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', - 'circuittermination', + 'circuittermination', 'powerfeed', ] CABLE_TERMINATION_TYPE_CHOICES = { diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py index 1d76a0bc0..fba17ff78 100644 --- a/netbox/dcim/filters.py +++ b/netbox/dcim/filters.py @@ -7,8 +7,8 @@ from tenancy.filtersets import TenancyFilterSet from tenancy.models import Tenant from utilities.constants import COLOR_CHOICES from utilities.filters import ( - MultiValueMACAddressFilter, MultiValueNumberFilter, NameSlugSearchFilterSet, NumericInFilter, TagFilter, - TreeNodeMultipleChoiceFilter, + MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter, NameSlugSearchFilterSet, NumericInFilter, + TagFilter, TreeNodeMultipleChoiceFilter, ) from virtualization.models import Cluster from .choices import * @@ -754,7 +754,7 @@ class InterfaceFilter(django_filters.FilterSet): queryset=Site.objects.all(), label='Site name (slug)', ) - device = django_filters.CharFilter( + device = MultiValueCharFilter( method='filter_device', field_name='name', label='Device', @@ -807,8 +807,10 @@ class InterfaceFilter(django_filters.FilterSet): def filter_device(self, queryset, name, value): try: - device = Device.objects.get(**{name: value}) - vc_interface_ids = device.vc_interfaces.values_list('id', flat=True) + devices = Device.objects.filter(**{'{}__in'.format(name): value}) + vc_interface_ids = [] + for device in devices: + vc_interface_ids.extend(device.vc_interfaces.values_list('id', flat=True)) return queryset.filter(pk__in=vc_interface_ids) except Device.DoesNotExist: return queryset.none() diff --git a/netbox/dcim/migrations/0066_cables.py b/netbox/dcim/migrations/0066_cables.py index 096344a06..b30a2a8fa 100644 --- a/netbox/dcim/migrations/0066_cables.py +++ b/netbox/dcim/migrations/0066_cables.py @@ -174,8 +174,8 @@ class Migration(migrations.Migration): ('length', models.PositiveSmallIntegerField(blank=True, null=True)), ('length_unit', models.PositiveSmallIntegerField(blank=True, null=True)), ('_abs_length', models.DecimalField(blank=True, decimal_places=4, max_digits=10, null=True)), - ('termination_a_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), - ('termination_b_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), + ('termination_a_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination', 'powerfeed']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), + ('termination_b_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination', 'powerfeed']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), ], ), migrations.AlterUniqueTogether( diff --git a/netbox/dcim/migrations/0083_3569_cable_fields.py b/netbox/dcim/migrations/0083_3569_cable_fields.py index 37e616514..be9dd75c2 100644 --- a/netbox/dcim/migrations/0083_3569_cable_fields.py +++ b/netbox/dcim/migrations/0083_3569_cable_fields.py @@ -82,7 +82,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='cable', name='status', - field=models.CharField(max_length=50), + field=models.CharField(default='connected', max_length=50), ), migrations.RunPython( code=cable_status_to_slug diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index b9bdb026a..7e16bad95 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -99,6 +99,8 @@ class CableTermination(models.Model): object_id_field='termination_b_id' ) + is_path_endpoint = True + class Meta: abstract = True @@ -2517,6 +2519,8 @@ class FrontPort(CableTermination, ComponentModel): validators=[MinValueValidator(1), MaxValueValidator(64)] ) + is_path_endpoint = False + objects = NaturalOrderingManager() tags = TaggableManager(through=TaggedItem) @@ -2580,6 +2584,8 @@ class RearPort(CableTermination, ComponentModel): validators=[MinValueValidator(1), MaxValueValidator(64)] ) + is_path_endpoint = False + objects = NaturalOrderingManager() tags = TaggableManager(through=TaggedItem) @@ -2913,6 +2919,8 @@ class Cable(ChangeLoggedModel): def clean(self): # Validate that termination A exists + if not hasattr(self, 'termination_a_type'): + raise ValidationError('Termination A type has not been specified') try: self.termination_a_type.model_class().objects.get(pk=self.termination_a_id) except ObjectDoesNotExist: @@ -2921,6 +2929,8 @@ class Cable(ChangeLoggedModel): }) # Validate that termination B exists + if not hasattr(self, 'termination_b_type'): + raise ValidationError('Termination B type has not been specified') try: self.termination_b_type.model_class().objects.get(pk=self.termination_b_id) except ObjectDoesNotExist: diff --git a/netbox/dcim/signals.py b/netbox/dcim/signals.py index c1aabf64d..71ee7ec3c 100644 --- a/netbox/dcim/signals.py +++ b/netbox/dcim/signals.py @@ -45,7 +45,7 @@ def update_connected_endpoints(instance, **kwargs): # Check if this Cable has formed a complete path. If so, update both endpoints. endpoint_a, endpoint_b, path_status = instance.get_path_endpoints() - if endpoint_a is not None and endpoint_b is not None: + if getattr(endpoint_a, 'is_path_endpoint', False) and getattr(endpoint_b, 'is_path_endpoint', False): endpoint_a.connected_endpoint = endpoint_b endpoint_a.connection_status = path_status endpoint_a.save() diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index c662da8ec..1b747ff75 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -177,8 +177,10 @@ VIRTUALCHASSIS_ACTIONS = """ CABLE_TERMINATION_PARENT = """ {% if value.device %} {{ value.device }} -{% else %} +{% elif value.circuit %} {{ value.circuit }} +{% elif value.power_panel %} + {{ value.power_panel }} {% endif %} """ @@ -855,7 +857,7 @@ class CableTable(BaseTable): orderable=False, verbose_name='Termination A' ) - termination_a = tables.Column( + termination_a = tables.LinkColumn( accessor=Accessor('termination_a'), orderable=False, verbose_name='' @@ -866,7 +868,7 @@ class CableTable(BaseTable): orderable=False, verbose_name='Termination B' ) - termination_b = tables.Column( + termination_b = tables.LinkColumn( accessor=Accessor('termination_b'), orderable=False, verbose_name='' diff --git a/netbox/ipam/forms.py b/netbox/ipam/forms.py index 613fc2865..0df5c2a5b 100644 --- a/netbox/ipam/forms.py +++ b/netbox/ipam/forms.py @@ -1250,6 +1250,10 @@ class VLANFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm): # class ServiceForm(BootstrapMixin, CustomFieldForm): + port = forms.IntegerField( + min_value=1, + max_value=65535 + ) tags = TagField( required=False ) diff --git a/netbox/ipam/migrations/0027_ipaddress_add_dns_name.py b/netbox/ipam/migrations/0027_ipaddress_add_dns_name.py index 534957ce1..c93034f3d 100644 --- a/netbox/ipam/migrations/0027_ipaddress_add_dns_name.py +++ b/netbox/ipam/migrations/0027_ipaddress_add_dns_name.py @@ -14,6 +14,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='ipaddress', name='dns_name', - field=models.CharField(blank=True, max_length=255, validators=[django.core.validators.RegexValidator(code='invalid', message='Only alphanumeric characters, hyphens, and periods are allowed in DNS names', regex='^[0-9A-Za-z.-]+$')]), + field=models.CharField(blank=True, max_length=255, validators=[django.core.validators.RegexValidator(code='invalid', message='Only alphanumeric characters, hyphens, periods, and underscores are allowed in DNS names', regex='^[0-9A-Za-z._-]+$')]), ), ] diff --git a/netbox/ipam/validators.py b/netbox/ipam/validators.py index 6669b7ec5..960675643 100644 --- a/netbox/ipam/validators.py +++ b/netbox/ipam/validators.py @@ -2,7 +2,7 @@ from django.core.validators import RegexValidator DNSValidator = RegexValidator( - regex='^[0-9A-Za-z.-]+$', - message='Only alphanumeric characters, hyphens, and periods are allowed in DNS names', + regex='^[0-9A-Za-z._-]+$', + message='Only alphanumeric characters, hyphens, periods, and underscores are allowed in DNS names', code='invalid' ) diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit index 5974f91d8..7dfa5e8aa 100755 --- a/scripts/git-hooks/pre-commit +++ b/scripts/git-hooks/pre-commit @@ -9,6 +9,24 @@ exec 1>&2 +EXIT=0 +RED='\033[0;31m' +NOCOLOR='\033[0m' + echo "Validating PEP8 compliance..." pycodestyle --ignore=W504,E501 netbox/ +if [ $? != 0 ]; then + EXIT=1 +fi +echo "Checking for missing migrations..." +python netbox/manage.py makemigrations --dry-run --check +if [ $? != 0 ]; then + EXIT=1 +fi + +if [ $EXIT != 0 ]; then + printf "${RED}COMMIT FAILED${NOCOLOR}\n" +fi + +exit $EXIT