Added
Link Here
|
1 |
--- cloudinit/net/bsd.py.orig 2021-07-05 03:47:58 UTC |
2 |
+++ cloudinit/net/bsd.py |
3 |
@@ -33,7 +33,7 @@ class BSDRenderer(renderer.Renderer): |
4 |
self.interface_configurations = {} |
5 |
self._postcmds = config.get('postcmds', True) |
6 |
|
7 |
- def _ifconfig_entries(self, settings, target=None): |
8 |
+ def _ifconfig_entries(self, settings): |
9 |
ifname_by_mac = net.get_interfaces_by_mac() |
10 |
for interface in settings.iter_interfaces(): |
11 |
device_name = interface.get("name") |
12 |
@@ -76,9 +76,10 @@ class BSDRenderer(renderer.Renderer): |
13 |
self.interface_configurations[device_name] = { |
14 |
'address': subnet.get('address'), |
15 |
'netmask': subnet.get('netmask'), |
16 |
+ 'mtu': subnet.get('mtu') or interface.get('mtu'), |
17 |
} |
18 |
|
19 |
- def _route_entries(self, settings, target=None): |
20 |
+ def _route_entries(self, settings): |
21 |
routes = list(settings.iter_routes()) |
22 |
for interface in settings.iter_interfaces(): |
23 |
subnets = interface.get("subnets", []) |
24 |
@@ -101,7 +102,7 @@ class BSDRenderer(renderer.Renderer): |
25 |
gateway = route.get('gateway') |
26 |
self.set_route(network, netmask, gateway) |
27 |
|
28 |
- def _resolve_conf(self, settings, target=None): |
29 |
+ def _resolve_conf(self, settings): |
30 |
nameservers = settings.dns_nameservers |
31 |
searchdomains = settings.dns_searchdomains |
32 |
for interface in settings.iter_interfaces(): |
33 |
@@ -114,11 +115,11 @@ class BSDRenderer(renderer.Renderer): |
34 |
# fails. |
35 |
try: |
36 |
resolvconf = ResolvConf(util.load_file(subp.target_path( |
37 |
- target, self.resolv_conf_fn))) |
38 |
+ self.target, self.resolv_conf_fn))) |
39 |
resolvconf.parse() |
40 |
except IOError: |
41 |
util.logexc(LOG, "Failed to parse %s, use new empty file", |
42 |
- subp.target_path(target, self.resolv_conf_fn)) |
43 |
+ subp.target_path(self.target, self.resolv_conf_fn)) |
44 |
resolvconf = ResolvConf('') |
45 |
resolvconf.parse() |
46 |
|
47 |
@@ -136,10 +137,12 @@ class BSDRenderer(renderer.Renderer): |
48 |
except ValueError: |
49 |
util.logexc(LOG, "Failed to add search domain %s", domain) |
50 |
util.write_file( |
51 |
- subp.target_path(target, self.resolv_conf_fn), |
52 |
+ subp.target_path(self.target, self.resolv_conf_fn), |
53 |
str(resolvconf), 0o644) |
54 |
|
55 |
def render_network_state(self, network_state, templates=None, target=None): |
56 |
+ if target: |
57 |
+ self.target = target |
58 |
self._ifconfig_entries(settings=network_state) |
59 |
self._route_entries(settings=network_state) |
60 |
self._resolve_conf(settings=network_state) |