def vhost_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) tpl = """ '{vhost}' => {{ 'home' => '{home}', 'user' => '{user}', 'group' => '{user}', 'aliases' => [{aliases}], }}, """ for style in VHOST_STYLES: response.write("$web_" + style[0] + "_vhosts = {") for v in VHost.objects.filter(style=style[0]): user = v.domain.owner().get_profile() response.write(tpl.format( vhost = v.name + '.' + unicode(v.domain), user = user.system_user_name(), home = user.system_user_home(), aliases = '"*.' + unicode(v.domain) + '"' if v.defaultvhost_set.exists() else '', )) response.write("}\n") return response
def vhost_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) tpl = """ '{vhost}' => {{ 'home' => '{home}', 'user' => '{user}', 'group' => '{user}', 'aliases' => [{aliases}], }}, """ for style in VHOST_STYLES: response.write("$web_" + style[0] + "_vhosts = {") for v in VHost.objects.filter(style=style[0]): user = v.domain.owner().get_profile() response.write( tpl.format( vhost=v.name + '.' + unicode(v.domain), user=user.system_user_name(), home=user.system_user_home(), aliases='"*.' + unicode(v.domain) + '"' if v.defaultvhost_set.exists() else '', )) response.write("}\n") return response
def lb_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) tpl = """ '{vhost}' => {{ 'style' => '{style}', 'cert_id' => {cert_id}, 'cert_ip' => {cert_ip}, 'aliases' => [{aliases}], }}, """ response.write("$web_lb_vhosts = {") for v in VHost.objects.all(): response.write( tpl.format( vhost=v.name + '.' + unicode(v.domain), style=v.style, cert_id='"' + str(v.cert.pk) + '"' if v.cert else 'undef', cert_ip='"' + str(v.cert.ip) + '"' if v.cert else 'undef', aliases='"*.' + unicode(v.domain) + '"' if v.defaultvhost_set.exists() else '', )) response.write("}\n") return response
def nodes(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) response.write( """ node default { } node core-io { include users } """ ) for s in Server.objects.all(): response.write("node '" + s.hostname + "' inherits core-io {\n") for service in s.services.all(): response.write("\tinclude " + unicode(service) + "\n") response.write("}\n") return response
def redirect_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) response.write("$web_redirects = {\n") for r in HTTPRedirect.objects.all(): response.write('"{vhost}" => {{ "target" => "{to}", }},\n'.format( vhost = r.name + '.' + unicode(r.domain), to = r.to, )) response.write("}\n") return response
def redirect_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) response.write("$web_redirects = {\n") for r in HTTPRedirect.objects.all(): response.write('"{vhost}" => {{ "target" => "{to}", }},\n'.format( vhost=r.name + '.' + unicode(r.domain), to=r.to, )) response.write("}\n") return response
def variables(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) for s in Service.objects.all(): ips = [] hostnames = [] for srv in s.server_set.filter(enabled=True): ips += ['"' + srv.ip + '"'] hostnames += ['"' + srv.hostname + '"'] response.write("$" + unicode(s) + "_nodes_ip = [" + ', '.join(ips) + "]\n") response.write("$" + unicode(s) + "_nodes_host = [" + ', '.join(hostnames) + "]\n") return response
def nodes(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) response.write(""" node default { } node core-io { include users } """) for s in Server.objects.all(): response.write("node '" + s.hostname + "' inherits core-io {\n") for service in s.services.all(): response.write("\tinclude " + unicode(service) + "\n") response.write("}\n") return response
def lb_export(request): response = HttpResponse(mimetype='text/plain') response.write(export_header()) tpl = """ '{vhost}' => {{ 'style' => '{style}', 'cert_id' => {cert_id}, 'cert_ip' => {cert_ip}, 'aliases' => [{aliases}], }}, """ response.write("$web_lb_vhosts = {") for v in VHost.objects.all(): response.write(tpl.format( vhost = v.name + '.' + unicode(v.domain), style = v.style, cert_id = '"' + str(v.cert.pk) + '"' if v.cert else 'undef', cert_ip = '"' + str(v.cert.ip) + '"' if v.cert else 'undef', aliases = '"*.' + unicode(v.domain) + '"' if v.defaultvhost_set.exists() else '', )) response.write("}\n") return response