|
|
@ -24,7 +24,7 @@ NOTE: this utility library requires DECORT platform version 3.4.0 or higher.
|
|
|
|
It is not compatible with older versions.
|
|
|
|
It is not compatible with older versions.
|
|
|
|
|
|
|
|
|
|
|
|
Requirements:
|
|
|
|
Requirements:
|
|
|
|
- python >= 2.6
|
|
|
|
- python >= 3.8
|
|
|
|
- PyJWT Python module
|
|
|
|
- PyJWT Python module
|
|
|
|
- requests Python module
|
|
|
|
- requests Python module
|
|
|
|
- netaddr Python module
|
|
|
|
- netaddr Python module
|
|
|
@ -40,6 +40,7 @@ import requests
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# TODO: the following functionality to be implemented and/or tested
|
|
|
|
# TODO: the following functionality to be implemented and/or tested
|
|
|
|
# 4) workflow callbacks
|
|
|
|
# 4) workflow callbacks
|
|
|
@ -150,7 +151,7 @@ class DecortController(object):
|
|
|
|
if self.authenticator == "jwt":
|
|
|
|
if self.authenticator == "jwt":
|
|
|
|
# validate supplied JWT on the DECORT controller
|
|
|
|
# validate supplied JWT on the DECORT controller
|
|
|
|
self.validate_jwt() # this call will abort the script if validation fails
|
|
|
|
self.validate_jwt() # this call will abort the script if validation fails
|
|
|
|
jwt_decoded = jwt.decode(self.jwt, verify=False)
|
|
|
|
jwt_decoded = jwt.decode(self.jwt, algorithms=["ES384"], options={"verify_signature": False})
|
|
|
|
self.decort_username = jwt_decoded['username'] + "@" + jwt_decoded['iss']
|
|
|
|
self.decort_username = jwt_decoded['username'] + "@" + jwt_decoded['iss']
|
|
|
|
elif self.authenticator == "legacy":
|
|
|
|
elif self.authenticator == "legacy":
|
|
|
|
# obtain session id from the DECORT controller and thus validate the the legacy user
|
|
|
|
# obtain session id from the DECORT controller and thus validate the the legacy user
|
|
|
@ -161,7 +162,7 @@ class DecortController(object):
|
|
|
|
# obtain JWT from Oauth2 provider and validate on the DECORT controller
|
|
|
|
# obtain JWT from Oauth2 provider and validate on the DECORT controller
|
|
|
|
self.obtain_oauth2_jwt()
|
|
|
|
self.obtain_oauth2_jwt()
|
|
|
|
self.validate_jwt() # this call will abort the script if validation fails
|
|
|
|
self.validate_jwt() # this call will abort the script if validation fails
|
|
|
|
jwt_decoded = jwt.decode(self.jwt, verify=False)
|
|
|
|
jwt_decoded = jwt.decode(self.jwt, algorithms=["ES384"], options={"verify_signature": False})
|
|
|
|
self.decort_username = jwt_decoded['username'] + "@" + jwt_decoded['iss']
|
|
|
|
self.decort_username = jwt_decoded['username'] + "@" + jwt_decoded['iss']
|
|
|
|
|
|
|
|
|
|
|
|
# self.run_phase = "Initializing DecortController instance complete."
|
|
|
|
# self.run_phase = "Initializing DecortController instance complete."
|
|
|
@ -388,7 +389,8 @@ class DecortController(object):
|
|
|
|
return None # actually, this directive will never be executed as fail_json aborts the script
|
|
|
|
return None # actually, this directive will never be executed as fail_json aborts the script
|
|
|
|
except requests.exceptions.Timeout:
|
|
|
|
except requests.exceptions.Timeout:
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['msg'] = "Timeout when trying to connect to '{}' when calling DECORT API.".format(api_resp.url)
|
|
|
|
self.result['msg'] = "Timeout when trying to connect to '{}' when calling DECORT API.".format(
|
|
|
|
|
|
|
|
api_resp.url)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
@ -605,7 +607,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
return ret_comp_id, ret_comp_dict, ret_rg_id
|
|
|
|
return ret_comp_id, ret_comp_dict, ret_rg_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_find(self, comp_id,
|
|
|
|
def compute_find(self, comp_id,
|
|
|
|
comp_name="", rg_id=0,
|
|
|
|
comp_name="", rg_id=0,
|
|
|
|
check_state=True):
|
|
|
|
check_state=True):
|
|
|
@ -652,7 +653,8 @@ class DecortController(object):
|
|
|
|
# Therefore, RG ID cannot be zero and compute name cannot be empty.
|
|
|
|
# Therefore, RG ID cannot be zero and compute name cannot be empty.
|
|
|
|
if not rg_id and comp_name == "":
|
|
|
|
if not rg_id and comp_name == "":
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['msg'] = "compute_find(): cannot find Compute by name when either name is empty or RG ID is zero."
|
|
|
|
self.result[
|
|
|
|
|
|
|
|
'msg'] = "compute_find(): cannot find Compute by name when either name is empty or RG ID is zero."
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
# fail the module - exit
|
|
|
|
# fail the module - exit
|
|
|
|
|
|
|
|
|
|
|
@ -879,7 +881,8 @@ class DecortController(object):
|
|
|
|
# return
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/extnet/list", api_params)
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/extnet/list", api_params)
|
|
|
|
extnet_list = json.loads(api_resp.content.decode('utf8')) # list of dicts: "name" holds "NET_ADDR/NETMASK", "id" is ID
|
|
|
|
extnet_list = json.loads(
|
|
|
|
|
|
|
|
api_resp.content.decode('utf8')) # list of dicts: "name" holds "NET_ADDR/NETMASK", "id" is ID
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Empty extnet_list does not constitute error condition, so we should not fail the module in
|
|
|
|
# Empty extnet_list does not constitute error condition, so we should not fail the module in
|
|
|
|
# this case. Therefore the following code fragment is commented out.
|
|
|
|
# this case. Therefore the following code fragment is commented out.
|
|
|
@ -1186,6 +1189,47 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_affinity(self,comp_dict,tags,aff,aaff,label=""):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "compute_affinity")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(computeId=comp_dict['id'])
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/affinityRulesClear", api_params)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/antiAffinityRulesClear", api_params)
|
|
|
|
|
|
|
|
if tags:
|
|
|
|
|
|
|
|
for tag in tags:
|
|
|
|
|
|
|
|
api_params = dict(computeId=comp_dict['id'],
|
|
|
|
|
|
|
|
key=tag['key'],
|
|
|
|
|
|
|
|
value=tag['value'], )
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/tagAdd", api_params)
|
|
|
|
|
|
|
|
if label:
|
|
|
|
|
|
|
|
api_params = dict(computeId=comp_dict['id'],
|
|
|
|
|
|
|
|
affinityLabel=label,)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/affinityLabelSet", api_params)
|
|
|
|
|
|
|
|
if aff:
|
|
|
|
|
|
|
|
if len(aff[0])>0:
|
|
|
|
|
|
|
|
for rule in aff:
|
|
|
|
|
|
|
|
api_params = dict(computeId=comp_dict['id'],
|
|
|
|
|
|
|
|
key=rule['key'],
|
|
|
|
|
|
|
|
value=rule['value'],
|
|
|
|
|
|
|
|
topology=rule['topology'],
|
|
|
|
|
|
|
|
mode=rule['mode'],
|
|
|
|
|
|
|
|
policy=rule['policy'],)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/affinityRuleAdd", api_params)
|
|
|
|
|
|
|
|
if aaff:
|
|
|
|
|
|
|
|
if len(aaff[0])>0:
|
|
|
|
|
|
|
|
for rule in aaff:
|
|
|
|
|
|
|
|
api_params = dict(computeId=comp_dict['id'],
|
|
|
|
|
|
|
|
key=rule['key'],
|
|
|
|
|
|
|
|
value=rule['value'],
|
|
|
|
|
|
|
|
topology=rule['topology'],
|
|
|
|
|
|
|
|
mode=rule['mode'],
|
|
|
|
|
|
|
|
policy=rule['policy'],)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/antiAffinityRuleAdd", api_params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
|
|
|
|
###################################
|
|
|
|
###################################
|
|
|
|
# OS image manipulation methods
|
|
|
|
# OS image manipulation methods
|
|
|
|
###################################
|
|
|
|
###################################
|
|
|
@ -1200,7 +1244,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
return image_id, ret_image_dict
|
|
|
|
return image_id, ret_image_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def image_find(self, image_id, image_name, account_id, rg_id=0, sepid=0, pool=""):
|
|
|
|
def image_find(self, image_id, image_name, account_id, rg_id=0, sepid=0, pool=""):
|
|
|
|
"""Locates image specified by name and returns its facts as dictionary.
|
|
|
|
"""Locates image specified by name and returns its facts as dictionary.
|
|
|
|
Primary use of this function is to obtain the ID of the image identified by its name and,
|
|
|
|
Primary use of this function is to obtain the ID of the image identified by its name and,
|
|
|
@ -1402,7 +1445,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
return ret_rg_id, ret_rg_dict
|
|
|
|
return ret_rg_id, ret_rg_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rg_provision(self, arg_account_id, arg_rg_name, arg_username, arg_quota={}, arg_location="", arg_desc=""):
|
|
|
|
def rg_provision(self, arg_account_id, arg_rg_name, arg_username, arg_quota={}, arg_location="", arg_desc=""):
|
|
|
|
"""Provision new RG according to the specified arguments.
|
|
|
|
"""Provision new RG according to the specified arguments.
|
|
|
|
If critical error occurs the embedded call to API function will abort further execution of the script
|
|
|
|
If critical error occurs the embedded call to API function will abort further execution of the script
|
|
|
@ -1434,7 +1476,8 @@ class DecortController(object):
|
|
|
|
target_gid = self.gid_get(arg_location)
|
|
|
|
target_gid = self.gid_get(arg_location)
|
|
|
|
if not target_gid:
|
|
|
|
if not target_gid:
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['msg'] = ("rg_provision() failed to obtain valid Grid ID for location '{}'").format(arg_location)
|
|
|
|
self.result['msg'] = ("rg_provision() failed to obtain valid Grid ID for location '{}'").format(
|
|
|
|
|
|
|
|
arg_location)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(accountId=arg_account_id,
|
|
|
|
api_params = dict(accountId=arg_account_id,
|
|
|
@ -1560,7 +1603,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "rg_state")
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "rg_state")
|
|
|
|
|
|
|
|
|
|
|
|
NOP_STATES_FOR_RG_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING", "DESTROYED"]
|
|
|
|
NOP_STATES_FOR_RG_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING",
|
|
|
|
|
|
|
|
"DESTROYED"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled"]
|
|
|
|
|
|
|
|
|
|
|
|
if arg_rg_dict['status'] in NOP_STATES_FOR_RG_CHANGE:
|
|
|
|
if arg_rg_dict['status'] in NOP_STATES_FOR_RG_CHANGE:
|
|
|
@ -2072,7 +2116,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "vins_state")
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "vins_state")
|
|
|
|
|
|
|
|
|
|
|
|
NOP_STATES_FOR_VINS_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING", "DESTROYED"]
|
|
|
|
NOP_STATES_FOR_VINS_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING",
|
|
|
|
|
|
|
|
"DESTROYED"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled"]
|
|
|
|
|
|
|
|
|
|
|
|
if vins_dict['status'] in NOP_STATES_FOR_VINS_CHANGE:
|
|
|
|
if vins_dict['status'] in NOP_STATES_FOR_VINS_CHANGE:
|
|
|
@ -2195,7 +2240,8 @@ class DecortController(object):
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['warning'] = ("vins_update(): ViNS ID {} is already connected to ext net ID {}, "
|
|
|
|
self.result['warning'] = ("vins_update(): ViNS ID {} is already connected to ext net ID {}, "
|
|
|
|
"no reconnection to default network will be done.").format(vins_dict['id'],
|
|
|
|
"no reconnection to default network will be done.").format(vins_dict['id'],
|
|
|
|
gw_config['ext_net_id'])
|
|
|
|
gw_config[
|
|
|
|
|
|
|
|
'ext_net_id'])
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
@ -2285,7 +2331,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['msg'] = "disk_find() in check mode: find Disk ID {} / name '{}' was requested.".format(disk_id, disk_name)
|
|
|
|
self.result['msg'] = "disk_find() in check mode: find Disk ID {} / name '{}' was requested.".format(disk_id,
|
|
|
|
|
|
|
|
disk_name)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
ret_disk_id = 0
|
|
|
|
ret_disk_id = 0
|
|
|
@ -2348,7 +2395,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['msg'] = "disk_provision() in check mode: create Disk name '{}' was requested.".format(disk_name)
|
|
|
|
self.result['msg'] = "disk_provision() in check mode: create Disk name '{}' was requested.".format(
|
|
|
|
|
|
|
|
disk_name)
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
target_gid = self.gid_get(location)
|
|
|
|
target_gid = self.gid_get(location)
|
|
|
@ -2400,7 +2448,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
if not new_size:
|
|
|
|
if not new_size:
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['failed'] = False
|
|
|
|
self.result['warning'] = "disk_resize(): zero size requested for Disk ID {} - ignoring.".format(disk_facts['id'])
|
|
|
|
self.result['warning'] = "disk_resize(): zero size requested for Disk ID {} - ignoring.".format(
|
|
|
|
|
|
|
|
disk_facts['id'])
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if new_size < disk_facts['sizeMax']:
|
|
|
|
if new_size < disk_facts['sizeMax']:
|
|
|
@ -2451,7 +2500,6 @@ class DecortController(object):
|
|
|
|
self.result['changed'] = True
|
|
|
|
self.result['changed'] = True
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Port Forward rules management
|
|
|
|
# Port Forward rules management
|
|
|
@ -2526,7 +2574,8 @@ class DecortController(object):
|
|
|
|
break
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
decon.result['failed'] = True
|
|
|
|
decon.result['failed'] = True
|
|
|
|
decon.result['msg'] = "Compute ID {} is not connected to ViNS ID {}.".format(comp_facts['id'], vins_facts['id'])
|
|
|
|
decon.result['msg'] = "Compute ID {} is not connected to ViNS ID {}.".format(comp_facts['id'],
|
|
|
|
|
|
|
|
vins_facts['id'])
|
|
|
|
return ret_rules
|
|
|
|
return ret_rules
|
|
|
|
|
|
|
|
|
|
|
|
existing_rules = []
|
|
|
|
existing_rules = []
|
|
|
@ -2641,3 +2690,368 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
ret_rules = self._pfw_get(comp_facts['id'], vins_facts['id'])
|
|
|
|
ret_rules = self._pfw_get(comp_facts['id'], vins_facts['id'])
|
|
|
|
return ret_rules
|
|
|
|
return ret_rules
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _k8s_get_by_id(self, k8s_id):
|
|
|
|
|
|
|
|
"""Helper function that locates k8s by ID and returns k8s facts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param (int) k8s_id: ID of the k8s to find and return facts for.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@return: k8s ID and a dictionary of k8s facts as provided by k8s/get API call. Note that if it fails
|
|
|
|
|
|
|
|
to find the k8s with the specified ID, it may return 0 for ID and empty dictionary for the facts. So
|
|
|
|
|
|
|
|
it is suggested to check the return values accordingly.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
ret_k8s_id = 0
|
|
|
|
|
|
|
|
ret_k8s_dict = dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not k8s_id:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_get_by_id(): zero k8s ID specified."
|
|
|
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(k8sId=k8s_id, )
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/get", api_params)
|
|
|
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
|
|
|
ret_k8s_id = k8s_id
|
|
|
|
|
|
|
|
ret_k8s_dict = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['warning'] = ("k8s_get_by_id(): failed to get k8s by ID {}. HTTP code {}, "
|
|
|
|
|
|
|
|
"response {}.").format(k8s_id, api_resp.status_code, api_resp.reason)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret_k8s_id, ret_k8s_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##############################
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# K8s management
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
##############################
|
|
|
|
|
|
|
|
def k8s_find(self, k8s_id, k8s_name="",rg_id=0,check_state=True):
|
|
|
|
|
|
|
|
"""Returns non zero k8s ID and a dictionary with k8s details on success, 0 and empty dictionary otherwise.
|
|
|
|
|
|
|
|
This method does not fail the run if k8s cannot be located by its name (arg_k8s_name), because this could be
|
|
|
|
|
|
|
|
an indicator of the requested k8s never existed before.
|
|
|
|
|
|
|
|
However, it does fail the run if k8s cannot be located by arg_k8s_id (if non zero specified) or if API errors
|
|
|
|
|
|
|
|
occur.
|
|
|
|
|
|
|
|
@param (int) arg_k8s_id: integer ID of the k8s to be found. If non-zero k8s ID is passed, account ID and k8s name
|
|
|
|
|
|
|
|
are ignored. However, k8s must be present in this case, as knowing its ID implies it already exists, otherwise
|
|
|
|
|
|
|
|
method will fail.
|
|
|
|
|
|
|
|
@param (string) arg_k8s_name: string that defines the name of k8s to be found. This parameter is case sensitive.
|
|
|
|
|
|
|
|
@param (bool) arg_check_state: tells the method to report k8s in valid states only.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@return: ID of the k8s, if found. Zero otherwise.
|
|
|
|
|
|
|
|
@return: dictionary with k8s facts if k8s is present. Empty dictionary otherwise. None on error.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Resource group can be in one of the following states:
|
|
|
|
|
|
|
|
# MODELED, CREATED, DISABLING, DISABLED, ENABLING, DELETING, DELETED, DESTROYED, DESTROYED
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Transient state (ending with ING) are invalid from k8s manipulation viewpoint
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
K8S_INVALID_STATES = ["MODELED","DESTROYED","DESTROYING"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_find")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret_k8s_id = 0
|
|
|
|
|
|
|
|
api_params = dict(includedeleted=True)
|
|
|
|
|
|
|
|
ret_k8s_dict = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if k8s_id:
|
|
|
|
|
|
|
|
ret_k8s_id, ret_k8s_dict = self._k8s_get_by_id(k8s_id)
|
|
|
|
|
|
|
|
if not ret_k8s_id:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_find(): cannot find k8s cluster by ID {}.".format(k8s_id)
|
|
|
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/list", api_params)
|
|
|
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
|
|
|
k8s_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
|
|
|
for k8s_item in k8s_list:
|
|
|
|
|
|
|
|
if k8s_item['name'] == k8s_name and k8s_item['rgId'] == rg_id:
|
|
|
|
|
|
|
|
if not check_state or k8s_item['status'] not in K8S_INVALID_STATES:
|
|
|
|
|
|
|
|
ret_k8s_id = k8s_item['id']
|
|
|
|
|
|
|
|
_, ret_k8s_dict = self._k8s_get_by_id(ret_k8s_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret_k8s_id, ret_k8s_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_state(self, arg_k8s_dict, arg_desired_state, arg_started=False):
|
|
|
|
|
|
|
|
"""Enable or disable k8s cluster.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param arg_k8s_dict: dictionary with the target k8s facts as returned by k8s_find(...) method or
|
|
|
|
|
|
|
|
.../k8s/get API call.
|
|
|
|
|
|
|
|
@param arg_desired_state: the desired state for this k8s cluster. Valid states are 'enabled' and 'disabled'.
|
|
|
|
|
|
|
|
@param arg_started: the desired tech state for this k8s cluster. Valid states are 'True' and 'False'.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_state")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOP_STATES_FOR_K8S_CHANGE = ["MODELED", "DISABLING",
|
|
|
|
|
|
|
|
"ENABLING", "DELETING",
|
|
|
|
|
|
|
|
"DELETED", "DESTROYING",
|
|
|
|
|
|
|
|
"DESTROYED", "CREATING",
|
|
|
|
|
|
|
|
"RESTORING"]
|
|
|
|
|
|
|
|
VALID_TARGET_STATES = ["ENABLED", "DISABLED"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if arg_k8s_dict['status'] in NOP_STATES_FOR_K8S_CHANGE:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = ("k8s_state(): no state change possible for k8s ID {} "
|
|
|
|
|
|
|
|
"in its current state '{}'.").format(arg_k8s_dict['id'], arg_k8s_dict['status'])
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
if arg_k8s_dict['status'] not in VALID_TARGET_STATES:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['warning'] = ("k8s_state(): unrecognized desired state '{}' requested "
|
|
|
|
|
|
|
|
"for k8s ID {}. No k8s state change will be done.").format(arg_desired_state,
|
|
|
|
|
|
|
|
arg_k8s_dict['id'])
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = ("k8s_state() in check mode: setting state of k8s ID {}, name '{}' to "
|
|
|
|
|
|
|
|
"'{}' was requested.").format(arg_k8s_dict['id'], arg_k8s_dict['name'],
|
|
|
|
|
|
|
|
arg_desired_state)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
if arg_desired_state == 'present':
|
|
|
|
|
|
|
|
arg_desired_state = 'enabled'
|
|
|
|
|
|
|
|
k8s_state_api = "" # This string will also be used as a flag to indicate that API call is necessary
|
|
|
|
|
|
|
|
api_params = dict(k8sId=arg_k8s_dict['id'])
|
|
|
|
|
|
|
|
expected_state = ""
|
|
|
|
|
|
|
|
tech_state = ""
|
|
|
|
|
|
|
|
if arg_k8s_dict['status'] in ["CREATED", "ENABLED"] and arg_desired_state == 'disabled':
|
|
|
|
|
|
|
|
k8s_state_api = "/restmachine/cloudapi/k8s/disable"
|
|
|
|
|
|
|
|
expected_state = "DISABLED"
|
|
|
|
|
|
|
|
elif arg_k8s_dict['status'] in ["CREATED", "DISABLED"] and arg_desired_state == 'enabled':
|
|
|
|
|
|
|
|
k8s_state_api = "/restmachine/cloudapi/k8s/enable"
|
|
|
|
|
|
|
|
expected_state = "ENABLED"
|
|
|
|
|
|
|
|
elif arg_k8s_dict['status'] == "ENABLED" and arg_desired_state == 'enabled' and arg_started is True and arg_k8s_dict['techStatus'] == "STOPPED":
|
|
|
|
|
|
|
|
k8s_state_api = "/restmachine/cloudapi/k8s/start"
|
|
|
|
|
|
|
|
tech_state = "STARTED"
|
|
|
|
|
|
|
|
elif arg_k8s_dict['status'] == "ENABLED" and arg_desired_state == 'enabled' and arg_started is False and arg_k8s_dict['techStatus'] == "STARTED":
|
|
|
|
|
|
|
|
k8s_state_api = "/restmachine/cloudapi/k8s/stop"
|
|
|
|
|
|
|
|
tech_state = "STOPPED"
|
|
|
|
|
|
|
|
if k8s_state_api != "":
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, k8s_state_api, api_params)
|
|
|
|
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
arg_k8s_dict['status'] = expected_state
|
|
|
|
|
|
|
|
arg_k8s_dict['started'] = tech_state
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = ("k8s_state(): no state change required for k8s ID {} from current "
|
|
|
|
|
|
|
|
"state '{}' to desired state '{}'.").format(arg_k8s_dict['id'],
|
|
|
|
|
|
|
|
arg_k8s_dict['status'],
|
|
|
|
|
|
|
|
arg_desired_state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_delete(self, k8s_id, permanently=False):
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_delete")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_delete() in check mode: delete K8s cluster ID {} was requested.".format(k8s_id)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(k8sId=k8s_id,
|
|
|
|
|
|
|
|
permanently=False,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/delete", api_params)
|
|
|
|
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_delete() K8s cluster ID {} was deleted.".format(k8s_id)
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_restore(self, k8s_id ):
|
|
|
|
|
|
|
|
"""Restores a deleted k8s cluster identified by ID.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param k8s_id: ID of the k8s cluster to restore.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_restore")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_restore() in check mode: restore k8s ID {} was requested.".format(k8s_id)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(k8sId=k8s_id)
|
|
|
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/restore", api_params)
|
|
|
|
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_enable(self,k8s_id):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_enable")
|
|
|
|
|
|
|
|
api_params = dict(k8sId=k8s_id)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/enable", api_params)
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_provision(self, k8s_name,
|
|
|
|
|
|
|
|
wg_name, k8ci_id,
|
|
|
|
|
|
|
|
rg_id, master_count,
|
|
|
|
|
|
|
|
master_cpu, master_ram,
|
|
|
|
|
|
|
|
master_disk, worker_count,
|
|
|
|
|
|
|
|
worker_cpu, worker_ram,
|
|
|
|
|
|
|
|
worker_disk, extnet_id,
|
|
|
|
|
|
|
|
with_lb, annotation, ):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_provision")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = ("k8s_provision() in check mode. Provision k8s '{}' in RG ID {} "
|
|
|
|
|
|
|
|
"was requested.").format(k8s_name, rg_id)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_url = "/restmachine/cloudapi/k8s/create"
|
|
|
|
|
|
|
|
api_params = dict(name=k8s_name,
|
|
|
|
|
|
|
|
rgId=rg_id,
|
|
|
|
|
|
|
|
k8ciId=k8ci_id,
|
|
|
|
|
|
|
|
workerGroupName=wg_name,
|
|
|
|
|
|
|
|
masterNum=master_count,
|
|
|
|
|
|
|
|
masterCpu=master_cpu,
|
|
|
|
|
|
|
|
masterRam=master_ram,
|
|
|
|
|
|
|
|
masterDisk=master_disk,
|
|
|
|
|
|
|
|
workerNum=worker_count,
|
|
|
|
|
|
|
|
workerCpu=worker_cpu,
|
|
|
|
|
|
|
|
workerRam=worker_ram,
|
|
|
|
|
|
|
|
workerDisk=worker_disk,
|
|
|
|
|
|
|
|
extnetId=extnet_id,
|
|
|
|
|
|
|
|
withLB=with_lb,
|
|
|
|
|
|
|
|
desc=annotation,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, api_url, api_params)
|
|
|
|
|
|
|
|
k8s_id = ""
|
|
|
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
|
|
|
for i in range(300):
|
|
|
|
|
|
|
|
api_get_url = "/restmachine/cloudapi/tasks/get"
|
|
|
|
|
|
|
|
api_get_params = dict(
|
|
|
|
|
|
|
|
auditId=api_resp.content.decode('utf8').replace('"', '')
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
api_get_resp = self.decort_api_call(requests.post, api_get_url, api_get_params)
|
|
|
|
|
|
|
|
ret_info = json.loads(api_get_resp.content.decode('utf8'))
|
|
|
|
|
|
|
|
if api_get_resp.status_code == 200:
|
|
|
|
|
|
|
|
if ret_info['status'] in ["PROCESSING", "SCHEDULED"]:
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
time.sleep(30)
|
|
|
|
|
|
|
|
elif ret_info['status'] == "ERROR":
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
elif ret_info['status'] == "OK":
|
|
|
|
|
|
|
|
k8s_id = ret_info['result'][0]
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
return k8s_id
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
k8s_id = ret_info['status']
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
# Timeout
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_workers_modify(self,arg_k8swg,arg_modwg):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_workers_modify")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.k8s_info['techStatus'] != "STARTED":
|
|
|
|
|
|
|
|
self.result['changed'] = False
|
|
|
|
|
|
|
|
self.result['msg'] = ("k8s_workers_modify(): Can't modify with TechStatus other then STARTED")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wg_del_list = []
|
|
|
|
|
|
|
|
wg_add_list = []
|
|
|
|
|
|
|
|
wg_modadd_list = []
|
|
|
|
|
|
|
|
wg_moddel_list = []
|
|
|
|
|
|
|
|
wg_outer = [rec['name'] for rec in arg_modwg]
|
|
|
|
|
|
|
|
wg_inner = [rec['name'] for rec in arg_k8swg['k8sGroups']['workers']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for rec in arg_k8swg['k8sGroups']['workers']:
|
|
|
|
|
|
|
|
if rec['name'] not in wg_outer:
|
|
|
|
|
|
|
|
wg_del_list.append(rec['id'])
|
|
|
|
|
|
|
|
for rec in arg_modwg:
|
|
|
|
|
|
|
|
if rec['name'] not in wg_inner:
|
|
|
|
|
|
|
|
wg_add_list.append(rec)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for rec_inn in arg_k8swg['k8sGroups']['workers']:
|
|
|
|
|
|
|
|
for rec_out in arg_modwg:
|
|
|
|
|
|
|
|
if rec_inn['num'] != rec_out['num']:
|
|
|
|
|
|
|
|
count = rec_inn['num']-rec_out['num']
|
|
|
|
|
|
|
|
cmp_list = []
|
|
|
|
|
|
|
|
if count > 0:
|
|
|
|
|
|
|
|
for cmp in rec_inn['detailedInfo'][:count]:
|
|
|
|
|
|
|
|
cmp_list.append(cmp['id'])
|
|
|
|
|
|
|
|
wg_moddel_list.append({rec_inn['id']:cmp_list})
|
|
|
|
|
|
|
|
if count < 0:
|
|
|
|
|
|
|
|
wg_modadd_list.append({rec_inn['id']:abs(count)})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if wg_del_list:
|
|
|
|
|
|
|
|
for wgid in wg_del_list:
|
|
|
|
|
|
|
|
api_params = dict(k8sId=self.k8s_id,workersGroupId=wgid)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/workersGroupDelete", api_params)
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
if wg_add_list:
|
|
|
|
|
|
|
|
for wg in wg_add_list:
|
|
|
|
|
|
|
|
api_params = dict(k8sId=self.k8s_id,
|
|
|
|
|
|
|
|
name=wg['name'],
|
|
|
|
|
|
|
|
workerNum=wg['num'],
|
|
|
|
|
|
|
|
workerCpu=wg['cpu'],
|
|
|
|
|
|
|
|
workerRam=wg['ram'],
|
|
|
|
|
|
|
|
workerDisk=wg['disk'],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/workersGroupAdd", api_params)
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
if wg_modadd_list:
|
|
|
|
|
|
|
|
for wg in wg_modadd_list:
|
|
|
|
|
|
|
|
for key in wg:
|
|
|
|
|
|
|
|
api_params = dict(k8sId=self.k8s_id,workersGroupId=key,num=wg[key])
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/workerAdd", api_params)
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
if wg_moddel_list:
|
|
|
|
|
|
|
|
for wg in wg_moddel_list:
|
|
|
|
|
|
|
|
for key in wg:
|
|
|
|
|
|
|
|
for cmpid in wg[key]:
|
|
|
|
|
|
|
|
api_params = dict(k8sId=self.k8s_id,workersGroupId=key,workerId=cmpid)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/deleteWorkerFromGroup", api_params)
|
|
|
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_k8ci_find(self,arg_k8ci_id):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_k8ci_find")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(includeDisabled=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8ci/list", api_params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
|
|
|
ret_k8ci_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
|
|
|
for k8ci_item in ret_k8ci_list:
|
|
|
|
|
|
|
|
if k8ci_item['id'] == arg_k8ci_id:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
self.result['msg'] = "k8s_k8ci_find(): cannot find ID."
|
|
|
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
|
|
|
self.result['msg'] = ("Failed to get k8ci list HTTP code {}.").format(api_resp.status_code)
|
|
|
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
return arg_k8ci_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def k8s_getConfig(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_getConfig")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(k8sId=self.k8s_id)
|
|
|
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/getConfig", api_params)
|
|
|
|
|
|
|
|
ret_conf = api_resp.content.decode('utf8')
|
|
|
|
|
|
|
|
return ret_conf
|
|
|
|
|
|
|
|
|
|
|
|