89
90
sys.stderr.write(msg + "\n")
90
91
raise Exception(msg)
95
# NB: we cannot support passthrough until curtin can convert from
96
# network_state to network-config yaml
93
97
ns = net.network_state.from_state_file(network_state)
98
raise ValueError('Not Supported; curtin lacks a network_state to '
99
'network_config converter.')
94
100
elif network_config:
95
ns = net.parse_net_config(network_config)
97
net.render_network_state(target=target, network_state=ns)
101
netcfg = config.load_config(network_config)
103
# curtin will pass-through the netconfig into the target
104
# for rendering at runtime unless the target OS does not
105
# support NETWORK_CONFIG_V2 feature.
106
LOG.info('Checking cloud-init in target [%s] for network '
107
'configuration passthrough support.', target)
109
passthrough = net.netconfig_passthrough_available(target)
110
except util.ProcessExecutionError:
111
LOG.warning('Failed to determine if passthrough is available')
114
LOG.info('Passing network configuration through to target: %s',
116
net.render_netconfig_passthrough(target, netconfig=netcfg)
118
ns = net.parse_net_config_data(netcfg.get('network', {}))
121
LOG.info('Rendering network configuration in target')
122
net.render_network_state(target=target, network_state=ns)
99
124
_maybe_remove_legacy_eth0(target)
100
LOG.info('Attempting to remove ipv6 privacy extensions')
101
125
_disable_ipv6_privacy_extensions(target)
102
126
_patch_ifupdown_ipv6_mtu_hook(target)
130
154
by default; this races with the cloud-image desire to disable them.
131
155
Resolve this by allowing the cloud-image setting to win. """
157
LOG.debug('Attempting to remove ipv6 privacy extensions')
133
158
cfg = util.target_path(target, path=path)
134
159
if not os.path.exists(cfg):
135
160
LOG.warn('Failed to find ipv6 privacy conf file %s', cfg)
143
168
lines = [f.strip() for f in contents.splitlines()
144
169
if not f.startswith("#")]
145
170
if lines == known_contents:
146
LOG.info('deleting file: %s', cfg)
171
LOG.info('Removing ipv6 privacy extension config file: %s', cfg)
147
172
util.del_file(cfg)
148
173
msg = "removed %s with known contents" % cfg
149
174
curtin_contents = '\n'.join(
153
178
"# net.ipv6.conf.default.use_tempaddr = 2"])
154
179
util.write_file(cfg, curtin_contents)
156
LOG.info('skipping, content didnt match')
157
LOG.debug("found content:\n%s", lines)
158
LOG.debug("expected contents:\n%s", known_contents)
181
LOG.debug('skipping removal of %s, expected content not found',
183
LOG.debug("Found content in file %s:\n%s", cfg, lines)
184
LOG.debug("Expected contents in file %s:\n%s", cfg, known_contents)
159
185
msg = (bmsg + " '%s' exists with user configured content." % cfg)
160
186
except Exception as e:
161
187
msg = bmsg + " %s exists, but could not be read. %s" % (cfg, e)