fix user key sync
diff --git a/planetstack/openstack/driver.py b/planetstack/openstack/driver.py
index e9988e3..530d93b 100644
--- a/planetstack/openstack/driver.py
+++ b/planetstack/openstack/driver.py
@@ -106,8 +106,12 @@
return 1
- def update_user(self, id, **kwds):
- return self.shell.keystone.users.update(id, **kwds)
+ def update_user(self, id, fields):
+ if 'password' in fields:
+ self.shell.keystone.users.update_password(id, fields['password'])
+ if 'enabled' in fields:
+ self.shell.keystone.users.update_enabled(id, fields['enabled'])
+ return 1
def create_router(self, name, set_gateway=True):
routers = self.shell.quantum.list_routers(name=name)['routers']
diff --git a/planetstack/openstack/manager.py b/planetstack/openstack/manager.py
index e310883..131b8fb 100644
--- a/planetstack/openstack/manager.py
+++ b/planetstack/openstack/manager.py
@@ -2,6 +2,7 @@
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
import string
import random
+import md5
from netaddr import IPAddress, IPNetwork
from planetstack import settings
@@ -56,7 +57,7 @@
@require_enabled
def init_caller(self, caller, tenant):
auth = {'username': caller.email,
- 'password': '',
+ 'password': md5.new(caller.password).hexdigest()[:6],
'tenant': tenant}
self.client = OpenStackClient(**auth)
self.driver = OpenStackDriver(client=self.client)
@@ -94,17 +95,16 @@
@require_enabled
def save_user(self, user):
+ name = user.email[:user.email.find('@')]
+ user_fields = {'name': name,
+ 'email': user.email,
+ 'password': md5.new(user.password).hexdigest()[:6],
+ 'enabled': True}
if not user.kuser_id:
- name = user.email[:user.email.find('@')]
- user_fields = {'name': name,
- 'email': user.email,
- 'password': user.password,
- 'enabled': True}
keystone_user = self.driver.create_user(**user_fields)
user.kuser_id = keystone_user.id
-
- if user.public_key:
- self.save_key(user.public_key, user.keyname)
+ else:
+ self.driver.update_user(user.kuser_id, user_fields)
if user.site:
self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'user')
@@ -113,6 +113,11 @@
else:
# may have admin role so attempt to remove it
self.driver.delete_user_role(user.kuser_id, user.site.tenant_id, 'admin')
+
+ if user.public_key:
+ self.init_caller(user, user.site.login_base)
+ self.save_key(user.public_key, user.keyname)
+ self.init_admin()
@require_enabled
def delete_user(self, user):
diff --git a/planetstack/openstack/observer.py b/planetstack/openstack/observer.py
index e4460a9..0690558 100644
--- a/planetstack/openstack/observer.py
+++ b/planetstack/openstack/observer.py
@@ -16,7 +16,7 @@
return
while True:
try:
- self.sync_roles()
+ #self.sync_roles()
self.sync_tenants()
self.sync_users()
#self.sync_user_tenant_roles()