Tony Mack | 5df6c55 | 2013-04-11 21:24:17 -0400 | [diff] [blame] | 1 | from types import StringTypes |
Tony Mack | 29c287f | 2013-04-11 21:07:16 -0400 | [diff] [blame] | 2 | from plstackapi.openstack.client import OpenStackClient |
| 3 | from plstackapi.openstack.driver import OpenStackDriver |
| 4 | from plstackapi.core.api.auth import auth_check |
| 5 | from plstackapi.core.models import Node |
| 6 | |
| 7 | def _get_nodes(filter): |
Tony Mack | 5df6c55 | 2013-04-11 21:24:17 -0400 | [diff] [blame] | 8 | if isinstance(filter, StringTypes) and filter.isdigit(): |
| 9 | filter = int(filter) |
Tony Mack | 29c287f | 2013-04-11 21:07:16 -0400 | [diff] [blame] | 10 | if isinstance(filter, int): |
| 11 | nodes = Node.objects.filter(id=filter) |
| 12 | elif isinstance(filter, StringTypes): |
| 13 | nodes = Node.objects.filter(name=filter) |
Tony Mack | 5df6c55 | 2013-04-11 21:24:17 -0400 | [diff] [blame] | 14 | elif isinstance(filter, dict): |
Tony Mack | 29c287f | 2013-04-11 21:07:16 -0400 | [diff] [blame] | 15 | nodes = Node.objects.filter(**filter) |
| 16 | else: |
| 17 | nodes = [] |
| 18 | return nodes |
| 19 | |
| 20 | def add_node(auth, fields={}): |
| 21 | """not implemented""" |
| 22 | return |
| 23 | |
| 24 | def delete_node(auth, filter={}): |
| 25 | """not implemented""" |
| 26 | return 1 |
| 27 | |
| 28 | def update_node(auth, id, fields={}): |
| 29 | return |
| 30 | |
| 31 | def get_nodes(auth, filter={}): |
| 32 | auth_check(auth) |
| 33 | nodes = _get_nodes(filter) |
| 34 | return nodes |
| 35 | |
| 36 | |
| 37 | |