diff --git a/src/integrationSplynx.py b/src/integrationSplynx.py index 11feae84..53397aeb 100644 --- a/src/integrationSplynx.py +++ b/src/integrationSplynx.py @@ -2,23 +2,24 @@ from pythonCheck import checkPythonVersion checkPythonVersion() import requests import warnings -from ispConfig import excludeSites, findIPv6usingMikrotik, bandwidthOverheadFactor, exceptionCPEs, splynx_api_key, splynx_api_secret, splynx_api_url +from liblqos_python import exclude_sites, find_ipv6_using_mikrotik, bandwidth_overhead_factor, splynx_api_key, \ + splynx_api_secret, splynx_api_url from integrationCommon import isIpv4Permitted import base64 from requests.auth import HTTPBasicAuth -if findIPv6usingMikrotik == True: +if find_ipv6_using_mikrotik() == True: from mikrotikFindIPv6 import pullMikrotikIPv6 from integrationCommon import NetworkGraph, NetworkNode, NodeType def buildHeaders(): - credentials = splynx_api_key + ':' + splynx_api_secret + credentials = splynx_api_key() + ':' + splynx_api_secret() credentials = base64.b64encode(credentials.encode()).decode() return {'Authorization' : "Basic %s" % credentials} def spylnxRequest(target, headers): # Sends a REST GET request to Spylnx and returns the # result in JSON - url = splynx_api_url + "/api/2.0/" + target + url = splynx_api_url() + "/api/2.0/" + target r = requests.get(url, headers=headers, timeout=10) return r.json() diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index 06313fb8..6e35865c 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -65,6 +65,9 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(use_ptmp_as_parent))?; m.add_wrapped(wrap_pyfunction!(uisp_base_url))?; m.add_wrapped(wrap_pyfunction!(uisp_auth_token))?; + m.add_wrapped(wrap_pyfunction!(splynx_api_key))?; + m.add_wrapped(wrap_pyfunction!(splynx_api_secret))?; + m.add_wrapped(wrap_pyfunction!(splynx_api_url))?; Ok(()) } @@ -490,4 +493,22 @@ fn uisp_base_url() -> PyResult { fn uisp_auth_token() -> PyResult { let config = lqos_config::load_config().unwrap(); Ok(config.uisp_integration.token) +} + +#[pyfunction] +fn splynx_api_key() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.spylnx_integration.api_key) +} + +#[pyfunction] +fn splynx_api_secret() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.spylnx_integration.api_secret) +} + +#[pyfunction] +fn splynx_api_url() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.spylnx_integration.url) } \ No newline at end of file