← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~kurt-easygo/cloud-init:fix-network-state-dhcp into cloud-init:master

 

kstieger has proposed merging ~kurt-easygo/cloud-init:fix-network-state-dhcp into cloud-init:master.

Commit message:
FIX: append type:dhcp[4|6] only if dhcp[4|6] is True in v2 networkconfig



Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~kurt-easygo/cloud-init/+git/cloud-init/+merge/363732

Previously the decision if subnets type should be dhcp or not was made on checking if the key 'dhcp' exists. But dhcp in the cfg dict is a boolean. 
After this change subnets['type'] is only 'dhcp' if it is True in the cfg dict.

This issue leaded to  inconsistant sysconfig/network-scripts on fedora. 'BOOTPROTO' was always 'dhcp', even if the address config was static.
(Fixes both, dhcp4 and dhcp6.)
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~kurt-easygo/cloud-init:fix-network-state-dhcp into cloud-init:master.
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index f76e508..539b76d 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -706,9 +706,9 @@ class NetworkStateInterpreter(object):
         """Common ipconfig extraction from v2 to v1 subnets array."""
 
         subnets = []
-        if 'dhcp4' in cfg:
+        if cfg.get('dhcp4'):
             subnets.append({'type': 'dhcp4'})
-        if 'dhcp6' in cfg:
+        if cfg.get('dhcp6'):
             self.use_ipv6 = True
             subnets.append({'type': 'dhcp6'})
 

Follow ups