blob: 9b6a65c2fd2ae00665dd55d791e5bb62a7a63c97 [file] [log] [blame]
Tony Mack5df6c552013-04-11 21:24:17 -04001from types import StringTypes
Tony Mack29c287f2013-04-11 21:07:16 -04002from plstackapi.openstack.client import OpenStackClient
3from plstackapi.openstack.driver import OpenStackDriver
4from plstackapi.core.api.auth import auth_check
5from plstackapi.core.models import Node
6
7def _get_nodes(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 nodes = Node.objects.filter(id=filter)
12 elif isinstance(filter, StringTypes):
13 nodes = Node.objects.filter(name=filter)
Tony Mack5df6c552013-04-11 21:24:17 -040014 elif isinstance(filter, dict):
Tony Mack29c287f2013-04-11 21:07:16 -040015 nodes = Node.objects.filter(**filter)
16 else:
17 nodes = []
18 return nodes
19
20def add_node(auth, fields={}):
21 """not implemented"""
22 return
23
24def delete_node(auth, filter={}):
25 """not implemented"""
26 return 1
27
28def update_node(auth, id, fields={}):
29 return
30
31def get_nodes(auth, filter={}):
32 auth_check(auth)
33 nodes = _get_nodes(filter)
34 return nodes
35
36
37