Tony Mack | aae0bf0 | 2013-04-09 09:43:50 -0400 | [diff] [blame] | 1 | from plstackapi.openstack.client import OpenStackClient |
| 2 | from plstackapi.openstack.driver import OpenStackDriver |
Tony Mack | f1c1224 | 2013-04-09 16:08:43 -0400 | [diff] [blame] | 3 | from plstackapi.core.api.auth import auth_check |
| 4 | from plstackapi.core.models import Flavor |
Tony Mack | aae0bf0 | 2013-04-09 09:43:50 -0400 | [diff] [blame] | 5 | |
Tony Mack | 29c287f | 2013-04-11 21:07:16 -0400 | [diff] [blame^] | 6 | def _get_flavors(filter): |
| 7 | if isinstance(filter, int): |
| 8 | flavors = Flavor.objects.filter(id=filter) |
| 9 | elif isinstance(filter, StringTypes): |
| 10 | flavors = Flavor.objects.filter(name=filter) |
| 11 | elif isinstance(filer, dict): |
| 12 | flavors = Flavor.objects.filter(**filter) |
| 13 | else: |
| 14 | flavors = [] |
| 15 | return flavors |
Tony Mack | aae0bf0 | 2013-04-09 09:43:50 -0400 | [diff] [blame] | 16 | |
| 17 | def add_flavor(auth, fields={}): |
| 18 | """not implemented""" |
| 19 | return |
| 20 | |
| 21 | def delete_flavor(auth, filter={}): |
| 22 | """not implemented""" |
| 23 | return 1 |
| 24 | |
| 25 | def get_flavors(auth, filter={}): |
| 26 | auth_check(auth) |
Tony Mack | 29c287f | 2013-04-11 21:07:16 -0400 | [diff] [blame^] | 27 | flavors = _get_flavors(filter) |
Tony Mack | aae0bf0 | 2013-04-09 09:43:50 -0400 | [diff] [blame] | 28 | return flavors |
| 29 | |
| 30 | |
| 31 | |