[PATCH 2/4] Add a DiskFile class for testing partitioning code as a non-root user.
Vratislav Podzimek
vpodzime at redhat.com
Fri Jul 25 06:13:47 UTC 2014
On Thu, 2014-07-24 at 10:42 -0400, Anne Mulhern wrote:
>
>
>
> ----- Original Message -----
> > From: "David Lehman" <dlehman at redhat.com>
> > To: anaconda-patches at lists.fedorahosted.org
> > Sent: Wednesday, July 23, 2014 5:04:26 PM
> > Subject: [PATCH 2/4] Add a DiskFile class for testing partitioning code as a non-root user.
> >
> > There seems to be some special treatment from parted (first free sector
> > is reported as 32) but the main purpose is to test partitioning code
> > without committing the changes to disk. It may be perfectly viable to
> > commit to these devices, but I haven't tried it yet. My intention is to
> > write unit tests for things like partition allocation -- which require
> > parted Device and Disk instances -- without requiring root access.
> > ---
> > blivet/devices.py | 29 +++++++++++++++++++++++++++++
> > 1 file changed, 29 insertions(+)
> >
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 1028817..dfdea44 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -1234,6 +1234,35 @@ class DiskDevice(StorageDevice):
> >
> > StorageDevice._preDestroy(self)
> >
> > +class DiskFile(DiskDevice):
> > + """ This is a file that we will pretend is a disk. """
> > + _devDir = ""
> > +
> > + def __init__(self, name, fmt=None,
> > + size=None, major=None, minor=None, sysfsPath='',
> > + parents=None, serial=None, vendor="", model="", bus="",
> > + exists=True):
> > + _name = os.path.basename(name)
> > + self._devDir = os.path.dirname(name)
> > +
> > + super(DiskFile, self).__init__(_name, fmt=fmt, size=size,
> > + major=major, minor=minor, sysfsPath=sysfsPath,
> > + parents=parents, serial=serial, vendor=vendor,
> > + model=model, bus=bus, exists=exists)
> > +
> > + #
> > + # Regular files do not have sysfs entries.
> > + #
> > + @property
> > + def sysfsPath(self):
> > + return ""
> > +
> > + @sysfsPath.setter
> > + def sysfsPath(self, value):
> > + pass
> > +
> > + def updateSysfsPath(self):
> > + pass
> >
> > class PartitionDevice(StorageDevice):
> > """ A disk partition.
> > --
> > 1.9.3
> >
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> >
>
> It would be helpful to document that the class
> is not intended to represent a real device. Maybe
> it should find its home somewhere in testing subdirectory instead of blivet
> subdirectory, as more appropriate to its intended use.
I don't agree with moving the class. We should provide this class to
users of Blivet for their tests. A bit clearer documentation would, of
course, be useful.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list