Merge lp:~julian-edwards/maas/moar-logging into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 2932
Proposed branch: lp:~julian-edwards/maas/moar-logging
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 47 lines (+13/-1)
2 files modified
src/maasserver/api/node_groups.py (+8/-1)
src/maasserver/models/macaddress.py (+5/-0)
To merge this branch: bzr merge lp:~julian-edwards/maas/moar-logging
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+233903@code.launchpad.net

Commit message

Logging of when mac addresses are linked to cluster interfaces, and when assigning a static IP fails because that link is not present (yet).

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
Revision history for this message
Julian Edwards (julian-edwards) :
Revision history for this message
Raphaël Badin (rvb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/node_groups.py'
2--- src/maasserver/api/node_groups.py 2014-09-07 23:44:35 +0000
3+++ src/maasserver/api/node_groups.py 2014-09-09 11:22:05 +0000
4@@ -256,9 +256,16 @@
5 continue
6 for interface, (ip_range, static_range) in interface_ranges.items():
7 ipaddress = netaddr.IPAddress(ip)
8- if ipaddress in ip_range or ipaddress in static_range:
9+ # Set the cluster interface only if it's new/changed.
10+ # This is only an optimisation to prevent repeated logging.
11+ changed = mac_address.cluster_interface != interface
12+ in_range = ipaddress in ip_range or ipaddress in static_range
13+ if in_range and changed:
14 mac_address.cluster_interface = interface
15 mac_address.save()
16+ maaslog.info(
17+ "%s %s linked to cluster interface %s",
18+ mac_address.node.hostname, mac_address, interface.name)
19
20 # Locate the Network to which this MAC belongs.
21 ipnetwork = interface.network
22
23=== modified file 'src/maasserver/models/macaddress.py'
24--- src/maasserver/models/macaddress.py 2014-08-19 15:29:49 +0000
25+++ src/maasserver/models/macaddress.py 2014-09-09 11:22:05 +0000
26@@ -38,9 +38,11 @@
27 from maasserver.models.nodegroupinterface import NodeGroupInterface
28 from maasserver.models.timestampedmodel import TimestampedModel
29 from netaddr import IPAddress
30+from provisioningserver.logger import get_maas_logger
31
32
33 mac_re = re.compile(r'^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
34+maaslog = get_maas_logger("macaddress")
35
36
37 def find_cluster_interface_responsible_for_ip(cluster_interfaces, ip_address):
38@@ -121,6 +123,9 @@
39 # also manages the node's IPv4 address."
40 if self.cluster_interface is None:
41 # No known cluster interface. Nothing we can do.
42+ maaslog.error(
43+ "%s: Tried to allocate an IP to MAC %s but its cluster "
44+ "interface is not known", self.node.hostname, self)
45 return []
46 else:
47 return NodeGroupInterface.objects.filter(