Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Masters Of The Universe (http://www.linux-archive.org/ubuntu-masters-universe/)
-   -   Fix PartitionSpec.getActualSize() (http://www.linux-archive.org/ubuntu-masters-universe/244145-fix-partitionspec-getactualsize.html)

David Cantrell 02-11-2009 11:54 PM

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

Martin Sivak 02-12-2009 11:54 AM

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

David Cantrell 02-12-2009 07:16 PM

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

Martin Sivak 02-13-2009 08:51 AM

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

David Cantrell 02-16-2009 10:16 PM

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 04:25 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.