mirror of
https://github.com/gyptazy/ProxLB.git
synced 2026-04-06 04:41:58 +02:00
fix
This commit is contained in:
@@ -13,6 +13,12 @@ except ImportError:
|
||||
from typing import Dict, Any
|
||||
from utils.logger import SystemdLogger
|
||||
|
||||
|
||||
if not PYYAML_PRESENT:
|
||||
print("The required library 'pyyaml' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
logger = SystemdLogger()
|
||||
|
||||
|
||||
@@ -26,21 +32,9 @@ class ConfigParser:
|
||||
Initializes the configuration file parser and validates the config file.
|
||||
"""
|
||||
logger.debug("Starting: ConfigParser.")
|
||||
self.test_module_dependencies = self.test_dependencies()
|
||||
self.config_path = self.test_config_path(config_path)
|
||||
logger.debug("Finished: ConfigParser.")
|
||||
|
||||
def test_dependencies(self) -> None:
|
||||
"""
|
||||
Checks if the required dependencies are installed.
|
||||
"""
|
||||
logger.debug("Starting: test_dependencies.")
|
||||
if not PYYAML_PRESENT:
|
||||
logger.critical("The required library 'pyyaml' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
logger.debug("Finished: test_dependencies.")
|
||||
|
||||
def test_config_path(self, config_path: str) -> None:
|
||||
"""
|
||||
Checks if configuration file is present at given config path.
|
||||
|
||||
@@ -20,10 +20,23 @@ try:
|
||||
URLLIB3_PRESENT = True
|
||||
except ImportError:
|
||||
URLLIB3_PRESENT = False
|
||||
|
||||
from typing import Dict, Any
|
||||
from utils.logger import SystemdLogger
|
||||
|
||||
|
||||
if not PROXMOXER_PRESENT:
|
||||
print("The required library 'proxmoxer' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
if not URLLIB3_PRESENT:
|
||||
print("The required library 'urllib3' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
if not REQUESTS_PRESENT:
|
||||
print("The required library 'requests' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
logger = SystemdLogger()
|
||||
|
||||
|
||||
@@ -45,7 +58,6 @@ class ProxmoxApi:
|
||||
None
|
||||
"""
|
||||
logger.debug("Starting: ProxmoxApi initialization.")
|
||||
self.test_module_dependencies = self.test_dependencies()
|
||||
self.proxmox_api = self.api_connect(proxlb_config)
|
||||
logger.debug("Finished: ProxmoxApi initialization.")
|
||||
|
||||
@@ -55,35 +67,6 @@ class ProxmoxApi:
|
||||
"""
|
||||
return getattr(self.proxmox_api, name)
|
||||
|
||||
def test_dependencies(self) -> None:
|
||||
"""
|
||||
Test for the presence of required libraries.
|
||||
|
||||
This method checks if the necessary libraries 'proxmoxer', 'urllib3', and 'requests'
|
||||
are installed. If any of these libraries are missing, it logs a critical error message
|
||||
and terminates the program.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
Raises:
|
||||
SystemExit: If the provided imports are not available.
|
||||
"""
|
||||
logger.debug("Starting: test_dependencies.")
|
||||
if not PROXMOXER_PRESENT:
|
||||
logger.critical("The required library 'proxmoxer' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
if not URLLIB3_PRESENT:
|
||||
logger.critical("The required library 'urllib3' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
if not REQUESTS_PRESENT:
|
||||
logger.critical("The required library 'requests' is not installed.")
|
||||
sys.exit(1)
|
||||
|
||||
logger.debug("Finished: test_dependencies.")
|
||||
|
||||
def api_connect_get_hosts(self, proxmox_api_endpoints: list) -> str:
|
||||
"""
|
||||
Perform a connectivity test to determine a working host for the Proxmox API.
|
||||
|
||||
11
service/proxlb.service
Normal file
11
service/proxlb.service
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=ProxLB - A loadbalancer for Proxmox clusters
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
ExecStart=python3 /usr/lib/python3/dist-packages/proxlb/main.py -c /etc/proxlb/proxlb.conf
|
||||
User=plb
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
1
setup.py
1
setup.py
@@ -17,4 +17,5 @@ setup(
|
||||
"proxmoxer",
|
||||
"pyyaml",
|
||||
],
|
||||
data_files=[('/etc/systemd/system', ['service/proxlb.service']), ('/etc/proxlb/', ['config/proxlb_example.yaml'])],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user