from observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import Controller, SiteDeployment, SiteDeployment
from core.models.user import User
-from core.models.controllerusers import ControllerUser
+from core.models.controlleruser import ControllerUser
from util.logger import Logger, logging
from observer.ansible import *
logger = Logger(level=logging.INFO)
-class SyncControllerUser(OpenStackSyncStep):
+class SyncControllerUsers(OpenStackSyncStep):
provides=[ControllerUser, User]
requested_interval=0
# We must also check if the user should have the admin role
roles = ['user']
if controller_user.user.is_admin:
- roles.append('admin')
+ roles.append('Admin')
# setup user home site roles at controller
if not controller_user.user.site:
'tenant':controller_user.user.site.login_base}
rendered = template.render(user_fields)
- res = run_template('sync_controller_users.yaml', user_fields,path='controller_users')
-
- # results is an array in which each element corresponds to an
- # "ok" string received per operation. If we get as many oks as
- # the number of operations we issued, that means a grand success.
- # Otherwise, the number of oks tell us which operation failed.
expected_length = len(roles) + 1
- if (len(res)==expected_length):
- controller_user.kuser_id = res[0]['id']
- controller_user.save()
- elif (len(res)):
- raise Exception('Could not assign roles for user %s'%user_fields['name'])
- else:
- raise Exception('Could not create or update user %s'%user_fields['name'])
+
+ res = run_template('sync_controller_users.yaml', user_fields,path='controller_users', expected_num=expected_length)
+
+ controller_user.kuser_id = res[0]['id']
+ controller_user.save()
def delete_record(self, controller_user):
if controller_user.kuser_id: