- self._apiName = '/admin'
- self._apiVersion = '/v1'
- self._apiResource = '/sdns'
- self._apiBase = '{}{}{}'.format(self._apiName,
- self._apiVersion, self._apiResource)
- def create(self, name, sdn_controller):
- http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
- postfields_dict=sdn_controller)
+ self._logger = logging.getLogger("osmclient")
+ self._apiName = "/admin"
+ self._apiVersion = "/v1"
+ self._apiResource = "/sdns"
+ self._apiBase = "{}{}{}".format(
+ self._apiName, self._apiVersion, self._apiResource
+ )
+
+ # SDNC '--wait' option
+ def _wait(self, id, wait_time, deleteFlag=False):
+ self._logger.debug("")
+ self._client.get_token()
+ # Endpoint to get operation status
+ apiUrlStatus = "{}{}{}".format(self._apiName, self._apiVersion, "/sdns")
+ # Wait for status for SDN instance creation/update/deletion
+ if isinstance(wait_time, bool):
+ wait_time = WaitForStatus.TIMEOUT_SDNC_OPERATION
+ WaitForStatus.wait_for_status(
+ "SDNC",
+ str(id),
+ wait_time,
+ apiUrlStatus,
+ self._http.get2_cmd,
+ deleteFlag=deleteFlag,
+ )
+
+ def _get_id_for_wait(self, name):
+ """Returns id of name, or the id itself if given as argument"""
+ self._logger.debug("")
+ for sdnc in self.list():
+ if name == sdnc["_id"] or name == sdnc["name"]:
+ return sdnc["_id"]
+ return ""
+
+ 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
+ )
+ # print('HTTP CODE: {}'.format(http_code))
+ # print('RESP: {}'.format(resp))
+ # if http_code in (200, 201, 202, 204):