Revision 23808592 snf-cyclades-app/synnefo/plankton/management/commands/image-show.py

b/snf-cyclades-app/synnefo/plankton/management/commands/image-show.py
1
# Copyright 2012 GRNET S.A. All rights reserved.
1
# Copyright 2012-2014 GRNET S.A. All rights reserved.
2 2
#
3 3
# Redistribution and use in source and binary forms, with or without
4 4
# modification, are permitted provided that the following conditions
......
30 30

  
31 31
from django.core.management.base import BaseCommand, CommandError
32 32

  
33
from synnefo.plankton.utils import image_backend
33
from synnefo.plankton.backend import PlanktonBackend
34 34
from snf_django.management import utils
35 35

  
36 36

  
......
44 44
            raise CommandError("Please provide an image ID")
45 45
        image_id = args[0]
46 46

  
47
        with image_backend(None) as backend:
48
            images = backend._list_images(None)
49
            try:
50
                image = filter(lambda x: x["id"] == image_id, images)[0]
51
            except IndexError:
52
                raise CommandError("Image not found. Use snf-manage image-list"
53
                                   " to get the list of all images.")
54
        utils.pprint_table(out=self.stdout, table=[image.values()], headers=image.keys(), vertical=True)
47
        with PlanktonBackend(None) as backend:
48
            image = backend.get_image(image_id)
49
        utils.pprint_table(out=self.stdout, table=[image.values()],
50
                           headers=image.keys(), vertical=True)

Also available in: Unified diff