diff --git a/src/integrationPowercode.py b/src/integrationPowercode.py index a1ed97df..756fcba2 100644 --- a/src/integrationPowercode.py +++ b/src/integrationPowercode.py @@ -2,20 +2,20 @@ from pythonCheck import checkPythonVersion checkPythonVersion() import requests import warnings -from ispConfig import excludeSites, findIPv6usingMikrotik, bandwidthOverheadFactor, exceptionCPEs, powercode_api_key, powercode_api_url +from liblqos_python import find_ipv6_using_mikrotik, powercode_api_key, powercode_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 from urllib3.exceptions import InsecureRequestWarning def getCustomerInfo(): headers= {'Content-Type': 'application/x-www-form-urlencoded'} - url = powercode_api_url + ":444/api/preseem/index.php" + url = powercode_api_url() + ":444/api/preseem/index.php" data = {} - data['apiKey'] = powercode_api_key + data['apiKey'] = powercode_api_key() data['action'] = 'list_customers' r = requests.post(url, data=data, headers=headers, verify=False, timeout=10) @@ -23,9 +23,9 @@ def getCustomerInfo(): def getListServices(): headers= {'Content-Type': 'application/x-www-form-urlencoded'} - url = powercode_api_url + ":444/api/preseem/index.php" + url = powercode_api_url() + ":444/api/preseem/index.php" data = {} - data['apiKey'] = powercode_api_key + data['apiKey'] = powercode_api_key() data['action'] = 'list_services' r = requests.post(url, data=data, headers=headers, verify=False, timeout=10) diff --git a/src/rust/lqos_config/src/etc/v15/mod.rs b/src/rust/lqos_config/src/etc/v15/mod.rs index a6e08d90..83420406 100644 --- a/src/rust/lqos_config/src/etc/v15/mod.rs +++ b/src/rust/lqos_config/src/etc/v15/mod.rs @@ -11,6 +11,7 @@ mod integration_common; mod ip_ranges; mod spylnx_integration; mod uisp_integration; +mod powercode_integration; pub use bridge::*; pub use long_term_stats::LongTermStats; pub use tuning::Tunables; \ No newline at end of file diff --git a/src/rust/lqos_config/src/etc/v15/top_config.rs b/src/rust/lqos_config/src/etc/v15/top_config.rs index 8d8da1bb..a855b24e 100644 --- a/src/rust/lqos_config/src/etc/v15/top_config.rs +++ b/src/rust/lqos_config/src/etc/v15/top_config.rs @@ -58,6 +58,9 @@ pub struct Config { /// UISP Integration pub uisp_integration: super::uisp_integration::UispIntegration, + + /// Powercode Integration + pub powercode_integration: super::powercode_integration::PowercodeIntegration, } impl Config { @@ -116,6 +119,7 @@ impl Default for Config { integration_common: super::integration_common::IntegrationConfig::default(), spylnx_integration: super::spylnx_integration::SplynxIntegration::default(), uisp_integration: super::uisp_integration::UispIntegration::default(), + powercode_integration: super::powercode_integration::PowercodeIntegration::default(), packet_capture_time: 10, queue_check_period_ms: 1000, } diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index bfe56cd2..b4e9ccb3 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -71,6 +71,9 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(automatic_import_uisp))?; m.add_wrapped(wrap_pyfunction!(automatic_import_splynx))?; m.add_wrapped(wrap_pyfunction!(queue_refresh_interval_mins))?; + m.add_wrapped(wrap_pyfunction!(automatic_import_powercode))?; + m.add_wrapped(wrap_pyfunction!(powercode_api_key))?; + m.add_wrapped(wrap_pyfunction!(powercode_api_url))?; Ok(()) } @@ -532,4 +535,22 @@ fn automatic_import_splynx() -> PyResult { fn queue_refresh_interval_mins() -> PyResult { let config = lqos_config::load_config().unwrap(); Ok(config.integration_common.queue_refresh_interval_mins) +} + +#[pyfunction] +fn automatic_import_powercode() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.powercode_integration.enable_powercode) +} + +#[pyfunction] +fn powercode_api_key() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.powercode_integration.powercode_api_key) +} + +#[pyfunction] +fn powercode_api_url() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.powercode_integration.powercode_api_url) } \ No newline at end of file