You are here: Home V2 Software Software More ... Memops Code Generation Strategy Documents Universal IDs (GUID/UUID)

Universal IDs (GUID/UUID)

Globally unique IDs - which to use and how to generate them Rasmus Fogh 2007

Status

GUIDs are needed for MetaModel objects, and  for API TopObjects. As of May 2007 the same homemade GUID generator is used for both, based on user name, organisation, exact time stamp, and an incremented integer. This is rather weak. It should be OK for MetaModel Elements, created in few places and slowly, but ought to be replaced by something better for TopObjects. See below for possibilities.

NOTE: Python 2.5 and higher has a built-in uuid module. You can chose between versions based on time, node-IDs and fully random.

Information

Generation of universal IDs is still a developing field, apparently. A quick google turns up

http://home.arcor.de/jurner/python/#pkg-uuid-0.3.1

http://sourceforge.net/tracker/index.php?func=detail&aid=1368955&group_id=5470&atid=305470

which are new since Peter sent out his summarising mail

For the time being I am using the uuid generator from

https://lists.ubuntu.com/archives/bazaar-ng/2005q2/000285.html

(in Peters mail). This uses system uuid generators if available, and degrades to pure Python otherwise. As I only need it for the MetaModel there is no need to agonise over the choice. We shall probably need a more careful consideration when we start generating guids for top objects.

 

Peter Kellers original  literature references:

http://www.cs.ucsc.edu/~ejw/scm12/scm12program.php - particularly
Odyssey-VCS

http://msdn.microsoft.com/library/?url=/library/en-us/dnmaj/html/nexgen.asp

OMG lifecycle spec
http://www.omg.org/cgi-bin/doc?ptc/2005-08-01

Some early useful links:

Ludovic Lauer: Concerning Unique Identifiers (http://www.dsps.net/uuid.html)
Peter Keller: http://www.opengroup.org/onlinepubs/9629399/apdxa.htm#tagcjh_20
Rasmus Fogh: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163604

 

The authoritative answer (Peter Keller):
Subject: Re: Core CCPN meeting

Hi Rasmus,

> - The topObjects will have a GUID an (automatically generated) global
> universal identifier as its key. GUIDs are generated in such a way as to
> eb globally unique, and serve to keep track of objects as you move them
> around, merge them, etc. The GUID will be used in all internal object
> references, like interpackage XML links.
>
[snip]

> Peter Keller is looking into a standard and code to make GUIDs.
>

Result: the code to make uuid's is part of the e2fsprogs package (because
it was originally developed to generate uuid's for ext2 filesystems). The
home page is here: http://e2fsprogs.sourceforge.net/

If it is already installed on your system, you should be able to do:

man 3 uuid_generate

You can download the file e2fsprogs-libs-xxx.tar.gz from sourceforge,
which contains only the libraries from the suite (including libuuid) -
this has been packaged specifically so that they can be built and used
independently of the tools to manage ext2 filesystems. I'll try building
it on my SPARC/Solaris system over the weekend, but it looks reasonably
self-contained.

For python: there are two implementations using the e2fsprogs ideas that I
have found.

The first is a python wrapper that uses libuuid if installed, otherwise it
falls back on an internal python implementation. The thread starts at
https://lists.ubuntu.com/archives/bazaar-ng/2005q2/000285.html . Follow
this thread through to the end if you decide to use it - various people
have suggested various changes. I don't know if this has been included in
any standard modules or distributions.


The second seems to be on my system already:

[bernoulli]~-130 > locate Uuid.py
/usr/lib/python2.3/site-packages/Ft/Lib/Uuid.pyc
/usr/lib/python2.3/site-packages/Ft/Lib/Uuid.py
/usr/lib/python2.3/site-packages/Ft/Lib/Uuid.pyo

[bernoulli]~-135 > python
Python 2.3.4 (#1, Feb  2 2005, 11:44:49)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Ft.Lib import Uuid
>>> dir(Uuid)
['CompareUuids', 'GenerateUuid', 'GetEthernetNode', 'GetRandomBytes',
'UuidAsString', '__builtins__', '__doc__', '__file__', '__name__',
'dev_rand', 'rng', 'socket']

This is a pure-python implementation, so is likely to be slow. Once again,
it is based on the e2fsprogs work.

There are several possibilities for window$:

Distribute a mingw-compiled version of libuuid

Find some other way of extracting a uuid from the system

Stick to a pure-python implementation and recommend that people switch
to *ix if they think it is too slow.

Just for fun, I also found this on-line
generator: http://www.somacon.com/p113.php

Regards,
Peter.