Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cloudinit/sources/DataSourceVultr.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ def _get_data(self):
# Process metadata
def get_datasource_data(self, md):
# Generate network config
self.netcfg = vultr.generate_network_config(md['interfaces'])
if "cloud_interfaces" in md:
# In the future we will just drop pre-configured
# network configs into the array. They need names though.
self.netcfg = vultr.add_interface_names(md['cloud_interfaces'])
else:
self.netcfg = vultr.generate_network_config(md['interfaces'])

# Grab vendordata
self.vendordata_raw = md['vendor-data']
Expand Down
41 changes: 41 additions & 0 deletions cloudinit/sources/helpers/vultr.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ def generate_public_network_interface(interface):
]
}

# Options that may or may not be used
if "mtu" in interface:
netcfg['mtu'] = interface['mtu']

if "accept-ra" in interface:
netcfg['accept-ra'] = interface['accept-ra']

if "routes" in interface:
netcfg['subnets'][0]['routes'] = interface['routes']

# Check for additional IP's
additional_count = len(interface['ipv4']['additional'])
if "ipv4" in interface and additional_count > 0:
Expand All @@ -162,6 +172,10 @@ def generate_public_network_interface(interface):
"address": additional['address'],
"netmask": additional['netmask']
}

if "routes" in additional:
add['routes'] = additional['routes']

netcfg['subnets'].append(add)

# Check for additional IPv6's
Expand All @@ -174,6 +188,10 @@ def generate_public_network_interface(interface):
"address": additional['address'],
"netmask": additional['netmask']
}

if "routes" in additional:
add['routes'] = additional['routes']

netcfg['subnets'].append(add)

# Add config to template
Expand Down Expand Up @@ -202,7 +220,30 @@ def generate_private_network_interface(interface):
]
}

# Options that may or may not be used
if "mtu" in interface:
netcfg['mtu'] = interface['mtu']

if "accept-ra" in interface:
netcfg['accept-ra'] = interface['accept-ra']

if "routes" in interface:
netcfg['subnets'][0]['routes'] = interface['routes']

return netcfg


# Make required adjustments to the network configs provided
def add_interface_names(interfaces):
for interface in interfaces:
interface_name = get_interface_name(interface['mac'])
if not interface_name:
raise RuntimeError(
"Interface: %s could not be found on the system" %
interface['mac'])
interface['name'] = interface_name

return interfaces


# vi: ts=4 expandtab