Re: [PATCH 1/2] Make the fcoe, iscsi and zfcp classes singletons

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

 



Would it be good to also make class DASD in storage/dasd.py a singleton,
even though we currently do not use it early in kickstart yet because it
does not activate DASDs but only low-level format them if necessary?

On 12/14/2009 04:21 PM, Hans de Goede wrote:
> The fcoe, iscsi and zfcp classes are designed to be instantiated only once,
> currently this is not enforced. This is causing trouble as their single
> instantiation currently is done in storage.__init__, which means they cannot
> be used before instData is instantiated, as that instantiates storage.
> 
> However we need them to connect to fcoe, iscsi and/or zfcp drives while
> parsing kickstart files (so the drivers can be referenced by UUID /
> /dev/disk/by-path / whatever), and instData is not yet instantiated at that
> time.
> 
> So this patch uses a very simple Singleton design pattern, so that we can
> instantiate them where ever we need them, and all references returned will
> will point to one shared global instance.
> ---
>  storage/fcoe.py  |   19 +++++++++++++++++++
>  storage/iscsi.py |   20 ++++++++++++++++++++
>  storage/zfcp.py  |   18 ++++++++++++++++++
>  3 files changed, 57 insertions(+), 0 deletions(-)
> 
> diff --git a/storage/fcoe.py b/storage/fcoe.py
> index 906c8c0..5a09f5d 100644
> --- a/storage/fcoe.py
> +++ b/storage/fcoe.py

> diff --git a/storage/iscsi.py b/storage/iscsi.py
> index 5bf6d28..809e266 100644
> --- a/storage/iscsi.py
> +++ b/storage/iscsi.py

> diff --git a/storage/zfcp.py b/storage/zfcp.py
> index 47271b9..7692cad 100644
> --- a/storage/zfcp.py
> +++ b/storage/zfcp.py
> @@ -323,11 +323,26 @@ class ZFCPDevice:
>          return True
> 
>  class ZFCP:
> +    """ ZFCP utility class.
> +
> +        This class will automatically online to ZFCP drives configured in
> +        /tmp/fcpconfig when the startup() method gets called. It can also be
> +        used to manually configure ZFCP devices through the addFCP() method.
> +
> +        As this class needs to make sure that /tmp/fcpconfig configured
> +        drives are only onlined once and as it keeps a global list of all ZFCP
> +        devices it is implemented as a Singleton.
> +    """
> +
>      def __init__(self):
>          self.fcpdevs = []
>          self.hasReadConfig = False
>          self.down = True
> 
> +    # So that users can write zfcp() to get the singleton instance
> +    def __call__(self):
> +        return self
> +
>      def readConfig(self):
>          try:
>              f = open("/tmp/fcpconfig", "r")
> @@ -420,4 +435,7 @@ class ZFCP:
>          f.write("alias scsi_hostadapter zfcp\n")
>          f.close()
> 
> +# Create ZFCP singleton
> +ZFCP = ZFCP()
> +
>  # vim:tw=78:ts=4:et:sw=4

Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
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