FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > 64 Studio > 64 Studio Developer

 
 
LinkBack Thread Tools
 
Old 01-29-2009, 03:30 PM
Joel Granados Moreno
 
Default Make pyblock compatible with new pyparted.

---
device.py | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/device.py b/device.py
index 828f198..2d26b52 100644
--- a/device.py
+++ b/device.py
@@ -335,7 +335,7 @@ class MultiPath:

def get_PedDevice(self):
import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")
@@ -476,22 +476,22 @@ class MultiPath:
dev = self.PedDevice
dev.open()
try:
- disk = _parted.PedDisk.new(dev)
- except _parted.error, msg:
+ disk = _parted.Disk(dev)
+ except _parted.DiskException, msg:
dev.close()
del dev
return
- part = disk.next_partition()
- while part:
- if part.is_active():
- name = "%sp%s" % (self.name, part.num)
+
+ for part in disk.partitions:
+ if part.active:
+ name = "%sp%s" % (self.name, part.number)
bdev = BlockDev(self.prefix + self.name)
bdev.mode = 0600
- map = _PartitionDeviceMap(0, part.geom.length, bdev,
- part.geom.start, part.num)
+ map = _PartitionDeviceMap(0, part.geometry.length, bdev,
+ part.geometry.start, part.number)
map.name = name
yield map
- part = disk.next_partition(part)
+
del disk
dev.close()
del dev
@@ -588,7 +588,7 @@ class RaidSet:

def get_PedDevice(self):
import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")
@@ -757,23 +757,23 @@ class RaidSet:
dev = self.PedDevice
dev.open()
try:
- disk = _parted.PedDisk.new(dev)
- except _parted.error, msg:
+ disk = _parted.Disk(device=dev)
+ except _parted.DiskException, msg:
dev.close()
del dev
return
- part = disk.next_partition()
- while part:
- if part.is_active():
- name = "%sp%s" % (self.name, part.num)
+
+ for part in disk.partitions:
+ if part.active:
+ name = "%sp%s" % (self.name, part.number)
bdev = BlockDev(self.prefix + self.name)
bdev.mode = 0600
- map = _PartitionDeviceMap(0, part.geom.length, bdev,
- part.geom.start, part.num)
+ map = _PartitionDeviceMap(0, part.geometry.length, bdev,
+ part.geometry.start, part.number)
map.name = name
map.create()
self._RaidSet__parts.append(map)
- part = disk.next_partition(part)
+
del disk
dev.close()
del dev
@@ -868,7 +868,7 @@ class RaidDev:

def get_PedDevice(self):
import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-29-2009, 05:52 PM
David Cantrell
 
Default Make pyblock compatible with new pyparted.

Comments:

1) I've pushed a change to pyparted for the 'partitions' property on a
parted.Disk object. You have lines like 'for part in disk.partitions'.
That won't work without the patch I just submitted because I
originally made the partitions property a hash table. After patching
anaconda and seeing your patch for pyblock here, I decided that a
partitions hash table isn't as useful as just as partitions list. Just
a comment, you don't have to change your code. Make sure you have the
latest pyparted if you are testing locally.


2) When you create a parted.Disk, there are two exceptions that can be
raised. If there is a low-level read error on the device, you'll get a
parted.IOException. The other error that could be raised is a
parted.DiskException, which currently only happens if you give
__init__() on parted.Disk something invalid.


Other than that, the patch looks fine. You picked up all of the
property name changes and things like is_active() to just active.


Thanks for jumping on this really quickly.

Joel Granados Moreno wrote:

---
device.py | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/device.py b/device.py
index 828f198..2d26b52 100644
--- a/device.py
+++ b/device.py
@@ -335,7 +335,7 @@ class MultiPath:

def get_PedDevice(self):

import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")
@@ -476,22 +476,22 @@ class MultiPath:
dev = self.PedDevice
dev.open()
try:
- disk = _parted.PedDisk.new(dev)
- except _parted.error, msg:
+ disk = _parted.Disk(dev)
+ except _parted.DiskException, msg:
dev.close()
del dev
return
- part = disk.next_partition()
- while part:
- if part.is_active():
- name = "%sp%s" % (self.name, part.num)
+
+ for part in disk.partitions:
+ if part.active:
+ name = "%sp%s" % (self.name, part.number)
bdev = BlockDev(self.prefix + self.name)
bdev.mode = 0600
- map = _PartitionDeviceMap(0, part.geom.length, bdev,
- part.geom.start, part.num)
+ map = _PartitionDeviceMap(0, part.geometry.length, bdev,
+ part.geometry.start, part.number)
map.name = name
yield map
- part = disk.next_partition(part)
+
del disk
dev.close()
del dev
@@ -588,7 +588,7 @@ class RaidSet:

def get_PedDevice(self):

import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")
@@ -757,23 +757,23 @@ class RaidSet:
dev = self.PedDevice
dev.open()
try:
- disk = _parted.PedDisk.new(dev)
- except _parted.error, msg:
+ disk = _parted.Disk(device=dev)
+ except _parted.DiskException, msg:
dev.close()
del dev
return
- part = disk.next_partition()
- while part:
- if part.is_active():
- name = "%sp%s" % (self.name, part.num)
+
+ for part in disk.partitions:
+ if part.active:
+ name = "%sp%s" % (self.name, part.number)
bdev = BlockDev(self.prefix + self.name)
bdev.mode = 0600
- map = _PartitionDeviceMap(0, part.geom.length, bdev,
- part.geom.start, part.num)
+ map = _PartitionDeviceMap(0, part.geometry.length, bdev,
+ part.geometry.start, part.number)
map.name = name
map.create()
self._RaidSet__parts.append(map)
- part = disk.next_partition(part)
+
del disk
dev.close()
del dev
@@ -868,7 +868,7 @@ class RaidDev:

def get_PedDevice(self):

import parted as _parted
- ret = _parted.PedDevice.get(self.bdev.path)
+ ret = _parted.getDevice(self.bdev.path)
del _parted
return ret
PedDevice = property(get_PedDevice, None, None, "parted.PedDevice")



--
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
 
Old 01-30-2009, 08:35 AM
Joel Granados
 
Default Make pyblock compatible with new pyparted.

----- "David Cantrell" <dcantrell@redhat.com> wrote:

> Comments:
>
> 1) I've pushed a change to pyparted for the 'partitions' property on a
>
> parted.Disk object. You have lines like 'for part in
> disk.partitions'.
> That won't work without the patch I just submitted because I
> originally made the partitions property a hash table. After patching
>
> anaconda and seeing your patch for pyblock here, I decided that a
> partitions hash table isn't as useful as just as partitions list.
> Just
> a comment, you don't have to change your code. Make sure you have the
>
> latest pyparted if you are testing locally.
>
> 2) When you create a parted.Disk, there are two exceptions that can be
>
> raised. If there is a low-level read error on the device, you'll get
> a
> parted.IOException. The other error that could be raised is a
> parted.DiskException, which currently only happens if you give
> __init__() on parted.Disk something invalid.

Ok, will modify the code to take into account the exceptions. And will also get some testing to see what happens

Thx for the review.

>
> Other than that, the patch looks fine. You picked up all of the
> property name changes and things like is_active() to just active.
>
> Thanks for jumping on this really quickly.
>
> Joel Granados Moreno wrote:
> > ---
> > device.py | 42 +++++++++++++++++++++---------------------
> > 1 files changed, 21 insertions(+), 21 deletions(-)
> >
> > diff --git a/device.py b/device.py
> > index 828f198..2d26b52 100644
> > --- a/device.py
> > +++ b/device.py
> > @@ -335,7 +335,7 @@ class MultiPath:
> >
> > def get_PedDevice(self):
> > import parted as _parted
> > - ret = _parted.PedDevice.get(self.bdev.path)
> > + ret = _parted.getDevice(self.bdev.path)
> > del _parted
> > return ret
> > PedDevice = property(get_PedDevice, None, None,
> "parted.PedDevice")
> > @@ -476,22 +476,22 @@ class MultiPath:
> > dev = self.PedDevice
> > dev.open()
> > try:
> > - disk = _parted.PedDisk.new(dev)
> > - except _parted.error, msg:
> > + disk = _parted.Disk(dev)
> > + except _parted.DiskException, msg:
> > dev.close()
> > del dev
> > return
> > - part = disk.next_partition()
> > - while part:
> > - if part.is_active():
> > - name = "%sp%s" % (self.name, part.num)
> > +
> > + for part in disk.partitions:
> > + if part.active:
> > + name = "%sp%s" % (self.name, part.number)
> > bdev = BlockDev(self.prefix + self.name)
> > bdev.mode = 0600
> > - map = _PartitionDeviceMap(0, part.geom.length,
> bdev,
> > - part.geom.start, part.num)
> > + map = _PartitionDeviceMap(0, part.geometry.length,
> bdev,
> > + part.geometry.start, part.number)
> > map.name = name
> > yield map
> > - part = disk.next_partition(part)
> > +
> > del disk
> > dev.close()
> > del dev
> > @@ -588,7 +588,7 @@ class RaidSet:
> >
> > def get_PedDevice(self):
> > import parted as _parted
> > - ret = _parted.PedDevice.get(self.bdev.path)
> > + ret = _parted.getDevice(self.bdev.path)
> > del _parted
> > return ret
> > PedDevice = property(get_PedDevice, None, None,
> "parted.PedDevice")
> > @@ -757,23 +757,23 @@ class RaidSet:
> > dev = self.PedDevice
> > dev.open()
> > try:
> > - disk = _parted.PedDisk.new(dev)
> > - except _parted.error, msg:
> > + disk = _parted.Disk(device=dev)
> > + except _parted.DiskException, msg:
> > dev.close()
> > del dev
> > return
> > - part = disk.next_partition()
> > - while part:
> > - if part.is_active():
> > - name = "%sp%s" % (self.name, part.num)
> > +
> > + for part in disk.partitions:
> > + if part.active:
> > + name = "%sp%s" % (self.name, part.number)
> > bdev = BlockDev(self.prefix + self.name)
> > bdev.mode = 0600
> > - map = _PartitionDeviceMap(0, part.geom.length,
> bdev,
> > - part.geom.start, part.num)
> > + map = _PartitionDeviceMap(0, part.geometry.length,
> bdev,
> > + part.geometry.start, part.number)
> > map.name = name
> > map.create()
> > self._RaidSet__parts.append(map)
> > - part = disk.next_partition(part)
> > +
> > del disk
> > dev.close()
> > del dev
> > @@ -868,7 +868,7 @@ class RaidDev:
> >
> > def get_PedDevice(self):
> > import parted as _parted
> > - ret = _parted.PedDevice.get(self.bdev.path)
> > + ret = _parted.getDevice(self.bdev.path)
> > del _parted
> > return ret
> > PedDevice = property(get_PedDevice, None, None,
> "parted.PedDevice")
>
>
> --
> 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

--
Joel Andres Granados
Red Hat / Brno Czech Republic

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-30-2009, 09:56 AM
Joel Granados
 
Default Make pyblock compatible with new pyparted.

Hey David:

After some consideration I have some questions ( comments bellow ), Guess I'm looking for some granularity.
----- "David Cantrell" <dcantrell@redhat.com> wrote:


>
> parted.IOException. The other error that could be raised is a

I think an IO error is pretty serious and should be propagated to the caller. In this specific situation, when you are doing a raidSet.activate() and there is some IO error with the set, it will raise an exception. Anaconda or whoever is calling should decide what to do.

> parted.DiskException, which currently only happens if you give
> __init__() on parted.Disk something invalid.

Guess this would only happen if parted.getDevice() went wrong, in which case the DeviceException would be received by the caller.

My Questions
What does pyparted do in these cases?:
1. when I try to open a device with no label (partition table).
2. when I try to open a device with a label but with no partitions.
3. when I try to open a device with a corrupt label.
4. when I try to get a disk from a device with corrupt label.
5. when I try to get a disk from a device valid label but with no partitions.
6. when I try to get a disk of a device with no label.
7. when I try to list partitions of a disk of a device with no label (if its possible to reach this situation)
8. when I try to list partitions of a valid disk with no partitions.
9. when I try to open a device from a device that is physically corrupt (IOerror)

IMO this is what could be returned.
1,2,3:
Should return a device, the only time a device should not be returned is when an IOerror occurs.

4,6:
should not create the disk and should give me an exception (or some way of telling that it has no label, like a special state of the disk object). The no label situation should be ignored in pyblocks case and should not be propagated to caller. we might want to propagate the corrupt label, thats discussable though.

5:
Should create a disk object.

7:
This state, IMO, should not be reached.

8:
should return something lik [].

9:
IOerror exception.

Pls note that I'm only referring to reading the partition table.

Regards.
--
Joel Andres Granados
Red Hat / Brno Czech Republic

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 02:20 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org