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
# 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)
from osmclient.common.exceptions import NotFound
import json
import logging
+import yaml
class SdnController(object):
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)
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)