blob: 94c38ebc75a89ea91403dba0c80f02e99e7d7fa9 [file] [log] [blame]
Tony Mack5df6c552013-04-11 21:24:17 -04001from types import StringTypes
Tony Mackaae0bf02013-04-09 09:43:50 -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 Flavor
Tony Mackaae0bf02013-04-09 09:43:50 -04006
Tony Mack29c287f2013-04-11 21:07:16 -04007def _get_flavors(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):
11 flavors = Flavor.objects.filter(id=filter)
12 elif isinstance(filter, StringTypes):
13 flavors = Flavor.objects.filter(name=filter)
Tony Mack5df6c552013-04-11 21:24:17 -040014 elif isinstance(filter, dict):
Tony Mack29c287f2013-04-11 21:07:16 -040015 flavors = Flavor.objects.filter(**filter)
16 else:
17 flavors = []
18 return flavors
Tony Mackaae0bf02013-04-09 09:43:50 -040019
20def add_flavor(auth, fields={}):
21 """not implemented"""
22 return
23
24def delete_flavor(auth, filter={}):
25 """not implemented"""
26 return 1
27
28def get_flavors(auth, filter={}):
29 auth_check(auth)
Tony Mack29c287f2013-04-11 21:07:16 -040030 flavors = _get_flavors(filter)
Tony Mackaae0bf02013-04-09 09:43:50 -040031 return flavors
32
33
34