Commit add02a5a authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Nomad 0.7.0 related ops config fixes.

parent f905ab7f
Pipeline #65582 canceled with stages
in 1 minute and 3 seconds
......@@ -14,22 +14,33 @@
import click
import json
import datetime
from nomad import infrastructure, datamodel
from nomad import infrastructure, datamodel, utils
from .admin import admin
@admin.group(help='''Add, import, export users.''')
def users():
pass
@admin.command(help='Import users to keycloak from a JSON file.', name='import')
@users.command(help='Import users to keycloak from a JSON file.', name='import')
@click.argument('PATH_TO_USERS_FILE', type=str, nargs=1)
def import_command(path_to_users_file):
with open(path_to_users_file, 'rt') as f:
users = json.load(f)
infrastructure.setup_logging()
logger = utils.get_logger(__name__)
for user_dict in users:
password = user_dict.pop('password')
user = datamodel.User(**user_dict)
infrastructure.keycloak.add_user(user, bcrypt_password=password, invite=False)
print('Imported %s' % user.name)
try:
password = user_dict.pop('password')
user_dict['created'] = datetime.datetime.fromtimestamp(user_dict['created']/1000)
user = datamodel.User(**user_dict)
infrastructure.keycloak.add_user(user, bcrypt_password=password, invite=False)
print('Imported %s' % user.name)
except Exception as e:
logger.error('could not import user', exc_info=e)
......@@ -3,6 +3,7 @@ export NOMAD_CLIENT_USER=admin
export NOMAD_FS_LOCAL_TMP=/nomad/fairdi/testing_major/fs/tmp
export NOMAD_MONGO_DB_NAME=fairdi_nomad_testing_major
export NOMAD_ELASTIC_INDEX_NAME=fairdi_nomad_testing_major
export NOMAD_ELASTIC_PORT=9202
export NOMAD_FS_LOCAL_TMP=/nomad/fairdi/testing_major/fs/tmp
export NOMAD_FS_STAGING=/nomad/fairdi/testing_major/fs/staging
export NOMAD_FS_PUBLIC=/nomad/fairdi/testing_major/fs/public
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment