|
|
@ -4056,8 +4056,8 @@ class DecortController(object):
|
|
|
|
self.result['msg'] = "_rg_listlb(): zero RG ID specified."
|
|
|
|
self.result['msg'] = "_rg_listlb(): zero RG ID specified."
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
self.amodule.fail_json(**self.result)
|
|
|
|
|
|
|
|
|
|
|
|
api_params = dict(rgId=rg_id)
|
|
|
|
api_params = dict(rgId=rg_id, includedeleted=True)
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/rg/listLb", api_params)
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/list", api_params)
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
if api_resp.status_code == 200:
|
|
|
|
ret_rg_vins_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
ret_rg_vins_list = json.loads(api_resp.content.decode('utf8'))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -4071,7 +4071,7 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
@returns: LB ID and dictionary with LB facts.
|
|
|
|
@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_id = 0
|
|
|
|
ret_lb_facts = None
|
|
|
|
ret_lb_facts = None
|
|
|
@ -4138,7 +4138,7 @@ class DecortController(object):
|
|
|
|
vinsId=vins_id,
|
|
|
|
vinsId=vins_id,
|
|
|
|
highlyAvailable=ha_status,
|
|
|
|
highlyAvailable=ha_status,
|
|
|
|
start=start,
|
|
|
|
start=start,
|
|
|
|
decs=annotation
|
|
|
|
desc=annotation
|
|
|
|
)
|
|
|
|
)
|
|
|
|
api_resp = self.decort_api_call(requests.post, api_url, api_params)
|
|
|
|
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.
|
|
|
|
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
|
|
@ -4177,7 +4177,7 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
NOP_STATES_FOR_LB_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING",
|
|
|
|
NOP_STATES_FOR_LB_CHANGE = ["MODELED", "DISABLING", "ENABLING", "DELETING", "DELETED", "DESTROYING",
|
|
|
|
"DESTROYED"]
|
|
|
|
"DESTROYED"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled","restart"]
|
|
|
|
VALID_TARGET_STATES = ["enabled", "disabled","restart", 'started']
|
|
|
|
VALID_TARGET_TSTATES = ["STARTED","STOPPED"]
|
|
|
|
VALID_TARGET_TSTATES = ["STARTED","STOPPED"]
|
|
|
|
|
|
|
|
|
|
|
|
if lb_dict['status'] in NOP_STATES_FOR_LB_CHANGE:
|
|
|
|
if lb_dict['status'] in NOP_STATES_FOR_LB_CHANGE:
|
|
|
@ -4468,6 +4468,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=[]):
|
|
|
|
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")
|
|
|
|
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
|
|
|
|
#lists from module and cloud
|
|
|
|
mod_backs_list = [back['name'] for back in mod_backends]
|
|
|
|
mod_backs_list = [back['name'] for back in mod_backends]
|
|
|
|
lb_backs_list = [back['name'] for back in lb_backends]
|
|
|
|
lb_backs_list = [back['name'] for back in lb_backends]
|
|
|
@ -4478,9 +4487,6 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
#FE
|
|
|
|
#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:
|
|
|
|
if del_list_backs:
|
|
|
|
|
|
|
|
|
|
|
|
self._lb_delete_backends(
|
|
|
|
self._lb_delete_backends(
|
|
|
@ -4503,6 +4509,9 @@ class DecortController(object):
|
|
|
|
mod_servers
|
|
|
|
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)
|
|
|
|
del_list_fronts = set(lb_front_list).difference(mod_front_list)
|
|
|
|
add_list_fronts = set(mod_front_list).difference(lb_front_list)
|
|
|
|
add_list_fronts = set(mod_front_list).difference(lb_front_list)
|
|
|
|
upd_front_list = set(lb_front_list).intersection(mod_front_list)
|
|
|
|
upd_front_list = set(lb_front_list).intersection(mod_front_list)
|
|
|
@ -4557,7 +4566,7 @@ class DecortController(object):
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/frontendDelete", api_params)
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/frontendDelete", api_params)
|
|
|
|
#del from cloud dict
|
|
|
|
#del from cloud dict
|
|
|
|
if type(front)==dict:
|
|
|
|
if type(front)==dict:
|
|
|
|
del self.lb_facts['frontends'][front['name']]
|
|
|
|
self.lb_facts['frontends'].remove(front)
|
|
|
|
self.result['changed'] = True
|
|
|
|
self.result['changed'] = True
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -4580,6 +4589,7 @@ class DecortController(object):
|
|
|
|
bind['address']if "address" in bind else bind_ip,
|
|
|
|
bind['address']if "address" in bind else bind_ip,
|
|
|
|
bind['port'],
|
|
|
|
bind['port'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
def _lb_create_backends(self,back_list,mod_backs,mod_serv):
|
|
|
|
def _lb_create_backends(self,back_list,mod_backs,mod_serv):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
@ -4663,8 +4673,8 @@ class DecortController(object):
|
|
|
|
serverName = server['name'],
|
|
|
|
serverName = server['name'],
|
|
|
|
address = server['address'],
|
|
|
|
address = server['address'],
|
|
|
|
port = mod_back['port'],
|
|
|
|
port = mod_back['port'],
|
|
|
|
check = server['check'] if "check" in server else None,
|
|
|
|
check = mod_back['check'] if "check" in mod_back else None,
|
|
|
|
**server['server_settings'] if "server_settings" in server else {},
|
|
|
|
**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)
|
|
|
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/lb/backendServerAdd", api_params)
|
|
|
|
self.result['changed'] = True
|
|
|
|
self.result['changed'] = True
|
|
|
@ -4723,11 +4733,14 @@ class DecortController(object):
|
|
|
|
lb_bind, = list(filter(lambda i: i['name'] == bind['name'],lb_front['bindings']))
|
|
|
|
lb_bind, = list(filter(lambda i: i['name'] == bind['name'],lb_front['bindings']))
|
|
|
|
del lb_bind['guid']
|
|
|
|
del lb_bind['guid']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not bind.get('address'):
|
|
|
|
|
|
|
|
bind['address'] = bind_ip
|
|
|
|
|
|
|
|
|
|
|
|
if dict(sorted(bind.items())) != dict(sorted(lb_bind.items())):
|
|
|
|
if dict(sorted(bind.items())) != dict(sorted(lb_bind.items())):
|
|
|
|
self._lb_bind_frontend(
|
|
|
|
self._lb_bind_frontend(
|
|
|
|
front,
|
|
|
|
front,
|
|
|
|
bind['name'],
|
|
|
|
bind['name'],
|
|
|
|
bind['address'] if "address" in bind else bind_ip,
|
|
|
|
bind['address'],
|
|
|
|
bind['port'],
|
|
|
|
bind['port'],
|
|
|
|
update=True,
|
|
|
|
update=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|