Another minor renames

parent ba6d9405
......@@ -5,8 +5,8 @@ from colorlog import warning as warn, info
CONFIG_HTTP = {
"DOC_ROOT": "doc-root",
"DOC_DEFAULT_NAME": "index.html",
"RESTCONF_API_ROOT": "/restconf",
"RESTCONF_NACM_API_ROOT": "/restconf_nacm",
"API_ROOT": "/restconf",
"NACM_API_ROOT": "/restconf_nacm",
"SERVER_NAME": "hyper-h2",
"PORT": 8443,
......@@ -25,14 +25,14 @@ CONFIG = {
}
NACM_ADMINS = CONFIG["NACM"]["ALLOWED_USERS"]
RESTCONF_NACM_API_ROOT_data = os.path.join(CONFIG_HTTP["RESTCONF_NACM_API_ROOT"], "data")
RESTCONF_API_ROOT_data = os.path.join(CONFIG_HTTP["RESTCONF_API_ROOT"], "data")
NACM_API_ROOT_data = os.path.join(CONFIG_HTTP["NACM_API_ROOT"], "data")
API_ROOT_data = os.path.join(CONFIG_HTTP["API_ROOT"], "data")
def load_config(filename: str):
global NACM_ADMINS
global RESTCONF_NACM_API_ROOT_data
global RESTCONF_API_ROOT_data
global NACM_API_ROOT_data
global API_ROOT_data
try:
with open(filename) as conf_fd:
......@@ -48,8 +48,8 @@ def load_config(filename: str):
# Shortcuts
NACM_ADMINS = CONFIG["NACM"]["ALLOWED_USERS"]
RESTCONF_NACM_API_ROOT_data = os.path.join(CONFIG_HTTP["RESTCONF_NACM_API_ROOT"], "data")
RESTCONF_API_ROOT_data = os.path.join(CONFIG_HTTP["RESTCONF_API_ROOT"], "data")
NACM_API_ROOT_data = os.path.join(CONFIG_HTTP["NACM_API_ROOT"], "data")
API_ROOT_data = os.path.join(CONFIG_HTTP["API_ROOT"], "data")
def print_config():
......
HTTP_SERVER:
DOC_ROOT: "jetconf/doc-root"
DOC_DEFAULT_NAME: "index.html"
RESTCONF_API_ROOT: "/restconf"
RESTCONF_NACM_API_ROOT: "/restconf_nacm"
API_ROOT: "/restconf"
NACM_API_ROOT: "/restconf_nacm"
SERVER_NAME: "hyper-h2"
SERVER_SSL_CERT: "jetconf/server.crt"
......
......@@ -8,7 +8,7 @@ from urllib.parse import parse_qs
from yangson.schema import NonexistentSchemaNode
from yangson.instance import NonexistentInstance
from .config import CONFIG_HTTP, NACM_ADMINS, RESTCONF_API_ROOT_data, RESTCONF_NACM_API_ROOT_data
from .config import CONFIG_HTTP, NACM_ADMINS, API_ROOT_data, NACM_API_ROOT_data
from .helpers import CertHelpers
from .data import BaseDatastore, Rpc, DataLockError, NacmForbiddenError, InstanceAlreadyPresent
......@@ -105,7 +105,7 @@ def create_get_nacm_api(ds: BaseDatastore):
prot.conn.send_headers(stream_id, response_headers)
prot.conn.send_data(stream_id, response.encode(), end_stream=True)
else:
pth = url_path[len(RESTCONF_NACM_API_ROOT_data):] or "/"
pth = url_path[len(NACM_API_ROOT_data):] or "/"
get(prot, headers, stream_id, ds.nacm.nacm_ds, pth)
return get_nacm_api_closure
......@@ -123,7 +123,7 @@ def create_get_api(ds: BaseDatastore):
else:
query_string = {}
pth = url_path[len(RESTCONF_API_ROOT_data):] or "/"
pth = url_path[len(API_ROOT_data):] or "/"
get(prot, headers, stream_id, ds, pth)
......@@ -196,7 +196,7 @@ def create_put_post_nacm_api(ds: BaseDatastore):
username = CertHelpers.get_field(prot.client_cert, "emailAddress")
pth = path[len(RESTCONF_NACM_API_ROOT_data):]
pth = path[len(NACM_API_ROOT_data):]
rpc1 = Rpc()
rpc1.username = username
......
......@@ -8,7 +8,7 @@ from h2.connection import H2Connection
from h2.events import DataReceived, RequestReceived, RemoteSettingsChanged
import jetconf.http_handlers as handlers
from .config import CONFIG_HTTP, RESTCONF_NACM_API_ROOT_data, RESTCONF_API_ROOT_data, load_config, print_config
from .config import CONFIG_HTTP, NACM_API_ROOT_data, API_ROOT_data, load_config, print_config
from .nacm import NacmConfig
from .data import JsonDatastore, Rpc, NacmForbiddenError, DataLockError, InstanceAlreadyPresent
......@@ -121,11 +121,11 @@ def run():
put_post_nacm_api = handlers.create_put_post_nacm_api(ex_datastore)
gl_handlers = HandlerList()
gl_handlers.register_handler(lambda m, p: (m == "POST") and (p.startswith(RESTCONF_NACM_API_ROOT_data)), put_post_nacm_api)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p == CONFIG_HTTP["RESTCONF_NACM_API_ROOT"]), handlers.api_root_handler)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p == CONFIG_HTTP["RESTCONF_API_ROOT"]), handlers.api_root_handler)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p.startswith(RESTCONF_NACM_API_ROOT_data)), get_nacm_api)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p.startswith(RESTCONF_API_ROOT_data)), get_api)
gl_handlers.register_handler(lambda m, p: (m == "POST") and (p.startswith(NACM_API_ROOT_data)), put_post_nacm_api)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p == CONFIG_HTTP["NACM_API_ROOT"]), handlers.api_root_handler)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p == CONFIG_HTTP["API_ROOT"]), handlers.api_root_handler)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p.startswith(NACM_API_ROOT_data)), get_nacm_api)
gl_handlers.register_handler(lambda m, p: (m == "GET") and (p.startswith(API_ROOT_data)), get_api)
gl_handlers.register_handler(lambda m, p: m == "GET", handlers.get_file)
# HTTP server init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment