Parse config to yaml for sdnc-create/update 49/8649/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 27 Feb 2020 12:04:23 +0000 (12:04 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 27 Feb 2020 12:04:23 +0000 (12:04 +0000)
Fix --wait on delete

Change-Id: I40d808b8e62b6c25ffc5b2085d027d82ba7a6bc5
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osmclient/common/wait.py
osmclient/sol005/sdncontroller.py

index e3152af..d8923ba 100644 (file)
@@ -18,7 +18,7 @@
 OSM API handling for the '--wait' option
 """
 
 OSM API handling for the '--wait' option
 """
 
-from osmclient.common.exceptions import ClientException
+from osmclient.common.exceptions import ClientException, NotFound
 import json
 from time import sleep
 import sys
 import json
 from time import sleep
 import sys
@@ -192,7 +192,9 @@ def wait_for_status(entity_label, entity_id, timeout, apiUrlStatus, http_cmd, de
                 # There was a timeout, so raise an exception
                 raise ClientException('operation timeout, waited for {} seconds'.format(timeout))
     except ClientException as exc:
                 # There was a timeout, so raise an exception
                 raise ClientException('operation timeout, waited for {} seconds'.format(timeout))
     except ClientException as exc:
-        message="Operation failed for {}:\nerror:\n{}".format(
+        if deleteFlag and isinstance(exc, NotFound):
+            return
+        message = "Operation failed for {}:\nerror:\n{}".format(
             entity_label,
             str(exc))
         raise ClientException(message)
             entity_label,
             str(exc))
         raise ClientException(message)
index 35ad9ee..b02632e 100644 (file)
@@ -24,6 +24,7 @@ from osmclient.common.exceptions import ClientException
 from osmclient.common.exceptions import NotFound
 import json
 import logging
 from osmclient.common.exceptions import NotFound
 import json
 import logging
+import yaml
 
 
 class SdnController(object):
 
 
 class SdnController(object):
@@ -66,6 +67,8 @@ class SdnController(object):
 
     def create(self, name, sdn_controller, wait=False):
         self._logger.debug("")
 
     def create(self, name, sdn_controller, wait=False):
         self._logger.debug("")
+        if 'config' in sdn_controller and isinstance(sdn_controller["config"], str):
+            sdn_controller["config"] = yaml.safe_load(sdn_controller["config"])
         self._client.get_token()
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=sdn_controller)
         self._client.get_token()
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=sdn_controller)
@@ -92,6 +95,8 @@ class SdnController(object):
 
     def update(self, name, sdn_controller, wait=False):
         self._logger.debug("")
 
     def update(self, name, sdn_controller, wait=False):
         self._logger.debug("")
+        if 'config' in sdn_controller and isinstance(sdn_controller["config"], str):
+            sdn_controller["config"] = yaml.safe_load(sdn_controller["config"])
         self._client.get_token()
         sdnc = self.get(name)
         sdnc_id_for_wait = self._get_id_for_wait(name)
         self._client.get_token()
         sdnc = self.get(name)
         sdnc_id_for_wait = self._get_id_for_wait(name)