-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
127 lines (103 loc) · 2.09 KB
/
settings.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
author: zerobits01
purpose: config file custom lib for handling IP and default route addresses
created: 10-Aug-2020
modified: 10-Aug-2020
"""
import configparser
cfg = configparser.ConfigParser()
config_example = '''
[host1]
con_ip = 172.16.229.129
con_port=32775
interface = ens3
ip = 10.0.3.10/24
gw = 10.0.3.1
[host2]
con_ip = 172.16.229.129
con_port=32773
interface = ens3
ip = 10.0.3.11/24
gw = 10.0.3.1
[admin]
con_ip = 172.16.229.129
con_port=32772
interface = ens3
ip = 10.0.0.10/24
gw = 10.0.0.1
[controller]
con_ip = 172.16.229.129
con_port=32781
interface = ens3
ip = 10.0.1.10/24
gw = 10.0.1.1
[ovs1]
con_ip = 172.16.229.129
con_port=32769
br = br0
interfaces = ens3, ens4, ens5, ens6, ens7, ens8, ens9
ip = 172.16.229.131
protocol = OpenFlow13
port = 6653
[ovs2]
con_ip = 172.16.229.129
con_port=32770
br = br0
interfaces = ens3, ens4, ens5, ens6, ens7, ens8, ens9
ip = 172.16.229.131
protocol = OpenFlow13
port = 6653
[ovs3]
con_ip = 172.16.229.129
con_port=32771
br = br0
interfaces = ens3, ens4, ens5, ens6, ens7, ens8, ens9
protocol = OpenFlow13
ip = 172.16.229.131
port = 6653
[django_server]
con_ip = 172.16.229.129
con_port=32779
interface = ens3
ip = 10.0.2.10/24
gw = 10.0.2.1
[wp_server]
con_ip = 172.16.229.129
con_port=32780
interface = ens3
ip = 10.0.2.11/24
gw = 10.0.2.1
[djangoDB_server]
con_ip = 172.16.229.129
con_port=32776
interface = ens3
ip = 10.0.2.12/24
gw = 10.0.2.1
[wpDB_server]
con_ip = 172.16.229.129
con_port=32777
interface = ens3
ip = 10.0.2.13/24
gw = 10.0.2.1
[build_server]
con_ip = 172.16.229.129
con_port=32778
interface = ens3
ip = 10.0.2.14/24
gw = 10.0.2.1
'''
def readConfig(config_file):
'''
reads config file from the topo.cfg and returns the dictionary
'''
cfg.read(config_file)
return cfg
if __name__ == "__main__":
try:
dct = readConfig('topo.cfg')
print(dct['server']['ip'])
except Exception as e:
print(e)
with open("topo.cfg.example", "w") as config_file:
print("[!] rename it to topo.cfg.example to topo.cfg")
config_file.writelines(config_example)