~xtoddx/nova/disable_creds

« back to all changes in this revision

Viewing changes to nova/image/local.py

  • Committer: Tarmac
  • Author(s): Ken Pepple
  • Date: 2011-03-21 20:31:51 UTC
  • mfrom: (807.4.4 lp735641)
  • Revision ID: tarmac-20110321203151-ul505l3fkuw91kkn
wrap and log errors getting image ids from local image store

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import random
21
21
import shutil
22
22
 
 
23
from nova import exception
23
24
from nova import flags
24
 
from nova import exception
 
25
from nova import log as logging
25
26
from nova.image import service
26
27
 
27
28
 
29
30
flags.DEFINE_string('images_path', '$state_path/images',
30
31
                    'path to decrypted images')
31
32
 
 
33
LOG = logging.getLogger('nova.image.local')
 
34
 
32
35
 
33
36
class LocalImageService(service.BaseImageService):
34
37
    """Image service storing images to local disk.
47
50
 
48
51
    def _ids(self):
49
52
        """The list of all image ids."""
50
 
        return [int(i, 16) for i in os.listdir(self._path)]
 
53
        images = []
 
54
        for image_dir in os.listdir(self._path):
 
55
            try:
 
56
                unhexed_image_id = int(image_dir, 16)
 
57
            except ValueError:
 
58
                LOG.error(
 
59
                    _("%s is not in correct directory naming format"\
 
60
                       % image_dir))
 
61
            else:
 
62
                images.append(unhexed_image_id)
 
63
        return images
51
64
 
52
65
    def index(self, context):
53
66
        return [dict(image_id=i['id'], name=i.get('name'))