def _parse_netloc()

in cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm/slurm/pcluster_slurm_config_generator.py [0:0]


def _parse_netloc(uri: str, uri_parse: ParseResult, attr: str) -> str:
    try:
        netloc = uri_parse.netloc
    except ValueError as e:
        error_msg = f"Failure to parse uri with error '{str(e)}'. Please review the provided URI ('{uri}')"
        log.critical(error_msg)
        raise CriticalError(error_msg)
    if not netloc:
        error_msg = f"Invalid URI specified. Please review the provided URI ('{uri}')"
        log.critical(error_msg)
        raise CriticalError(error_msg)
    if attr == "host":
        ret = uri_parse.hostname
    elif attr == "port":
        ret = uri_parse.port
        # Provide default MySQL port if port is not explicitely set
        if not ret:
            ret = "3306"
    return ret