/usr/lib/python2.7/dist-packages/maasserver/dhcp_connect.py is in python-django-maas 1.5+bzr2252-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # Copyright 2012-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""DHCP management module: connect DHCP tasks with signals."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
__all__ = [
]
from maasserver.models import (
Config,
NodeGroup,
NodeGroupInterface,
)
from maasserver.signals import connect_to_field_change
def dhcp_post_change_NodeGroupInterface(instance, old_values, **kwargs):
"""Update the DHCP config related to the saved nodegroupinterface."""
# Circular import.
from maasserver.dhcp import configure_dhcp
configure_dhcp(instance.nodegroup)
connect_to_field_change(
dhcp_post_change_NodeGroupInterface, NodeGroupInterface,
[
'ip',
'management',
'interface',
'subnet_mask',
'broadcast_ip',
'router_ip',
'ip_range_low',
'ip_range_high',
])
def dhcp_post_edit_status_NodeGroup(instance, old_values, **kwargs):
"""Reconfigure DHCP for a NodeGroup after its status has changed."""
# This could be optimized a bit by detecting if the status change is
# actually a change from 'do not manage DHCP' to 'manage DHCP'.
# Circular import.
from maasserver.dhcp import configure_dhcp
configure_dhcp(instance)
connect_to_field_change(dhcp_post_edit_status_NodeGroup, NodeGroup, ['status'])
def dhcp_post_edit_name_NodeGroup(instance, old_values, **kwargs):
"""Reconfigure DHCP for a NodeGroup after its name has changed."""
# Circular import.
from maasserver.dhcp import configure_dhcp
configure_dhcp(instance)
connect_to_field_change(dhcp_post_edit_name_NodeGroup, NodeGroup, ['name'])
def ntp_server_changed(sender, instance, created, **kwargs):
"""The ntp_server config item changed, so write new DHCP configs."""
from maasserver.dhcp import configure_dhcp
for nodegroup in NodeGroup.objects.all():
configure_dhcp(nodegroup)
Config.objects.config_changed_connect("ntp_server", ntp_server_changed)
|