Merge ~ltrager/maas:enable_vnic_characteristics_on_s390x into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: f11fbf1b55808d64255682f104ef00ace589119b
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:enable_vnic_characteristics_on_s390x
Merge into: maas:master
Diff against target: 114 lines (+78/-9)
2 files modified
src/metadataserver/tests/test_vendor_data.py (+48/-1)
src/metadataserver/vendor_data.py (+30/-8)
Reviewer Review Type Date Requested Status
Björn Tillenius Approve
MAAS Lander Approve
Review via email: mp+401011@code.launchpad.net

Commit message

Automatically enable VNIC characteristics on S390X when deploying a VM host

S390X partitions do not forward packets over bridges by default. To allow
packet forward VNIC characteristics must be enabled. Do this by default
when a VM host is deployed.

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

UNIT TESTS
-b enable_vnic_characteristics_on_s390x lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 32e91beee705559183f74408858169aee68ed940

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good to me, but please see comment inline.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/tests/test_vendor_data.py b/src/metadataserver/tests/test_vendor_data.py
2index 3fd39d4..cc9288f 100644
3--- a/src/metadataserver/tests/test_vendor_data.py
4+++ b/src/metadataserver/tests/test_vendor_data.py
5@@ -422,7 +422,54 @@ class TestGenerateKVMPodConfiguration(MAASServerTestCase):
6 {
7 "path": "/etc/rc.local",
8 "content": (
9- "#!/bin/sh\n" "ppc64_cpu --smt=off\n" "exit 0\n"
10+ "#!/bin/sh\n"
11+ "# This file was generated by MAAS to disable SMT "
12+ "on PPC64EL since\n"
13+ "# VMs are not supported otherwise.\n"
14+ "ppc64_cpu --smt=off\n"
15+ "exit 0\n"
16+ ),
17+ "permissions": "0755",
18+ },
19+ ],
20+ ),
21+ config,
22+ )
23+ self.assertIn(("runcmd", ["/etc/rc.local"]), config)
24+
25+ def test_enables_vnic_characteristics_on_s390x(self):
26+ password = "123secure"
27+ self.patch(vendor_data, "_generate_password").return_value = password
28+ node = factory.make_Node(
29+ status=NODE_STATUS.DEPLOYING,
30+ osystem="ubuntu",
31+ netboot=False,
32+ architecture="s390x/generic",
33+ register_vmhost=True,
34+ )
35+ config = list(generate_kvm_pod_configuration(node))
36+ self.assertIn(
37+ (
38+ "write_files",
39+ [
40+ {
41+ "path": "/etc/rc.local",
42+ "content": (
43+ "#!/bin/bash\n"
44+ "# This file was generated by MAAS to enable VNIC "
45+ "characteristics to allow\n"
46+ "# packets to be forwarded over a bridge.\n"
47+ 'for bridge in $(bridge link show | awk -F"[ :]" '
48+ "'{ print $3 }'); do\n"
49+ " # Isolated networks are not associated with "
50+ "a qeth and do not need\n"
51+ " # anything enabled. Ignore them.\n"
52+ " phy_addr=$(lsqeth $bridge 2>/dev/null | "
53+ "awk -F ': ' '/cdev0/ {print $2}')\n"
54+ ' if [ -n "$phy_addr" ]; then\n'
55+ " chzdev $phy_addr vnicc/learning=1\n"
56+ " fi\n"
57+ "done\n"
58 ),
59 "permissions": "0755",
60 },
61diff --git a/src/metadataserver/vendor_data.py b/src/metadataserver/vendor_data.py
62index 8236e8e..81092df 100644
63--- a/src/metadataserver/vendor_data.py
64+++ b/src/metadataserver/vendor_data.py
65@@ -251,19 +251,41 @@ def generate_kvm_pod_configuration(node):
66 },
67 ]
68
69- # disable SMT on ppc64el since VMs are not supported otherwise
70 if arch == "ppc64el":
71+ rc_script = dedent(
72+ """\
73+ #!/bin/sh
74+ # This file was generated by MAAS to disable SMT on PPC64EL since
75+ # VMs are not supported otherwise.
76+ ppc64_cpu --smt=off
77+ exit 0
78+ """
79+ )
80+ elif arch == "s390x":
81+ rc_script = dedent(
82+ """\
83+ #!/bin/bash
84+ # This file was generated by MAAS to enable VNIC characteristics to allow
85+ # packets to be forwarded over a bridge.
86+ for bridge in $(bridge link show | awk -F"[ :]" '{ print $3 }'); do
87+ # Isolated networks are not associated with a qeth and do not need
88+ # anything enabled. Ignore them.
89+ phy_addr=$(lsqeth $bridge 2>/dev/null | awk -F ': ' '/cdev0/ {print $2}')
90+ if [ -n "$phy_addr" ]; then
91+ chzdev $phy_addr vnicc/learning=1
92+ fi
93+ done
94+ """
95+ )
96+ else:
97+ rc_script = None
98+
99+ if rc_script:
100 rc_local = "/etc/rc.local"
101 yield "write_files", [
102 {
103 "path": rc_local,
104- "content": dedent(
105- """\
106- #!/bin/sh
107- ppc64_cpu --smt=off
108- exit 0
109- """
110- ),
111+ "content": rc_script,
112 "permissions": "0755",
113 },
114 ]

Subscribers

People subscribed via source and target branches