Merge pick up, tweaked role/site/plcore_base or os_manager path when OpenStack not present
diff --git a/planetstack/core/api/site_privileges.py b/planetstack/core/api/site_privileges.py
index 85a8a83..6d79701 100644
--- a/planetstack/core/api/site_privileges.py
+++ b/planetstack/core/api/site_privileges.py
@@ -1,8 +1,7 @@
from types import StringTypes
import re
-from openstack.client import OpenStackClient
-from openstack.driver import OpenStackDriver
-from core.api.auth import auth_check
+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
@@ -23,7 +22,9 @@
return site_privileges
def add_site_privilege(auth, fields):
- driver = OpenStackDriver(client = auth_check(auth))
+ 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'))
@@ -32,13 +33,9 @@
if slices: fields['site'] = sites[0]
if roles: fields['role'] = roles[0]
+ auth['tenant'] = sites[0].login_base
site_privilege = SitePrivilege(**fields)
-
- # update nova role
- driver.add_user_role(site_privilege.user.kuser_id,
- site_privilege.site.tenant_id,
- site_privilege.role.name)
-
+ site_privilege.os_manager = OpenStackManager(auth=auth, caller = user)
site_privilege.save()
return site_privilege
@@ -46,17 +43,21 @@
return
def delete_site_privilege(auth, filter={}):
- driver = OpenStackDriver(client = auth_check(auth))
+ 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:
- driver.delete_user_role(kuser_id=site_privilege.user.id,
- tenant_id = site_privilege.site.tenant_id,
- role_name = site_privilege.role.name)
+ 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={}):
- client = auth_check(auth)
+ 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'))