update restapi to use OpenStackManager instead of OpenStackDriver
diff --git a/plstackapi/core/api/slice_memberships.py b/plstackapi/core/api/slice_memberships.py
index 431552d..ae6baa4 100644
--- a/plstackapi/core/api/slice_memberships.py
+++ b/plstackapi/core/api/slice_memberships.py
@@ -1,7 +1,6 @@
from types import StringTypes
-from plstackapi.openstack.client import OpenStackClient
-from plstackapi.openstack.driver import OpenStackDriver
-from plstackapi.core.api.auth import auth_check
+from django.contrib.auth import authenticate
+from plstackapi.openstack.manager import OpenStackManager
from plstackapi.core.models import SliceMembership
from plstackapi.core.api.users import _get_users
from plstackapi.core.api.slices import _get_slices
@@ -22,7 +21,9 @@
def add_slice_membership(auth, fields):
- driver = OpenStackDriver(client = auth_check(auth))
+ 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'))
@@ -32,12 +33,8 @@
if roles: fields['role'] = roles[0]
slice_membership = SliceMembership(**fields)
-
- # update nova role
- driver.add_user_role(slice_membership.user.user_id,
- slice_membership.slice.tenant_id,
- slice_membership.role.name)
-
+ auth['tenant'] = sites[0].login_base
+ slice_membership.os_manager = OpenStackManager(auth=auth, caller = user)
slice_membership.save()
return slice_membership
@@ -45,17 +42,19 @@
return
def delete_slice_membership(auth, filter={}):
- driver = OpenStackDriver(client = auth_check(auth))
+ 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:
- driver.delete_user_role(user_id=slice_membership.user.id,
- tenant_id = slice_membership.slice.tenant_id,
- role_name = slice_membership.role.name)
+ slice_membership.os_manager = OpenStackManager(auth=auth, caller = user)
slice_membership.delete()
return 1
def get_slice_memberships(auth, filter={}):
- client = auth_check(auth)
+ 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'))