Beispiel #1
0
def get_sites_with_config(bench_path):
    from bench.config.common_site_config import get_config
    from bench.config.site_config import get_site_config

    sites = get_sites(bench_path=bench_path)
    dns_multitenant = get_config(bench_path).get('dns_multitenant')

    ret = []
    for site in sites:
        site_config = get_site_config(site, bench_path=bench_path)
        ret.append({
            "name":
            site,
            "port":
            site_config.get('nginx_port'),
            "ssl_certificate":
            site_config.get('ssl_certificate'),
            "ssl_certificate_key":
            site_config.get('ssl_certificate_key')
        })

        if dns_multitenant and site_config.get('domains'):
            for domain in site_config.get('domains'):
                # domain can be a string or a dict with 'domain', 'ssl_certificate', 'ssl_certificate_key'
                if isinstance(domain, basestring):
                    domain = {'domain': domain}

                domain['name'] = site
                ret.append(domain)

    use_wildcard_certificate(bench_path, ret)

    return ret
Beispiel #2
0
def get_sites_with_config(bench_path):
	from bench.config.common_site_config import get_config
	from bench.config.site_config import get_site_config

	sites = get_sites(bench_path=bench_path)
	dns_multitenant = get_config(bench_path).get('dns_multitenant')

	ret = []
	for site in sites:
		site_config = get_site_config(site, bench_path=bench_path)
		ret.append({
			"name": site,
			"port": site_config.get('nginx_port'),
			"ssl_certificate": site_config.get('ssl_certificate'),
			"ssl_certificate_key": site_config.get('ssl_certificate_key')
		})

		if dns_multitenant and site_config.get('domains'):
			for domain in site_config.get('domains'):
				# domain can be a string or a dict with 'domain', 'ssl_certificate', 'ssl_certificate_key'
				if isinstance(domain, basestring):
					domain = { 'domain': domain }

				domain['name'] = site
				ret.append(domain)

	use_wildcard_certificate(bench_path, ret)

	return ret
Beispiel #3
0
def get_sites_with_config(bench_path):
    from bench.config.common_site_config import get_config
    from bench.config.site_config import get_site_config

    sites = get_sites(bench_path=bench_path)
    dns_multitenant = get_config(bench_path).get('dns_multitenant')

    ret = []
    for site in sites:
        try:
            site_config = get_site_config(site, bench_path=bench_path)
        except Exception as e:
            strict_nginx = get_config(bench_path).get('strict_nginx')
            if strict_nginx:
                print(
                    "\n\nERROR: The site config for the site {} is broken.".
                    format(site),
                    "If you want this command to pass, instead of just throwing an error,",
                    "You may remove the 'strict_nginx' flag from common_site_config.json or set it to 0",
                    "\n\n")
                raise (e)
            else:
                print(
                    "\n\nWARNING: The site config for the site {} is broken.".
                    format(site),
                    "If you want this command to fail, instead of just showing a warning,",
                    "You may add the 'strict_nginx' flag to common_site_config.json and set it to 1",
                    "\n\n")
                continue

        ret.append({
            "name":
            site,
            "port":
            site_config.get('nginx_port'),
            "ssl_certificate":
            site_config.get('ssl_certificate'),
            "ssl_certificate_key":
            site_config.get('ssl_certificate_key')
        })

        if dns_multitenant and site_config.get('domains'):
            for domain in site_config.get('domains'):
                # domain can be a string or a dict with 'domain', 'ssl_certificate', 'ssl_certificate_key'
                if isinstance(domain, str) or isinstance(domain, unicode):
                    domain = {'domain': domain}

                domain['name'] = site
                ret.append(domain)

    use_wildcard_certificate(bench_path, ret)

    return ret
Beispiel #4
0
def get_sites_with_config(bench_path):
	from bench.config.common_site_config import get_config
	from bench.config.site_config import get_site_config

	sites = get_sites(bench_path=bench_path)
	dns_multitenant = get_config(bench_path).get('dns_multitenant')

	ret = []
	for site in sites:
		try:
			site_config = get_site_config(site, bench_path=bench_path)
		except Exception as e:
			strict_nginx = get_config(bench_path).get('strict_nginx')
			if strict_nginx:
				print("\n\nERROR: The site config for the site {} is broken.".format(site),
					"If you want this command to pass, instead of just throwing an error,",
					"You may remove the 'strict_nginx' flag from common_site_config.json or set it to 0",
					"\n\n")
				raise (e)
			else:
				print("\n\nWARNING: The site config for the site {} is broken.".format(site),
					"If you want this command to fail, instead of just showing a warning,",
					"You may add the 'strict_nginx' flag to common_site_config.json and set it to 1",
					"\n\n")
				continue

		ret.append({
			"name": site,
			"port": site_config.get('nginx_port'),
			"ssl_certificate": site_config.get('ssl_certificate'),
			"ssl_certificate_key": site_config.get('ssl_certificate_key')
		})

		if dns_multitenant and site_config.get('domains'):
			for domain in site_config.get('domains'):
				# domain can be a string or a dict with 'domain', 'ssl_certificate', 'ssl_certificate_key'
				if isinstance(domain, str) or isinstance(domain, unicode):
					domain = { 'domain': domain }

				domain['name'] = site
				ret.append(domain)

	use_wildcard_certificate(bench_path, ret)

	return ret
Beispiel #5
0
def make_bench_manager_nginx_conf(bench_path,
                                  yes=False,
                                  port=23624,
                                  domain=None):
    from bench import env
    from bench.config.site_config import get_site_config
    from bench.config.common_site_config import get_config

    template = env.get_template('bench_manager_nginx.conf')
    bench_path = os.path.abspath(bench_path)
    sites_path = os.path.join(bench_path, "sites")

    config = get_config(bench_path)
    site_config = get_site_config(domain, bench_path=bench_path)
    sites = prepare_sites(config, bench_path)
    bench_name = get_bench_name(bench_path)

    template_vars = {
        "port": port,
        "domain": domain,
        "bench_manager_site_name": "bench-manager.local",
        "sites_path": sites_path,
        "http_timeout": config.get("http_timeout"),
        "webserver_port": config.get('webserver_port'),
        "socketio_port": config.get('socketio_port'),
        "bench_name": bench_name,
        "error_pages": get_error_pages(),
        "ssl_certificate": site_config.get('ssl_certificate'),
        "ssl_certificate_key": site_config.get('ssl_certificate_key')
    }

    bench_manager_nginx_conf = template.render(**template_vars)

    conf_path = os.path.join(bench_path, "config", "nginx.conf")

    if not yes and os.path.exists(conf_path):
        click.confirm(
            'nginx.conf already exists and bench-manager configuration will be appended to it. Do you want to continue?',
            abort=True)

    with open(conf_path, "a") as myfile:
        myfile.write(bench_manager_nginx_conf)
Beispiel #6
0
def make_bench_manager_nginx_conf(bench_path, yes=False, port=23624, domain=None):
	from bench import env
	from bench.config.site_config import get_site_config
	from bench.config.common_site_config import get_config

	template = env.get_template('bench_manager_nginx.conf')
	bench_path = os.path.abspath(bench_path)
	sites_path = os.path.join(bench_path, "sites")

	config = get_config(bench_path)
	site_config = get_site_config(domain, bench_path=bench_path)
	sites = prepare_sites(config, bench_path)
	bench_name = get_bench_name(bench_path)

	template_vars = {
		"port": port,
		"domain": domain,
		"bench_manager_site_name": "bench-manager.local",
		"sites_path": sites_path,
		"http_timeout": config.get("http_timeout"),
		"webserver_port": config.get('webserver_port'),
		"socketio_port": config.get('socketio_port'),
		"bench_name": bench_name,
		"error_pages": get_error_pages(),
		"ssl_certificate": site_config.get('ssl_certificate'),
		"ssl_certificate_key": site_config.get('ssl_certificate_key')
	}

	bench_manager_nginx_conf = template.render(**template_vars)

	conf_path = os.path.join(bench_path, "config", "nginx.conf")

	if not yes and os.path.exists(conf_path):
		click.confirm('nginx.conf already exists and bench-manager configuration will be appended to it. Do you want to continue?',
			abort=True)

	with open(conf_path, "a") as myfile:
		myfile.write(bench_manager_nginx_conf)