Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/openstack_observer/steps/sync_controller_slices.py b/xos/openstack_observer/steps/sync_controller_slices.py
index f64f9a8..1a6f517 100644
--- a/xos/openstack_observer/steps/sync_controller_slices.py
+++ b/xos/openstack_observer/steps/sync_controller_slices.py
@@ -40,7 +40,7 @@
raise Exception("slice createor %s has not accout at controller %s" % (controller_slice.slice.creator, controller_slice.controller.name))
else:
controller_user = controller_users[0]
- roles = ['Admin']
+ roles = ['admin']
max_instances=int(controller_slice.slice.max_slivers)
tenant_fields = {'endpoint':controller_slice.controller.auth_url,
diff --git a/xos/openstack_observer/steps/sync_controller_users.py b/xos/openstack_observer/steps/sync_controller_users.py
index 7979d82..d30d0ff 100644
--- a/xos/openstack_observer/steps/sync_controller_users.py
+++ b/xos/openstack_observer/steps/sync_controller_users.py
@@ -22,28 +22,28 @@
if (deleted):
return ControllerUser.deleted_objects.all()
else:
- return ControllerUser.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+ return ControllerUser.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
def sync_record(self, controller_user):
logger.info("sync'ing user %s at controller %s" % (controller_user.user, controller_user.controller))
- controller_register = json.loads(controller_user.controller.backend_register)
+ controller_register = json.loads(controller_user.controller.backend_register)
if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
+ raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
if not controller_user.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_user.controller)
return
- template = os_template_env.get_template('sync_controller_users.yaml')
+ template = os_template_env.get_template('sync_controller_users.yaml')
# All users will have at least the 'user' role at their home site/tenant.
- # We must also check if the user should have the admin role
- roles = ['user']
+ # We must also check if the user should have the admin role
+ roles = ['user']
if controller_user.user.is_admin:
- roles.append('Admin')
-
- # setup user home site roles at controller
+ roles.append('admin')
+
+ # setup user home site roles at controller
if not controller_user.user.site:
raise Exception('Siteless user %s'%controller_user.user.email)
else:
@@ -54,33 +54,34 @@
#if ctrl_site_deployments:
# # need the correct tenant id for site at the controller
- # tenant_id = ctrl_site_deployments[0].tenant_id
+ # tenant_id = ctrl_site_deployments[0].tenant_id
# tenant_name = ctrl_site_deployments[0].site_deployment.site.login_base
user_fields = {
- 'endpoint':controller_user.controller.auth_url,
- 'name': controller_user.user.email,
- 'email': controller_user.user.email,
- 'password': controller_user.user.remote_password,
- 'admin_user': controller_user.controller.admin_user,
- 'admin_password': controller_user.controller.admin_password,
- 'ansible_tag':'%s@%s'%(controller_user.user.email.replace('@','-at-'),controller_user.controller.name),
- 'admin_tenant': controller_user.controller.admin_tenant,
- 'roles':roles,
- 'tenant':controller_user.user.site.login_base}
-
- rendered = template.render(user_fields)
- expected_length = len(roles) + 1
+ 'endpoint':controller_user.controller.auth_url,
+ 'name': controller_user.user.email,
+ 'email': controller_user.user.email,
+ 'password': controller_user.user.remote_password,
+ 'admin_user': controller_user.controller.admin_user,
+ 'admin_password': controller_user.controller.admin_password,
+ 'ansible_tag':'%s@%s'%(controller_user.user.email.replace('@','-at-'),controller_user.controller.name),
+ 'admin_tenant': controller_user.controller.admin_tenant,
+ 'roles':roles,
+ 'tenant':controller_user.user.site.login_base
+ }
- res = run_template('sync_controller_users.yaml', user_fields,path='controller_users', expected_num=expected_length)
+ rendered = template.render(user_fields)
+ expected_length = len(roles) + 1
+
+ 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.backend_status = '1 - OK'
controller_user.save()
def delete_record(self, controller_user):
- controller_register = json.loads(controller_user.controller.backend_register)
+ controller_register = json.loads(controller_user.controller.backend_register)
if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
+ raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
if controller_user.kuser_id:
driver = self.driver.admin_driver(controller=controller_user.controller)