blob: 8fd6141ff7ba0178ccdc9031c509ca67d8339ebd [file] [log] [blame]
Tony Mack5df6c552013-04-11 21:24:17 -04001from types import StringTypes
Tony Mack53310082013-04-09 09:26:12 -04002from plstackapi.openstack.client import OpenStackClient
3from plstackapi.openstack.driver import OpenStackDriver
Tony Mackf1c12242013-04-09 16:08:43 -04004from plstackapi.core.api.auth import auth_check
5from plstackapi.core.models import Image
Tony Mack53310082013-04-09 09:26:12 -04006
Tony Mack29c287f2013-04-11 21:07:16 -04007def _get_images(filter):
Tony Mack5df6c552013-04-11 21:24:17 -04008 if isinstance(filter, StringTypes) and filter.isdigit():
9 filter = int(filter)
Tony Mack29c287f2013-04-11 21:07:16 -040010 if isinstance(filter, int):
Tony Mack771f4b92013-04-12 01:49:57 -040011 images = Image.objects.filter(id=filter)
Tony Mack29c287f2013-04-11 21:07:16 -040012 elif isinstance(filter, StringTypes):
Tony Mack771f4b92013-04-12 01:49:57 -040013 images = Image.objects.filter(name=filter)
Tony Mack5df6c552013-04-11 21:24:17 -040014 elif isinstance(filter, dict):
Tony Mack771f4b92013-04-12 01:49:57 -040015 images = Image.objects.filter(**filter)
Tony Mack29c287f2013-04-11 21:07:16 -040016 else:
17 images = []
18 return images
Tony Mack53310082013-04-09 09:26:12 -040019
20def add_image(auth, fields={}):
21 """not implemented"""
22 return
23
24def delete_image(auth, filter={}):
25 """not implemented"""
26 return 1
27
28def get_images(auth, filter={}):
29 auth_check(auth)
Tony Mack29c287f2013-04-11 21:07:16 -040030 images = _get_images(filter)
Tony Mack53310082013-04-09 09:26:12 -040031 return images
32
33
34