Update scheduler.py to use the new config, and comment out the influx stuff

This commit is contained in:
Herbert Wolverson committed 2023-12-14 11:08:23 -06:00
1 parent adc0174e64
commit b604dba613
5 files changed
+46 -22

No files matched your search

@@ -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(())
}
@@ -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
@@ -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,
}
}
}
+21
View File
@@ -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<String> {
fn splynx_api_url() -> PyResult<String> {
let config = lqos_config::load_config().unwrap();
Ok(config.spylnx_integration.url)
}
#[pyfunction]
fn automatic_import_uisp() -> PyResult<bool> {
let config = lqos_config::load_config().unwrap();
Ok(config.uisp_integration.enable_uisp)
}
#[pyfunction]
fn automatic_import_splynx() -> PyResult<bool> {
let config = lqos_config::load_config().unwrap();
Ok(config.uisp_integration.enable_uisp)
}
#[pyfunction]
fn queue_refresh_interval_mins() -> PyResult<u32> {
let config = lqos_config::load_config().unwrap();
Ok(config.integration_common.queue_refresh_interval_mins)
}
+18 -22
View File
@@ -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()