diff --git a/src/rust/lqos_config/src/etc/migration.rs b/src/rust/lqos_config/src/etc/migration.rs index 92079c54..c947a84c 100644 --- a/src/rust/lqos_config/src/etc/migration.rs +++ b/src/rust/lqos_config/src/etc/migration.rs @@ -212,6 +212,8 @@ fn migrate_integration_common( new_config.integration_common.circuit_name_as_address = python_config.circuit_name_use_address; new_config.integration_common.always_overwrite_network_json = python_config.overwrite_network_json_always; + new_config.integration_common.queue_refresh_interval_mins = + python_config.queue_refresh_interval_mins; Ok(()) } diff --git a/src/rust/lqos_config/src/etc/v15/example.toml b/src/rust/lqos_config/src/etc/v15/example.toml index 28833bdc..dba70997 100644 --- a/src/rust/lqos_config/src/etc/v15/example.toml +++ b/src/rust/lqos_config/src/etc/v15/example.toml @@ -55,6 +55,7 @@ allow_subnets = [ "172.16.0.0/12", "10.0.0.0/8", "100.64.0.0/16", "192.168.0.0/1 [integration_common] circuit_name_as_address = false always_overwrite_network_json = false +queue_refresh_interval_mins = 30 [spylnx_integration] enable_spylnx = false diff --git a/src/rust/lqos_config/src/etc/v15/integration_common.rs b/src/rust/lqos_config/src/etc/v15/integration_common.rs index 0e64f881..f0cc9f3d 100644 --- a/src/rust/lqos_config/src/etc/v15/integration_common.rs +++ b/src/rust/lqos_config/src/etc/v15/integration_common.rs @@ -9,6 +9,9 @@ pub struct IntegrationConfig { /// Always overwrite network.json? pub always_overwrite_network_json: bool, + + /// Queue refresh interval in minutes + pub queue_refresh_interval_mins: u32, } impl Default for IntegrationConfig { @@ -16,6 +19,7 @@ impl Default for IntegrationConfig { Self { circuit_name_as_address: false, always_overwrite_network_json: false, + queue_refresh_interval_mins: 30, } } } \ No newline at end of file diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index 6e35865c..bfe56cd2 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -68,6 +68,9 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(splynx_api_key))?; m.add_wrapped(wrap_pyfunction!(splynx_api_secret))?; m.add_wrapped(wrap_pyfunction!(splynx_api_url))?; + 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))?; Ok(()) } @@ -511,4 +514,22 @@ fn splynx_api_secret() -> PyResult { fn splynx_api_url() -> PyResult { let config = lqos_config::load_config().unwrap(); Ok(config.spylnx_integration.url) +} + +#[pyfunction] +fn automatic_import_uisp() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.uisp_integration.enable_uisp) +} + +#[pyfunction] +fn automatic_import_splynx() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.uisp_integration.enable_uisp) +} + +#[pyfunction] +fn queue_refresh_interval_mins() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.integration_common.queue_refresh_interval_mins) } \ No newline at end of file diff --git a/src/scheduler.py b/src/scheduler.py index f35bfd10..c99c676f 100644 --- a/src/scheduler.py +++ b/src/scheduler.py @@ -1,15 +1,11 @@ import time import datetime from LibreQoS import refreshShapers, refreshShapersUpdateOnly -from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs -from ispConfig import influxDBEnabled, automaticImportUISP, automaticImportSplynx -try: - from ispConfig import queueRefreshIntervalMins -except: - queueRefreshIntervalMins = 30 -if automaticImportUISP: +#from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs +from liblqos_python import automatic_import_uisp, automatic_import_splynx, queue_refresh_interval_mins +if automatic_import_uisp(): from integrationUISP import importFromUISP -if automaticImportSplynx: +if automatic_import_splynx(): from integrationSplynx import importFromSplynx from apscheduler.schedulers.background import BlockingScheduler from apscheduler.executors.pool import ThreadPoolExecutor @@ -17,26 +13,26 @@ from apscheduler.executors.pool import ThreadPoolExecutor ads = BlockingScheduler(executors={'default': ThreadPoolExecutor(1)}) def importFromCRM(): - if automaticImportUISP: + if automatic_import_uisp(): try: importFromUISP() except: print("Failed to import from UISP") - elif automaticImportSplynx: + elif automatic_import_splynx(): try: importFromSplynx() except: print("Failed to import from Splynx") -def graphHandler(): - try: - refreshBandwidthGraphs() - except: - print("Failed to update bandwidth graphs") - try: - refreshLatencyGraphs() - except: - print("Failed to update latency graphs") +#def graphHandler(): +# try: +# refreshBandwidthGraphs() +# except: +# print("Failed to update bandwidth graphs") +# try: +# refreshLatencyGraphs() +# except: +# print("Failed to update latency graphs") def importAndShapeFullReload(): importFromCRM() @@ -49,9 +45,9 @@ def importAndShapePartialReload(): if __name__ == '__main__': importAndShapeFullReload() - ads.add_job(importAndShapePartialReload, 'interval', minutes=queueRefreshIntervalMins, max_instances=1) + ads.add_job(importAndShapePartialReload, 'interval', minutes=queue_refresh_interval_mins(), max_instances=1) - if influxDBEnabled: - ads.add_job(graphHandler, 'interval', seconds=10, max_instances=1) + #if influxDBEnabled: + # ads.add_job(graphHandler, 'interval', seconds=10, max_instances=1) ads.start()