|
|
@@ -296,18 +296,18 @@ def install_sample_user():
|
|
|
Setup the de-activated sample user with a certain id. Do not create a user profile.
|
|
|
"""
|
|
|
|
|
|
- try:
|
|
|
- user = auth_models.User.objects.get(username=SAMPLE_USERNAME)
|
|
|
- except auth_models.User.DoesNotExist:
|
|
|
- try:
|
|
|
- user = auth_models.User.objects.create(username=SAMPLE_USERNAME, password='!', is_active=False, is_superuser=False, id=1100713, pk=1100713)
|
|
|
- LOG.info('Installed a user called "%s"' % (SAMPLE_USERNAME,))
|
|
|
- except Exception, e:
|
|
|
- LOG.info('Sample user race condition: %s' % e)
|
|
|
- user = auth_models.User.objects.get(username=SAMPLE_USERNAME)
|
|
|
- LOG.info('Sample user race condition, got: %s' % user)
|
|
|
-
|
|
|
- fs = cluster.get_hdfs()
|
|
|
- fs.do_as_user(SAMPLE_USERNAME, fs.create_home_dir)
|
|
|
+ user, created = auth_models.User.objects.get_or_create(
|
|
|
+ username=SAMPLE_USERNAME,
|
|
|
+ password='!',
|
|
|
+ is_active=False,
|
|
|
+ is_superuser=False,
|
|
|
+ id=1100713,
|
|
|
+ pk=1100713)
|
|
|
+
|
|
|
+ if created:
|
|
|
+ LOG.info('Installed a user called "%s"' % (SAMPLE_USERNAME,))
|
|
|
+
|
|
|
+ fs = cluster.get_hdfs()
|
|
|
+ fs.do_as_user(SAMPLE_USERNAME, fs.create_home_dir)
|
|
|
|
|
|
return user
|