[PATCH rhel7-branch 4/6] network: generate kickstart commands for bridge devices (#1075195)

Radek Vykydal rvykydal at redhat.com
Thu Sep 25 11:30:33 UTC 2014


Resolves: rhbz#1075195
---
 pyanaconda/network.py | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 3ec10fe..867fa5b 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -597,6 +597,8 @@ def ksdata_from_ifcfg(devname, uuid=None):
         nd.device = devname
     elif nm.nm_device_type_is_team(devname):
         nd.device = devname
+    elif nm.nm_device_type_is_bridge(devname):
+        nd.device = devname
     elif nm.nm_device_type_is_vlan(devname):
         if devname != default_ks_vlan_interface_name(nd.device, nd.vlanid):
             nd.interfacename = devname
@@ -615,6 +617,9 @@ def ifcfg_to_ksdata(ifcfg, devname):
     # no network command for team slaves
     if ifcfg.get("TEAM_MASTER"):
         return None
+    # no network command for bridge slaves
+    if ifcfg.get("BRIDGE"):
+        return None
 
     # ipv4 and ipv6
     if ifcfg.get("ONBOOT") and ifcfg.get("ONBOOT" ) == "no":
@@ -693,7 +698,7 @@ def ifcfg_to_ksdata(ifcfg, devname):
     # bonding
     # FIXME: dracut has only BOND_OPTS
     if ifcfg.get("BONDING_MASTER") == "yes" or ifcfg.get("TYPE") == "Bond":
-        slaves = get_bond_slaves_from_ifcfgs([devname, ifcfg.get("UUID")])
+        slaves = get_slaves_from_ifcfgs("MASTER", [devname, ifcfg.get("UUID")])
         if slaves:
             kwargs["bondslaves"] = ",".join(slaves)
         bondopts = ifcfg.get("BONDING_OPTS")
@@ -721,6 +726,20 @@ def ifcfg_to_ksdata(ifcfg, devname):
         if teamconfig:
             nd.teamconfig = teamconfig
 
+    # bridging
+    if ifcfg.get("TYPE") == "Bridge":
+        slaves = get_slaves_from_ifcfgs("BRIDGE", [devname, ifcfg.get("UUID")])
+        if slaves:
+            kwargs["bridgeslaves"] = ",".join(slaves)
+
+        bridgeopts = ifcfg.get("BRIDGING_OPTS").replace('_', '-').split()
+        if ifcfg.get("STP"):
+            bridgeopts.append("%s=%s" % ("stp", ifcfg.get("STP")))
+        if ifcfg.get("DELAY"):
+            bridgeopts.append("%s=%s" % ("forward-delay", ifcfg.get("DELAY")))
+        if bridgeopts:
+            kwargs["bridgeopts"] = ",".join(bridgeopts)
+
     return nd
 
 def hostname_ksdata(hostname):
@@ -745,6 +764,8 @@ def find_ifcfg_file_of_device(devname, root_path=""):
         ifcfg_path = find_ifcfg_file([("DEVICE", devname)])
     elif nm.nm_device_type_is_vlan(devname):
         ifcfg_path = find_ifcfg_file([("DEVICE", devname)])
+    elif nm.nm_device_type_is_bridge(devname):
+        ifcfg_path = find_ifcfg_file([("DEVICE", devname)])
     elif nm.nm_device_type_is_ethernet(devname):
         try:
             hwaddr = nm.nm_device_perm_hwaddress(devname)
@@ -762,6 +783,10 @@ def find_ifcfg_file_of_device(devname, root_path=""):
                                               ("TEAM_MASTER", nonempty)],
                                              root_path)
             if not ifcfg_path:
+                ifcfg_path = find_ifcfg_file([("HWADDR", hwaddr_check),
+                                              ("BRIDGE", nonempty)],
+                                             root_path)
+            if not ifcfg_path:
                 ifcfg_path = find_ifcfg_file([("HWADDR", hwaddr_check)], root_path)
         if not ifcfg_path:
             ifcfg_path = find_ifcfg_file([("DEVICE", devname)], root_path)
@@ -783,9 +808,10 @@ def find_ifcfg_file(values, root_path=""):
             return filepath
     return None
 
-def get_bond_slaves_from_ifcfgs(master_specs):
-    """List of slave device names of master specified by master_specs.
+def get_slaves_from_ifcfgs(master_option, master_specs):
+    """List of slaves of master specified by master_specs in master_option.
 
+       master_option is ifcfg option containing spec of master
        master_specs is a list containing device name of master (dracut)
        and/or master's connection uuid
     """
@@ -794,7 +820,7 @@ def get_bond_slaves_from_ifcfgs(master_specs):
     for filepath in _ifcfg_files(netscriptsDir):
         ifcfg = IfcfgFile(filepath)
         ifcfg.read()
-        master = ifcfg.get("MASTER")
+        master = ifcfg.get(master_option)
         if master in master_specs:
             device = ifcfg.get("DEVICE")
             if device:
-- 
1.9.3



More information about the anaconda-patches mailing list