Blob Blame History Raw
From abe64cecf310d482f1779c10af5f903c4c0bd98c Mon Sep 17 00:00:00 2001
From: Edward Haas <edwardh@redhat.com>
Date: Tue, 13 Aug 2019 20:37:53 +0800
Subject: [PATCH] nm.applier: Prioritize base iface activation before the vlan

When both the base interface and the VLAN interface are created in one
transaction, the base interface must be activated before the vlan one,
otherwise the VLAN activation fails.

The new VLAN interfaces are now activated after all other interfaces.

Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Gris Ge <fge@redhat.com>
---
 libnmstate/nm/applier.py       |  8 ++++++++
 libnmstate/schema.py           |  2 ++
 1 files changed, 10 insertions(+)

diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py
index ae5cd75..750ca3d 100644
--- a/libnmstate/nm/applier.py
+++ b/libnmstate/nm/applier.py
@@ -21,6 +21,8 @@ import itertools
 import six
 
 from libnmstate.error import NmstateValueError
+from libnmstate.schema import Interface
+from libnmstate.schema import InterfaceType
 from libnmstate.schema import LinuxBridge as LB
 
 from . import bond
@@ -118,6 +120,7 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
     con_profiles_by_devname = _index_profiles_by_devname(con_profiles)
     new_ifaces = _get_new_ifaces(con_profiles)
     new_ifaces_to_activate = set()
+    new_vlan_ifaces_to_activate = set()
     new_ovs_interface_to_activate = set()
     new_ovs_port_to_activate = set()
     master_ifaces_to_edit = set()
@@ -133,6 +136,8 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
                     new_ovs_interface_to_activate.add(ifname)
                 elif iface_desired_state['type'] == ovs.PORT_TYPE:
                     new_ovs_port_to_activate.add(ifname)
+                elif iface_desired_state[Interface.TYPE] == InterfaceType.VLAN:
+                    new_vlan_ifaces_to_activate.add(ifname)
                 else:
                     new_ifaces_to_activate.add(ifname)
         else:
@@ -186,6 +191,9 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
     for dev, con_profile in ifaces_to_edit:
         device.modify(dev, con_profile)
 
+    for ifname in new_vlan_ifaces_to_activate:
+        device.activate(dev=None, connection_id=ifname)
+
     for dev, actions in six.viewitems(remove_devs_actions):
         for action in actions:
             action(dev)
diff --git a/libnmstate/schema.py b/libnmstate/schema.py
index 1737003..0af60ef 100644
--- a/libnmstate/schema.py
+++ b/libnmstate/schema.py
@@ -88,6 +88,7 @@ class InterfaceType(object):
     KEY = Interface.TYPE
 
     BOND = 'bond'
+    DUMMY = 'dummy'
     ETHERNET = 'ethernet'
     LINUX_BRIDGE = 'linux-bridge'
     OVS_BRIDGE = 'ovs-bridge'
@@ -98,6 +99,7 @@ class InterfaceType(object):
 
     VIRT_TYPES = (
         BOND,
+        DUMMY,
         LINUX_BRIDGE,
         OVS_BRIDGE,
         OVS_PORT,
-- 
2.22.1