fix parser vim config without quotes 23/6223/2
authorlombardof <flombardo@cnit.it>
Fri, 25 May 2018 15:48:59 +0000 (17:48 +0200)
committerlombardof <flombardo@cnit.it>
Mon, 28 May 2018 10:43:28 +0000 (12:43 +0200)
Change-Id: I7cdbd01d2445bdf966ce16a83ae057895d6601f5
Signed-off-by: lombardof <flombardo@cnit.it>
vimhandler/views.py

index 880cf3f..78e2e67 100644 (file)
@@ -18,7 +18,7 @@ from django.shortcuts import render, redirect
 from django.contrib.auth.decorators import login_required, permission_required
 from django.http import HttpResponse, JsonResponse
 from lib.osm.osmclient.client import Client
-import json
+import yaml
 import logging
 
 logging.basicConfig(level=logging.DEBUG)
@@ -59,13 +59,12 @@ def create(request):
                 vim_data['config'][config_key] = v
         if 'additional_conf' in new_vim_dict:
             try:
-                additional_conf_dict = json.loads(new_vim_dict['additional_conf'])
+                additional_conf_dict = yaml.safe_load(new_vim_dict['additional_conf'])
                 for k,v in additional_conf_dict.items():
                     vim_data['config'][k] = v
             except Exception as e:
                 # TODO return error on json.loads exception
                 print e
-
         result = client.vim_create(vim_data)
         # TODO  'vim:show', to_redirect=True, vim_id=vim_id
         return __response_handler(request, result, 'vim:list', to_redirect=True)