lookup site
diff --git a/plstackapi/planetstack/api/users.py b/plstackapi/planetstack/api/users.py
index 13b83d8..403f079 100644
--- a/plstackapi/planetstack/api/users.py
+++ b/plstackapi/planetstack/api/users.py
@@ -1,17 +1,24 @@
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.planetstack.api.auth import auth_check
-from plstackapi.planetstack.models import User
+from plstackapi.planetstack.models import User, Site
def add_user(auth, fields):
driver = OpenStackDriver(client = auth_check(auth))
user = User(**fields)
+ if 'site' in fields:
+ if isinstance(fields['site'], int):
+ sites = Site.objects.filter(id=fields['site'])
+ else:
+ sites = Site.objects.filter(login_base=fields['site'])
+ if sites:
+ user.site = sites[0]
nova_fields = {'name': user.email[:self.email.find('@')],
'email': user.email,
'password': user.name,
'enabled': user.enabled}
- tenant = driver.create_user(**nova_fields)
+ user = driver.create_user(**nova_fields)
user.user_id=user.id
user.save()
return user