- k8s_cluster['vim_account'] = get_vim_account_id(k8s_cluster['vim_account'])
- http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
- postfields_dict=k8s_cluster)
- #print 'HTTP CODE: {}'.format(http_code)
- #print 'RESP: {}'.format(resp)
- if http_code in (200, 201, 202, 204):
- if resp:
- resp = json.loads(resp)
- if not resp or 'id' not in resp:
- raise ClientException('unexpected response from server - {}'.format(
- resp))
- print(resp['id'])
- else:
- msg = ""
- if resp:
- try:
- msg = json.loads(resp)
- except ValueError:
- msg = resp
- raise ClientException("failed to add K8s cluster {} - {}".format(name, msg))
+ 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.post_cmd(
+ endpoint=self._apiBase, postfields_dict=k8s_cluster
+ )
+ # print 'HTTP CODE: {}'.format(http_code)
+ # print 'RESP: {}'.format(resp)
+ # if http_code in (200, 201, 202, 204):
+ if resp:
+ resp = json.loads(resp)
+ if not resp or "id" not in resp:
+ raise ClientException("unexpected response from server - {}".format(resp))
+ print(resp["id"])
+ # else:
+ # msg = ""
+ # if resp:
+ # try:
+ # msg = json.loads(resp)
+ # except ValueError:
+ # msg = resp
+ # raise ClientException("failed to add K8s cluster {} - {}".format(name, msg))