diff --git a/mdb/admin.py b/mdb/admin.py index 05801fe..d760063 100644 --- a/mdb/admin.py +++ b/mdb/admin.py @@ -3,9 +3,10 @@ import ipaddress from django.contrib import admin, messages from django.db.models import Count from mdb.forms import InterfaceForm -from mdb.models import Ip6Address, Interface, Ip4Address, DhcpOption, DhcpCustomField, DomainSrvRecord, DomainTxtRecord, \ - DomainCnameRecord, DomainARecord, Domain, Host, Ip4Subnet, Ip6Subnet, Nameserver, MailExchange, OperatingSystem, \ - HostType, DhcpConfig, DomainAAAARecord +from mdb.models import ( + Ip6Address, Interface, Ip4Address, DhcpOption, DhcpCustomField, DomainSrvRecord, DomainTxtRecord, + DomainCnameRecord, DomainARecord, Domain, Host, Ip4Subnet, Ip6Subnet, Nameserver, MailExchange, OperatingSystem, + HostType, DhcpConfig, DomainAAAARecord) class Ip6AddressInline(admin.TabularInline): @@ -37,22 +38,22 @@ class HostAdmin(admin.ModelAdmin): 'fields': ('owner', 'location', 'description') }), ('Hardware and Software Information', { - 'fields': (('hostname', 'host_type'), ('pxe_key', 'pxe_installable'), ('brand', 'model'), 'serial_number', ('operating_system', 'virtual')) + 'fields': ( + ('hostname', 'host_type'), + ('pxe_key', 'pxe_installable'), + ('brand', 'model'), + 'serial_number', + ('operating_system', 'virtual')) }), - # FIXME: Not in use - # ('Domain and Kerberos Information', { - # 'description': 'If this host is a member of the LDAP domain, you need to tick the request kerberos principal checkbox. A principal will then be created for the host.', - # 'classes': ['collapse'], - # 'fields': ('request_kerberos_principal', 'kerberos_principal_created', - # ('kerberos_principal_name', 'kerberos_principal_created_date')) - # }), ) actions = ['set_installable'] + @staticmethod def mac_addresses(self, host): addresses = host.interface_set.filter(macaddr__isnull=False).values_list('macaddr', flat=True) return ", ".join(addresses) + @staticmethod def ip_addresses(self, host): addresses = host.interface_set.filter(ip4address__isnull=False).values_list('ip4address__address', flat=True) return ", ".join(addresses) @@ -69,7 +70,8 @@ class HostAdmin(admin.ModelAdmin): ipv6_enabled.boolean = True - def _get_host_warning_message(self, host, ifs): + @staticmethod + def _get_host_warning_message(host, ifs): ifs_str = ', '.join([_if.name for _if in ifs]) return 'Host {} might not be installable since interface(s) {} has no IP set.'.format(host, ifs_str) diff --git a/mdb/api/views.py b/mdb/api/views.py index dd9ec89..20e8966 100644 --- a/mdb/api/views.py +++ b/mdb/api/views.py @@ -15,6 +15,6 @@ class HostPXEValidate(APIView): serializer.is_valid(raise_exception=True) - host = serializer.save() # sets Host.pxe_installable=False + serializer.save() # sets Host.pxe_installable=False return Response({'valid_pxe_key': True}) diff --git a/mdb/apps.py b/mdb/apps.py index 159d9aa..6a0f310 100644 --- a/mdb/apps.py +++ b/mdb/apps.py @@ -7,4 +7,4 @@ class MdbAppConfig(AppConfig): def ready(self): # all models are loaded, now attach signals - import mdb.signals \ No newline at end of file + import mdb.signals # noqa diff --git a/mdb/models.py b/mdb/models.py index adf5ed7..0b9b470 100644 --- a/mdb/models.py +++ b/mdb/models.py @@ -319,7 +319,7 @@ class Ip6Subnet(models.Model): # content += "$ORIGIN " + ".".join(network.exploded.replace(":","")[:16])[::-1] + ".ip6.arpa.\n" for addr in self.ip6address_set.all(): - #if addr.interface_set.count() == 0: continue + # if addr.interface_set.count() == 0: continue if addr.interface.domain is None: continue diff --git a/mdb/tests.py b/mdb/tests.py index 8a48d96..d4b27eb 100644 --- a/mdb/tests.py +++ b/mdb/tests.py @@ -68,13 +68,13 @@ class RunManagementCommands(TestCase): fixtures = ['test_data'] def test_zone_sync(self): - expected_zone_file = '' + # expected_zone_file = '' with io.BytesIO() as f: call_command('zone-sync', debug=True, stdout=f) # TODO check expected_zone_file def test_dhcp_sync(self): - expected_dhcp_file = '' + # expected_dhcp_file = '' with io.BytesIO() as f: call_command('dhcp-sync', stdout=f) # TODO check expected_dhcp_file diff --git a/mdb/utils.py b/mdb/utils.py index 7f16f3d..c930bfc 100644 --- a/mdb/utils.py +++ b/mdb/utils.py @@ -17,7 +17,7 @@ def format_domain_serial_and_add_one(serial): """ The serial contains todays date, just update it. """ try: number = int(res[0]) - except: + except ValueError: number = 1 if number >= 99: """ This is bad... Just keep the number on 99. @@ -31,4 +31,4 @@ def format_domain_serial_and_add_one(serial): else: """ Just return the first serial for today. """ return "%4d%02d%02d%02d" % \ - (today.year, today.month, today.day, 1) \ No newline at end of file + (today.year, today.month, today.day, 1) diff --git a/mdbsite/settings.py b/mdbsite/settings.py index 23c99d7..ee78e03 100644 --- a/mdbsite/settings.py +++ b/mdbsite/settings.py @@ -116,7 +116,7 @@ SUIT_CONFIG = { ), # misc - 'LIST_PER_PAGE': 30 + 'LIST_PER_PAGE': 35 } REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),