bugfix: Fix regexp in "kimchi.utils.get_next_clone_name"

The regular expression used in the function
"kimchi.utils.get_next_clone_name" has an extra '-' which
isn't needed.

The following commands, executed from an interactive Python shell,
demonstrate the bug:

>>> from kimchi.utils import get_next_clone_name
>>> get_next_clone_name(['foo'], 'index', '.html')
u'index-clone-1.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html'], 'index', '.html')
u'index-clone-1.html'

Even though the name 'index-clone-1.html' is provided as an existing
name, the function still returns a duplicate value.

Fix the regular expression by removing an unnecessary character.

The following commands demonstrate the bug fix:

>>> from kimchi.utils import get_next_clone_name
>>> get_next_clone_name(['foo'], 'index', '.html')
u'index-clone-1.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html'], 'index', '.html')
u'index-clone-2.html'
>>> get_next_clone_name(['foo', 'index-clone-1.html', 'index-clone-2.html'], 'index', '.html')
u'index-clone-3.html'

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
issue #543: Generate unique names when creating volumes without name

If the user creates a volume without setting its name, Kimchi generates a
default value. However, another volume with that generated name may
already exist and the volume creation may fail.

The following commands demonstrate the issue:

$ kimchi_rest /storagepools/default/storagevolumes | grep name
    "name":"60f46fdc-8ecc-4601-90d6-b3b44d35c337-0.img",
    "name":"bdd22e7c-7794-4bdf-8d2b-0089242c8b16-0.img",
    "name":"c16a7e02-6dcf-48c5-83de-1bb2d8a110a8-0.img",

$ kimchi_rest -m POST /storagepools/default/storagevolumes '{"url": "http://www.google.com/index.html"}'
{
  "status":"running",
  "message":"OK",
  "id":"2",
  "target_uri":"/storagepools/default/storagevolumes/index.html"
}

$ kimchi_rest -m POST /storagepools/default/storagevolumes '{"url": "http://www.google.com/index.html"}'
{
  "reason":"KCHVOL0001E: Storage volume index.html already exists",
  "code":"400 Bad Request",
  "call_stack":"Traceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py\", line 656, in respond\n    response.body = self.handler()\n  File \"/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py\", line 188, in __call__\n    self.body = self.oldhandler(*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py\", line 34, in __call__\n    return self.callable(*self.args, **self.kwargs)\n  File \"/home/vianac/LTC/kimchi/src/kimchi/control/base.py\", line 331, in index\n    raise cherrypy.HTTPError(400, e.message)\nHTTPError: (400, u'KCHVOL0001E: Storage volume index.html already exists')\n"

Generate a unique name when creating a storage volume without a name.

The following commands demonstrate the bug fix:

$ kimchi_rest /storagepools/default/storagevolumes | grep name
    "name":"60f46fdc-8ecc-4601-90d6-b3b44d35c337-0.img",
    "name":"bdd22e7c-7794-4bdf-8d2b-0089242c8b16-0.img",
    "name":"c16a7e02-6dcf-48c5-83de-1bb2d8a110a8-0.img",

$ kimchi_rest -m POST /storagepools/default/storagevolumes '{"url": "http://www.google.com/index.html"}'
{
  "status":"running",
  "message":"OK",
  "id":"1",
  "target_uri":"/storagepools/default/storagevolumes/index.html"
}

$ kimchi_rest -m POST /storagepools/default/storagevolumes '{"url": "http://www.google.com/index.html"}'
{
  "status":"running",
  "message":"OK",
  "id":"2",
  "target_uri":"/storagepools/default/storagevolumes/index.html (1)"
}

$ kimchi_rest -m POST /storagepools/default/storagevolumes '{"url": "http://www.google.com/index.html"}'
{
  "status":"running",
  "message":"OK",
  "id":"3",
  "target_uri":"/storagepools/default/storagevolumes/index.html (2)"
}

Fix issue #543 ("Download a volume with same basename will result
error").

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
Remove empty directories after rpm -e kimchi on fedora

Some directories were not removed on rpm -e due no declaration on %files
section. Also, the directory was being created in runtime. Now, it is
being created on rpm build.

Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
Don't let empty directories left on suse

Some directories were not removed on rpm -e due no declaration on %files
section. Also, the directory was being created in runtime. Now, it is
being created on rpm build.

Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
Remove directories under /var/lib/kimchi if empty on ubuntu

Add the directory structure in the buildroot. Dpkg automatically removes
empty directories.

Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>