[refactor] Fail mysql_conn if the mainint has > 1 ip address

This commit is contained in:
William Wernert
2020-11-30 11:09:06 -05:00
parent 704f024441
commit 040b435278

View File

@@ -18,9 +18,13 @@ def mysql_conn(retry):
return False
mainint = __salt__['pillar.get']('host:mainint')
mainip = __salt__['grains.get']('ip_interfaces').get(mainint)[0]
ip_arr = __salt__['grains.get']('ip_interfaces').get(mainint)
mysql_up = False
if len(ip_arr) == 1:
mainip = ip_arr[0]
for i in range(0, retry):
log.debug(f'Connection attempt {i+1}')
try:
@@ -47,5 +51,10 @@ def mysql_conn(retry):
if not mysql_up:
log.error(f'Could not connect to MySQL server on {mainip} after {retry} attempts.')
else:
log.error(f'Main interface {mainint} has more than one IP address assigned to it, which is not supported.')
log.debug(f'{mainint}:')
for addr in ip_arr:
log.debug(f' - {addr}')
return mysql_up