-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
46 lines (36 loc) · 1.14 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# xbi1.__init__.py
import configparser
from proxmoxer import ProxmoxAPI
from xbi1_pvei import pvei_logger
from xbi1_pvei.pvei import PVEInterface
config = configparser.ConfigParser()
config.read('ini.conf')
# pvei_api_state checks interface
# if proxmox connection established
# then changes state to True
pvei_api_state: bool = False
try:
# pvei is ProxmoxVE's interface
# should be exported and used
pvei = PVEInterface(
ProxmoxAPI(
config['PROXMOX']['host'],
user=config['PROXMOX']['user'],
password=config['PROXMOX']['password'],
verify_ssl=False
)
)
# important note: ⚠️
# The Proxmox API module was called once in the
# code file containing the PVE Interface class.
# And it's called again in this code as well.
# A study will be done on this.
if pvei:
# if connection established without problem
pvei_api_state = True
except Exception as exception:
# for any exceptions
pvei_logger.logger.exception(exception.args[0])
finally:
if not pvei_api_state:
pvei_logger.logger.warning('PVEInterface cant created')