add hobo agent
This commit is contained in:
parent
3e0204663e
commit
7b174d9ce0
|
@ -0,0 +1,55 @@
|
|||
import os
|
||||
import urlparse
|
||||
import ConfigParser
|
||||
|
||||
from tenant_schemas.utils import tenant_context
|
||||
from hobo.agent.common.management.commands import hobo_deploy
|
||||
from hobo.multitenant.settings_loaders import KnownServices
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Command(hobo_deploy.Command):
|
||||
|
||||
def deploy_specifics(self, hobo_environment, tenant):
|
||||
super(Command, self).deploy_specifics(hobo_environment, tenant)
|
||||
with tenant_context(tenant):
|
||||
services = hobo_environment.get('services')
|
||||
ini_file = os.path.join(tenant.get_directory(), 'wcs-olap.ini')
|
||||
schemas_path = os.path.join(tenant.get_directory(), 'schemas')
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(ini_file)
|
||||
|
||||
if not os.path.exists(schemas_path):
|
||||
os.mkdir(schemas_path)
|
||||
if not config.has_section('wcs-olap'):
|
||||
config.add_section('wcs-olap')
|
||||
config.set('wcs-olap', 'cubes_model_dirs', schemas_path)
|
||||
config.set('wcs-olap', 'pg_dsn', 'dbname=%s' % settings.DATABASES['default']['NAME'])
|
||||
|
||||
for service in services:
|
||||
if service.get('this'):
|
||||
this = service
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('unable to find this service')
|
||||
our_key = this['secret_key']
|
||||
for service in services:
|
||||
if (service.get('this') or not service.get('secret_key')
|
||||
or service['service-id'] != 'wcs' or not service.get('base_url')):
|
||||
continue
|
||||
base_url = service['base_url']
|
||||
schema = (urlparse.urlparse(base_url).netloc.split(':')[0]
|
||||
.replace('.', '_').replace('-', '_'))
|
||||
orig = urlparse.urlparse(this.get('base_url')).netloc.split(':')[0]
|
||||
their_key = service.get('secret_key')
|
||||
key = KnownServices.shared_secret(our_key, their_key)
|
||||
|
||||
if config.has_section(base_url):
|
||||
config.remove_section(base_url)
|
||||
config.add_section(base_url)
|
||||
config.set(base_url, 'orig', orig)
|
||||
config.set(base_url, 'key', key)
|
||||
config.set(base_url, 'schema', schema)
|
||||
with open(ini_file, 'w') as f:
|
||||
config.write(f)
|
|
@ -14,5 +14,6 @@ Depends: ${python:Depends},
|
|||
python-django-tenant-schemas,
|
||||
python-psycopg2,
|
||||
python-django-mellon,
|
||||
gunicorn
|
||||
gunicorn,
|
||||
wcs-olap
|
||||
Description: BI dashboard from Postgres db with star schema
|
||||
|
|
|
@ -4,14 +4,15 @@ import os
|
|||
|
||||
PROJECT_NAME = 'bijoe'
|
||||
|
||||
# SAML2 authentication
|
||||
INSTALLED_APPS += ('mellon',)
|
||||
|
||||
#
|
||||
# hobotization (multitenant)
|
||||
#
|
||||
execfile('/usr/lib/hobo/debian_config_common.py')
|
||||
|
||||
# SAML2 authentication
|
||||
INSTALLED_APPS = ('bijoe.hobo_agent',) + INSTALLED_APPS + ('mellon',)
|
||||
AUTHENTICATION_BACKENDS = ('mellon.backends.SAMLBackend',)
|
||||
|
||||
#
|
||||
# local settings
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue