forked from mehdiBezahaf/intent-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
44 lines (32 loc) · 1.27 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from __future__ import annotations
import os
from functools import lru_cache
from pathlib import Path
from typing import Optional
import httpx
from pydantic import BaseSettings
from yarl import URL
onos_api_url = URL(os.getenv("ONOS_API_URL", "http://localhost:8181/onos/v1/"))
hosts_url = str(os.getenv("HOSTS_URL", onos_api_url / "hosts"))
switches_url = str(os.getenv("SWITCHES_URL", onos_api_url / "devices"))
links_url = str(os.getenv("LINKS_URL", onos_api_url / "links"))
imr_url = URL(onos_api_url / "imr" / "imr")
ngcdi_url = URL(os.getenv("NGCDI_URL", "http://localhost:5000/api"))
telegram_url = URL("https://api.telegram.org/")
login = "onos"
password = "rocks"
api_key = "be5460c7-eec9-4323-a894-fabaeb74831f"
class Settings(BaseSettings):
webhook_user: str = "webhook"
webhook_pass: str
telegram_token: Optional[str]
neat_test_topo_template: Optional[Path]
neat_test_topo_extra: Optional[Path]
test_config_dir: Optional[Path] = Path("/tmp")
@lru_cache
def get_settings() -> Settings:
return Settings()
def onos_api_client() -> httpx.AsyncClient:
return httpx.AsyncClient(base_url=str(onos_api_url), auth=(login, password))
def onos_imr_api_client() -> httpx.AsyncClient:
return httpx.AsyncClient(base_url=str(imr_url), auth=(login, password))