← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~raharper/cloud-init:add-netplan-bridge-port-priority into cloud-init:master

 

Ryan Harper has proposed merging ~raharper/cloud-init:add-netplan-bridge-port-priority into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)
Related bugs:
  Bug #1735821 in nplan (Ubuntu): "netplan needs bridge port-priority support"
  https://bugs.launchpad.net/ubuntu/+source/nplan/+bug/1735821

For more details, see:
https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/334611

netplan: render bridge port-priority values
    
Update netplan renderer to write out bridge port-priority values
now that netplan supports the feature.
    
LP: #1735821
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~raharper/cloud-init:add-netplan-bridge-port-priority into cloud-init:master.
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
index d3788af..6bee3d3 100644
--- a/cloudinit/net/netplan.py
+++ b/cloudinit/net/netplan.py
@@ -311,12 +311,12 @@ class Renderer(renderer.Renderer):
                     if newname is None:
                         continue
                     br_config.update({newname: value})
-                    if newname == 'path-cost':
-                        # <interface> <cost> -> <interface>: int(<cost>)
+                    if newname in ['path-cost', 'port-priority']:
+                        # <interface> <value> -> <interface>: int(<value>)
                         newvalue = {}
-                        for costval in value:
-                            (port, cost) = costval.split()
-                            newvalue[port] = int(cost)
+                        for val in value:
+                            (port, portval) = val.split()
+                            newvalue[port] = int(portval)
                         br_config.update({newname: newvalue})
 
                 if len(br_config) > 0:
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index e9e2cf4..903c543 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -47,7 +47,7 @@ NET_CONFIG_TO_V2 = {
                'bridge_maxage': 'max-age',
                'bridge_maxwait': None,
                'bridge_pathcost': 'path-cost',
-               'bridge_portprio': None,
+               'bridge_portprio': 'port-priority',
                'bridge_stp': 'stp',
                'bridge_waitport': None}}
 
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index f3fa2a3..310903b 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -758,6 +758,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
                             path-cost:
                                 eth3: 50
                                 eth4: 75
+                            port-priority:
+                                eth3: 28
+                                eth4: 14
                             priority: 22
                             stp: false
                         routes:

Follow ups