diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9e26dfee..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/annet/adapters/netbox/v41/storage.py b/annet/adapters/netbox/v41/storage.py index de5d1f4c..548ef620 100644 --- a/annet/adapters/netbox/v41/storage.py +++ b/annet/adapters/netbox/v41/storage.py @@ -1,8 +1,8 @@ import ssl from adaptix import P from adaptix.conversion import get_converter, link, link_constant, link_function -from annetbox.v41 import client_sync -from annetbox.v41 import models as api_models +# from annetbox.v41 import client_sync +# from annetbox.v41 import models as api_models from annet.adapters.netbox.common.adapter import NetboxAdapter, get_device_breed, get_device_hw from annet.adapters.netbox.common.storage_base import BaseNetboxStorage diff --git a/annet/rest_api.py b/annet/rest_api.py index 145569c0..95e1c430 100644 --- a/annet/rest_api.py +++ b/annet/rest_api.py @@ -3,7 +3,7 @@ Предоставляет HTTP endpoints для команд ann get, ann diff, ann patch и ann deploy """ -from typing import List, Optional, Any +from typing import Dict, List, Optional, Any from contextlib import asynccontextmanager from fastapi import FastAPI, HTTPException, Query as QueryParam @@ -16,6 +16,7 @@ from annet.storage import get_storage, Query from annet.api import Deployer from annet.output import output_driver_connector +from annet.argparse import Arg # Модели данных для API @@ -178,6 +179,7 @@ def _create_cli_args(query_data: DeviceQuery, options: GenerationOptions, args_c 'no_acl_exclusive': False, 'max_tasks': None, 'ignore_disabled': False, + 'show_hosts_progress': False, } # Добавляем специфичные для diff опции @@ -213,20 +215,30 @@ def _create_cli_args(query_data: DeviceQuery, options: GenerationOptions, args_c }) # Создаем объект аргументов нужного типа - class MockArgs: - def __init__(self, **kwargs): - for key, value in kwargs.items(): - setattr(self, key, value) - self._enum_args = [] - - def stdin(self, filter_acl=None, config=None): - return { - 'filter_acl': None, - 'config': None, - } - return MockArgs(**args_dict) +class MockArgs: + def __init__(self, **kwargs): + print("KWARGS", kwargs) + for key, value in kwargs.items(): + print(key, value) + setattr(self, key, value) + # self._enum_args = {} + + def stdin(self, filter_acl=None, config=None): + return { + 'filter_acl': None, + 'config': None, + } + + @classmethod + def _enum_args(cls) -> Dict[str, Arg]: + ret = {} + for base in cls.__mro__: + for name, value in vars(base).items(): + if not name.startswith("_") and isinstance(value, Arg): + ret[name] = value + return ret @app.get("/", response_model=ApiResponse) async def root():