Project

General

Profile

Download (978 Bytes) Statistics
| Branch: | Tag: | Revision:

root / entrouvert / djommon / multitenant / management / commands / deploy.py @ bb762ce4

1
import urllib2
2
import json
3
import sys
4

    
5
from django.core.management import call_command
6
from django.core.management.base import BaseCommand, CommandError
7

    
8
from tenant_schemas.utils import tenant_context
9
from entrouvert.djommon.multitenant.middleware import TenantMiddleware
10

    
11
class Command(BaseCommand):
12
    help = 'Deploy a tenant from hobo'
13

    
14
    def handle(self, base_url, **options):
15
        environment = json.load(sys.stdin)
16
        for service in environment['services']:
17
            if service['base_url'] == base_url:
18
                break
19
        else:
20
            raise CommandError('Service %s not found' % base_url)
21
        hostname = urllib2.urlparse.urlsplit(base_url).netloc
22

    
23
        call_command('create_tenant', hostname)
24

    
25
        tenant = TenantMiddleware.get_tenant_by_hostname(hostname)
26
        with tenant_context(tenant):
27
            self.deploy_tenant(environment, service, options)
28

    
29
    def deploy_tenant(self, environment, service, options):
30
        pass
(5-5/13)