Refactor to /opt/planetstack, final tweaks to make sure planetstack can run in non...
[plstackapi.git] / planetstack / core / api / nodes.py
1 from types import StringTypes
2 from openstack.client import OpenStackClient
3 from openstack.driver import OpenStackDriver
4 from core.api.auth import auth_check
5 from core.models import Node
6  
7 def _get_nodes(filter):
8     if isinstance(filter, StringTypes) and filter.isdigit():
9         filter = int(filter)
10     if isinstance(filter, int):
11         nodes = Node.objects.filter(id=filter)
12     elif isinstance(filter, StringTypes):
13         nodes = Node.objects.filter(name=filter)
14     elif isinstance(filter, dict):
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