fix bug in vim-create with config 83/6183/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 21 May 2018 14:45:33 +0000 (16:45 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 21 May 2018 14:45:33 +0000 (16:45 +0200)
Change-Id: I9b4030aa18c2274c06bc40a55b1fb8f2c1e40be0
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/scripts/osm.py
osmclient/sol005/vim.py

index 66d1f32..78dd232 100755 (executable)
@@ -861,7 +861,7 @@ def vim_create(ctx,
         vim['vim-tenant-name'] = tenant
         vim['vim-type'] = account_type
         vim['description'] = description
-        vim ['config'] = config
+        vim['config'] = config
         if sdn_controller or sdn_port_mapping:
             ctx.obj.vim.create(name, vim, sdn_controller, sdn_port_mapping)
         else:
index 9d10302..dc107ef 100644 (file)
@@ -31,10 +31,10 @@ class Vim(object):
         self._client = client
         self._apiName = '/admin'
         self._apiVersion = '/v1'
-        self._apiResource = '/vims'
+        self._apiResource = '/vim_accounts'
         self._apiBase = '{}{}{}'.format(self._apiName,
                                         self._apiVersion, self._apiResource)
-    def create(self, name, vim_access, sdn_controller, sdn_port_mapping):
+    def create(self, name, vim_access, sdn_controller=None, sdn_port_mapping=None):
         if 'vim-type' not in vim_access:
             #'openstack' not in vim_access['vim-type']):
             raise Exception("vim type not provided")
@@ -43,9 +43,9 @@ class Vim(object):
         vim_account['name'] = name
         vim_account = self.update_vim_account_dict(vim_account, vim_access)
 
-        vim_config = {}
+        vim_config = {'hello': 'hello'}
         if 'config' in vim_access and vim_access['config'] is not None:
-            vim_config = json.loads(vim_access['config'])
+            vim_config = yaml.safe_load(vim_access['config'])
         if sdn_controller:
             sdnc = self._client.sdnc.get(sdn_controller)
             vim_config['sdn-controller'] = sdnc['_id']
@@ -78,7 +78,7 @@ class Vim(object):
             if config=="":
                 vim_config = None
             else:
-                vim_config = json.loads(vim_account['config'])
+                vim_config = yaml.safe_load(vim_account['config'])
         if sdn_controller:
             sdnc = self._client.sdnc.get(sdn_controller)
             vim_config['sdn-controller'] = sdnc['_id']