in installer/resources/src/install_soca.py [0:0]
def validate_soca_config(user_specified_inputs, install_properties):
# We run one final validation check at the end, comparing the install properties from config.yml and user inputs
print("\n====== Verifying SOCA Configuration ======\n")
errors = []
exit_installer = False # Installer will exit if user has invalid default_config.yml params that require a file edit
if user_specified_inputs["vpc_id"]:
private_subnets = ast.literal_eval(base64.b64decode(user_specified_inputs["private_subnets"]).decode("utf-8"))
private_subnet_azs = [k.split(",")[1] for k in private_subnets if k.split(",")[1]]
public_subnets = ast.literal_eval(base64.b64decode(user_specified_inputs["public_subnets"]).decode("utf-8"))
public_subnet_azs = [k.split(",")[1] for k in public_subnets]
# if AZ is = 2, check if ES data nodes is 1,2 or a multiple. No restriction when using > 3 AZs
if not user_specified_inputs["es_domain"]:
if user_specified_inputs["vpc_id"]:
max_azs = len(list(dict.fromkeys(private_subnet_azs)))
else:
max_azs = install_properties.Config.network.max_azs
if max_azs == 2:
# No limitation when using 3 or more AZs. 1 is not an option here
data_nodes = install_properties.Config.elasticsearch.data_nodes
if (data_nodes % 2) == 0 or data_nodes <= 2:
pass
else:
errors.append("Config > ElasticSearch > data_nodes must be 1,2 or a multiple of 2.")
exit_installer = True
if user_specified_inputs["vpc_id"]:
# Validate network configuration when using a custom VPC
if len(list(dict.fromkeys(private_subnet_azs))) == 1:
errors.append(f"Your private subnets are only configured to use a single AZ ({private_subnet_azs}). You must use at least 2 AZs for HA")
if len(list(dict.fromkeys(public_subnet_azs))) == 1:
errors.append(f"Your public subnets are only configured to use a single AZ ({public_subnet_azs}). You must use at least 2 AZs for HA")
else:
# check if az is min 2
if install_properties.Config.network.max_azs < 2:
errors.append("Config > Network > max_azs must be at least 2")
exit_installer = True
if not errors:
print(f"{fg('green')}Configuration valid. {attr('reset')}")
return True
else:
for message in errors:
print(f"{fg('red')}- {message} {attr('reset')}")
print(f"{fg('red')}\n /!\ Unable to validate configuration. Please fix the errors listed above and try again. {attr('reset')}")
if exit_installer is True:
sys.exit(1)
else:
return False