cook: add support for creating secondary hoboes (#15797)
{ "create-hobo": { "url": "https://hobo.second.example.net", "title": "Secondary Publik" }},
This commit is contained in:
parent
a81cdb0280
commit
f9424f64d9
|
@ -29,11 +29,12 @@ from django.core.management import call_command
|
|||
from django.db import connection
|
||||
from django.db.models import Max
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.text import slugify
|
||||
|
||||
from hobo.agent.common.management.commands.hobo_deploy import (
|
||||
Command as HoboDeployCommand)
|
||||
from hobo.multitenant.middleware import TenantMiddleware
|
||||
from hobo.environment.models import (AVAILABLE_SERVICES, Authentic, Wcs,
|
||||
from hobo.environment.models import (AVAILABLE_SERVICES, Authentic, Wcs, Hobo,
|
||||
Passerelle, Combo, Fargo, Welco, MandayeJS, Chrono, Corbo, BiJoe,
|
||||
Variable)
|
||||
from hobo.deploy.signals import notify_agents
|
||||
|
@ -101,7 +102,22 @@ class Command(BaseCommand):
|
|||
raise CommandError('timeout waiting for %s' % ', '.join(
|
||||
[x.base_url for x in services]))
|
||||
|
||||
def create_hobo(self, url):
|
||||
def create_hobo(self, url, primary=False, title=None, slug=None):
|
||||
if connection.get_tenant().schema_name == 'public':
|
||||
# if we're not currently in a tenant then we force the creation of
|
||||
# a primary hobo
|
||||
primary = True
|
||||
|
||||
if not primary:
|
||||
if not slug:
|
||||
slug = 'hobo-%s' % slugify(title)
|
||||
self.create_site(Hobo, url, title, slug,
|
||||
template_name='', variables=None)
|
||||
domain = get_domain(url)
|
||||
tenant = TenantMiddleware.get_tenant_by_hostname(domain)
|
||||
connection.set_tenant(tenant)
|
||||
return
|
||||
|
||||
domain = get_domain(url)
|
||||
try:
|
||||
call_command('create_hobo_tenant', domain)
|
||||
|
|
Loading…
Reference in New Issue