Fix PartitionSpec.getActualSize()
Fix autopart run with the new pyparted.
--- partRequests.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/partRequests.py b/partRequests.py index e9b86c9..d4b41ce 100644 --- a/partRequests.py +++ b/partRequests.py @@ -522,11 +522,11 @@ class PartitionSpec(RequestSpec): for drive in self.drive: part = diskset.disks[drive].getPartitionByPath("/dev/%s" % self.device) - if not part: - # XXX kickstart might still call this before allocating the partitions - raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet" + if part: + size += part.getSize(unit="MB") - size += part.getSize(unit="MB") + if size == 0: + return self.requestSize return size -- 1.6.1.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Fix PartitionSpec.getActualSize()
The code looks ok, but i wonder why to use if not drive: ... if drive: ... instead of the plain and simple if drive: .. else: ...
Martin ----- "David Cantrell" <dcantrell@redhat.com> wrote: > Fix autopart run with the new pyparted. > --- > partRequests.py | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/partRequests.py b/partRequests.py > index e9b86c9..d4b41ce 100644 > --- a/partRequests.py > +++ b/partRequests.py > @@ -522,11 +522,11 @@ class PartitionSpec(RequestSpec): > for drive in self.drive: > part = diskset.disks[drive].getPartitionByPath("/dev/%s" > % self.device) > > - if not part: > - # XXX kickstart might still call this before > allocating the partitions > - raise RuntimeError, "Checking the size of a partition > which hasn't been allocated yet" > + if part: > + size += part.getSize(unit="MB") > > - size += part.getSize(unit="MB") > + if size == 0: > + return self.requestSize > > return size > > -- > 1.6.1.3 > > _______________________________________________ > Anaconda-devel-list mailing list > Anaconda-devel-list@redhat.com > https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Fix PartitionSpec.getActualSize()
Not following the question. self.drive is a list of drives, so iterate
over that and try to get a parted.Partition for the device on that drive. Add in the size of that partition. Failing all that, return requestSize. The reason I'm iterating over request.drive is because it can be a list and in my mind, that's valid for things like RAID. But all of this code is likely to vanish soon anyway. Just what we have now. Martin Sivak wrote: The code looks ok, but i wonder why to use if not drive: ... if drive: ... instead of the plain and simple if drive: .. else: ... Martin ----- "David Cantrell" <dcantrell@redhat.com> wrote: Fix autopart run with the new pyparted. --- partRequests.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/partRequests.py b/partRequests.py index e9b86c9..d4b41ce 100644 --- a/partRequests.py +++ b/partRequests.py @@ -522,11 +522,11 @@ class PartitionSpec(RequestSpec): for drive in self.drive: part = diskset.disks[drive].getPartitionByPath("/dev/%s" % self.device) - if not part: - # XXX kickstart might still call this before allocating the partitions - raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet" + if part: + size += part.getSize(unit="MB") - size += part.getSize(unit="MB") + if size == 0: + return self.requestSize return size -- 1.6.1.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list -- David Cantrell <dcantrell@redhat.com> Red Hat / Honolulu, HI _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Fix PartitionSpec.getActualSize()
Yep the iteration is ok but the part:
>if not part: > raise RuntimeError, "Checking the size of a .. " >if part: > size += part.getSize(unit="MB") why not use If: .. else: .. It is just cosmetic, so no big deal.. the patch itself looks ok ----- "David Cantrell" <dcantrell@redhat.com> wrote: > Not following the question. self.drive is a list of drives, so > iterate > over that and try to get a parted.Partition for the device on that > drive. Add in the size of that partition. Failing all that, return > requestSize. > > The reason I'm iterating over request.drive is because it can be a > list > and in my mind, that's valid for things like RAID. But all of this > code > is likely to vanish soon anyway. Just what we have now. > > Martin Sivak wrote: > > The code looks ok, but i wonder why to use if not drive: ... if > drive: ... instead of the plain and simple if drive: .. else: ... > > > > Martin > > > > ----- "David Cantrell" <dcantrell@redhat.com> wrote: > > > >> Fix autopart run with the new pyparted. > >> --- > >> partRequests.py | 8 ++++---- > >> 1 files changed, 4 insertions(+), 4 deletions(-) > >> > >> diff --git a/partRequests.py b/partRequests.py > >> index e9b86c9..d4b41ce 100644 > >> --- a/partRequests.py > >> +++ b/partRequests.py > >> @@ -522,11 +522,11 @@ class PartitionSpec(RequestSpec): > >> for drive in self.drive: > >> part = > diskset.disks[drive].getPartitionByPath("/dev/%s" > >> % self.device) > >> > >> - if not part: > >> - # XXX kickstart might still call this before > >> allocating the partitions > >> - raise RuntimeError, "Checking the size of a > partition > >> which hasn't been allocated yet" > >> + if part: > >> + size += part.getSize(unit="MB") > >> > >> - size += part.getSize(unit="MB") > >> + if size == 0: > >> + return self.requestSize > >> > >> return size > >> > >> -- > >> 1.6.1.3 > >> > >> _______________________________________________ > >> Anaconda-devel-list mailing list > >> Anaconda-devel-list@redhat.com > >> https://www.redhat.com/mailman/listinfo/anaconda-devel-list > > > > _______________________________________________ > > Anaconda-devel-list mailing list > > Anaconda-devel-list@redhat.com > > https://www.redhat.com/mailman/listinfo/anaconda-devel-list > > > -- > David Cantrell <dcantrell@redhat.com> > Red Hat / Honolulu, HI > > _______________________________________________ > Anaconda-devel-list mailing list > Anaconda-devel-list@redhat.com > https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Fix PartitionSpec.getActualSize()
Martin Sivak wrote:
Yep the iteration is ok but the part: if not part: raise RuntimeError, "Checking the size of a .. " if part: size += part.getSize(unit="MB") why not use If: .. else: .. It is just cosmetic, so no big deal.. the patch itself looks ok The 'if not part' block is gone in the patch. The only thing that happens in the loop is each part is obtained and if it exists, getSize() is called and the size is added in to the size variable. ----- "David Cantrell" <dcantrell@redhat.com> wrote: Not following the question. self.drive is a list of drives, so iterate over that and try to get a parted.Partition for the device on that drive. Add in the size of that partition. Failing all that, return requestSize. The reason I'm iterating over request.drive is because it can be a list and in my mind, that's valid for things like RAID. But all of this code is likely to vanish soon anyway. Just what we have now. Martin Sivak wrote: The code looks ok, but i wonder why to use if not drive: ... if drive: ... instead of the plain and simple if drive: .. else: ... Martin ----- "David Cantrell" <dcantrell@redhat.com> wrote: Fix autopart run with the new pyparted. --- partRequests.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/partRequests.py b/partRequests.py index e9b86c9..d4b41ce 100644 --- a/partRequests.py +++ b/partRequests.py @@ -522,11 +522,11 @@ class PartitionSpec(RequestSpec): for drive in self.drive: part = diskset.disks[drive].getPartitionByPath("/dev/%s" % self.device) - if not part: - # XXX kickstart might still call this before allocating the partitions - raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet" + if part: + size += part.getSize(unit="MB") - size += part.getSize(unit="MB") + if size == 0: + return self.requestSize return size -- 1.6.1.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list -- David Cantrell <dcantrell@redhat.com> Red Hat / Honolulu, HI _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list -- David Cantrell <dcantrell@redhat.com> Red Hat / Honolulu, HI _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
| All times are GMT. The time now is 11:53 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.