Merge ~mfo/maas:3.1 into maas:3.1
- Git
- lp:~mfo/maas
- 3.1
- Merge into 3.1
Proposed by
Mauricio Faria de Oliveira
Status: | Merged |
---|---|
Merged at revision: | 5ad7060e524668a7eff438fa21fe5bd2199e4ff1 |
Proposed branch: | ~mfo/maas:3.1 |
Merge into: | maas:3.1 |
Diff against target: |
688 lines (+123/-247) 7 files modified
debian/changelog (+6/-0) dev/null (+0/-0) setup.cfg (+1/-1) src/maasserver/dhcp.py (+9/-15) src/maasserver/tests/test_dhcp.py (+12/-108) src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py (+41/-56) src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py (+54/-67) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MAAS Lander | Approve | ||
Mauricio Faria de Oliveira | Pending | ||
Review via email:
|
Commit message
Description of the change
Please ignore and do not merge; only for tests.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b 3.1 lp:~mfo/maas/+git/maas into -b 3.1 lp:~maas-committers/maas
STATUS: SUCCESS
COMMIT: 209cc3eb6038b5e
review:
Approve
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mauricio Faria de Oliveira (mfo) wrote : | # |
jenkins: !test
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b 3.1 lp:~mfo/maas/+git/maas into -b 3.1 lp:~maas-committers/maas
STATUS: SUCCESS
COMMIT: 2761b73c5d63e3d
review:
Approve
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mauricio Faria de Oliveira (mfo) wrote : | # |
jenkins: !test
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b 3.1 lp:~mfo/maas/+git/maas into -b 3.1 lp:~maas-committers/maas
STATUS: SUCCESS
COMMIT: 5ad7060e524668a
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/creds.yaml b/creds.yaml | |||
2 | 0 | deleted file mode 100644 | 0 | deleted file mode 100644 |
3 | index e69de29..0000000 | |||
4 | --- a/creds.yaml | |||
5 | +++ /dev/null | |||
6 | diff --git a/debian/changelog b/debian/changelog | |||
7 | index 204172d..39b080c 100644 | |||
8 | --- a/debian/changelog | |||
9 | +++ b/debian/changelog | |||
10 | @@ -1,3 +1,9 @@ | |||
11 | 1 | maas (1:3.1.2-0ubuntu1) focal; urgency=medium | ||
12 | 2 | |||
13 | 3 | * New upstream release, MAAS 3.1.2. | ||
14 | 4 | |||
15 | 5 | -- Mauricio Faria de Oliveira <mfo@canonical.com> Mon, 04 Sep 2023 14:14:22 -0300 | ||
16 | 6 | |||
17 | 1 | maas (1:3.1.2~rc1-0ubuntu1) focal; urgency=medium | 7 | maas (1:3.1.2~rc1-0ubuntu1) focal; urgency=medium |
18 | 2 | 8 | ||
19 | 3 | * New upstream release, MAAS 3.1.2 RC1. | 9 | * New upstream release, MAAS 3.1.2 RC1. |
20 | diff --git a/setup.cfg b/setup.cfg | |||
21 | index ca76a6a..4a59a2d 100644 | |||
22 | --- a/setup.cfg | |||
23 | +++ b/setup.cfg | |||
24 | @@ -1,6 +1,6 @@ | |||
25 | 1 | [metadata] | 1 | [metadata] |
26 | 2 | name = maas | 2 | name = maas |
28 | 3 | version = 3.1.2rc1 | 3 | version = 3.1.2 |
29 | 4 | description = Metal As A Service | 4 | description = Metal As A Service |
30 | 5 | long_description = file: README.rst | 5 | long_description = file: README.rst |
31 | 6 | url = https://maas.io/ | 6 | url = https://maas.io/ |
32 | diff --git a/src/maasserver/dhcp.py b/src/maasserver/dhcp.py | |||
33 | index f1bcd74..ac30d84 100644 | |||
34 | --- a/src/maasserver/dhcp.py | |||
35 | +++ b/src/maasserver/dhcp.py | |||
36 | @@ -224,17 +224,15 @@ def ip_is_on_vlan(ip_address, vlan): | |||
37 | 224 | ) | 224 | ) |
38 | 225 | 225 | ||
39 | 226 | 226 | ||
41 | 227 | def get_ip_address_for_interface(interface, vlan, ip_version: int): | 227 | def get_ip_address_for_interface(interface, vlan): |
42 | 228 | """Return the IP address for `interface` on `vlan`.""" | 228 | """Return the IP address for `interface` on `vlan`.""" |
43 | 229 | for ip_address in interface.ip_addresses.all(): | 229 | for ip_address in interface.ip_addresses.all(): |
47 | 230 | if ip_is_version(ip_address, ip_version) and ip_is_on_vlan( | 230 | if ip_is_on_vlan(ip_address, vlan): |
45 | 231 | ip_address, vlan | ||
46 | 232 | ): | ||
48 | 233 | return ip_address | 231 | return ip_address |
49 | 234 | return None | 232 | return None |
50 | 235 | 233 | ||
51 | 236 | 234 | ||
53 | 237 | def get_ip_address_for_rack_controller(rack_controller, vlan, ip_version: int): | 235 | def get_ip_address_for_rack_controller(rack_controller, vlan): |
54 | 238 | """Return the IP address for `rack_controller` on `vlan`.""" | 236 | """Return the IP address for `rack_controller` on `vlan`.""" |
55 | 239 | # First we build a list of all interfaces that have an IP address | 237 | # First we build a list of all interfaces that have an IP address |
56 | 240 | # on that vlan. Then we pick the best interface for that vlan | 238 | # on that vlan. Then we pick the best interface for that vlan |
57 | @@ -245,12 +243,10 @@ def get_ip_address_for_rack_controller(rack_controller, vlan, ip_version: int): | |||
58 | 245 | matching_interfaces = set() | 243 | matching_interfaces = set() |
59 | 246 | for interface in interfaces: | 244 | for interface in interfaces: |
60 | 247 | for ip_address in interface.ip_addresses.all(): | 245 | for ip_address in interface.ip_addresses.all(): |
64 | 248 | if ip_is_version(ip_address, ip_version) and ip_is_on_vlan( | 246 | if ip_is_on_vlan(ip_address, vlan): |
62 | 249 | ip_address, vlan | ||
63 | 250 | ): | ||
65 | 251 | matching_interfaces.add(interface) | 247 | matching_interfaces.add(interface) |
66 | 252 | interface = get_best_interface(matching_interfaces) | 248 | interface = get_best_interface(matching_interfaces) |
68 | 253 | return get_ip_address_for_interface(interface, vlan, ip_version) | 249 | return get_ip_address_for_interface(interface, vlan) |
69 | 254 | 250 | ||
70 | 255 | 251 | ||
71 | 256 | @typed | 252 | @typed |
72 | @@ -493,19 +489,17 @@ def make_subnet_config( | |||
73 | 493 | return subnet_config | 489 | return subnet_config |
74 | 494 | 490 | ||
75 | 495 | 491 | ||
77 | 496 | def make_failover_peer_config(vlan, rack_controller, ip_version: int): | 492 | def make_failover_peer_config(vlan, rack_controller): |
78 | 497 | """Return DHCP failover peer configuration dict for a rack controller.""" | 493 | """Return DHCP failover peer configuration dict for a rack controller.""" |
79 | 498 | is_primary = vlan.primary_rack_id == rack_controller.id | 494 | is_primary = vlan.primary_rack_id == rack_controller.id |
80 | 499 | interface_ip_address = get_ip_address_for_rack_controller( | 495 | interface_ip_address = get_ip_address_for_rack_controller( |
82 | 500 | rack_controller, vlan, ip_version | 496 | rack_controller, vlan |
83 | 501 | ) | 497 | ) |
84 | 502 | if is_primary: | 498 | if is_primary: |
85 | 503 | peer_rack = vlan.secondary_rack | 499 | peer_rack = vlan.secondary_rack |
86 | 504 | else: | 500 | else: |
87 | 505 | peer_rack = vlan.primary_rack | 501 | peer_rack = vlan.primary_rack |
91 | 506 | peer_address = get_ip_address_for_rack_controller( | 502 | peer_address = get_ip_address_for_rack_controller(peer_rack, vlan) |
89 | 507 | peer_rack, vlan, ip_version | ||
90 | 508 | ) | ||
92 | 509 | name = "failover-vlan-%d" % vlan.id | 503 | name = "failover-vlan-%d" % vlan.id |
93 | 510 | return ( | 504 | return ( |
94 | 511 | name, | 505 | name, |
95 | @@ -659,7 +653,7 @@ def get_dhcp_configure_for( | |||
96 | 659 | if has_secondary: | 653 | if has_secondary: |
97 | 660 | # Generate the failover peer for this VLAN. | 654 | # Generate the failover peer for this VLAN. |
98 | 661 | peer_name, peer_config, peer_rack = make_failover_peer_config( | 655 | peer_name, peer_config, peer_rack = make_failover_peer_config( |
100 | 662 | vlan, rack_controller, ip_version | 656 | vlan, rack_controller |
101 | 663 | ) | 657 | ) |
102 | 664 | else: | 658 | else: |
103 | 665 | peer_name, peer_config, peer_rack = None, None, None | 659 | peer_name, peer_config, peer_rack = None, None, None |
104 | diff --git a/src/maasserver/tests/test_dhcp.py b/src/maasserver/tests/test_dhcp.py | |||
105 | index 6383535..dc2975a 100644 | |||
106 | --- a/src/maasserver/tests/test_dhcp.py | |||
107 | +++ b/src/maasserver/tests/test_dhcp.py | |||
108 | @@ -815,16 +815,10 @@ class TestGetIPAddressForInterface(MAASServerTestCase): | |||
109 | 815 | interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL, vlan=vlan) | 815 | interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL, vlan=vlan) |
110 | 816 | subnet = factory.make_Subnet(vlan=vlan) | 816 | subnet = factory.make_Subnet(vlan=vlan) |
111 | 817 | ip_address = factory.make_StaticIPAddress( | 817 | ip_address = factory.make_StaticIPAddress( |
116 | 818 | ip=factory.pick_ip_in_Subnet(subnet), | 818 | alloc_type=IPADDRESS_TYPE.AUTO, subnet=subnet, interface=interface |
113 | 819 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
114 | 820 | subnet=subnet, | ||
115 | 821 | interface=interface, | ||
117 | 822 | ) | 819 | ) |
118 | 823 | self.assertEqual( | 820 | self.assertEqual( |
123 | 824 | ip_address, | 821 | ip_address, dhcp.get_ip_address_for_interface(interface, vlan) |
120 | 825 | dhcp.get_ip_address_for_interface( | ||
121 | 826 | interface, vlan, subnet.get_ip_version() | ||
122 | 827 | ), | ||
124 | 828 | ) | 822 | ) |
125 | 829 | 823 | ||
126 | 830 | def test_returns_None(self): | 824 | def test_returns_None(self): |
127 | @@ -832,15 +826,10 @@ class TestGetIPAddressForInterface(MAASServerTestCase): | |||
128 | 832 | interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL, vlan=vlan) | 826 | interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL, vlan=vlan) |
129 | 833 | subnet = factory.make_Subnet(vlan=vlan) | 827 | subnet = factory.make_Subnet(vlan=vlan) |
130 | 834 | factory.make_StaticIPAddress( | 828 | factory.make_StaticIPAddress( |
135 | 835 | ip=factory.pick_ip_in_Subnet(subnet), | 829 | alloc_type=IPADDRESS_TYPE.AUTO, subnet=subnet, interface=interface |
132 | 836 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
133 | 837 | subnet=subnet, | ||
134 | 838 | interface=interface, | ||
136 | 839 | ) | 830 | ) |
137 | 840 | self.assertIsNone( | 831 | self.assertIsNone( |
141 | 841 | dhcp.get_ip_address_for_interface( | 832 | dhcp.get_ip_address_for_interface(interface, factory.make_VLAN()) |
139 | 842 | interface, factory.make_VLAN(), subnet.get_ip_version() | ||
140 | 843 | ) | ||
142 | 844 | ) | 833 | ) |
143 | 845 | 834 | ||
144 | 846 | 835 | ||
145 | @@ -855,16 +844,11 @@ class TestGetIPAddressForRackController(MAASServerTestCase): | |||
146 | 855 | ) | 844 | ) |
147 | 856 | subnet = factory.make_Subnet(vlan=vlan) | 845 | subnet = factory.make_Subnet(vlan=vlan) |
148 | 857 | ip_address = factory.make_StaticIPAddress( | 846 | ip_address = factory.make_StaticIPAddress( |
153 | 858 | ip=factory.pick_ip_in_Subnet(subnet), | 847 | alloc_type=IPADDRESS_TYPE.AUTO, subnet=subnet, interface=interface |
150 | 859 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
151 | 860 | subnet=subnet, | ||
152 | 861 | interface=interface, | ||
154 | 862 | ) | 848 | ) |
155 | 863 | self.assertEqual( | 849 | self.assertEqual( |
156 | 864 | ip_address, | 850 | ip_address, |
160 | 865 | dhcp.get_ip_address_for_rack_controller( | 851 | dhcp.get_ip_address_for_rack_controller(rack_controller, vlan), |
158 | 866 | rack_controller, vlan, subnet.get_ip_version() | ||
159 | 867 | ), | ||
161 | 868 | ) | 852 | ) |
162 | 869 | 853 | ||
163 | 870 | def test_returns_ip_address_from_best_interface_on_rack_controller(self): | 854 | def test_returns_ip_address_from_best_interface_on_rack_controller(self): |
164 | @@ -884,10 +868,7 @@ class TestGetIPAddressForRackController(MAASServerTestCase): | |||
165 | 884 | ) | 868 | ) |
166 | 885 | subnet = factory.make_Subnet(vlan=vlan) | 869 | subnet = factory.make_Subnet(vlan=vlan) |
167 | 886 | factory.make_StaticIPAddress( | 870 | factory.make_StaticIPAddress( |
172 | 887 | ip=factory.pick_ip_in_Subnet(subnet), | 871 | alloc_type=IPADDRESS_TYPE.AUTO, subnet=subnet, interface=interface |
169 | 888 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
170 | 889 | subnet=subnet, | ||
171 | 890 | interface=interface, | ||
173 | 891 | ) | 872 | ) |
174 | 892 | bond_ip_address = factory.make_StaticIPAddress( | 873 | bond_ip_address = factory.make_StaticIPAddress( |
175 | 893 | alloc_type=IPADDRESS_TYPE.AUTO, | 874 | alloc_type=IPADDRESS_TYPE.AUTO, |
176 | @@ -896,9 +877,7 @@ class TestGetIPAddressForRackController(MAASServerTestCase): | |||
177 | 896 | ) | 877 | ) |
178 | 897 | self.assertEqual( | 878 | self.assertEqual( |
179 | 898 | bond_ip_address, | 879 | bond_ip_address, |
183 | 899 | dhcp.get_ip_address_for_rack_controller( | 880 | dhcp.get_ip_address_for_rack_controller(rack_controller, vlan), |
181 | 900 | rack_controller, vlan, subnet.get_ip_version() | ||
182 | 901 | ), | ||
184 | 902 | ) | 881 | ) |
185 | 903 | 882 | ||
186 | 904 | 883 | ||
187 | @@ -2104,12 +2083,11 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
188 | 2104 | primary_rack=primary_rack, | 2083 | primary_rack=primary_rack, |
189 | 2105 | secondary_rack=secondary_rack, | 2084 | secondary_rack=secondary_rack, |
190 | 2106 | ) | 2085 | ) |
192 | 2107 | subnet = factory.make_Subnet(vlan=vlan, version=4) | 2086 | subnet = factory.make_Subnet(vlan=vlan) |
193 | 2108 | primary_interface = factory.make_Interface( | 2087 | primary_interface = factory.make_Interface( |
194 | 2109 | INTERFACE_TYPE.PHYSICAL, node=primary_rack, vlan=vlan | 2088 | INTERFACE_TYPE.PHYSICAL, node=primary_rack, vlan=vlan |
195 | 2110 | ) | 2089 | ) |
196 | 2111 | primary_ip = factory.make_StaticIPAddress( | 2090 | primary_ip = factory.make_StaticIPAddress( |
197 | 2112 | ip=factory.pick_ip_in_Subnet(subnet), | ||
198 | 2113 | alloc_type=IPADDRESS_TYPE.AUTO, | 2091 | alloc_type=IPADDRESS_TYPE.AUTO, |
199 | 2114 | subnet=subnet, | 2092 | subnet=subnet, |
200 | 2115 | interface=primary_interface, | 2093 | interface=primary_interface, |
201 | @@ -2118,7 +2096,6 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
202 | 2118 | INTERFACE_TYPE.PHYSICAL, node=secondary_rack, vlan=vlan | 2096 | INTERFACE_TYPE.PHYSICAL, node=secondary_rack, vlan=vlan |
203 | 2119 | ) | 2097 | ) |
204 | 2120 | secondary_ip = factory.make_StaticIPAddress( | 2098 | secondary_ip = factory.make_StaticIPAddress( |
205 | 2121 | ip=factory.pick_ip_in_Subnet(subnet), | ||
206 | 2122 | alloc_type=IPADDRESS_TYPE.AUTO, | 2099 | alloc_type=IPADDRESS_TYPE.AUTO, |
207 | 2123 | subnet=subnet, | 2100 | subnet=subnet, |
208 | 2124 | interface=secondary_interface, | 2101 | interface=secondary_interface, |
209 | @@ -2135,7 +2112,7 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
210 | 2135 | }, | 2112 | }, |
211 | 2136 | secondary_rack, | 2113 | secondary_rack, |
212 | 2137 | ), | 2114 | ), |
214 | 2138 | dhcp.make_failover_peer_config(vlan, primary_rack, 4), | 2115 | dhcp.make_failover_peer_config(vlan, primary_rack), |
215 | 2139 | ) | 2116 | ) |
216 | 2140 | 2117 | ||
217 | 2141 | def test_renders_config_for_secondary(self): | 2118 | def test_renders_config_for_secondary(self): |
218 | @@ -2146,12 +2123,11 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
219 | 2146 | primary_rack=primary_rack, | 2123 | primary_rack=primary_rack, |
220 | 2147 | secondary_rack=secondary_rack, | 2124 | secondary_rack=secondary_rack, |
221 | 2148 | ) | 2125 | ) |
223 | 2149 | subnet = factory.make_Subnet(vlan=vlan, version=4) | 2126 | subnet = factory.make_Subnet(vlan=vlan) |
224 | 2150 | primary_interface = factory.make_Interface( | 2127 | primary_interface = factory.make_Interface( |
225 | 2151 | INTERFACE_TYPE.PHYSICAL, node=primary_rack, vlan=vlan | 2128 | INTERFACE_TYPE.PHYSICAL, node=primary_rack, vlan=vlan |
226 | 2152 | ) | 2129 | ) |
227 | 2153 | primary_ip = factory.make_StaticIPAddress( | 2130 | primary_ip = factory.make_StaticIPAddress( |
228 | 2154 | ip=factory.pick_ip_in_Subnet(subnet), | ||
229 | 2155 | alloc_type=IPADDRESS_TYPE.AUTO, | 2131 | alloc_type=IPADDRESS_TYPE.AUTO, |
230 | 2156 | subnet=subnet, | 2132 | subnet=subnet, |
231 | 2157 | interface=primary_interface, | 2133 | interface=primary_interface, |
232 | @@ -2160,7 +2136,6 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
233 | 2160 | INTERFACE_TYPE.PHYSICAL, node=secondary_rack, vlan=vlan | 2136 | INTERFACE_TYPE.PHYSICAL, node=secondary_rack, vlan=vlan |
234 | 2161 | ) | 2137 | ) |
235 | 2162 | secondary_ip = factory.make_StaticIPAddress( | 2138 | secondary_ip = factory.make_StaticIPAddress( |
236 | 2163 | ip=factory.pick_ip_in_Subnet(subnet), | ||
237 | 2164 | alloc_type=IPADDRESS_TYPE.AUTO, | 2139 | alloc_type=IPADDRESS_TYPE.AUTO, |
238 | 2165 | subnet=subnet, | 2140 | subnet=subnet, |
239 | 2166 | interface=secondary_interface, | 2141 | interface=secondary_interface, |
240 | @@ -2177,78 +2152,7 @@ class TestMakeFailoverPeerConfig(MAASServerTestCase): | |||
241 | 2177 | }, | 2152 | }, |
242 | 2178 | primary_rack, | 2153 | primary_rack, |
243 | 2179 | ), | 2154 | ), |
316 | 2180 | dhcp.make_failover_peer_config(vlan, secondary_rack, 4), | 2155 | dhcp.make_failover_peer_config(vlan, secondary_rack), |
245 | 2181 | ) | ||
246 | 2182 | |||
247 | 2183 | # See https://bugs.launchpad.net/maas/+bug/2027621 | ||
248 | 2184 | def test_renders_config_for_secondary_should_not_mix_v4_and_v6_addresses( | ||
249 | 2185 | self, | ||
250 | 2186 | ): | ||
251 | 2187 | primary_rack = factory.make_RackController() | ||
252 | 2188 | secondary_rack = factory.make_RackController() | ||
253 | 2189 | vlan = factory.make_VLAN( | ||
254 | 2190 | dhcp_on=True, | ||
255 | 2191 | primary_rack=primary_rack, | ||
256 | 2192 | secondary_rack=secondary_rack, | ||
257 | 2193 | ) | ||
258 | 2194 | subnet_v4 = factory.make_Subnet(vlan=vlan, version=4) | ||
259 | 2195 | subnet_v6 = factory.make_Subnet(vlan=vlan, version=6) | ||
260 | 2196 | primary_interface = factory.make_Interface( | ||
261 | 2197 | INTERFACE_TYPE.PHYSICAL, node=primary_rack, vlan=vlan | ||
262 | 2198 | ) | ||
263 | 2199 | primary_ip_v4 = factory.make_StaticIPAddress( | ||
264 | 2200 | ip=factory.pick_ip_in_Subnet(subnet_v4), | ||
265 | 2201 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
266 | 2202 | subnet=subnet_v4, | ||
267 | 2203 | interface=primary_interface, | ||
268 | 2204 | ) | ||
269 | 2205 | primary_ip_v6 = factory.make_StaticIPAddress( | ||
270 | 2206 | ip=factory.pick_ip_in_Subnet(subnet_v6), | ||
271 | 2207 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
272 | 2208 | subnet=subnet_v6, | ||
273 | 2209 | interface=primary_interface, | ||
274 | 2210 | ) | ||
275 | 2211 | secondary_interface = factory.make_Interface( | ||
276 | 2212 | INTERFACE_TYPE.PHYSICAL, node=secondary_rack, vlan=vlan | ||
277 | 2213 | ) | ||
278 | 2214 | secondary_ip_v4 = factory.make_StaticIPAddress( | ||
279 | 2215 | ip=factory.pick_ip_in_Subnet(subnet_v4), | ||
280 | 2216 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
281 | 2217 | subnet=subnet_v4, | ||
282 | 2218 | interface=secondary_interface, | ||
283 | 2219 | ) | ||
284 | 2220 | secondary_ip_v6 = factory.make_StaticIPAddress( | ||
285 | 2221 | ip=factory.pick_ip_in_Subnet(subnet_v6), | ||
286 | 2222 | alloc_type=IPADDRESS_TYPE.AUTO, | ||
287 | 2223 | subnet=subnet_v6, | ||
288 | 2224 | interface=secondary_interface, | ||
289 | 2225 | ) | ||
290 | 2226 | failover_peer_name = "failover-vlan-%d" % vlan.id | ||
291 | 2227 | self.assertEqual( | ||
292 | 2228 | ( | ||
293 | 2229 | failover_peer_name, | ||
294 | 2230 | { | ||
295 | 2231 | "name": failover_peer_name, | ||
296 | 2232 | "mode": "secondary", | ||
297 | 2233 | "address": str(secondary_ip_v4.ip), | ||
298 | 2234 | "peer_address": str(primary_ip_v4.ip), | ||
299 | 2235 | }, | ||
300 | 2236 | primary_rack, | ||
301 | 2237 | ), | ||
302 | 2238 | dhcp.make_failover_peer_config(vlan, secondary_rack, 4), | ||
303 | 2239 | ) | ||
304 | 2240 | self.assertEqual( | ||
305 | 2241 | ( | ||
306 | 2242 | failover_peer_name, | ||
307 | 2243 | { | ||
308 | 2244 | "name": failover_peer_name, | ||
309 | 2245 | "mode": "secondary", | ||
310 | 2246 | "address": str(secondary_ip_v6.ip), | ||
311 | 2247 | "peer_address": str(primary_ip_v6.ip), | ||
312 | 2248 | }, | ||
313 | 2249 | primary_rack, | ||
314 | 2250 | ), | ||
315 | 2251 | dhcp.make_failover_peer_config(vlan, secondary_rack, 6), | ||
317 | 2252 | ) | 2156 | ) |
318 | 2253 | 2157 | ||
319 | 2254 | 2158 | ||
320 | diff --git a/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py b/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py | |||
321 | index 221289a..4da0512 100755 | |||
322 | --- a/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py | |||
323 | +++ b/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py | |||
324 | @@ -162,7 +162,7 @@ class IPMI(BMCConfig): | |||
325 | 162 | password=None, | 162 | password=None, |
326 | 163 | ipmi_k_g="", | 163 | ipmi_k_g="", |
327 | 164 | ipmi_privilege_level="", | 164 | ipmi_privilege_level="", |
329 | 165 | **kwargs, | 165 | **kwargs |
330 | 166 | ): | 166 | ): |
331 | 167 | self.username = username | 167 | self.username = username |
332 | 168 | self.password = password | 168 | self.password = password |
333 | @@ -174,7 +174,7 @@ class IPMI(BMCConfig): | |||
334 | 174 | def _bmc_get_config(self, section=None): | 174 | def _bmc_get_config(self, section=None): |
335 | 175 | """Fetch and cache all BMC settings.""" | 175 | """Fetch and cache all BMC settings.""" |
336 | 176 | print("INFO: Reading current IPMI BMC values...") | 176 | print("INFO: Reading current IPMI BMC values...") |
338 | 177 | cmd = ["bmc-config", "--checkout", "--verbose"] | 177 | cmd = ["bmc-config", "--checkout"] |
339 | 178 | if section: | 178 | if section: |
340 | 179 | cmd += ["-S", section] | 179 | cmd += ["-S", section] |
341 | 180 | try: | 180 | try: |
342 | @@ -438,53 +438,41 @@ class IPMI(BMCConfig): | |||
343 | 438 | def _config_ipmi_lan_channel_settings(self): | 438 | def _config_ipmi_lan_channel_settings(self): |
344 | 439 | """Enable IPMI-over-Lan (Lan_Channel) if it is disabled""" | 439 | """Enable IPMI-over-Lan (Lan_Channel) if it is disabled""" |
345 | 440 | print("INFO: Configuring IPMI Lan_Channel...") | 440 | print("INFO: Configuring IPMI Lan_Channel...") |
346 | 441 | lan_channel = self._bmc_config.get("Lan_Channel", {}) | ||
347 | 441 | 442 | ||
353 | 442 | for channel in [ | 443 | for key in [ |
354 | 443 | "Lan_Channel", | 444 | "Volatile_Access_Mode", |
355 | 444 | "Lan_Channel_Channel_1", | 445 | "Non_Volatile_Access_Mode", |
351 | 445 | "Lan_Channel_Channel_2", | ||
352 | 446 | "Lan_Channel_Channel_3", | ||
356 | 447 | ]: | 446 | ]: |
367 | 448 | lan_channel = self._bmc_config.get(channel, {}) | 447 | if lan_channel.get(key) != "Always_Available": |
368 | 449 | 448 | print( | |
369 | 450 | if not lan_channel: | 449 | "INFO: Enabling BMC network access - Lan_Channel:%s" % key |
370 | 451 | continue | 450 | ) |
371 | 452 | 451 | # Some BMC's don't support setting Lan_Channel (see LP: #1287274). | |
372 | 453 | for key in [ | 452 | # If that happens, it would cause the script to fail preventing |
373 | 454 | "Volatile_Access_Mode", | 453 | # the script from continuing. To address this, simply catch the |
374 | 455 | "Non_Volatile_Access_Mode", | 454 | # error, return and allow the script to continue. |
375 | 456 | ]: | 455 | try: |
376 | 457 | if lan_channel.get(key) != "Always_Available": | 456 | self._bmc_set("Lan_Channel", key, "Always_Available") |
377 | 457 | except Exception: | ||
378 | 458 | print( | 458 | print( |
381 | 459 | "INFO: Enabling BMC network access - %s:%s" | 459 | "WARNING: Unable to set Lan_Channel:%s. " |
382 | 460 | % (channel, key) | 460 | "BMC may be unavailable over the network!" % key |
383 | 461 | ) | 461 | ) |
410 | 462 | # Some BMC's don't support setting Lan_Channel (see LP: #1287274). | 462 | |
411 | 463 | # If that happens, it would cause the script to fail preventing | 463 | self._bmc_set_keys( |
412 | 464 | # the script from continuing. To address this, simply catch the | 464 | "Lan_Channel", |
413 | 465 | # error, return and allow the script to continue. | 465 | [ |
414 | 466 | try: | 466 | "%s_%s" % (auth_type, volatility) |
415 | 467 | self._bmc_set(channel, key, "Always_Available") | 467 | for auth_type in [ |
416 | 468 | except Exception: | 468 | "Enable_User_Level_Auth", |
417 | 469 | print( | 469 | "Enable_Per_Message_Auth", |
418 | 470 | "WARNING: Unable to set %s:%s. " | 470 | "Enable_Pef_Alerting", |
419 | 471 | "BMC may be unavailable over the network!" | 471 | ] |
420 | 472 | % (channel, key) | 472 | for volatility in ["Volatile", "Non_Volatile"] |
421 | 473 | ) | 473 | ], |
422 | 474 | 474 | "Yes", | |
423 | 475 | self._bmc_set_keys( | 475 | ) |
398 | 476 | channel, | ||
399 | 477 | [ | ||
400 | 478 | f"{auth_type}_{volatility}" | ||
401 | 479 | for auth_type in [ | ||
402 | 480 | "Enable_User_Level_Auth", | ||
403 | 481 | "Enable_Per_Message_Auth", | ||
404 | 482 | "Enable_Pef_Alerting", | ||
405 | 483 | ] | ||
406 | 484 | for volatility in ["Volatile", "Non_Volatile"] | ||
407 | 485 | ], | ||
408 | 486 | "Yes", | ||
409 | 487 | ) | ||
424 | 488 | 476 | ||
425 | 489 | def _config_lan_conf_auth(self): | 477 | def _config_lan_conf_auth(self): |
426 | 490 | """Configure Lan_Conf_Auth.""" | 478 | """Configure Lan_Conf_Auth.""" |
427 | @@ -719,9 +707,6 @@ class IPMI(BMCConfig): | |||
428 | 719 | mac_address = None | 707 | mac_address = None |
429 | 720 | for section_name, key in [ | 708 | for section_name, key in [ |
430 | 721 | ("Lan_Conf", "IP_Address"), | 709 | ("Lan_Conf", "IP_Address"), |
431 | 722 | ("Lan_Conf_Channel_1", "IP_Address"), | ||
432 | 723 | ("Lan_Conf_Channel_2", "IP_Address"), | ||
433 | 724 | ("Lan_Conf_Channel_3", "IP_Address"), | ||
434 | 725 | ("Lan6_Conf", "IPv6_Static_Addresses"), | 710 | ("Lan6_Conf", "IPv6_Static_Addresses"), |
435 | 726 | ("Lan6_Conf", "IPv6_Dynamic_Addresses"), | 711 | ("Lan6_Conf", "IPv6_Dynamic_Addresses"), |
436 | 727 | ]: | 712 | ]: |
437 | @@ -744,28 +729,28 @@ class IPMI(BMCConfig): | |||
438 | 744 | time.sleep(2) | 729 | time.sleep(2) |
439 | 745 | continue | 730 | continue |
440 | 746 | if section_name.startswith("Lan6_"): | 731 | if section_name.startswith("Lan6_"): |
443 | 747 | return section_name, "[%s]" % ip, mac_address | 732 | return "[%s]" % ip, mac_address |
444 | 748 | return section_name, ip, mac_address | 733 | return ip, mac_address |
445 | 749 | # No valid IP address was found. | 734 | # No valid IP address was found. |
447 | 750 | return None, None, mac_address | 735 | return None, mac_address |
448 | 751 | 736 | ||
449 | 752 | def get_bmc_ip(self): | 737 | def get_bmc_ip(self): |
450 | 753 | """Configure and retreive IPMI BMC IP.""" | 738 | """Configure and retreive IPMI BMC IP.""" |
452 | 754 | section_name, ip_address, mac_address = self._get_bmc_ip() | 739 | ip_address, mac_address = self._get_bmc_ip() |
453 | 755 | if ip_address: | 740 | if ip_address: |
454 | 756 | return ip_address, mac_address | 741 | return ip_address, mac_address |
455 | 757 | print("INFO: Attempting to enable preconfigured static IP on BMC...") | 742 | print("INFO: Attempting to enable preconfigured static IP on BMC...") |
457 | 758 | self._bmc_set(section_name, "IP_Address_Source", "Static") | 743 | self._bmc_set("Lan_Conf", "IP_Address_Source", "Static") |
458 | 759 | for _ in range(6): | 744 | for _ in range(6): |
459 | 760 | time.sleep(10) | 745 | time.sleep(10) |
461 | 761 | _, ip_address, mac_address = self._get_bmc_ip(True) | 746 | ip_address, mac_address = self._get_bmc_ip(True) |
462 | 762 | if ip_address: | 747 | if ip_address: |
463 | 763 | return ip_address, mac_address | 748 | return ip_address, mac_address |
464 | 764 | print("INFO: Attempting to enable DHCP on BMC...") | 749 | print("INFO: Attempting to enable DHCP on BMC...") |
466 | 765 | self._bmc_set(section_name, "IP_Address_Source", "Use_DHCP") | 750 | self._bmc_set("Lan_Conf", "IP_Address_Source", "Use_DHCP") |
467 | 766 | for _ in range(6): | 751 | for _ in range(6): |
468 | 767 | time.sleep(10) | 752 | time.sleep(10) |
470 | 768 | _, ip_address, mac_address = self._get_bmc_ip(True) | 753 | ip_address, mac_address = self._get_bmc_ip(True) |
471 | 769 | if ip_address: | 754 | if ip_address: |
472 | 770 | print("WARNING: BMC is configured to use DHCP!") | 755 | print("WARNING: BMC is configured to use DHCP!") |
473 | 771 | return ip_address, mac_address | 756 | return ip_address, mac_address |
474 | diff --git a/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py b/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py | |||
475 | index 73e84b0..90f4af1 100644 | |||
476 | --- a/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py | |||
477 | +++ b/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py | |||
478 | @@ -538,25 +538,20 @@ EndSection | |||
479 | 538 | self.assertRaises(SystemExit, self.ipmi.add_bmc_user) | 538 | self.assertRaises(SystemExit, self.ipmi.add_bmc_user) |
480 | 539 | 539 | ||
481 | 540 | def test_set_ipmi_lan_channel_setting_verifies(self): | 540 | def test_set_ipmi_lan_channel_setting_verifies(self): |
494 | 541 | 541 | self.ipmi._bmc_config = { | |
495 | 542 | for channel in [ | 542 | "Lan_Channel": { |
496 | 543 | "Lan_Channel", | 543 | "Volatile_Access_Mode": "Always_Available", |
497 | 544 | "Lan_Channel_Channel_1", | 544 | "Non_Volatile_Access_Mode": "Always_Available", |
486 | 545 | "Lan_Channel_Channel_2", | ||
487 | 546 | "Lan_Channel_Channel_3", | ||
488 | 547 | ]: | ||
489 | 548 | self.ipmi._bmc_config = { | ||
490 | 549 | channel: { | ||
491 | 550 | "Volatile_Access_Mode": "Always_Available", | ||
492 | 551 | "Non_Volatile_Access_Mode": "Always_Available", | ||
493 | 552 | }, | ||
498 | 553 | } | 545 | } |
505 | 554 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 546 | } |
506 | 555 | mock_bmc_set_keys = self.patch(self.ipmi, "_bmc_set_keys") | 547 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
507 | 556 | self.ipmi._config_ipmi_lan_channel_settings() | 548 | mock_bmc_set_keys = self.patch(self.ipmi, "_bmc_set_keys") |
508 | 557 | self.assertFalse(mock_bmc_set.called) | 549 | self.ipmi._config_ipmi_lan_channel_settings() |
509 | 558 | mock_bmc_set_keys.assert_called_once_with( | 550 | self.assertThat(mock_bmc_set, MockNotCalled()) |
510 | 559 | channel, | 551 | self.assertThat( |
511 | 552 | mock_bmc_set_keys, | ||
512 | 553 | MockCalledOnceWith( | ||
513 | 554 | "Lan_Channel", | ||
514 | 560 | [ | 555 | [ |
515 | 561 | "%s_%s" % (auth_type, volatility) | 556 | "%s_%s" % (auth_type, volatility) |
516 | 562 | for auth_type in [ | 557 | for auth_type in [ |
517 | @@ -567,36 +562,36 @@ EndSection | |||
518 | 567 | for volatility in ["Volatile", "Non_Volatile"] | 562 | for volatility in ["Volatile", "Non_Volatile"] |
519 | 568 | ], | 563 | ], |
520 | 569 | "Yes", | 564 | "Yes", |
522 | 570 | ) | 565 | ), |
523 | 566 | ) | ||
524 | 571 | 567 | ||
525 | 572 | def test_set_ipmi_lan_channel_setting_enables(self): | 568 | def test_set_ipmi_lan_channel_setting_enables(self): |
537 | 573 | for channel in [ | 569 | self.ipmi._bmc_config = { |
538 | 574 | "Lan_Channel", | 570 | "Lan_Channel": { |
539 | 575 | "Lan_Channel_Channel_1", | 571 | "Volatile_Access_Mode": "Disabled", |
540 | 576 | "Lan_Channel_Channel_2", | 572 | "Non_Volatile_Access_Mode": "Pre_Boot_only", |
530 | 577 | "Lan_Channel_Channel_3", | ||
531 | 578 | ]: | ||
532 | 579 | self.ipmi._bmc_config = { | ||
533 | 580 | channel: { | ||
534 | 581 | "Volatile_Access_Mode": "Disabled", | ||
535 | 582 | "Non_Volatile_Access_Mode": "Pre_Boot_only", | ||
536 | 583 | }, | ||
541 | 584 | } | 573 | } |
557 | 585 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 574 | } |
558 | 586 | mock_bmc_set_keys = self.patch(self.ipmi, "_bmc_set_keys") | 575 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
559 | 587 | self.ipmi._config_ipmi_lan_channel_settings() | 576 | mock_bmc_set_keys = self.patch(self.ipmi, "_bmc_set_keys") |
560 | 588 | mock_bmc_set.assert_has_calls( | 577 | self.ipmi._config_ipmi_lan_channel_settings() |
561 | 589 | ( | 578 | self.assertThat( |
562 | 590 | call(channel, "Volatile_Access_Mode", "Always_Available"), | 579 | mock_bmc_set, |
563 | 591 | call( | 580 | MockCallsMatch( |
564 | 592 | channel, | 581 | call( |
565 | 593 | "Non_Volatile_Access_Mode", | 582 | "Lan_Channel", "Volatile_Access_Mode", "Always_Available" |
566 | 594 | "Always_Available", | 583 | ), |
567 | 595 | ), | 584 | call( |
568 | 596 | ) | 585 | "Lan_Channel", |
569 | 597 | ) | 586 | "Non_Volatile_Access_Mode", |
570 | 598 | mock_bmc_set_keys.assert_called_once_with( | 587 | "Always_Available", |
571 | 599 | channel, | 588 | ), |
572 | 589 | ), | ||
573 | 590 | ) | ||
574 | 591 | self.assertThat( | ||
575 | 592 | mock_bmc_set_keys, | ||
576 | 593 | MockCalledOnceWith( | ||
577 | 594 | "Lan_Channel", | ||
578 | 600 | [ | 595 | [ |
579 | 601 | "%s_%s" % (auth_type, volatility) | 596 | "%s_%s" % (auth_type, volatility) |
580 | 602 | for auth_type in [ | 597 | for auth_type in [ |
581 | @@ -607,7 +602,8 @@ EndSection | |||
582 | 607 | for volatility in ["Volatile", "Non_Volatile"] | 602 | for volatility in ["Volatile", "Non_Volatile"] |
583 | 608 | ], | 603 | ], |
584 | 609 | "Yes", | 604 | "Yes", |
586 | 610 | ) | 605 | ), |
587 | 606 | ) | ||
588 | 611 | 607 | ||
589 | 612 | def test_config_lan_conf_auth(self): | 608 | def test_config_lan_conf_auth(self): |
590 | 613 | self.ipmi._bmc_config = {"Lan_Channel_Auth": {}} | 609 | self.ipmi._bmc_config = {"Lan_Channel_Auth": {}} |
591 | @@ -947,9 +943,7 @@ EndSection | |||
592 | 947 | "MAC_Address": mac_address, | 943 | "MAC_Address": mac_address, |
593 | 948 | } | 944 | } |
594 | 949 | } | 945 | } |
598 | 950 | self.assertEqual( | 946 | self.assertEqual((ip, mac_address), self.ipmi._get_bmc_ip()) |
596 | 951 | ("Lan_Conf", ip, mac_address), self.ipmi._get_bmc_ip() | ||
597 | 952 | ) | ||
599 | 953 | 947 | ||
600 | 954 | def test_get_bmc_ipv6_static(self): | 948 | def test_get_bmc_ipv6_static(self): |
601 | 955 | ip = factory.make_ipv6_address() | 949 | ip = factory.make_ipv6_address() |
602 | @@ -960,9 +954,7 @@ EndSection | |||
603 | 960 | "MAC_Address": mac_address, | 954 | "MAC_Address": mac_address, |
604 | 961 | } | 955 | } |
605 | 962 | } | 956 | } |
609 | 963 | self.assertEqual( | 957 | self.assertEqual((f"[{ip}]", mac_address), self.ipmi._get_bmc_ip()) |
607 | 964 | ("Lan6_Conf", f"[{ip}]", mac_address), self.ipmi._get_bmc_ip() | ||
608 | 965 | ) | ||
610 | 966 | 958 | ||
611 | 967 | def test_get_bmc_ipv6_dynamic(self): | 959 | def test_get_bmc_ipv6_dynamic(self): |
612 | 968 | ip = factory.make_ipv6_address() | 960 | ip = factory.make_ipv6_address() |
613 | @@ -973,9 +965,7 @@ EndSection | |||
614 | 973 | "MAC_Address": mac_address, | 965 | "MAC_Address": mac_address, |
615 | 974 | } | 966 | } |
616 | 975 | } | 967 | } |
620 | 976 | self.assertEqual( | 968 | self.assertEqual((f"[{ip}]", mac_address), self.ipmi._get_bmc_ip()) |
618 | 977 | ("Lan6_Conf", f"[{ip}]", mac_address), self.ipmi._get_bmc_ip() | ||
619 | 978 | ) | ||
621 | 979 | 969 | ||
622 | 980 | def test_get_bmc_ipv6_gets_mac_From_ipv4(self): | 970 | def test_get_bmc_ipv6_gets_mac_From_ipv4(self): |
623 | 981 | ip = factory.make_ipv6_address() | 971 | ip = factory.make_ipv6_address() |
624 | @@ -984,20 +974,18 @@ EndSection | |||
625 | 984 | "Lan_Conf": {"MAC_Address": mac_address}, | 974 | "Lan_Conf": {"MAC_Address": mac_address}, |
626 | 985 | "Lan6_Conf": {"IPv6_Dynamic_Addresses": ip}, | 975 | "Lan6_Conf": {"IPv6_Dynamic_Addresses": ip}, |
627 | 986 | } | 976 | } |
631 | 987 | self.assertEqual( | 977 | self.assertEqual((f"[{ip}]", mac_address), self.ipmi._get_bmc_ip()) |
629 | 988 | ("Lan6_Conf", f"[{ip}]", mac_address), self.ipmi._get_bmc_ip() | ||
630 | 989 | ) | ||
632 | 990 | 978 | ||
633 | 991 | def test_get_bmc_ip_finds_none(self): | 979 | def test_get_bmc_ip_finds_none(self): |
634 | 992 | self.patch(self.ipmi, "_bmc_get").return_value = "" | 980 | self.patch(self.ipmi, "_bmc_get").return_value = "" |
636 | 993 | self.assertEqual((None, None, None), self.ipmi._get_bmc_ip()) | 981 | self.assertEqual((None, None), self.ipmi._get_bmc_ip()) |
637 | 994 | 982 | ||
638 | 995 | def test_get_bmc_ip(self): | 983 | def test_get_bmc_ip(self): |
639 | 996 | ip = factory.make_ip_address() | 984 | ip = factory.make_ip_address() |
640 | 997 | mac_address = factory.make_mac_address() | 985 | mac_address = factory.make_mac_address() |
641 | 998 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 986 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
642 | 999 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") | 987 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") |
644 | 1000 | mock_get_bmc_ip.return_value = None, ip, mac_address | 988 | mock_get_bmc_ip.return_value = ip, mac_address |
645 | 1001 | 989 | ||
646 | 1002 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) | 990 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) |
647 | 1003 | self.assertThat(mock_bmc_set, MockNotCalled()) | 991 | self.assertThat(mock_bmc_set, MockNotCalled()) |
648 | @@ -1009,9 +997,9 @@ EndSection | |||
649 | 1009 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 997 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
650 | 1010 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") | 998 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") |
651 | 1011 | mock_get_bmc_ip.side_effect = ( | 999 | mock_get_bmc_ip.side_effect = ( |
655 | 1012 | ("Lan_Conf", None, mac_address), | 1000 | (None, mac_address), |
656 | 1013 | ("Lan_Conf", None, mac_address), | 1001 | (None, mac_address), |
657 | 1014 | ("Lan_Conf", ip, mac_address), | 1002 | (ip, mac_address), |
658 | 1015 | ) | 1003 | ) |
659 | 1016 | 1004 | ||
660 | 1017 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) | 1005 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) |
661 | @@ -1029,8 +1017,8 @@ EndSection | |||
662 | 1029 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 1017 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
663 | 1030 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") | 1018 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") |
664 | 1031 | mock_get_bmc_ip.side_effect = ( | 1019 | mock_get_bmc_ip.side_effect = ( |
667 | 1032 | *[("Lan_Conf", None, mac_address) for _ in range(8)], | 1020 | *[(None, mac_address) for _ in range(8)], |
668 | 1033 | ("Lan_Conf", ip, mac_address), | 1021 | (ip, mac_address), |
669 | 1034 | ) | 1022 | ) |
670 | 1035 | 1023 | ||
671 | 1036 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) | 1024 | self.assertEqual((ip, mac_address), self.ipmi.get_bmc_ip()) |
672 | @@ -1041,7 +1029,6 @@ EndSection | |||
673 | 1041 | call("Lan_Conf", "IP_Address_Source", "Use_DHCP"), | 1029 | call("Lan_Conf", "IP_Address_Source", "Use_DHCP"), |
674 | 1042 | ), | 1030 | ), |
675 | 1043 | ) | 1031 | ) |
676 | 1044 | |||
677 | 1045 | self.assertThat( | 1032 | self.assertThat( |
678 | 1046 | mock_get_bmc_ip, | 1033 | mock_get_bmc_ip, |
679 | 1047 | MockCallsMatch(call(), *[call(True) for _ in range(8)]), | 1034 | MockCallsMatch(call(), *[call(True) for _ in range(8)]), |
680 | @@ -1050,7 +1037,7 @@ EndSection | |||
681 | 1050 | def test_get_bmc_ip_fails(self): | 1037 | def test_get_bmc_ip_fails(self): |
682 | 1051 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") | 1038 | mock_bmc_set = self.patch(self.ipmi, "_bmc_set") |
683 | 1052 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") | 1039 | mock_get_bmc_ip = self.patch(self.ipmi, "_get_bmc_ip") |
685 | 1053 | mock_get_bmc_ip.return_value = ("Lan_Conf", None, None) | 1040 | mock_get_bmc_ip.return_value = (None, None) |
686 | 1054 | 1041 | ||
687 | 1055 | self.assertRaises(SystemExit, self.ipmi.get_bmc_ip) | 1042 | self.assertRaises(SystemExit, self.ipmi.get_bmc_ip) |
688 | 1056 | self.assertThat( | 1043 | self.assertThat( |
UNIT TESTS
-b 3.1 lp:~mfo/maas/+git/maas into -b 3.1 lp:~maas-committers/maas
STATUS: SUCCESS a1dd141440b2ed6 e7bd6ea678
COMMIT: 9a57e03fb199af5