Commit 277fde98 authored by Nikolai R Kristiansen's avatar Nikolai R Kristiansen
Browse files

Misc pep8 cleanups

parent 257b00be
......@@ -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)
......
......@@ -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})
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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)
......@@ -116,7 +116,7 @@ SUIT_CONFIG = {
),
# misc
'LIST_PER_PAGE': 30
'LIST_PER_PAGE': 35
}
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment