Merge ~adam-collard/maas:update_vlan-log-string into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 4a609d48ca55b8a51922ab44d1af2868a71b437e
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:update_vlan-log-string
Merge into: maas:master
Diff against target: 46 lines (+23/-1)
2 files modified
src/maasserver/models/interface.py (+1/-1)
src/maasserver/models/tests/test_interface.py (+22/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+431906@code.launchpad.net

Commit message

Fix log message with Interface save

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b update_vlan-log-string lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 3937cbb412b78152fa94e25c882a9022b66e0aa6

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b update_vlan-log-string lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 4a609d48ca55b8a51922ab44d1af2868a71b437e

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/models/interface.py b/src/maasserver/models/interface.py
2index 46b6e66..225bf7c 100644
3--- a/src/maasserver/models/interface.py
4+++ b/src/maasserver/models/interface.py
5@@ -1661,7 +1661,7 @@ class Interface(CleanSave, TimestampedModel):
6 parent.vlan_id = self.vlan_id
7 parent.save()
8 maaslog.info(
9- f"{parent.get_log_string}: "
10+ f"{parent.get_log_string()}: "
11 f"VLAN updated to match {self.get_log_string()} "
12 f"(vlan={parent.vlan_id})."
13 )
14diff --git a/src/maasserver/models/tests/test_interface.py b/src/maasserver/models/tests/test_interface.py
15index 4eba238..b9c2e9b 100644
16--- a/src/maasserver/models/tests/test_interface.py
17+++ b/src/maasserver/models/tests/test_interface.py
18@@ -1396,6 +1396,28 @@ class TestUpdateInterfaceParentsOnSave(MAASServerTestCase):
19 factory.make_Interface(self.iftype, parents=[parent1, parent2])
20 self.assertIsNone(reload_object(static_ip))
21
22+ def test_log_message(self):
23+ node_config = factory.make_NodeConfig()
24+ parent1 = factory.make_Interface(
25+ iftype=INTERFACE_TYPE.PHYSICAL,
26+ node_config=node_config,
27+ name="parent1",
28+ )
29+ parent2 = factory.make_Interface(
30+ iftype=INTERFACE_TYPE.PHYSICAL,
31+ node_config=node_config,
32+ name="parent2",
33+ )
34+ with FakeLogger("maas.interface") as maaslog:
35+ child = factory.make_Interface(
36+ self.iftype, parents=[parent1, parent2], name="child"
37+ )
38+ hostname = node_config.node.hostname
39+ self.assertEqual(
40+ f"parent2 (physical) on {hostname}: VLAN updated to match child ({self.iftype}) on {hostname} (vlan={child.vlan_id}).\n",
41+ maaslog.output,
42+ )
43+
44
45 class TestInterfaceUpdateNeighbour(MAASServerTestCase):
46 """Tests for `Interface.update_neighbour`."""

Subscribers

People subscribed via source and target branches