- self._apiName = '/admin'
- self._apiVersion = '/v1'
- self._apiResource = '/wim_accounts'
- self._apiBase = '{}{}{}'.format(self._apiName,
- self._apiVersion, self._apiResource)
- def create(self, name, wim_input, wim_port_mapping=None):
- if 'wim_type' not in wim_input:
+ self._logger = logging.getLogger("osmclient")
+ self._apiName = "/admin"
+ self._apiVersion = "/v1"
+ self._apiResource = "/wim_accounts"
+ self._apiBase = "{}{}{}".format(
+ self._apiName, self._apiVersion, self._apiResource
+ )
+
+ # WIM '--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, "/wim_accounts")
+ # Wait for status for WIM instance creation/deletion
+ if isinstance(wait_time, bool):
+ wait_time = WaitForStatus.TIMEOUT_WIM_OPERATION
+ WaitForStatus.wait_for_status(
+ "WIM",
+ 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 wim in self.list():
+ if name == wim["uuid"]:
+ return wim["uuid"]
+ for wim in self.list():
+ if name == wim["name"]:
+ return wim["uuid"]
+ return ""
+
+ def create(self, name, wim_input, wim_port_mapping=None, wait=False):
+ self._logger.debug("")
+ self._client.get_token()
+ if "wim_type" not in wim_input: