[blivet:master 07/25] Override resize() method in subclasses of StorageDevice
Anne Mulhern
amulhern at redhat.com
Tue Apr 22 14:35:55 UTC 2014
----- Original Message -----
> From: "David" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Monday, April 21, 2014 10:37:16 AM
> Subject: Re: [blivet:master 07/25] Override resize() method in subclasses of StorageDevice
>
>
> On 04/16/2014 04:54 PM, mulhern wrote:
> > Now raises an exception other than NotImplementedError to keep pylint
> > happy.
> >
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> > blivet/devices.py | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 09127e9..6a88c6d 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -1147,6 +1147,9 @@ class DiskDevice(StorageDevice):
> > def description(self):
> > return self.model
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> > +
>
> I think it would make more sense to redefine StorageDevice.resize than
> to make classes that already inherit "resizable = False" define a resize
> method that is pure boilerplate.
>
> > @property
> > def size(self):
> > """ The disk's size """
> > @@ -1989,6 +1992,8 @@ class DMDevice(StorageDevice):
> > """ This device's backing device. """
> > return self.parents[0]
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class DMLinearDevice(DMDevice):
> > _type = "dm-linear"
> > @@ -2249,6 +2254,9 @@ class ContainerDevice(StorageDevice):
> > if member in self.parents:
> > self.parents.remove(member)
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> > +
> > class LVMVolumeGroupDevice(ContainerDevice):
> > """ An LVM Volume Group
> >
> > @@ -3919,6 +3927,8 @@ class NoDevice(StorageDevice):
> > log_method_call(self, self.name, status=self.status)
> > self._preDestroy()
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class TmpFSDevice(NoDevice):
> > """ A nodev device for a tmpfs filesystem. """
> > @@ -4038,6 +4048,8 @@ class FileDevice(StorageDevice):
> > log_method_call(self, self.name, status=self.status)
> > os.unlink(self.path)
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class SparseFileDevice(FileDevice):
> > """A sparse file on a filesystem.
> > @@ -4151,6 +4163,8 @@ class LoopDevice(StorageDevice):
> > def slave(self):
> > return self.parents[0]
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class iScsiDiskDevice(DiskDevice, NetworkStorageDevice):
> > """ An iSCSI disk. """
> > @@ -4338,6 +4352,8 @@ class OpticalDevice(StorageDevice):
> > except OSError as e:
> > log.warning("error ejecting cdrom %s: %s", self.name, e)
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class ZFCPDiskDevice(DiskDevice):
> > """ A mainframe ZFCP disk. """
> > @@ -4503,6 +4519,8 @@ class NFSDevice(StorageDevice, NetworkStorageDevice):
> > """ Destroy the device. """
> > log_method_call(self, self.name, status=self.status)
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> >
> > class BTRFSDevice(StorageDevice):
> > """ Base class for BTRFS volume and sub-volume devices. """
> > @@ -4594,6 +4612,9 @@ class BTRFSDevice(StorageDevice):
> > spec = super(BTRFSDevice, self).fstabSpec
> > return spec
> >
> > + def resize(self):
> > + raise errors.DeviceError("Cannot resize disk %s, because it has
> > type %s" % (self, self.type))
> > +
> > class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice):
> > _type = "btrfs volume"
> > vol_id = btrfs.MAIN_VOLUME_ID
>
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>
Ok. I think it'll need a bit more thought, so I'm withdrawing it from this patch set.
- mulhern
More information about the anaconda-patches
mailing list