ozwillo: augment debug logs (#18785)

This commit is contained in:
Benjamin Dauvergne 2017-09-19 11:33:56 +02:00
parent 08962e7524
commit 450a8e2e68
1 changed files with 14 additions and 1 deletions

View File

@ -83,10 +83,12 @@ def create_publik_instance(request):
logger.debug(u'ozwillo: create publik instance request, %r', data)
if 'organization_name' not in data.keys():
logger.warning(u'ozwillo: missing organization_name')
return HttpResponseBadRequest('missing parameter "organization_name"')
org_name = slugify(data['organization_name'])
if OzwilloInstance.objects.filter(domain_slug=org_name):
logger.warning(u'ozwillo: instance %s already exists', org_name)
return HttpResponseBadRequest('instance %s already exists' % org_name)
OzwilloInstance.objects.create(external_ozwillo_id=data['instance_id'], domain_slug=org_name)
@ -105,6 +107,7 @@ def create_publik_instance(request):
def ozwillo_deploy_thread(data):
logger.debug(u'ozwillo: deploy thread start')
# Request parsing
client_id = data['client_id']
client_secret = data['client_secret']
@ -129,9 +132,11 @@ def ozwillo_deploy_thread(data):
json.dump(template_recipe, open(recipe_file_path, 'w'))
logger.debug(u'ozwillo: cooking %s', template_recipe)
call_command('cook', recipe_file_path, timeout=1000, verbosity=0)
# Load user portal template
logger.debug(u'ozwillo: loading combo template')
subprocess.check_call([
'sudo', '-u', 'combo',
'combo-manage', 'tenant_command', 'import_site',
@ -140,6 +145,7 @@ def ozwillo_deploy_thread(data):
])
# Load agent portal template
logger.debug(u'ozwillo: loading combo agent template')
subprocess.check_call([
'sudo', '-u', 'combo',
'combo-manage', 'tenant_command', 'import_site',
@ -148,6 +154,7 @@ def ozwillo_deploy_thread(data):
])
# Configure OIDC Ozwillo authentication
logger.debug(u'ozwillo: configuring OIDC ozwillo authentication')
domain_name = 'connexion-%s.%s' % (instance_name, settings.OZWILLO_ENV_DOMAIN)
subprocess.check_call([
'sudo', '-u', 'authentic-multitenant',
@ -166,6 +173,7 @@ def ozwillo_deploy_thread(data):
])
# Create admin user
logger.debug(u'ozwillo: creating admin user')
create_user_script = os.path.dirname(__file__) + '/scripts/create_user_ozwillo.py'
subprocess.check_call([
'sudo', '-u', 'authentic-multitenant',
@ -174,6 +182,7 @@ def ozwillo_deploy_thread(data):
])
# Load passerelle template
logger.debug(u'ozwillo: loading passerelle template')
subprocess.check_call([
'sudo', '-u', 'passerelle',
'passerelle-manage', 'tenant_command', 'import_site',
@ -215,7 +224,9 @@ def ozwillo_deploy_thread(data):
data=json.dumps(services),
auth=(client_id, client_secret),
headers=headers)
logger.debug(u'ozwillo: registration response, %r', response.content)
logger.debug(u'ozwillo: registration response, status=%s content=%r', response.status_code,
response.content)
logger.debug(u'ozwillo: deploy thread finished')
@csrf_exempt
@ -249,6 +260,7 @@ def delete_publik_instance(request):
def ozwillo_destroy_thread(instance):
logger.debug(u'ozwillo: destroy thread start')
instance_slug = instance.domain_slug
services = settings.OZWILLO_SERVICES
wcs = services['wcs-au-quotidien']
@ -272,4 +284,5 @@ def ozwillo_destroy_thread(instance):
])
instance.delete()
logger.debug(u'ozwillo: destroy thread finished')
return instance_slug