Create schema: dmedia/drive and dmedia/partition.

Bug #812048 reported by David Green
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Dmedia
In Progress
High
David Green

Bug Description

This is related to:
    lp:692449
    lp:714941

I've created a simple udisks wrapper in lp:~david4dev/dmedia/udisks .

We need a way to store drive and partition information for imports and file stores. IMO the best way to do this is through separate schema for partition and drive. That way imports and file stores could simply link to the document for the partition (which itself could link to the drive).

I suggest something like this for the partition schema:

    >>> doc = {
    ... '_id': '1a123456-ab12-1ab2-12a3-1abcd12ab1a2',
    ... 'type': 'dmedia/partition',
    ... 'size':140123456789,
    ... 'label':'Data',
    ... 'partition_label':'',
    ... 'fs':'ext4',
    ... 'drive':'irojEJDwkdmsoJQDIWDKOW'
    ... }

Where _id is the UUID (http://hal.freedesktop.org/docs/udisks/Device.html#Device:IdUuid). size is the number of bytes capacity (http://hal.freedesktop.org/docs/udisks/Device.html#Device:PartitionSize). label is the label that you see in the file manager (http://hal.freedesktop.org/docs/udisks/Device.html#Device:IdLabel) and partition_label is the partition label (http://hal.freedesktop.org/docs/udisks/Device.html#Device:PartitionLabel) which are actually different things. fs is the filesystem type (http://hal.freedesktop.org/docs/udisks/Device.html#Device:IdType). drive links to the _id of the drive.

Something like this for the drive schema:

    >>> doc = {
    ... '_id': 'irojEJDwkdmsoJQDIWDKOW',
    ... 'type': 'dmedia/device',
    ... 'size':238123456789,
    ... 'serial':'3MH05AVA',
    ... 'wwn':'50014ee0016eb572',
    ... 'vendor':'BELKIN',
    ... 'model':'ST910021AS',
    ... 'revision':'3.07'
    ... }

Where _id is a random id. size is the drive size in bytes. serial is the drive serial (http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveSerial). wwn is the dive World Wide Number (http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveWwn). vendor is the drive vendor (http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveVendor). model is the drive model (http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveModel). revision is the drive revision (http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveRevision).

So the filestore and import schema can have a 'partition' key which has the value of the _id or the partition document.

Does this make sense?

Tags: udisk

Related branches

Changed in dmedia:
status: New → Triaged
importance: Undecided → High
David Green (david4dev)
Changed in dmedia:
assignee: nobody → David Green (david4dev)
tags: added: udisk
Revision history for this message
David Green (david4dev) wrote :

Actually I think the _id of dmedia/drive shouldn't be a random string because that has no relation to the actual drive. This means we might unintentionally get several entries for the same drive.

We really need a functional mapping of a drive to an id and I was thinking we could use the serial for this. The only thing holding me back is the possibility that serial is unknown and therefore blank (see: http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveSerial ).

Perhaps we could use a hash of the information we have. Something like this:

    hashlib.md5("%s-%s-%s-%s-%s" % (vendor,model,revision,serial,wwn)).hexdigest()

I know md5 isn't the most secure hashing algorithm but it's realistically good enough for this use case and gives a relatively terse id (only 32 characters).

Any feedback on this?

Revision history for this message
David Green (david4dev) wrote :

Actually,

    b32encode(sha1("%s-%s-%s-%s-%s" % (vendor,model,revision,serial,wwn)).digest())

would be a better approach.

David Green (david4dev)
Changed in dmedia:
status: Triaged → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.