Move UUID generation stuff to a reutilizable place

Change-Id: Idae862f7095d9e6298e9c3541f588fd7f928f3d6