- http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,cluster['_id']),
- postfields_dict=k8s_cluster)
- # print 'HTTP CODE: {}'.format(http_code)
- # print 'RESP: {}'.format(resp)
- #if http_code in (200, 201, 202, 204):
- #pass
- #else:
- # msg = ""
- # if resp:
- # try:
- # msg = json.loads(resp)
- # except ValueError:
- # msg = resp
- # raise ClientException("failed to update K8s cluster {} - {}".format(name, msg))
+ if "vim_account" in k8s_cluster:
+ vim_account = self._get_vim_account(k8s_cluster["vim_account"])
+ k8s_cluster["vim_account"] = vim_account["_id"]
+ if "vca" in vim_account:
+ k8s_cluster["vca_id"] = vim_account["vca"]
+ http_code, resp = self._http.patch_cmd(
+ endpoint="{}/{}".format(self._apiBase, cluster["_id"]),
+ postfields_dict=k8s_cluster,
+ )
+
+ if wait:
+ wait_id = cluster["_id"]
+ self._wait(wait_id, wait)
+
+ self._logger.debug("HTTP CODE: {}".format(http_code))
+ self._logger.debug("RESP: {}".format(resp))
+
+ if http_code in (200, 201, 202, 204):
+ print("Updated")
+ else:
+ msg = ""
+ if resp:
+ try:
+ msg = json.loads(resp)
+ except ValueError:
+ msg = resp
+ raise ClientException(
+ "failed to update K8s cluster {} - {}".format(name, msg)
+ )