summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOracle.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2019-08-28 16:10:35 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-08-28 16:10:35 +0000
commite7881d5c62e68e4962e2fcd3d12089e5a3b94dc9 (patch)
tree0c305efc8e6f046c08062c28e42cbdd239e7130c /cloudinit/sources/DataSourceOracle.py
parentd1b022217a652c7a84d5430c9e571987864d3982 (diff)
downloadvyos-cloud-init-e7881d5c62e68e4962e2fcd3d12089e5a3b94dc9.tar.gz
vyos-cloud-init-e7881d5c62e68e4962e2fcd3d12089e5a3b94dc9.zip
Oracle: Render secondary vnic IP and MTU values only
When rendering secondary vnic configuration from IMDS, only emit configuration for the IP and MTU values only. Add support to mutate either a v1 or a v2 network_config input.
Diffstat (limited to 'cloudinit/sources/DataSourceOracle.py')
-rw-r--r--cloudinit/sources/DataSourceOracle.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py
index 6e73f568..1cb0636c 100644
--- a/cloudinit/sources/DataSourceOracle.py
+++ b/cloudinit/sources/DataSourceOracle.py
@@ -51,8 +51,8 @@ def _add_network_config_from_opc_imds(network_config):
include the secondary VNICs.
:param network_config:
- A v1 network config dict with the primary NIC already configured. This
- dict will be mutated.
+ A v1 or v2 network config dict with the primary NIC already configured.
+ This dict will be mutated.
:raises:
Exceptions are not handled within this function. Likely exceptions are
@@ -88,20 +88,24 @@ def _add_network_config_from_opc_imds(network_config):
LOG.debug('Interface with MAC %s not found; skipping', mac_address)
continue
name = interfaces_by_mac[mac_address]
- subnet = {
- 'type': 'static',
- 'address': vnic_dict['privateIp'],
- 'netmask': vnic_dict['subnetCidrBlock'].split('/')[1],
- 'gateway': vnic_dict['virtualRouterIp'],
- 'control': 'manual',
- }
- network_config['config'].append({
- 'name': name,
- 'type': 'physical',
- 'mac_address': mac_address,
- 'mtu': MTU,
- 'subnets': [subnet],
- })
+
+ if network_config['version'] == 1:
+ subnet = {
+ 'type': 'static',
+ 'address': vnic_dict['privateIp'],
+ }
+ network_config['config'].append({
+ 'name': name,
+ 'type': 'physical',
+ 'mac_address': mac_address,
+ 'mtu': MTU,
+ 'subnets': [subnet],
+ })
+ elif network_config['version'] == 2:
+ network_config['ethernets'][name] = {
+ 'addresses': [vnic_dict['privateIp']],
+ 'mtu': MTU, 'dhcp4': False, 'dhcp6': False,
+ 'match': {'macaddress': mac_address}}
class DataSourceOracle(sources.DataSource):