fix bugs
diff --git a/plstackapi/planetstack/api/sites.py b/plstackapi/planetstack/api/sites.py
index 0cd73e5..ac10df9 100644
--- a/plstackapi/planetstack/api/sites.py
+++ b/plstackapi/planetstack/api/sites.py
@@ -13,11 +13,11 @@
tenant = driver.create_tenant(**nova_fields)
site.tenant_id=tenant.id
site.save()
- return role
+ return site
-def update_site(auth, tenant_id, **fields):
+def update_site(auth, login_base, **fields):
driver = OpenStackDriver(client = auth_check(auth))
- sites = Site.objects.filter(tenant_id=tenant_id)
+ sites = Site.objects.filter(login_base=login_base)
if not sites:
return
@@ -27,8 +27,8 @@
nova_fields['description'] = fields['name']
if 'enabled' in fields:
nova_fields['enabled'] = fields['enabled']
-
- site.updtae(**fields)
+ driver.update_tenant(site.tenant_id, **nova_fields)
+ site.update(**fields)
return site
def delete_site(auth, filter={}):
diff --git a/plstackapi/planetstack/views/sites.py b/plstackapi/planetstack/views/sites.py
index 37b39dd..fa693cf 100644
--- a/plstackapi/planetstack/views/sites.py
+++ b/plstackapi/planetstack/views/sites.py
@@ -3,14 +3,14 @@
from rest_framework.response import Response
from rest_framework import status
-from plstackapi.planetstack.api.roles import add_site, delete_site, get_sites
+from plstackapi.planetstack.api.sites import add_site, delete_site, get_sites
from plstackapi.planetstack.serializers import SiteSerializer
from plstackapi.util.request import parse_request
class SiteListCreate(APIView):
"""
- List all roles or create a new site.
+ List all sites or create a new site.
"""
def post(self, request, format = None):
@@ -37,14 +37,14 @@
data = parse_request(request.DATA)
if 'auth' not in data:
return Response(status=status.HTTP_400_BAD_REQUEST)
- sites = get_sites(data['auth'], {'tenant_id': pk})
+ sites = get_sites(data['auth'], {'login_base': pk})
if not sites:
return Response(status=status.HTTP_404_NOT_FOUND)
serializer = SiteSerializer(sites[0])
return Response(serializer.data)
def put(self, request, pk, format=None):
- """update a role"""
+ """update a site"""
data = parse_request(request.DATA)
if 'auth' not in data:
return Response(status=status.HTTP_400_BAD_REQUEST)
@@ -59,7 +59,7 @@
data = parse_request(request.DATA)
if 'auth' not in data:
return Response(status=status.HTTP_400_BAD_REQUEST)
- delete_site(data['auth'], {'tenant_id': pk})
+ delete_site(data['auth'], {'login_base': pk})
return Response(status=status.HTTP_204_NO_CONTENT)