|
|
|
@ -392,10 +392,12 @@ class DecortController(object):
|
|
|
|
|
retry_counter = retry_counter - 1
|
|
|
|
|
else:
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
self.result['msg'] = ("Error when calling DECORT API '{}', HTTP status code '{}', "
|
|
|
|
|
"reason '{}', parameters '{}'.").format(api_resp.url,
|
|
|
|
|
api_resp.status_code,
|
|
|
|
|
api_resp.reason, arg_params)
|
|
|
|
|
self.result['msg'] = (
|
|
|
|
|
f'Error when calling DECORT API {api_resp.url}'
|
|
|
|
|
f', HTTP status code {api_resp.status_code}'
|
|
|
|
|
f', reason "{api_resp.reason}"'
|
|
|
|
|
f', parameters {arg_params}, text {api_resp.text}.'
|
|
|
|
|
)
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
return None # actually, this directive will never be executed as fail_json aborts the script
|
|
|
|
|
|
|
|
|
@ -1102,10 +1104,6 @@ class DecortController(object):
|
|
|
|
|
elif not new_ram:
|
|
|
|
|
new_ram = comp_dict['ram']
|
|
|
|
|
|
|
|
|
|
# stupid hack?
|
|
|
|
|
if new_ram > 1 and new_ram < 512:
|
|
|
|
|
new_ram = new_ram * 1024
|
|
|
|
|
|
|
|
|
|
if comp_dict['cpus'] == new_cpu and comp_dict['ram'] == new_ram:
|
|
|
|
|
# no need to call API in this case, as requested size is not different from the current one
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
@ -1247,7 +1245,7 @@ class DecortController(object):
|
|
|
|
|
if comp_dict['affinityRules']:
|
|
|
|
|
for rule in comp_dict['affinityRules']:
|
|
|
|
|
del rule['guid']
|
|
|
|
|
if rule not in aff:
|
|
|
|
|
if not aff or rule not in aff:
|
|
|
|
|
affrule_del.append(rule)
|
|
|
|
|
|
|
|
|
|
if aff:
|
|
|
|
@ -1259,7 +1257,7 @@ class DecortController(object):
|
|
|
|
|
if comp_dict['antiAffinityRules']:
|
|
|
|
|
for rule in comp_dict['antiAffinityRules']:
|
|
|
|
|
del rule['guid']
|
|
|
|
|
if rule not in aaff:
|
|
|
|
|
if not aaff or rule not in aaff:
|
|
|
|
|
aaffrule_del.append(rule)
|
|
|
|
|
|
|
|
|
|
if aaff:
|
|
|
|
@ -1388,7 +1386,6 @@ class DecortController(object):
|
|
|
|
|
return image_record['id'], image_record
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
self.result['msg'] = ("Failed to find OS image by name '{}', SEP ID {}, pool '{}' for "
|
|
|
|
|
"account ID '{}'.").format(image_name,
|
|
|
|
|
sepid, pool,
|
|
|
|
@ -1441,7 +1438,7 @@ class DecortController(object):
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/image/list", api_params)
|
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
|
|
images_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
for image_record in images_list:
|
|
|
|
|
for image_record in images_list['data']:
|
|
|
|
|
if image_record['name'] == virt_name and image_record['status'] == "CREATED" and image_record['type'] == "virtual":
|
|
|
|
|
if sepid == 0 and pool == "":
|
|
|
|
|
# if no filtering by SEP ID or pool name is requested, return the first match
|
|
|
|
@ -1450,7 +1447,6 @@ class DecortController(object):
|
|
|
|
|
if full_match:
|
|
|
|
|
return image_record['id'], image_record
|
|
|
|
|
|
|
|
|
|
self.result['failed'] = True
|
|
|
|
|
self.result['msg'] = ("Failed to find virtual OS image by name '{}', SEP ID {}, pool '{}' for "
|
|
|
|
|
"account ID '{}'.").format(virt_name,
|
|
|
|
|
sepid, pool,
|
|
|
|
@ -1563,9 +1559,10 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
@param (int) )rg_id: ID of the RG to find and return facts for.
|
|
|
|
|
|
|
|
|
|
@return: RG ID and a dictionary of RG facts as provided by rg/get API call. Note that if it fails
|
|
|
|
|
to find the RG 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.
|
|
|
|
|
@return: RG ID and a dictionary of RG facts as provided by rg/get
|
|
|
|
|
API call. Note that if it fails to find the RG 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_rg_id = 0
|
|
|
|
|
ret_rg_dict = dict()
|
|
|
|
@ -1575,14 +1572,41 @@ class DecortController(object):
|
|
|
|
|
self.result['msg'] = "rg_get_by_id(): zero RG ID specified."
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
|
|
api_params = dict(rgId=rg_id, )
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/rg/get", api_params)
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
ret_rg_id = rg_id
|
|
|
|
|
ret_rg_dict = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
api_params = {'rgId': rg_id}
|
|
|
|
|
|
|
|
|
|
# Get RG base info
|
|
|
|
|
api_rg_resp = self.decort_api_call(
|
|
|
|
|
arg_req_function=requests.post,
|
|
|
|
|
arg_api_name='/restmachine/cloudapi/rg/get',
|
|
|
|
|
arg_params=api_params
|
|
|
|
|
)
|
|
|
|
|
if api_rg_resp.status_code != 200:
|
|
|
|
|
self.result['warning'] = (
|
|
|
|
|
f'rg_get_by_id(): failed to get RG by ID {rg_id}.'
|
|
|
|
|
f' HTTP code {api_rg_resp.status_code}'
|
|
|
|
|
f', response {api_rg_resp.reason}.'
|
|
|
|
|
)
|
|
|
|
|
return ret_rg_id, ret_rg_dict
|
|
|
|
|
ret_rg_id = rg_id
|
|
|
|
|
ret_rg_dict = api_rg_resp.json()
|
|
|
|
|
|
|
|
|
|
# Get RG resources info
|
|
|
|
|
rg_status = ret_rg_dict.get('status')
|
|
|
|
|
if not rg_status or rg_status in ('DELETED', 'DESTROYED'):
|
|
|
|
|
return ret_rg_id, ret_rg_dict
|
|
|
|
|
api_rg_res_resp = self.decort_api_call(
|
|
|
|
|
arg_req_function=requests.post,
|
|
|
|
|
arg_api_name='/restmachine/cloudapi/rg/getResourceConsumption',
|
|
|
|
|
arg_params=api_params
|
|
|
|
|
)
|
|
|
|
|
if api_rg_res_resp.status_code != 200:
|
|
|
|
|
self.result['warning'] = (
|
|
|
|
|
f'rg_get_by_id(): failed to get RG Resources by ID {rg_id}.'
|
|
|
|
|
f' HTTP code {api_rg_res_resp.status_code}'
|
|
|
|
|
f', response {api_rg_res_resp.reason}.'
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
self.result['warning'] = ("rg_get_by_id(): failed to get RG by ID {}. HTTP code {}, "
|
|
|
|
|
"response {}.").format(rg_id, api_resp.status_code, api_resp.reason)
|
|
|
|
|
ret_rg_dict['Resources'] = api_rg_res_resp.json()
|
|
|
|
|
|
|
|
|
|
return ret_rg_id, ret_rg_dict
|
|
|
|
|
|
|
|
|
@ -1658,7 +1682,7 @@ class DecortController(object):
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
# try to locate RG by name - start with getting all RGs IDs within the specified account
|
|
|
|
|
#api_params['accountId'] = arg_account_id
|
|
|
|
|
api_params['includedeleted'] = False
|
|
|
|
|
api_params['includedeleted'] = True
|
|
|
|
|
#api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/account/listRG", api_params)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/rg/list",api_params)
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
@ -1841,7 +1865,7 @@ class DecortController(object):
|
|
|
|
|
# - when quering resource limits, the keys are in the form of cloud units (CU_*)
|
|
|
|
|
query_key_map = dict(cpu='CU_C',
|
|
|
|
|
ram='CU_M',
|
|
|
|
|
disk='CU_D',
|
|
|
|
|
disk='CU_DM',
|
|
|
|
|
ext_ips='CU_I',
|
|
|
|
|
net_transfer='CU_NP',)
|
|
|
|
|
set_key_map = dict(cpu='maxCPUCapacity',
|
|
|
|
@ -2250,9 +2274,9 @@ class DecortController(object):
|
|
|
|
|
# self.result['msg'] = "vins_find(): cannot find Account ID {}.".format(account_id)
|
|
|
|
|
# self.amodule.fail_json(**self.result)
|
|
|
|
|
# NOTE: account's 'vins' attribute does not list destroyed ViNSes!
|
|
|
|
|
for runner in rg_facts['vins']:
|
|
|
|
|
# api_params['vinsId'] = runner
|
|
|
|
|
ret_vins_id, ret_vins_facts = self._vins_get_by_id(runner)
|
|
|
|
|
account_vinses = self._get_all_account_vinses(account_id)
|
|
|
|
|
for vins in account_vinses:
|
|
|
|
|
ret_vins_id, ret_vins_facts = self._vins_get_by_id(vins['id'])
|
|
|
|
|
if ret_vins_id and ret_vins_facts['name'] == vins_name:
|
|
|
|
|
if not check_state or ret_vins_facts['status'] not in VINS_INVALID_STATES:
|
|
|
|
|
return ret_vins_id, ret_vins_facts
|
|
|
|
@ -2729,7 +2753,7 @@ class DecortController(object):
|
|
|
|
|
"write_iops_sec_max",
|
|
|
|
|
"size_iops_sec",
|
|
|
|
|
):
|
|
|
|
|
if val and val < self.MIN_IOPS:
|
|
|
|
|
if val and val < MIN_IOPS:
|
|
|
|
|
self.result['msg'] = (f"{arg} was set below the minimum iops {MIN_IOPS}: {val} provided")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@ -2812,12 +2836,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
DISK_INVALID_STATES = ["MODELED", "CREATING", "DELETING", "DESTROYING"]
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
self.result['msg'] = "disk_find() in check mode: find Disk ID {} / name '{}' was requested.".format(disk_id,
|
|
|
|
|
name)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
ret_disk_id = 0
|
|
|
|
|
ret_disk_facts = None
|
|
|
|
|
|
|
|
|
@ -2833,10 +2851,18 @@ class DecortController(object):
|
|
|
|
|
return 0, None
|
|
|
|
|
elif name:
|
|
|
|
|
if account_id:
|
|
|
|
|
api_params = dict(accountId=account_id,name=name)
|
|
|
|
|
api_params = {
|
|
|
|
|
'accountId': account_id,
|
|
|
|
|
'name': name,
|
|
|
|
|
'show_all': True
|
|
|
|
|
}
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/search", api_params)
|
|
|
|
|
disks_list = api_resp.json()
|
|
|
|
|
# Filtering disks by status
|
|
|
|
|
excluded_statuses = ('PURGED', 'DESTROYED')
|
|
|
|
|
filter_f = lambda x: x.get('status') not in excluded_statuses
|
|
|
|
|
disks_list = [d for d in disks_list if filter_f(d)]
|
|
|
|
|
# the above call may return more than one matching disk
|
|
|
|
|
disks_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
if len(disks_list) == 0:
|
|
|
|
|
return 0, None
|
|
|
|
|
elif len(disks_list) > 1:
|
|
|
|
@ -3108,7 +3134,7 @@ class DecortController(object):
|
|
|
|
|
if runner['vmId'] == comp_facts['id']:
|
|
|
|
|
existing_rules.append(runner)
|
|
|
|
|
|
|
|
|
|
if not len(existing_rules) and not len(new_rules):
|
|
|
|
|
if not existing_rules and not new_rules:
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
self.result['warning'] = ("pfw_configure(): both existing and new port forwarding rule lists "
|
|
|
|
|
"for Compute ID {} are empty - nothing to do.").format(comp_facts['id'])
|
|
|
|
@ -3116,9 +3142,15 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
if new_rules == None or len(new_rules) == 0:
|
|
|
|
|
# delete all existing rules for this Compute
|
|
|
|
|
api_params = dict(vinsId=vins_facts['id'],
|
|
|
|
|
ruleId=-1)
|
|
|
|
|
self.decort_api_call(requests.post, "/restmachine/cloudapi/vins/natRuleDel", api_params)
|
|
|
|
|
for rule in existing_rules:
|
|
|
|
|
self.decort_api_call(
|
|
|
|
|
arg_req_function=requests.post,
|
|
|
|
|
arg_api_name="/restmachine/cloudapi/vins/natRuleDel",
|
|
|
|
|
arg_params={
|
|
|
|
|
'vinsId': vins_facts['id'],
|
|
|
|
|
'ruleId': rule['id']
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
return ret_rules
|
|
|
|
|
|
|
|
|
@ -3456,7 +3488,7 @@ class DecortController(object):
|
|
|
|
|
api_params = dict(name=k8s_name,
|
|
|
|
|
rgId=rg_id,
|
|
|
|
|
k8ciId=k8ci_id,
|
|
|
|
|
vins_Id=vins_id,
|
|
|
|
|
vinsId=vins_id,
|
|
|
|
|
workerGroupName=def_wg_name,
|
|
|
|
|
networkPlugin=plugin,
|
|
|
|
|
masterNum=master_count,
|
|
|
|
@ -3488,6 +3520,7 @@ class DecortController(object):
|
|
|
|
|
extnetOnly=extnet_only,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
upload_files = None
|
|
|
|
|
if oidc_cert:
|
|
|
|
|
upload_files = {'oidcCertificate': ('cert.pem', str(oidc_cert),'application/x-x509-ca-cert')}
|
|
|
|
|
|
|
|
|
@ -3534,9 +3567,15 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "k8s_workers_modify")
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
result_msg = 'k8s_workers_modify() in check mode: No changing.'
|
|
|
|
|
if self.result.get('msg'):
|
|
|
|
|
self.result['msg'] += f'\n{result_msg}'
|
|
|
|
|
else:
|
|
|
|
|
self.result['msg'] = result_msg
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@ -3698,6 +3737,14 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "bservice_provision")
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
result_msg = 'bservice_provision() in check mode: No changing.'
|
|
|
|
|
if self.result.get('msg'):
|
|
|
|
|
self.result['msg'] += f'\n{result_msg}'
|
|
|
|
|
else:
|
|
|
|
|
self.result['msg'] = result_msg
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
api_url = "/restmachine/cloudapi/bservice/create"
|
|
|
|
|
api_params = dict(
|
|
|
|
|
name = bs_name,
|
|
|
|
@ -3827,11 +3874,12 @@ class DecortController(object):
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "group_find")
|
|
|
|
|
|
|
|
|
|
if group_id == 0:
|
|
|
|
|
try:
|
|
|
|
|
i = bs_info['groupsName'].index(group_name)
|
|
|
|
|
except:
|
|
|
|
|
return 0,None
|
|
|
|
|
group_id = int(bs_info['groups'][i])
|
|
|
|
|
for group in bs_info['groups']:
|
|
|
|
|
if group['name'] == group_name:
|
|
|
|
|
return self._group_get_by_id(bs_id=bs_id,
|
|
|
|
|
g_id=group['id'])
|
|
|
|
|
return 0, None
|
|
|
|
|
|
|
|
|
|
return self._group_get_by_id(bs_id,group_id)
|
|
|
|
|
|
|
|
|
|
def group_state(self,bs_id,gr_id,desired_state):
|
|
|
|
@ -3925,7 +3973,7 @@ class DecortController(object):
|
|
|
|
|
else:
|
|
|
|
|
list_extnet.append(net['id'])
|
|
|
|
|
|
|
|
|
|
if gr_dict['vinses'] != list_vins:
|
|
|
|
|
if sorted(gr_dict['vinses']) != sorted(list_vins):
|
|
|
|
|
api_url = "/restmachine/cloudapi/bservice/groupUpdateVins"
|
|
|
|
|
api_params = dict(
|
|
|
|
|
serviceId=bs_id,
|
|
|
|
@ -3946,11 +3994,7 @@ class DecortController(object):
|
|
|
|
|
):
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "group_provision")
|
|
|
|
|
|
|
|
|
|
list_vins= list()
|
|
|
|
|
for net in arg_network:
|
|
|
|
|
if net['type'] == 'VINS':
|
|
|
|
|
list_vins.append(net['id'])
|
|
|
|
|
|
|
|
|
|
api_url = "/restmachine/cloudapi/bservice/groupAdd"
|
|
|
|
|
api_params = dict(
|
|
|
|
|
serviceId = bs_id,
|
|
|
|
@ -3962,13 +4006,15 @@ class DecortController(object):
|
|
|
|
|
imageId = arg_image_id,
|
|
|
|
|
driver = arg_driver,
|
|
|
|
|
role = arg_role,
|
|
|
|
|
vinses = list_vins,
|
|
|
|
|
vinses = [n['id'] for n in arg_network if n['type'] == 'VINS'],
|
|
|
|
|
extnets = [n['id'] for n in arg_network if n['type'] == 'EXTNET'],
|
|
|
|
|
timeoutStart = arg_timeout
|
|
|
|
|
)
|
|
|
|
|
self.decort_api_call(requests.post, api_url, api_params)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, api_url, api_params)
|
|
|
|
|
new_bsgroup_id = int(api_resp.text)
|
|
|
|
|
self.result['failed'] = False
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
return
|
|
|
|
|
return new_bsgroup_id
|
|
|
|
|
|
|
|
|
|
def group_delete(self,bs_id,gr_id):
|
|
|
|
|
|
|
|
|
@ -4023,8 +4069,8 @@ class DecortController(object):
|
|
|
|
|
self.result['msg'] = "_rg_listlb(): zero RG ID specified."
|
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
|
|
api_params = dict(rgId=rg_id)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/rg/listLb", api_params)
|
|
|
|
|
api_params = dict(rgId=rg_id, includedeleted=True)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/list", api_params)
|
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
|
ret_rg_vins_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
|
else:
|
|
|
|
@ -4038,7 +4084,7 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
@returns: LB ID and dictionary with LB facts.
|
|
|
|
|
"""
|
|
|
|
|
LB_INVALID_STATES = ["ENABLING", "DISABLING", "DELETING", "DELETED", "DESTROYING", "DESTROYED"]
|
|
|
|
|
LB_INVALID_STATES = ["ENABLING", "DISABLING", "DELETING", "DESTROYING", "DESTROYED"]
|
|
|
|
|
|
|
|
|
|
ret_lb_id = 0
|
|
|
|
|
ret_lb_facts = None
|
|
|
|
@ -4105,7 +4151,7 @@ class DecortController(object):
|
|
|
|
|
vinsId=vins_id,
|
|
|
|
|
highlyAvailable=ha_status,
|
|
|
|
|
start=start,
|
|
|
|
|
decs=annotation
|
|
|
|
|
desc=annotation
|
|
|
|
|
)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, api_url, api_params)
|
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
|
@ -4144,7 +4190,7 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
NOP_STATES_FOR_LB_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING",
|
|
|
|
|
"DESTROYED"]
|
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled","restart"]
|
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled","restart", 'started']
|
|
|
|
|
VALID_TARGET_TSTATES = ["STARTED","STOPPED"]
|
|
|
|
|
|
|
|
|
|
if lb_dict['status'] in NOP_STATES_FOR_LB_CHANGE:
|
|
|
|
@ -4435,6 +4481,15 @@ class DecortController(object):
|
|
|
|
|
def lb_update(self,prime,front_ha_ip,back_ha_ip,lb_backends=[],lb_frontends=[],mod_backends=[],mod_servers=[],mod_frontends=[]):
|
|
|
|
|
|
|
|
|
|
self.result['waypoints'] = "{} -> {}".format(self.result['waypoints'], "lb_update")
|
|
|
|
|
|
|
|
|
|
if self.amodule.check_mode:
|
|
|
|
|
result_msg = 'lb_update() in check mode: No changing.'
|
|
|
|
|
if self.result.get('msg'):
|
|
|
|
|
self.result['msg'] += f'\n{result_msg}'
|
|
|
|
|
else:
|
|
|
|
|
self.result['msg'] = result_msg
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
#lists from module and cloud
|
|
|
|
|
mod_backs_list = [back['name'] for back in mod_backends]
|
|
|
|
|
lb_backs_list = [back['name'] for back in lb_backends]
|
|
|
|
@ -4445,9 +4500,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
#FE
|
|
|
|
|
|
|
|
|
|
mod_front_list = [front['name'] for front in mod_frontends]
|
|
|
|
|
lb_front_list = [front['name'] for front in lb_frontends]
|
|
|
|
|
|
|
|
|
|
if del_list_backs:
|
|
|
|
|
|
|
|
|
|
self._lb_delete_backends(
|
|
|
|
@ -4470,6 +4522,9 @@ class DecortController(object):
|
|
|
|
|
mod_servers
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
mod_front_list = [front['name'] for front in mod_frontends]
|
|
|
|
|
lb_front_list = [front['name'] for front in lb_frontends]
|
|
|
|
|
|
|
|
|
|
del_list_fronts = set(lb_front_list).difference(mod_front_list)
|
|
|
|
|
add_list_fronts = set(mod_front_list).difference(lb_front_list)
|
|
|
|
|
upd_front_list = set(lb_front_list).intersection(mod_front_list)
|
|
|
|
@ -4524,7 +4579,7 @@ class DecortController(object):
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/frontendDelete", api_params)
|
|
|
|
|
#del from cloud dict
|
|
|
|
|
if type(front)==dict:
|
|
|
|
|
del self.lb_facts['frontends'][front['name']]
|
|
|
|
|
self.lb_facts['frontends'].remove(front)
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
@ -4547,7 +4602,8 @@ class DecortController(object):
|
|
|
|
|
bind['address']if "address" in bind else bind_ip,
|
|
|
|
|
bind['port'],
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
def _lb_create_backends(self,back_list,mod_backs,mod_serv):
|
|
|
|
|
'''
|
|
|
|
|
Create backends and add servers to them
|
|
|
|
@ -4630,8 +4686,8 @@ class DecortController(object):
|
|
|
|
|
serverName = server['name'],
|
|
|
|
|
address = server['address'],
|
|
|
|
|
port = mod_back['port'],
|
|
|
|
|
check = server['check'] if "check" in server else None,
|
|
|
|
|
**server['server_settings'] if "server_settings" in server else {},
|
|
|
|
|
check = mod_back['check'] if "check" in mod_back else None,
|
|
|
|
|
**mod_back['server_settings'] if "server_settings" in mod_back else {},
|
|
|
|
|
)
|
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/backendServerAdd", api_params)
|
|
|
|
|
self.result['changed'] = True
|
|
|
|
@ -4690,11 +4746,14 @@ class DecortController(object):
|
|
|
|
|
lb_bind, = list(filter(lambda i: i['name'] == bind['name'],lb_front['bindings']))
|
|
|
|
|
del lb_bind['guid']
|
|
|
|
|
|
|
|
|
|
if not bind.get('address'):
|
|
|
|
|
bind['address'] = bind_ip
|
|
|
|
|
|
|
|
|
|
if dict(sorted(bind.items())) != dict(sorted(lb_bind.items())):
|
|
|
|
|
self._lb_bind_frontend(
|
|
|
|
|
front,
|
|
|
|
|
bind['name'],
|
|
|
|
|
bind['address'] if "address" in bind else bind_ip,
|
|
|
|
|
bind['address'],
|
|
|
|
|
bind['port'],
|
|
|
|
|
update=True,
|
|
|
|
|
)
|
|
|
|
|