FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 03-17-2009, 02:00 PM
Hans de Goede
 
Default Tell NM not to touch interfaces when / is on a network disk

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
" % 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
")
+ # 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
")
+ 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-17-2009, 02:30 PM
David Lehman
 
Default Tell NM not to touch interfaces when / is on a network disk

On Tue, 2009-03-17 at 15:59 +0100, 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.

My intention with NetworkDevice was for it to be a stripped-down class
to represent a network interface, maybe even contain as an attribute the
"real" network interface instance from network.py. Devices like iscsi
would have the NetworkDevice as one of their parents, so they would have
a way to up/down the interface as needed to set up the device. However,
if this works well then great.


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

Again, not what I had imagined, but I didn't dig down to actually
implementing any network storage devices so maybe my plan was
impractical. The important thing is that it works well and minimizes
unnecessary entanglements, which it seems to do.

Dave

>
> And last if fixes the code in network.py to properly write NM_CONTROLLED=NO
> when / uses a network backed device.
> ---
> 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
" % 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
")
> + # 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
")
> + 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-17-2009, 05:11 PM
Hans de Goede
 
Default Tell NM not to touch interfaces when / is on a network disk

David Lehman wrote:

On Tue, 2009-03-17 at 15:59 +0100, 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.


My intention with NetworkDevice was for it to be a stripped-down class
to represent a network interface, maybe even contain as an attribute the
"real" network interface instance from network.py. Devices like iscsi
would have the NetworkDevice as one of their parents, so they would have
a way to up/down the interface as needed to set up the device. However,
if this works well then great.



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


Again, not what I had imagined, but I didn't dig down to actually
implementing any network storage devices so maybe my plan was
impractical. The important thing is that it works well and minimizes
unnecessary entanglements, which it seems to do.



Ok,

pushed (with some syntax fixes, testing is good). in the future we might have to
revisit this, but for now this works and is pretty clean IMHO.

Regards,

Hans

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

Thread Tools




All times are GMT. The time now is 09:25 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org