Re: [PATCH 2/3] Make sure multipathd starts on systems using mpath storage (#615040)

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

 



On Wed, 28 Jul 2010, Chris Lumens wrote:

That is unfortunate.  How about this:


[PATCH 2/3] Make sure multipathd starts on systems using mpath storage (#615040)

Multipath storage is currently the only type of storage where we need to
make sure a userspace service is running.  Add in support for us to
expand on this later if necessary.

You're going in the right direction.  However, you won't have a ksdata
object unless you're doing a kickstart install either.  I should have
explained that in the previous mail too, I suppose.

Perhaps what you should do is have a storage.services property that does
the map and set stuff, then have instdata refer to that as well...

diff --git a/instdata.py b/instdata.py
index aefad18..0b60656 100644
--- a/instdata.py
+++ b/instdata.py
@@ -169,6 +169,12 @@ class InstallData:
                                    self.rootPassword["lock"],
                                    algo=self.getPassAlgo())

+        for svc in self.ksdata.services.enabled:
+            iutil.execWithRedirect("/sbin/chkconfig",
+                                   [svc, "on"],
+                                   stdout="/dev/tty5", stderr="/dev/tty5",
+                                   root=self.anaconda.rootPath)
+
         if self.anaconda.isKickstart:
             for svc in self.ksdata.services.disabled:
                 iutil.execWithRedirect("/sbin/chkconfig",

services = self.anaconda.storage.services
if self.anaconda.isKickstart:
   services.extend(self.ksdata.services.enabled)

for svc in services:
   ...

Note that for master, in addition to removing "id", you'll want to use
"if self.ksdata" instead because isKickstart does not exist.

Third iteration:

[PATCH] Make sure multipathd starts on systems using mpath storage (#615040)

Multipath storage is currently the only type of storage where we need to
make sure a userspace service is running.  Add in support for us to
expand on this later if necessary.
---
 instdata.py                 |   16 ++++++++++------
 storage/__init__.py         |    4 ++++
 storage/devices.py          |   33 +++++++++++++++++++++++++++++++++
 storage/formats/__init__.py |    6 ++++++
 4 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/instdata.py b/instdata.py
index aefad18..a01a7ac 100644
--- a/instdata.py
+++ b/instdata.py
@@ -169,19 +169,17 @@ class InstallData:
                                    self.rootPassword["lock"],
                                    algo=self.getPassAlgo())

+        services = list(self.storage.services)
+
         if self.anaconda.isKickstart:
+            services.extend(self.ksdata.services.enabled)
+
             for svc in self.ksdata.services.disabled:
                 iutil.execWithRedirect("/sbin/chkconfig",
                                        [svc, "off"],
                                        stdout="/dev/tty5", stderr="/dev/tty5",
                                        root=self.anaconda.rootPath)

-            for svc in self.ksdata.services.enabled:
-                iutil.execWithRedirect("/sbin/chkconfig",
-                                       [svc, "on"],
-                                       stdout="/dev/tty5", stderr="/dev/tty5",
-                                       root=self.anaconda.rootPath)
-
             for gd in self.ksdata.group.groupList:
                 if not self.users.createGroup(name=gd.name,
                                               gid=gd.gid,
@@ -202,6 +200,12 @@ class InstallData:
                                              gecos=ud.gecos):
                     log.error("User %s already exists, not creating." % ud.name)

+        for svc in services:
+            iutil.execWithRedirect("/sbin/chkconfig",
+                                   [svc, "on"],
+                                   stdout="/dev/tty5", stderr="/dev/tty5",
+                                   root=self.anaconda.rootPath)
+

     def writeKS(self, filename):
         f = open(filename, "w")
diff --git a/storage/__init__.py b/storage/__init__.py
index 42a9142..6ed7678 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -165,6 +165,9 @@ def storageComplete(anaconda):
             if dev.format.type == "luks" and not dev.format.exists:
                 dev.format.passphrase = anaconda.id.storage.encryptionPassphrase

+    map(lambda d: anaconda.id.storage.services.add(d.services),
+        anaconda.id.storage.fsset)
+
     if anaconda.isKickstart:
         return

@@ -289,6 +292,7 @@ class Storage(object):
                                      iscsi=self.iscsi,
                                      dasd=self.dasd)
         self.fsset = FSSet(self.devicetree, self.anaconda.rootPath)
+        self.services = set()

     def doIt(self):
         self.devicetree.processActions()
diff --git a/storage/devices.py b/storage/devices.py
index 8833ae2..e5dd16e 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -199,6 +199,7 @@ class Device(object):

     _type = "generic device"
     _packages = []
+    _services = []

     def __init__(self, name, parents=None):
         """ Create a Device instance.
@@ -370,6 +371,20 @@ class Device(object):
         return packages

     @property
+    def services(self):
+        """ List of services required to manage devices of this type.
+
+            This list includes the services required by its parent devices."
+        """
+        services = self._services
+        for parent in self.parents:
+            for service in parent.services:
+                if service not in services:
+                    services.append(service)
+
+        return services
+
+    @property
     def mediaPresent(self):
         return True

@@ -487,6 +502,23 @@ class StorageDevice(Device):
         return packages

     @property
+    def services(self):
+        """ List of services required to manage devices of this type.
+
+            This list includes the services required by this device's
+            format type as well those required by all of its parent
+            devices.
+        """
+        services = super(StorageDevice, self).services
+        services.extend(self.format.services)
+        for parent in self.parents:
+            for service in parent.format.services:
+                if service not in services:
+                    services.append(service)
+
+        return services
+
+    @property
     def partedDevice(self):
         if self.exists and self.status and not self._partedDevice:
             log.debug("looking up parted Device: %s" % self.path)
@@ -3067,6 +3099,7 @@ class MultipathDevice(DMDevice):
     """ A multipath device """
     _type = "dm-multipath"
     _packages = ["device-mapper-multipath"]
+    _services = ["multipathd"]
     _partitionable = True
     _isDisk = True

diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index 2decf4c..906790c 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -145,6 +145,7 @@ class DeviceFormat(object):
     _supported = False                  # is supported
     _linuxNative = False                # for clearpart
     _packages = []                      # required packages
+    _services = []                      # required services
     _resizable = False                  # can be resized
     _bootable = False                   # can be used as boot
     _migratable = False                 # can be migrated
@@ -341,6 +342,11 @@ class DeviceFormat(object):
         return self._packages

     @property
+    def services(self):
+        """ Services required to manage formats of this type. """
+        return self._services
+
+    @property
     def resizable(self):
         """ Can formats of this type be resized? """
         return self._resizable and self.exists

--
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

_______________________________________________
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