remove obsolete api-related views and api files
diff --git a/xos/core/api/__init__.py b/xos/core/api/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/xos/core/api/__init__.py
+++ /dev/null
diff --git a/xos/core/api/auth.py b/xos/core/api/auth.py
deleted file mode 100644
index 8796f14..0000000
--- a/xos/core/api/auth.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from openstack.client import OpenStackClient
-
-def auth_check(username, password, tenant):
- client = OpenStackClient(username=username,
- password=password,
- tenant=tenant)
- client.authenticate()
- return client
diff --git a/xos/core/api/deployment_networks.py b/xos/core/api/deployment_networks.py
deleted file mode 100644
index ee1f68e..0000000
--- a/xos/core/api/deployment_networks.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from types import StringTypes
-from core.models import Deployment
-from django.contrib.auth import authenticate
-
-def _get_deployment_networks(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- deployment_networks = Deployment.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- deployment_networks = Deployment.objects.filter(name=filter)
- elif isinstance(filter, dict):
- deployment_networks = Deployment.objects.filter(**filter)
- else:
- deployment_networks = []
- return deployment_networks
-
-def add_deployment_network(auth, name):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- deployment = Deployment(name=name)
- deployment.save()
- return deployment
-
-def delete_deployment_network(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- deployments = _get_deployment_networks(filter)
- for deployment in deployments:
- deployment.delete()
- return 1
-
-def get_deployment_networks(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- deployments = _get_deployment_networks(filter)
- return deployments
-
-
-
diff --git a/xos/core/api/images.py b/xos/core/api/images.py
deleted file mode 100644
index 933216f..0000000
--- a/xos/core/api/images.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from core.models import Image
-
-def _get_images(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- images = Image.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- images = Image.objects.filter(name=filter)
- elif isinstance(filter, dict):
- images = Image.objects.filter(**filter)
- else:
- images = []
- return images
-
-def add_image(auth, fields={}):
- """not implemented"""
- return
-
-def delete_image(auth, filter={}):
- """not implemented"""
- return 1
-
-def get_images(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- images = _get_images(filter)
- return images
-
-
-
diff --git a/xos/core/api/instances.py b/xos/core/api/instances.py
deleted file mode 100644
index 92e928c..0000000
--- a/xos/core/api/instances.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import Instance, Slice
-from core.api.images import _get_images
-from core.api.slices import _get_slices
-from core.api.deployment_networks import _get_deployment_networks
-from core.api.nodes import _get_nodes
-
-def _get_instances(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- instances = Instance.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- instances = Instance.objects.filter(name=filter)
- elif isinstance(filter, dict):
- instances = Instance.objects.filter(**filter)
- else:
- instances = []
- return instances
-
-def add_instance(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
-
- images = _get_images(fields.get('image'))
- slices = _get_slices(fields.get('slice'))
- deployment_networks = _get_deployment_networks(fields.get('deploymentNetwork'))
- nodes = _get_nodes(fields.get('node'))
- if images: fields['image'] = images[0]
- if slices: fields['slice'] = slices[0]
- if deployment_networks: fields['deploymentNetwork'] = deployment_networks[0]
- if nodes: fields['node'] = nodes[0]
-
- instance = Instance(**fields)
- auth['tenant'] = instance.slice.name
- instance.os_manager = OpenStackManager(auth=auth, caller = user)
- instance.save()
- return instance
-
-def update_instance(auth, instance, **fields):
- return
-
-def delete_instance(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- instances = _get_instances(filter)
- for instance in instances:
- auth['tenant'] = instance.slice.name
- slice.os_manager = OpenStackManager(auth=auth, caller = user)
- instance.delete()
- return 1
-
-def get_instances(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- if 'slice' in filter:
- slices = _get_slices(filter.get('slice'))
- if slices: filter['slice'] = slices[0]
- instances = _get_instances(filter)
- return instances
-
-
-
diff --git a/xos/core/api/nodes.py b/xos/core/api/nodes.py
deleted file mode 100644
index 4f7ceeb..0000000
--- a/xos/core/api/nodes.py
+++ /dev/null
@@ -1,36 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from core.models import Node
-
-def _get_nodes(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- nodes = Node.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- nodes = Node.objects.filter(name=filter)
- elif isinstance(filter, dict):
- nodes = Node.objects.filter(**filter)
- else:
- nodes = []
- return nodes
-
-def add_node(auth, fields={}):
- """not implemented"""
- return
-
-def delete_node(auth, filter={}):
- """not implemented"""
- return 1
-
-def update_node(auth, id, fields={}):
- return
-
-def get_nodes(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- nodes = _get_nodes(filter)
- return nodes
-
-
-
diff --git a/xos/core/api/roles.py b/xos/core/api/roles.py
deleted file mode 100644
index 4ea05c9..0000000
--- a/xos/core/api/roles.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import Role
-
-
-def _get_roles(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- roles = Role.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- roles = Role.objects.filter(role_type=filter)
- elif isinstance(filter, dict):
- roles = Role.objects.filter(**filter)
- else:
- roles = []
- return roles
-
-def add_role(auth, name):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- role = Role(role_type=name)
- role.os_manager = OpenStackManager(auth=auth, caller = user)
- role.save()
- return role
-
-def delete_role(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- roles = _get_roles(filter)
- for role in roles:
- auth['tenant'] = user.site.login_base
- role.os_manager = OpenStackManager(auth=auth, caller = user)
- role.delete()
- return 1
-
-def get_roles(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- return _get_roles(filter)
-
diff --git a/xos/core/api/site_privileges.py b/xos/core/api/site_privileges.py
deleted file mode 100644
index 6d79701..0000000
--- a/xos/core/api/site_privileges.py
+++ /dev/null
@@ -1,73 +0,0 @@
-from types import StringTypes
-import re
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import SitePrivilege
-from core.api.users import _get_users
-from core.api.sites import _get_sites
-from core.api.roles import _get_roles
-
-
-def _get_site_privileges(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- site_privileges = SitePrivilege.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- site_privileges = SitePrivilege.objects.filter(name=filter)
- elif isinstance(filter, dict):
- site_privileges = SitePrivilege.objects.filter(**filter)
- else:
- site_privileges = []
- return site_privileges
-
-def add_site_privilege(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
-
- users = _get_user(fields.get('user'))
- sites = _get_slice(fields.get('site'))
- roles = _get_role(fields.get('role'))
-
- if users: fields['user'] = users[0]
- if slices: fields['site'] = sites[0]
- if roles: fields['role'] = roles[0]
-
- auth['tenant'] = sites[0].login_base
- site_privilege = SitePrivilege(**fields)
- site_privilege.os_manager = OpenStackManager(auth=auth, caller = user)
- site_privilege.save()
- return site_privilege
-
-def update_site_privilege(auth, id, **fields):
- return
-
-def delete_site_privilege(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
- manager = OpenStackManager(auth=auth, caller = user)
-
- site_privileges = _get_site_privileges(filter)
- for site_privilege in site_privileges:
- auth['tenant'] = user.site.login_base
- site_privilege.os_manager = OpenStackManager(auth=auth, caller = user)
- site_privilege.delete()
- return 1
-
-def get_site_privileges(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- users = _get_users(filter.get('user'))
- sites = _get_slices(filter.get('site'))
- roles = _get_roles(filter.get('role'))
-
- if users: filter['user'] = users[0]
- if sites: filter['site'] = sites[0]
- if roles: filter['role'] = roles[0]
-
- site_privileges = _get_site_privileges(filter)
- return site_privileges
-
-
-
diff --git a/xos/core/api/sites.py b/xos/core/api/sites.py
deleted file mode 100644
index 123f139..0000000
--- a/xos/core/api/sites.py
+++ /dev/null
@@ -1,60 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import Site
-
-def _get_sites(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- sites = Site.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- sites = Site.objects.filter(login_base=filter)
- elif isinstance(filter, dict):
- sites = Site.objects.filter(**filter)
- else:
- sites = []
- return sites
-
-def add_site(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- site = Site(**fields)
- site.os_manager = OpenStackManager(auth=auth, caller = user)
- site.save()
- return site
-
-def update_site(auth, id, **fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- sites = _get_sites(id)
- if not sites:
- return
-
- site = Site[0]
- site.os_manager = OpenStackManager(auth=auth, caller = user)
- site.update(**fields)
- return site
-
-def delete_site(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
- sites = _get_sites(id)
- for site in sites:
- site.os_manager = OpenStackManager(auth=auth, caller = user)
- site.delete()
- return 1
-
-def get_sites(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- sites = _get_sites(filter)
- return sites
-
-
-
diff --git a/xos/core/api/slice_memberships.py b/xos/core/api/slice_memberships.py
deleted file mode 100644
index 3e25ae7..0000000
--- a/xos/core/api/slice_memberships.py
+++ /dev/null
@@ -1,70 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import SliceMembership
-from core.api.users import _get_users
-from core.api.slices import _get_slices
-from core.api.roles import _get_roles
-
-def _get_slice_memberships(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- slice_memberships = SitePrivilege.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- slice_memberships = SitePrivilege.objects.filter(name=filter)
- elif isinstance(filter, dict):
- slice_memberships = SitePrivilege.objects.filter(**filter)
- else:
- slice_memberships = []
- return slice_memberships
-
-
-def add_slice_membership(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
-
- users = _get_users(fields.get('user'))
- slices = _get_slices(fields.get('slice'))
- roles = _get_roles(fields.get('role'))
-
- if users: fields['user'] = users[0]
- if slices: fields['slice'] = slices[0]
- if roles: fields['role'] = roles[0]
-
- slice_membership = SliceMembership(**fields)
- auth['tenant'] = sites[0].login_base
- slice_membership.os_manager = OpenStackManager(auth=auth, caller = user)
- slice_membership.save()
- return slice_membership
-
-def update_slice_membership(auth, id, **fields):
- return
-
-def delete_slice_membership(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- slice_memberships = _get_slice_memberships(filter)
- for slice_membership in slice_memberships:
- slice_membership.os_manager = OpenStackManager(auth=auth, caller = user)
- slice_membership.delete()
- return 1
-
-def get_slice_memberships(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- users = _get_users(fields.get('user'))
- slices = _get_slices(fields.get('slice'))
- roles = _get_roles(fields.get('role'))
-
- if users: fields['user'] = users[0]
- if slices: fields['slice'] = slices[0]
- if roles: fields['role'] = roles[0]
-
- slice_memberships = _get_slice_memberships(filter)
- return slice_memberships
-
-
-
diff --git a/xos/core/api/slices.py b/xos/core/api/slices.py
deleted file mode 100644
index c9e94a2..0000000
--- a/xos/core/api/slices.py
+++ /dev/null
@@ -1,74 +0,0 @@
-import re
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import Slice
-from core.api.sites import _get_sites
-
-def _get_slices(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- slices = Slice.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- slices = Slice.objects.filter(name=filter)
- elif isinstance(filter, dict):
- slices = Slice.objects.filter(**filter)
- else:
- slices = []
- return slices
-
-
-def add_slice(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- login_base = fields['name'][:fields['name'].find('_')]
- sites = _get_sites(login_base)
- if sites: fields['site'] = sites[0]
- slice = Slice(**fields)
- slice.os_manager = OpenStackManager(auth=auth, caller = user)
- slice.save()
- return slice
-
-def update_slice(auth, id, **fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- slices = _get_slices(id)
- if not slices:
- return
- slice = slices[0]
- sites = _get_sites(fields.get('site'))
- if sites: fields['site'] = sites[0]
-
- slice.os_manager = OpenStackManager(auth=auth, caller = user)
- for (k,v) in fields.items():
- setattr(slice, k, v)
- slice.save()
-
- return slice
-
-def delete_slice(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
- slices = _get_slices(filter)
- for slice in slices:
- slice.os_manager = OpenStackManager(auth=auth, caller = user)
- slice.delete()
- return 1
-
-def get_slices(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- if 'site' in filter:
- sites = _get_sites(filter.get('site'))
- if sites: filter['site'] = sites[0]
- slices = _get_slices(filter)
- return slices
-
-
-
diff --git a/xos/core/api/subnets.py b/xos/core/api/subnets.py
deleted file mode 100644
index d618eda..0000000
--- a/xos/core/api/subnets.py
+++ /dev/null
@@ -1,74 +0,0 @@
-import commands
-from types import StringTypes
-from openstack.client import OpenStackClient
-from openstack.driver import OpenStackDriver
-from core.api.auth import auth_check
-from core.models import Subnet
-from core.api.slices import _get_slices
-
-
-def _get_subnets(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- subnets = Subnet.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- # the name is the subnet's slice's name
- slices = _get_slices(filter)
- slice = None
- if slices: slice=slices[0]
- subnets = Subnet.objects.filter(slice=slice)
- elif isinstance(filter, dict):
- subnets = Subnet.objects.filter(**filter)
- else:
- subnets = []
- return subnets
-
-def add_subnet(auth, fields):
- driver = OpenStackDriver(client = auth_check(auth))
- slices = _get_slices(fields.get('slice'))
- if slices: fields['slice'] = slices[0]
- subnet = Subnet(**fields)
- # create quantum subnet
- quantum_subnet = driver.create_subnet(name= subnet.slice.name,
- network_id=subnet.slice.network_id,
- cidr_ip = subnet.cidr,
- ip_version=subnet.ip_version,
- start = subnet.start,
- end = subnet.end)
- subnet.subnet_id=quantum_subnet['id']
- ## set dns servers
- #driver.update_subnet(subnet.id, {'dns_nameservers': ['8.8.8.8', '8.8.4.4']})
-
- # add subnet as interface to slice's router
- try: driver.add_router_interface(subnet.slice.router_id, subnet.subnet_id)
- except: pass
- #add_route = 'route add -net %s dev br-ex gw 10.100.0.5' % self.cidr
- commands.getstatusoutput(add_route)
- subnet.save()
- return subnet
-
-def update_subnet(auth, subnet, **fields):
- return
-
-def delete_subnet(auth, filter={}):
- driver = OpenStackDriver(client = auth_check(auth))
- subnets = Subnet.objects.filter(**filter)
- for subnet in subnets:
- driver.delete_router_interface(subnet.slice.router_id, subnet.subnet_id)
- driver.delete_subnet(subnet.subnet_id)
- subnet.delete()
- #del_route = 'route del -net %s' % subnet.cidr
- commands.getstatusoutput(del_route)
- return 1
-
-def get_subnets(auth, filter={}):
- client = auth_check(auth)
- if 'slice' in filter:
- slice = _get_slice(filter.get('slice'))
- if slice: filter['slice'] = slice
- subnets = Subnet.objects.filter(**filter)
- return subnets
-
-
-
diff --git a/xos/core/api/users.py b/xos/core/api/users.py
deleted file mode 100644
index 08e851c..0000000
--- a/xos/core/api/users.py
+++ /dev/null
@@ -1,75 +0,0 @@
-from types import StringTypes
-from django.contrib.auth import authenticate
-from openstack.manager import OpenStackManager
-from core.models import User, Site
-from core.api.sites import _get_sites
-
-def _get_users(filter):
- if isinstance(filter, StringTypes) and filter.isdigit():
- filter = int(filter)
- if isinstance(filter, int):
- users = User.objects.filter(id=filter)
- elif isinstance(filter, StringTypes):
- users = User.objects.filter(email=filter)
- elif isinstance(filter, dict):
- users = User.objects.filter(**filter)
- else:
- users = []
- return users
-
-def add_user(auth, fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- sites = _get_sites(fields.get('site'))
- if sites: fields['site'] = sites[0]
- user = User(**fields)
- user.os_manager = OpenStackManager(auth=auth, caller = user)
- user.save()
- return user
-
-def update_user(auth, id, **fields):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
-
- users = User.objects.filter(id=id)
- if not users:
- return
-
- user = users[0]
- nova_fields = {}
- if 'email' in fields:
- nova_fields['name'] = fields['email'][:self.email.find('@')]
- nova_fields['email'] = fields['email']
- if 'password' in fields:
- nova_fields['password'] = fields['password']
- if 'enabled' in fields:
- nova_fields['enabled'] = fields['enabled']
- sites = _get_sites(fields.get('site'))
- if sites: fields['site'] = sites[0]
- user.os_manager = OpenStackManager(auth=auth, caller = user)
- for (k,v) in fields.items():
- setattr(user, k, v)
- user.save()
- return user
-
-def delete_user(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- auth['tenant'] = user.site.login_base
- users = _get_users(filter)
- for user in users:
- user.os_manager = OpenStackManager(auth=auth, caller = user)
- user.delete()
- return 1
-
-def get_users(auth, filter={}):
- user = authenticate(username=auth.get('username'),
- password=auth.get('password'))
- users = _get_users(filter)
- return users
-
-
-
diff --git a/xos/core/api_root.py b/xos/core/api_root.py
deleted file mode 100644
index c3d69f1..0000000
--- a/xos/core/api_root.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from rest_framework.decorators import api_view
-from rest_framework.response import Response
-from rest_framework.reverse import reverse
-
-@api_view(['GET'])
-def api_root(request, format=None):
- return Response({
- 'deployments': reverse('deployment-list', request=request, format=format),
- 'images': reverse('image-list', request=request, format=format),
- 'nodes': reverse('node-list', request=request, format=format),
- 'projects': reverse('project-list', request=request, format=format),
- 'reservations': reverse('reservation-list', request=request, format=format),
- 'roles': reverse('role-list', request=request, format=format),
- 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
- 'serviceresources': reverse('serviceresource-list', request=request, format=format),
- 'sites': reverse('site-list', request=request, format=format),
- 'slices': reverse('slice-list', request=request, format=format),
- 'instances': reverse('instance-list', request=request, format=format),
- 'tags': reverse('tag-list', request=request, format=format),
- 'users': reverse('user-list', request=request, format=format),
- })
diff --git a/xos/core/views/deployments.py b/xos/core/views/deployments.py
deleted file mode 100644
index 285a53a..0000000
--- a/xos/core/views/deployments.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from core.serializers import DeploymentSerializer
-from rest_framework import generics
-from core.models import Deployment
-
-class DeploymentList(generics.ListCreateAPIView):
- queryset = Deployment.objects.all()
- serializer_class = DeploymentSerializer
-
-class DeploymentDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Deployment.objects.all()
- serializer_class = DeploymentSerializer
-
diff --git a/xos/core/views/images.py b/xos/core/views/images.py
deleted file mode 100644
index 5ea5d76..0000000
--- a/xos/core/views/images.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from core.serializers import ImageSerializer
-from rest_framework import generics
-from core.models import Image
-
-class ImageList(generics.ListCreateAPIView):
- queryset = Image.objects.all()
- serializer_class = ImageSerializer
-
-class ImageDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Image.objects.all()
- serializer_class = ImageSerializer
-
diff --git a/xos/core/views/instances.py b/xos/core/views/instances.py
deleted file mode 100644
index e424538..0000000
--- a/xos/core/views/instances.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import InstanceSerializer
-from rest_framework import generics
-from core.models import Instance
-
-class InstanceList(generics.ListCreateAPIView):
- queryset = Instance.objects.all()
- serializer_class = InstanceSerializer
-
-class InstanceDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Instance.objects.all()
- serializer_class = InstanceSerializer
-
-
diff --git a/xos/core/views/nodes.py b/xos/core/views/nodes.py
deleted file mode 100644
index 8706114..0000000
--- a/xos/core/views/nodes.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import NodeSerializer
-from rest_framework import generics
-from core.models import Node
-
-class NodeList(generics.ListCreateAPIView):
- queryset = Node.objects.all()
- serializer_class = NodeSerializer
-
-class NodeDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Node.objects.all()
- serializer_class = NodeSerializer
-
-
diff --git a/xos/core/views/projects.py b/xos/core/views/projects.py
deleted file mode 100644
index c5311d5..0000000
--- a/xos/core/views/projects.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import ProjectSerializer
-from rest_framework import generics
-from core.models import Project
-
-class ProjectList(generics.ListCreateAPIView):
- queryset = Project.objects.all()
- serializer_class = ProjectSerializer
-
-class ProjectDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Project.objects.all()
- serializer_class = ProjectSerializer
-
-
diff --git a/xos/core/views/reservations.py b/xos/core/views/reservations.py
deleted file mode 100644
index 03f79eb..0000000
--- a/xos/core/views/reservations.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import ReservationSerializer
-from rest_framework import generics
-from core.models import Reservation
-
-class ReservationList(generics.ListCreateAPIView):
- queryset = Reservation.objects.all()
- serializer_class = ReservationSerializer
-
-class ReservationDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Reservation.objects.all()
- serializer_class = ReservationSerializer
-
-
diff --git a/xos/core/views/roles.py b/xos/core/views/roles.py
deleted file mode 100644
index 13c9917..0000000
--- a/xos/core/views/roles.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import RoleSerializer
-from rest_framework import generics
-from core.models import Role
-
-class RoleList(generics.ListCreateAPIView):
- queryset = Role.objects.all()
- serializer_class = RoleSerializer
-
-class RoleDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Role.objects.all()
- serializer_class = RoleSerializer
-
-
diff --git a/xos/core/views/serviceclasses.py b/xos/core/views/serviceclasses.py
deleted file mode 100644
index b8b1b70..0000000
--- a/xos/core/views/serviceclasses.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import ServiceClassSerializer
-from rest_framework import generics
-from core.models import ServiceClass
-
-class ServiceClassList(generics.ListCreateAPIView):
- queryset = ServiceClass.objects.all()
- serializer_class = ServiceClassSerializer
-
-class ServiceClassDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = ServiceClass.objects.all()
- serializer_class = ServiceClassSerializer
-
-
diff --git a/xos/core/views/serviceresources.py b/xos/core/views/serviceresources.py
deleted file mode 100644
index e394c18..0000000
--- a/xos/core/views/serviceresources.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import ServiceResourceSerializer
-from rest_framework import generics
-from core.models import ServiceResource
-
-class ServiceResourceList(generics.ListCreateAPIView):
- queryset = ServiceResource.objects.all()
- serializer_class = ServiceResourceSerializer
-
-class ServiceResourceDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = ServiceResource.objects.all()
- serializer_class = ServiceResourceSerializer
-
-
diff --git a/xos/core/views/site_privileges.py b/xos/core/views/site_privileges.py
deleted file mode 100644
index 90053e5..0000000
--- a/xos/core/views/site_privileges.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import SitePrivilegeSerializer
-from rest_framework import generics
-from core.models import SitePrivilege
-
-class SitePrivilegeList(generics.ListCreateAPIView):
- queryset = SitePrivilege.objects.all()
- serializer_class = SitePrivilegeSerializer
-
-class SitePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = SitePrivilege.objects.all()
- serializer_class = SitePrivilegeSerializer
-
-
diff --git a/xos/core/views/sites.py b/xos/core/views/sites.py
deleted file mode 100644
index 4ec9cb2..0000000
--- a/xos/core/views/sites.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from core.serializers import SiteSerializer
-from rest_framework import generics
-from core.models import Site
-
-class SiteList(generics.ListCreateAPIView):
- queryset = Site.objects.all()
- serializer_class = SiteSerializer
-
-class SiteDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Site.objects.all()
- serializer_class = SiteSerializer
diff --git a/xos/core/views/slice_privileges.py b/xos/core/views/slice_privileges.py
deleted file mode 100644
index 4dd1f93..0000000
--- a/xos/core/views/slice_privileges.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import SlicePrivilegeSerializer
-from rest_framework import generics
-from core.models import SlicePrivilege
-
-class SlicePrivilegeList(generics.ListCreateAPIView):
- queryset = SlicePrivilege.objects.all()
- serializer_class = SlicePrivilegeSerializer
-
-class SlicePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = SlicePrivilege.objects.all()
- serializer_class = SlicePrivilegeSerializer
-
-
diff --git a/xos/core/views/slices.py b/xos/core/views/slices.py
deleted file mode 100644
index e3ab139..0000000
--- a/xos/core/views/slices.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import SliceSerializer
-from rest_framework import generics
-from core.models import Slice
-
-class SliceList(generics.ListCreateAPIView):
- queryset = Slice.objects.all()
- serializer_class = SliceSerializer
-
-class SliceDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Slice.objects.all()
- serializer_class = SliceSerializer
-
-
diff --git a/xos/core/views/subnets.py b/xos/core/views/subnets.py
deleted file mode 100644
index 881f615..0000000
--- a/xos/core/views/subnets.py
+++ /dev/null
@@ -1,66 +0,0 @@
-from django.http import Http404
-from rest_framework.views import APIView
-from rest_framework.response import Response
-from rest_framework import status
-
-from core.api.subnets import add_subnet, delete_subnet, get_subnets, update_subnet
-from core.serializers import SubnetSerializer
-from util.request import parse_request
-
-
-class SubnetListCreate(APIView):
- """
- List all subnets or create a new subnet.
- """
-
- def post(self, request, format = None):
- data = parse_request(request.DATA)
- if 'auth' not in data:
- return Response(status=status.HTTP_400_BAD_REQUEST)
- elif 'subnet' in data:
- subnet = add_subnet(data['auth'], data['subnet'])
- serializer = SubnetSerializer(subnet)
- return Response(serializer.data, status=status.HTTP_201_CREATED)
- else:
- subnets = get_subnets(data['auth'])
- serializer = SubnetSerializer(subnets, many=True)
- return Response(serializer.data)
-
-
-class SubnetRetrieveUpdateDestroy(APIView):
- """
- Retrieve, update or delete a subnet
- """
-
- def post(self, request, pk, format=None):
- """Retrieve a subnet"""
- data = parse_request(request.DATA)
- if 'auth' not in data:
- return Response(status=status.HTTP_400_BAD_REQUEST)
- subnets = get_subnets(data['auth'], {'id': pk})
- if not subnets:
- return Response(status=status.HTTP_404_NOT_FOUND)
- serializer = SubnetSerializer(subnets[0])
- return Response(serializer.data)
-
- def put(self, request, pk, format=None):
- """update a subnet"""
- data = parse_request(request.DATA)
- if 'auth' not in data:
- return Response(status=status.HTTP_400_BAD_REQUEST)
- elif 'subnet' not in data:
- return Response(status=status.HTTP_400_BAD_REQUEST)
-
- subnet = update_subnet(pk, data['subnet'])
- serializer = SubnetSerializer(subnet)
- return Response(serializer.data)
-
- def delete(self, request, pk, format=None):
- data = parse_request(request.DATA)
- if 'auth' not in data:
- return Response(status=status.HTTP_400_BAD_REQUEST)
- delete_subnet(data['auth'], {'id': pk})
- return Response(status=status.HTTP_204_NO_CONTENT)
-
-
-
diff --git a/xos/core/views/tags.py b/xos/core/views/tags.py
deleted file mode 100644
index ba8a035..0000000
--- a/xos/core/views/tags.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from core.serializers import TagSerializer
-from rest_framework import generics
-from core.models import Tag
-
-class TagList(generics.ListCreateAPIView):
- queryset = Tag.objects.all()
- serializer_class = TagSerializer
-
-class TagDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = Tag.objects.all()
- serializer_class = TagSerializer
-
-
diff --git a/xos/core/views/users.py b/xos/core/views/users.py
deleted file mode 100644
index 06ac0f3..0000000
--- a/xos/core/views/users.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from core.serializers import UserSerializer
-from rest_framework import generics
-from core.models import User
-
-class UserList(generics.ListCreateAPIView):
- queryset = User.objects.all()
- serializer_class = UserSerializer
-
-class UserDetail(generics.RetrieveUpdateDestroyAPIView):
- queryset = User.objects.all()
- serializer_class = UserSerializer
diff --git a/xos/util/request.py b/xos/util/request.py
deleted file mode 100644
index 3769b19..0000000
--- a/xos/util/request.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import ast
-from django.http.request import QueryDict
-
-def parse_request(request):
- d = {}
- if isinstance(request, unicode):
- d = ast.literal_eval(request)
- elif isinstance(request, QueryDict):
- for (k,v) in request.items():
- d[k] = ast.literal_eval(v)
- elif isinstance(request, dict):
- d = request
-
- return d