summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceAzure.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2019-08-13 20:13:05 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-08-13 20:13:05 +0000
commit7f674256c1426ffc419fd6b13e66a58754d94939 (patch)
tree8d5c5972ca8bc66a2408ed08955bd6d752d465b8 /cloudinit/sources/DataSourceAzure.py
parent155847209e6a3ed5face91a133d8488a703f3f93 (diff)
downloadvyos-cloud-init-7f674256c1426ffc419fd6b13e66a58754d94939.tar.gz
vyos-cloud-init-7f674256c1426ffc419fd6b13e66a58754d94939.zip
azure/net: generate_fallback_nic emits network v2 config instead of v1
The function generate_fallback_config is used by Azure by default when not consuming IMDS configuration data. This function is also used by any datasource which does not implement it's own network config. This simple fallback configuration sets up dhcp on the most likely NIC. It will now emit network v2 instead of network v1. This is a step toward moving all components talking in v2 and allows us to avoid costly conversions between v1 and v2 for newer distributions which rely on netplan.
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
-rwxr-xr-xcloudinit/sources/DataSourceAzure.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index d2fad9bb..e6ed2f3b 100755
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -1241,7 +1241,7 @@ def parse_network_config(imds_metadata):
privateIpv4 = addr4['privateIpAddress']
if privateIpv4:
if dev_config.get('dhcp4', False):
- # Append static address config for nic > 1
+ # Append static address config for ip > 1
netPrefix = intf['ipv4']['subnet'][0].get(
'prefix', '24')
if not dev_config.get('addresses'):
@@ -1251,6 +1251,11 @@ def parse_network_config(imds_metadata):
ip=privateIpv4, prefix=netPrefix))
else:
dev_config['dhcp4'] = True
+ # non-primary interfaces should have a higher
+ # route-metric (cost) so default routes prefer
+ # primary nic due to lower route-metric value
+ dev_config['dhcp4-overrides'] = {
+ 'route-metric': (idx + 1) * 100}
for addr6 in intf['ipv6']['ipAddress']:
privateIpv6 = addr6['privateIpAddress']
if privateIpv6: