Skip to content

Commit

Permalink
Update the dev-setup guide for pulp 3
Browse files Browse the repository at this point in the history
Also added some minor tweaks to the dev env:
- Ignore migrations with gitignore
- Alow setting the admin password with manage.py
  • Loading branch information
Sean Myers committed Mar 13, 2017
1 parent c60e760 commit 2caf79a
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 438 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Vagrantfile

# Built documentation
docs/_build
docs/_diagrams
docs/_diagrams

# Django migrations
# Ignored during early development to prevent accidental commits;
# we'll want these to not be ignored when releasing pulp 3.0
app/pulp/app/migrations
2 changes: 1 addition & 1 deletion app/pulp/app/db-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ fi
python manage.py reset_db --noinput
python manage.py makemigrations pulp_app --noinput
python manage.py migrate --noinput
python manage.py reset-admin-password --random
python manage.py reset-admin-password --password admin
popd
38 changes: 25 additions & 13 deletions app/pulp/app/management/commands/reset-admin-password.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ class Command(BaseCommand):
help = _('Resets "admin" user\'s password.')

def add_arguments(self, parser):
parser.add_argument('--random',
action='store_true',
dest='random',
default=False,
help=_('Generate random password for \'admin\' user.'))
exclusive = parser.add_mutually_exclusive_group()
exclusive.add_argument('--random',
action='store_true',
dest='random',
default=False,
help=_('Generate random password for \'admin\' user.'))
exclusive.add_argument('-p', '--password',
dest='password',
default=None,
help=_('INSECURE: Use the given password for \'admin\' user.'))

def handle(self, *args, **options):
user = User.objects.get_or_create(username='admin', is_superuser=True)[0]
Expand All @@ -27,13 +32,20 @@ def handle(self, *args, **options):
user.save()
self.stdout.write(_('Successfully set "admin" user\'s password to "%s".') % password)
else:
password = getpass(_('Please enter new password for user "admin": '))
password2 = getpass(_('Please enter new password for user "admin" again: '))
if options['password']:
password = options['password']
else:
# this bit duplicates behavior in the builtin "changepassword" command, so
# at this point we can probably just call out to that command, leaving this one
# focused on generating random passwords or setting passwords in automation
password = getpass(_('Please enter new password for user "admin": '))
password2 = getpass(_('Please enter new password for user "admin" again: '))
if password != password2:
raise CommandError(_('The passwords did not match.'))

if not password:
raise CommandError(_("The password must be at least 1 character long."))
if password == password2:
user.set_password(password)
user.save()
self.stdout.write(_('Successfully set password for "admin" user.'))
else:
raise CommandError(_('The passwords did not match.'))

user.set_password(password)
user.save()
self.stdout.write(_('Successfully set password for "admin" user.'))
Loading

0 comments on commit 2caf79a

Please sign in to comment.