Skip to content

Commit

Permalink
ISSUE #499
Browse files Browse the repository at this point in the history
* Adds a "get LibreQOS directory" function to the Python library.
* Uses it to establish the correct location for uisp_integration.
* Modifies `scheduler.py` to call the new UISP integration directly.
  • Loading branch information
thebracket committed Jun 17, 2024
1 parent 6ed0b88 commit 4930c47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/rust/lqos_python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(influx_db_url))?;
m.add_wrapped(wrap_pyfunction!(get_weights))?;
m.add_wrapped(wrap_pyfunction!(get_tree_weights))?;
m.add_wrapped(wrap_pyfunction!(get_libreqos_directory))?;

Ok(())
}
Expand Down Expand Up @@ -661,4 +662,10 @@ pub fn get_tree_weights() -> PyResult<Vec<device_weights::NetworkNodeWeight>> {
Err(PyOSError::new_err(e.to_string()))
}
}
}

#[pyfunction]
pub fn get_libreqos_directory() -> PyResult<String> {
let config = lqos_config::load_config().unwrap();
Ok(config.lqos_directory)
}
9 changes: 5 additions & 4 deletions src/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import datetime
from LibreQoS import refreshShapers, refreshShapersUpdateOnly
from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs
import subprocess
from liblqos_python import automatic_import_uisp, automatic_import_splynx, queue_refresh_interval_mins, \
automatic_import_powercode, automatic_import_sonar, influx_db_enabled
if automatic_import_uisp():
from integrationUISP import importFromUISP
automatic_import_powercode, automatic_import_sonar, influx_db_enabled, get_libreqos_directory
if automatic_import_splynx():
from integrationSplynx import importFromSplynx
if automatic_import_powercode():
Expand All @@ -20,7 +19,9 @@
def importFromCRM():
if automatic_import_uisp():
try:
importFromUISP()
# Call bin/uisp_integration
path = get_libreqos_directory() + "/bin/uisp_integration"
subprocess.run([path])
except:
print("Failed to import from UISP")
elif automatic_import_splynx():
Expand Down

0 comments on commit 4930c47

Please sign in to comment.