Skip to content

Commit

Permalink
consolidate paths in config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jul 31, 2018
1 parent 75ffa91 commit 2760e1a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
14 changes: 11 additions & 3 deletions tljh/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
tljh-config show firstlevel.second_level
"""

import os
import sys
import argparse
from ruamel.yaml import YAML
from copy import deepcopy
from tljh import systemd, traefik


INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
STATE_DIR = os.path.join(INSTALL_PREFIX, 'state')
CONFIG_FILE = os.path.join(INSTALL_PREFIX, 'config.yaml')


yaml = YAML(typ='rt')


Expand All @@ -28,7 +37,7 @@ def set_item_in_config(config, property_path, value):
config is not mutated.
property_path is a series of dot separated values. Any part of the path
that does not exist is created.
that does not exist is created.
"""
path_components = property_path.split('.')

Expand Down Expand Up @@ -156,8 +165,7 @@ def reload_component(component):
# FIXME: Verify hub is back up?
print('Hub reload with new configuration complete')
elif component == 'proxy':
# FIXME: How to set path here?
traefik.ensure_traefik_config('/opt/tljh/hub/state')
traefik.ensure_traefik_config(STATE_DIR)
systemd.restart_service('configurable-http-proxy')
systemd.restart_service('traefik')
print('Proxy reload with new configuration complete')
Expand Down
3 changes: 1 addition & 2 deletions tljh/configurer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import os
import yaml

INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
CONFIG_FILE = os.path.join(INSTALL_PREFIX, 'config.yaml')
from tljh.config import CONFIG_FILE

# Default configuration for tljh
# User provided config is merged into this
Expand Down
6 changes: 1 addition & 5 deletions tljh/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
from ruamel.yaml import YAML

from tljh import conda, systemd, traefik, user, apt

INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
STATE_DIR = os.path.join(INSTALL_PREFIX, 'state')
from tljh.config import INSTALL_PREFIX, HUB_ENV_PREFIX, USER_ENV_PREFIX, STATE_DIR

HERE = os.path.abspath(os.path.dirname(__file__))

Expand Down
10 changes: 5 additions & 5 deletions tljh/jupyterhub_config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
JupyterHub config for the littlest jupyterhub.
"""
import copy
import os
from systemdspawner import SystemdSpawner
from tljh import user, configurer

import yaml
import copy

INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
from systemdspawner import SystemdSpawner
from tljh import user, configurer
from tljh.config import INSTALL_PREFIX, USER_ENV_PREFIX


class CustomSpawner(SystemdSpawner):
Expand Down

0 comments on commit 2760e1a

Please sign in to comment.