default_forge_uri = 'https://forgeapi.puppet.com/v3/modules'
default_puppet_root_env_dir = os.sep + os.path.join('etc', 'puppetlabs', 'code', 'environments')
default_http_timeout = 30
+ max_http_timeout = 600
open_args = {}
if six.PY3:
self.cache_file = None
self.environments = []
self.puppet_root_env_dir = self.default_puppet_root_env_dir
+ self.forge_uri = self.default_forge_uri
+ self.http_timeout = self.default_http_timeout
self.description = textwrap.dedent('''\
Collects information about all used Puppet Modules from {url}
res['default_forge_uri'] = self.default_forge_uri
res['default_http_timeout'] = self.default_http_timeout
+ res['max_http_timeout'] = self.max_http_timeout
res['default_puppet_root_env_dir'] = self.default_puppet_root_env_dir
res['open_args'] = self.open_args
if 'puppet_env_dir' in config and config['puppet_env_dir']:
path = config['puppet_env_dir']
if os.path.isabs(path):
- self.puppet_root_env_dir = os.path.normapath(path)
+ self.puppet_root_env_dir = os.path.normpath(path)
else:
msg = (
"Path for the Puppet environments {p!r} must be "
p=path, f=yaml_file)
self.error_data.append(msg)
+ if 'forge_uri' in config and config['forge_uri'] and str(config['forge_uri']).strip():
+ self.forge_uri = str(config['forge_uri']).strip()
+
+ if 'http_timeout' in config and config['http_timeout']:
+ msg = "Invalid HTTP timeout {t!r} in {f!r} found.".format(
+ t=config['http_timeout'], f=yaml_file)
+ try:
+ http_timeout = int(config['http_timeout'])
+ if http_timeout > 0 and http_timeout < self.max_http_timeout:
+ self.http_timeout = http_timeout
+ else:
+ self.error_data.append(msg)
+ except ValueError:
+ self.error_data.append(msg)
+
# -------------------------------------------------------------------------
def run(self):
"""Main routine."""