diff --git a/.gitignore b/.gitignore index 3f4aebd..8ded001 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ doc/source/rho.rst .coverage .vagrant *.retry + +.vscode/ \ No newline at end of file diff --git a/rho/host_discovery.py b/rho/host_discovery.py index 2bc223d..be3e2db 100644 --- a/rho/host_discovery.py +++ b/rho/host_discovery.py @@ -21,6 +21,8 @@ PING_LOG_PATH, process_discovery_scan) +DEFAULT_DISCOVERY_TIMEOUT = 20 + def process_ping_output(out_lines): """Find successful hosts from the output of a ping command. @@ -138,7 +140,14 @@ def create_ping_inventory(vault, vault_pass, profile_ranges, profile_port, ansible_utils.log_yaml_inventory('Ping inventory', yml_dict) total_hosts_count = len(all_hosts) - rho_discovery_timeout = os.getenv('RHO_DISCOVERY_TIMEOUT', 5) + rho_discovery_timeout = os.getenv( + 'RHO_DISCOVERY_TIMEOUT', DEFAULT_DISCOVERY_TIMEOUT) + + try: + rho_discovery_timeout = int(rho_discovery_timeout) + except ValueError: + rho_discovery_timeout = DEFAULT_DISCOVERY_TIMEOUT + discovery_timeout = ((total_hosts_count // int(forks)) + 1) \ * rho_discovery_timeout diff --git a/rho/inventory_scan.py b/rho/inventory_scan.py index 9fac2fa..9746869 100644 --- a/rho/inventory_scan.py +++ b/rho/inventory_scan.py @@ -23,6 +23,8 @@ from rho.translation import _ as t from rho.utilities import str_to_ascii +DEFAULT_HOST_SCAN_TIMEOUT = 30 + # Creates the filtered main inventory on which the custom # modules to collect facts are run. This inventory can be @@ -313,7 +315,14 @@ def inventory_scan(hosts_yml_path, facts_to_collect, report_path, forks=forks, vars=json.dumps(ansible_vars)) - rho_host_scan_timeout = os.getenv('RHO_HOST_SCAN_TIMEOUT', 10) + rho_host_scan_timeout = os.getenv( + 'RHO_HOST_SCAN_TIMEOUT', DEFAULT_HOST_SCAN_TIMEOUT) + + try: + rho_host_scan_timeout = int(rho_host_scan_timeout) + except ValueError: + rho_host_scan_timeout = DEFAULT_HOST_SCAN_TIMEOUT + host_scan_timeout = ((len(hosts) // int(forks)) + 1) \ * rho_host_scan_timeout utilities.log.info('Starting scan for group "%s" with %d systems'