Re: [PATCH 2/2] Tell NM not to touch interfaces when / is on a network disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Hans de Goede wrote:
This patch renames storage.NetworkDevice to storage.NetworkStorageDevice,
as NetworkDevice as classname also is used in network.py .

It also changes NetworkStorageDevice so that it does not inherit from Device,
as it is now intended for use in multiple inheritance together with
StorageDevice (or a derived class) as explained further in the comments
in the code.

Then this patch changes iScsiDiskDevice and NFSDevice to additional inherit
from NetworkStorageDevice (next to what they were already inheriting from.

And last if fixes the code in network.py to properly write NM_CONTROLLED=NO
when / uses a network backed device.

Note this one is currently untested (rather slow test cycle), but I still send it
to get some comments before I spend time testing it only to get the whole concept
of it burned down afterwards :)

Regards,

Hans



---
 network.py         |   13 ++++++++-----
 storage/devices.py |   35 +++++++++++++++++++----------------
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/network.py b/network.py
index 4a2eca9..0b0571e 100644
--- a/network.py
+++ b/network.py
@@ -581,14 +581,17 @@ class Network:
                 f.write("MTU=%s\n" % dev.get('MTU'))
# tell NetworkManager not to touch any interfaces used during
-            # installation when / is on a network device. Ideally we would only
-            # tell NM not to touch the interface(s) actually used for /, but we
-            # have no logic to determine that
+            # installation when / is on a network backed device.
             if anaconda is not None:
                 import storage
                 rootdev = anaconda.id.storage.fsset.rootDevice
-                if isinstance(rootdev, storage.devices.NetworkDevice):
-                    f.write("NM_CONTROLLED=no\n")
+                # FIXME: use device.host_address to only add "NM_CONTROLLED=no"
+                # for interfaces actually used enroute to the device
+                for device in anaconda.id.storage.devices:
+                    if rootdev.dependsOn(device) and isinstance(device,
+                                        storage.devices.NetworkStorageDevice):
+                        f.write("NM_CONTROLLED=no\n")
+                        break
f.close()
             os.chmod(newifcfg, 0644)
diff --git a/storage/devices.py b/storage/devices.py
index 2d283fc..34cb607 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -405,25 +405,26 @@ class Device(object):
         return True
-class NetworkDevice(Device):
-    """ A network device """
-    _type = "network device"
+class NetworkStorageDevice:
+    """ Virtual base class for network backed storage devices """
- def __init__(self, name, parents=None):
-        """ Create a NetworkDevice instance.
+    def __init__(self, host_address):
+        """ Create a NetworkStorage Device instance. Note this class is only
+            to be used as a baseclass and then only with multiple inheritance.
+            The only correct use is:
+            class MyStorageDevice(StorageDevice, NetworkStorageDevice):
- Arguments:
-
-                name -- the device name (generally an interface name)
-
-            Keyword Arguments:
+            The sole purpose of this class is to:
+            1) Be able to check if a StorageDevice is network backed
+               (using isinstance).
+            2) To be able to get the host address of the host (server) backing
+               the storage.
- parents -- a list of required Device instances
-                description -- a string describing the device
+            Arguments:
+ host_address -- host address of the backing server
         """
-        Device.__init__(self, name, parents=parents)
-        self.active = False
+        self.host_address = host_address
class StorageDevice(Device):
@@ -2656,7 +2657,7 @@ class DirectoryDevice(FileDevice):
         self.exists = False
-class iScsiDiskDevice(DiskDevice):
+class iScsiDiskDevice(DiskDevice, NetworkStorageDevice):
     """ An iSCSI disk. """
     _type = "iscsi"
     _packages = ["iscsi-initiator-utils"]
@@ -2669,6 +2670,7 @@ class iScsiDiskDevice(DiskDevice):
         del kwargs["iscsi_address"]
         del kwargs["iscsi_port"]
         DiskDevice.__init__(self, device, **kwargs)
+        NetworkStorageDevice.__init__(self.iscsi_address)
         log.debug("created new iscsi disk %s %s:%d" % (self.iscsi_name, self.iscsi_address, self.iscsi_port))
class OpticalDevice(StorageDevice):
@@ -2806,13 +2808,14 @@ class PRePBootDevice(PartitionDevice):
                                  parents=parents, primary=primary)
-class NFSDevice(StorageDevice):
+class NFSDevice(StorageDevice, NetworkStorageDevice):
     """ An NFS device """
     _type = "nfs"
def __init__(self, device, format=None, parents=None):
         # we could make host/ip, path, &c but will anything use it?
         StorageDevice.__init__(device, format=format, parents=parents)
+        NetworkStorageDevice.__init__(device.split(":")[0])
@property
     def path(self):

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux