Merge ~bjornt/maas:revert-bug-2043970-3.3 into maas:3.3

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: a1392cb2f2c2f9f62126cfb8a15a06c3b919307c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:revert-bug-2043970-3.3
Merge into: maas:3.3
Diff against target: 126 lines (+2/-60)
4 files modified
src/maasserver/forms/settings.py (+0/-14)
src/maasserver/models/config.py (+0/-1)
src/metadataserver/builtin_scripts/network.py (+2/-15)
src/metadataserver/builtin_scripts/tests/test_network.py (+0/-30)
Reviewer Review Type Date Requested Status
Björn Tillenius Approve
Review via email: mp+465491@code.launchpad.net

Commit message

Revert "fix(metadataserver): leave discovered interfaces disconnected"

This reverts commit 41fb68392a2d22da358ed337633c166f70bfbcb0.

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Self-approve reversal of backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/forms/settings.py b/src/maasserver/forms/settings.py
index 41c33ea..ea3598e 100644
--- a/src/maasserver/forms/settings.py
+++ b/src/maasserver/forms/settings.py
@@ -1054,20 +1054,6 @@ CONFIG_ITEMS = {
1054 "max_value": 90,1054 "max_value": 90,
1055 },1055 },
1056 },1056 },
1057 "auto_vlan_creation": {
1058 "default": True,
1059 "form": forms.BooleanField,
1060 "form_kwargs": {
1061 "label": "Automatically create VLANs and Fabrics for interfaces",
1062 "required": False,
1063 "help_text": (
1064 "Enables the creation of a default VLAN and Fabric for "
1065 "discovered network interfaces when MAAS cannot connect it "
1066 "to an existing one. When disabled, the interface is left "
1067 "disconnected in these cases."
1068 ),
1069 },
1070 },
1071}1057}
10721058
10731059
diff --git a/src/maasserver/models/config.py b/src/maasserver/models/config.py
index bd9d5a6..55dc312 100644
--- a/src/maasserver/models/config.py
+++ b/src/maasserver/models/config.py
@@ -146,7 +146,6 @@ def get_default_config():
146 "vault_enabled": False,146 "vault_enabled": False,
147 # Windows settings147 # Windows settings
148 "windows_kms_host": None,148 "windows_kms_host": None,
149 "auto_vlan_creation": True,
150 }149 }
151150
152151
diff --git a/src/metadataserver/builtin_scripts/network.py b/src/metadataserver/builtin_scripts/network.py
index ee222cf..b21b36a 100644
--- a/src/metadataserver/builtin_scripts/network.py
+++ b/src/metadataserver/builtin_scripts/network.py
@@ -1,7 +1,7 @@
1from django.db.models.expressions import RawSQL1from django.db.models.expressions import RawSQL
2from netaddr import IPAddress, IPNetwork2from netaddr import IPAddress, IPNetwork
33
4from maasserver.enum import INTERFACE_TYPE, IPADDRESS_TYPE, NODE_STATUS4from maasserver.enum import INTERFACE_TYPE, IPADDRESS_TYPE
5from maasserver.models.config import Config5from maasserver.models.config import Config
6from maasserver.models.fabric import Fabric6from maasserver.models.fabric import Fabric
7from maasserver.models.interface import (7from maasserver.models.interface import (
@@ -506,26 +506,13 @@ def update_parent_vlans(node, interface, parent_nics, update_ip_addresses):
506 parent_nic.save()506 parent_nic.save()
507507
508508
509def auto_vlan_creation(node) -> bool:
510 if node.is_controller:
511 # Always create controller's vlans
512 return True
513
514 if node.status == NODE_STATUS.DEPLOYED:
515 # don't create empty vlan/fabric for interfaces discovered by HW sync,
516 # they cannot be used.
517 return False
518
519 return Config.objects.get_config("auto_vlan_creation", True)
520
521
522def guess_vlan_for_interface(node, links):509def guess_vlan_for_interface(node, links):
523 # Make sure that the VLAN on the interface is correct. When510 # Make sure that the VLAN on the interface is correct. When
524 # links exists on this interface we place it into the correct511 # links exists on this interface we place it into the correct
525 # VLAN. If it cannot be determined and its a new interface it512 # VLAN. If it cannot be determined and its a new interface it
526 # gets placed on its own fabric.513 # gets placed on its own fabric.
527 new_vlan = get_interface_vlan_from_links(node, links)514 new_vlan = get_interface_vlan_from_links(node, links)
528 if new_vlan is None and auto_vlan_creation(node):515 if new_vlan is None:
529 # If the default VLAN on the default fabric has no interfaces516 # If the default VLAN on the default fabric has no interfaces
530 # associated with it, the first interface will be placed there517 # associated with it, the first interface will be placed there
531 # (rather than creating a new fabric).518 # (rather than creating a new fabric).
diff --git a/src/metadataserver/builtin_scripts/tests/test_network.py b/src/metadataserver/builtin_scripts/tests/test_network.py
index a9ef0f0..832e918 100644
--- a/src/metadataserver/builtin_scripts/tests/test_network.py
+++ b/src/metadataserver/builtin_scripts/tests/test_network.py
@@ -10,7 +10,6 @@ from maasserver.enum import (
10 NODE_TYPE,10 NODE_TYPE,
11)11)
12from maasserver.models import Event, EventType12from maasserver.models import Event, EventType
13from maasserver.models.config import Config
14from maasserver.models.fabric import Fabric13from maasserver.models.fabric import Fabric
15from maasserver.models.interface import (14from maasserver.models.interface import (
16 BondInterface,15 BondInterface,
@@ -87,35 +86,6 @@ class TestUpdateInterfaces(MAASServerTestCase, UpdateInterfacesMixin):
87 eth0 = node.current_config.interface_set.get(name="eth0")86 eth0 = node.current_config.interface_set.get(name="eth0")
88 self.assertEqual(eth0.numa_node, node.default_numanode)87 self.assertEqual(eth0.numa_node, node.default_numanode)
8988
90 def test_dont_create_default_vlan_for_deployed_machines(self):
91 node = factory.make_Machine(status=NODE_STATUS.DEPLOYED)
92 data = FakeCommissioningData()
93 data_eth0 = data.create_physical_network(
94 "eth0",
95 mac_address="11:11:11:11:11:11",
96 )
97 data_eth0.state = "up"
98 self.update_interfaces(node, data)
99 eth0 = PhysicalInterface.objects.get(
100 name="eth0", node_config=node.current_config
101 )
102 self.assertIsNone(eth0.vlan)
103
104 def test_dont_create_default_vlan_if_disabled(self):
105 Config.objects.set_config(name="auto_vlan_creation", value=False)
106 node = factory.make_Machine(status=NODE_STATUS.NEW)
107 data = FakeCommissioningData()
108 data_eth0 = data.create_physical_network(
109 "eth0",
110 mac_address="11:11:11:11:11:11",
111 )
112 data_eth0.state = "up"
113 self.update_interfaces(node, data)
114 eth0 = PhysicalInterface.objects.get(
115 name="eth0", node_config=node.current_config
116 )
117 self.assertIsNone(eth0.vlan)
118
119 def test_all_new_physical_interfaces_no_links(self):89 def test_all_new_physical_interfaces_no_links(self):
120 controller = self.create_empty_controller()90 controller = self.create_empty_controller()
121 data = FakeCommissioningData()91 data = FakeCommissioningData()

Subscribers

People subscribed via source and target branches