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
7 def _get_nodes(filter):
8 if isinstance(filter, StringTypes) and filter.isdigit():
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)
20 def add_node(auth, fields={}):
24 def delete_node(auth, filter={}):
28 def update_node(auth, id, fields={}):
31 def get_nodes(auth, filter={}):
33 nodes = _get_nodes(filter)