summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-03-17 19:06:57 +0100
committerHans de Goede <hdegoede@redhat.com>2009-03-17 19:08:38 +0100
commit164e80fd66563a410579df3d1a521e7557621a71 (patch)
tree949b0944b2c99b5294fadc6000c627c902a043ff
parent2a6e841778c7b75fa09e8396d0ad9777b0a6c0e0 (diff)
downloadanaconda-164e80fd66563a410579df3d1a521e7557621a71.tar.gz
anaconda-164e80fd66563a410579df3d1a521e7557621a71.tar.xz
anaconda-164e80fd66563a410579df3d1a521e7557621a71.zip
Tell NM not to touch interfaces when / is on a network disk
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.
-rw-r--r--network.py13
-rw-r--r--storage/devices.py37
2 files changed, 28 insertions, 22 deletions
diff --git a/network.py b/network.py
index 4a2eca9d5..5dc9060f0 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 d in anaconda.id.storage.devices:
+ if rootdev.dependsOn(d) and isinstance(d,
+ 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 c9d63fc42..c74233763 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(object):
+ """ 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"]
@@ -2666,6 +2667,7 @@ class iScsiDiskDevice(DiskDevice):
self.iscsi_address = kwargs.pop("iscsi_address")
self.iscsi_port = int(kwargs.pop("iscsi_port"))
DiskDevice.__init__(self, device, **kwargs)
+ NetworkStorageDevice.__init__(self, self.iscsi_address)
log.debug("created new iscsi disk %s %s:%d" % (self.iscsi_name, self.iscsi_address, self.iscsi_port))
class OpticalDevice(StorageDevice):
@@ -2803,13 +2805,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)
+ StorageDevice.__init__(self, device, format=format, parents=parents)
+ NetworkStorageDevice.__init__(self, device.split(":")[0])
@property
def path(self):