← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~chad.smith/cloud-init:network-stp-handle-0 into cloud-init:master

 

Chad Smith has proposed merging ~chad.smith/cloud-init:network-stp-handle-0 into cloud-init:master.

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

For more details, see:
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/331898

net: Handle bridge stp values of 0 and convert to boolean type

Update unit tests to pass a 0 instead of 'off' to validate that network
state is properly written.
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:network-stp-handle-0 into cloud-init:master.
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index 890dbf8..0e830ee 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -468,7 +468,7 @@ class NetworkStateInterpreter(object):
 
         # convert value to boolean
         bridge_stp = iface.get('bridge_stp')
-        if bridge_stp and type(bridge_stp) != bool:
+        if bridge_stp is not None and type(bridge_stp) != bool:
             if bridge_stp in ['on', '1', 1]:
                 bridge_stp = True
             elif bridge_stp in ['off', '0', 0]:
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 17c9342..bbb63cb 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1283,7 +1283,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
                   - eth0
                   - eth1
                 params:
-                  bridge_stp: 'off'
+                  bridge_stp: 0
                   bridge_bridgeprio: 22
                 subnets:
                   - type: static

Follow ups