54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
from __future__ import annotations
|
|
from logging import getLogger
|
|
|
|
from .dazy import Meta, Template
|
|
from .desc import (
|
|
WEEGEE_INTERFACE_CONF_WG, WEEGEE_INTERFACE_CONF_WGQUICK, WEEGEE_INTERFACE_CONF_OPENWRT,
|
|
WEEGEE_PEER_CONF_WG, WEEGEE_PEER_CONF_OPENWRT, WEEGEE_CONF_WG, WEEGEE_CONF_OPENWRT,
|
|
)
|
|
|
|
from .config import WeegeeConfig, WeegeeContext
|
|
from .core import (
|
|
WeegeeBase, WeegeeHook, WeegeeHost, WeegeePublicInterface, WeegeeInterface, WeegeePeer, WeegeeConnection,
|
|
find_host_interfaces, find_interface_connections, find_interface_other_peers,
|
|
do_discover_interface, do_config_interface, config_interface,
|
|
do_sync_interface, sync_interface, sync_all_interfaces,
|
|
)
|
|
from .remote import WeegeeRemoteServer, REMOTE_COMMAND_SETS
|
|
from .extra import WeegeeServer, WeegeeClient
|
|
|
|
logger = getLogger(__name__)
|
|
|
|
ALL_TEMPLATES = (
|
|
WEEGEE_INTERFACE_CONF_WG, WEEGEE_INTERFACE_CONF_WGQUICK, WEEGEE_INTERFACE_CONF_OPENWRT,
|
|
WEEGEE_PEER_CONF_WG, WEEGEE_PEER_CONF_OPENWRT, WEEGEE_CONF_WG, WEEGEE_CONF_OPENWRT,
|
|
)
|
|
|
|
|
|
def setup(context: WeegeeContext) -> None:
|
|
logger.info('setup: metas')
|
|
for meta in (WeegeeHook, WeegeeHost, WeegeePublicInterface, WeegeeInterface, WeegeePeer, WeegeeConnection):
|
|
logger.debug(' ' + meta.BASE.name)
|
|
Meta.parse(context.instance, meta.BASE.get_name(), meta.BASE.spec).save()
|
|
|
|
logger.info('setup: templates')
|
|
for temp in ALL_TEMPLATES:
|
|
logger.debug(' ' + temp.name)
|
|
Template(temp.get_name(), temp.template, context.instance).save()
|
|
|
|
logger.info('setup: items')
|
|
if not WeegeeHost.exists(context, WeegeeHost.LOCAL_HOST_NAME):
|
|
logger.debug(f' {WeegeeHost.get_name(WeegeeHost.LOCAL_HOST_NAME)}')
|
|
WeegeeHost.create(context, WeegeeHost.LOCAL_HOST_NAME).save()
|
|
|
|
|
|
__all__ = [x.__name__ for x in (
|
|
WeegeeConfig, WeegeeContext,
|
|
WeegeeHook, WeegeeHook, WeegeeInterface, WeegeePeer, WeegeeConnection,
|
|
WeegeeServer, WeegeeClient,
|
|
setup,
|
|
do_config_interface, do_discover_interface,
|
|
find_host_interfaces, find_interface_connections, find_interface_other_peers,
|
|
do_sync_interface, sync_interface, sync_all_interfaces,
|
|
)]
|