nettoolkit 0.0.3__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__init__.py +49 -0
  2. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/__init__.cpython-38.pyc +0 -0
  3. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/addressing.cpython-38.pyc +0 -0
  4. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/gpl.cpython-38.pyc +0 -0
  5. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/hierarchy.cpython-38.pyc +0 -0
  6. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/hierarchy_rules.cpython-38.pyc +0 -0
  7. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/__pycache__/jset.cpython-38.pyc +0 -0
  8. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/addressing.py +920 -0
  9. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/gpl.py +1207 -0
  10. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/hierarchy.py +558 -0
  11. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/hierarchy_rules.py +229 -0
  12. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit/jset.py +109 -0
  13. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit-0.0.3-py3.8.egg-info/PKG-INFO +41 -0
  14. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit-0.0.3-py3.8.egg-info/SOURCES.txt +12 -0
  15. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit-0.0.3-py3.8.egg-info/dependency_links.txt +1 -0
  16. Users/ALI/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/nettoolkit-0.0.3-py3.8.egg-info/top_level.txt +1 -0
@@ -0,0 +1,229 @@
1
+
2
+
3
+
4
+ candidates_require_suffix = {
5
+ 'family',
6
+ 'filter',
7
+ 'term',
8
+ 'source-port',
9
+ 'destination-port',
10
+ 'ip-protocol',
11
+ 'forwarding-class',
12
+ 'loss-priority',
13
+ 'count',
14
+ 'ether-type',
15
+ 'host-name',
16
+ 'domain-name',
17
+ 'time-zone',
18
+ 'aging-timer',
19
+ 'no-tcp-reset',
20
+ 'authentication-order',
21
+ 'console', 'auxiliary',
22
+ 'encrypted-password', 'secret',
23
+ 'timeout',
24
+ 'source-address',
25
+ 'events',
26
+ 'announcement', 'message',
27
+ 'tries-before-disconnect',
28
+ 'class', 'user', 'uid', 'full-name',
29
+ 'idle-timeout', 'connection-limit', 'rate-limit',
30
+ 'permissions',
31
+ 'allow-commands',
32
+ 'root-login',
33
+ 'protocol-version',
34
+ 'key-exchange',
35
+ 'any',
36
+ 'interactive-commands',
37
+ 'change-log',
38
+ 'match',
39
+ 'facility-override',
40
+ 'host',
41
+ 'file',
42
+ 'authorization',
43
+ 'daemon', 'kernel',
44
+ 'commit',
45
+ # 'server',
46
+ 'device-count',
47
+ 'link-down',
48
+ 'interface-range',
49
+ 'member',
50
+ 'description',
51
+ 'unit',
52
+ '802.3ad',
53
+ 'mtu',
54
+ 'address',
55
+ 'interface-mode',
56
+ # 'members',
57
+ 'storm-control',
58
+ 'recovery-timeout',
59
+ 'link-speed',
60
+ 'periodic',
61
+ 'vrrp-group',
62
+ 'virtual-address',
63
+ 'priority',
64
+ 'fast-interval',
65
+ 'hold-time',
66
+ 'priority-hold-time',
67
+ 'interface',
68
+ 'priority-cost',
69
+ 'input',
70
+ 'output',
71
+ 'location',
72
+ 'contact',
73
+ 'authorization',
74
+ 'client-list-name',
75
+ 'trap-group',
76
+ 'version',
77
+ 'interval',
78
+ 'rising-threshold',
79
+ 'falling-threshold',
80
+ 'storm-control-profiles',
81
+ 'bandwidth-level',
82
+ 'group',
83
+ 'router-id',
84
+ 'autonomous-system',
85
+ 'export',
86
+ 'import',
87
+ 'preference',
88
+ 'minimum-hold-time',
89
+ 'type',
90
+ 'neighbor',
91
+ 'delay',
92
+ 'holddown',
93
+ 'rapid-runs',
94
+ 'external-preference',
95
+ 'reference-bandwidth',
96
+ 'area',
97
+ 'interface-type',
98
+ 'metric',
99
+ 'simple-password',
100
+ 'egress-policy',
101
+ 'label-withdrawal-delay',
102
+ 'transport-address',
103
+ 'keepalive-interval',
104
+ 'keepalive-timeout',
105
+ 'igp-synchronization', 'holddown-interval',
106
+ 'hello-interval',
107
+ 'failover-delay',
108
+ 'startup-silent-period',
109
+ 'global-mac-table-aging-time',
110
+ 'management-address',
111
+ 'port-id-subtype',
112
+ 'bridge-priority',
113
+ 'max-age',
114
+ 'forward-delay',
115
+ 'mode',
116
+ 'prefix-list',
117
+ 'authentication-key',
118
+ 'local-address',
119
+ 'vlan',
120
+ 'policy-statement',
121
+ 'load-balance',
122
+ 'rib',
123
+ 'origin',
124
+ 'community',
125
+ 'next',
126
+ 'tag',
127
+ 'policy',
128
+ 'local-preference',
129
+ 'firewall',
130
+ 'as-path',
131
+ 'dscp',
132
+ 'low',
133
+ 'loss-priority',
134
+ 'prefix-list-filter',
135
+ 'exp',
136
+ 'scheduler-map',
137
+ 'percent',
138
+ 'buffer-size',
139
+ 'guaranteed-rate',
140
+ 'transmit-rate',
141
+ 'output-traffic-control-profile',
142
+ # 'scheduler',
143
+ 'ttl',
144
+ 'instance-type',
145
+ 'route-distinguisher',
146
+ 'route',
147
+ 'next-hop',
148
+ 'vlan-id',
149
+ 'l3-interface',
150
+
151
+ 'archive', # Multiple words following archive
152
+ 'member-range'
153
+
154
+
155
+ }
156
+
157
+ candidates_require_suffix_include_members = {
158
+
159
+ }
160
+ candidates_require_suffix_exclude_members = {
161
+ 'filter': ('input', 'output'),
162
+ 'interactive-commands': ('interactive-commands',),
163
+ 'vlan': ('members'),
164
+ 'firewall': ('family', ),
165
+ # 'nc': ('loss-priority', )
166
+
167
+
168
+ }
169
+
170
+ candidates_distributed_to_multi_lines = {
171
+ 'set',
172
+ 'add',
173
+ 'community',
174
+ }
175
+ candidates_distributed_to_multi_lines_exclude = {
176
+
177
+ }
178
+ candidates_distributed_to_multi_lines_include = {
179
+ 'community': ('add', 'set'),
180
+ }
181
+
182
+
183
+ candidates_can_club_members = {
184
+ 'source-port',
185
+ 'destination-port',
186
+ 'events',
187
+ 'permissions',
188
+ 'members',
189
+ 'apply-path',
190
+ 'protocol',
191
+ 'code-points',
192
+ 'code-point',
193
+ 'icmp-type',
194
+ 'apply-groups',
195
+ 'vrf-export',
196
+ 'next-hop',
197
+ 'import',
198
+
199
+
200
+ }
201
+
202
+ candidates_not_expand_if_single = set()
203
+ candidates_not_expand_in_anycase = set()
204
+
205
+
206
+ # EXCEPTIONAL_WORDS = {
207
+ # 'firewall',
208
+
209
+ # }
210
+
211
+ description_strings = {
212
+ 'description',
213
+ 'secret',
214
+ 'announcement',
215
+ 'message',
216
+ 'allow-commands',
217
+ 'encrypted-password',
218
+ 'authentication-key',
219
+ 'simple-password',
220
+ 'full-name',
221
+ 'match',
222
+ 'apply-path',
223
+ 'archive',
224
+ 'member-range',
225
+ 'location',
226
+ 'contact',
227
+ 'as-path',
228
+ }
229
+
@@ -0,0 +1,109 @@
1
+ # -----------------------------------------------------------------------------
2
+ # IMPORTS
3
+ # -----------------------------------------------------------------------------
4
+
5
+ from .gpl import Default, STR, Container
6
+
7
+ # ---------------------------------------------------------------------------- #
8
+ # J-Set
9
+ # ---------------------------------------------------------------------------- #
10
+
11
+ class JSet(Default, STR, Container):
12
+ """Juniper Standard to set converter"""
13
+
14
+ def __init__(self, input_file=None, input_list=None):
15
+ self.output = []
16
+ self.err = False
17
+ if input_file or input_list: self.set_input(input_file, input_list)
18
+
19
+ @property
20
+ def objVar(self): return self.output
21
+
22
+ def set_input(self, input_file=None, input_list=None):
23
+ """set input list from either provided input.
24
+ --> None
25
+
26
+ :param input_file: input text file i/o
27
+ :type input_file: i/o
28
+
29
+ :param input_list: input in format of list or tuple
30
+ :type input_list: list, tuple
31
+ """
32
+ if not input_file and not input_list:
33
+ pass
34
+ elif input_file:
35
+ self.read_input_file(input_file)
36
+ elif input_list:
37
+ self.read_input_list(input_list)
38
+
39
+ @property
40
+ def to_set(self):
41
+ """reads juniper standard config and convert it to set, store it to output
42
+ --> None
43
+ """
44
+ varL, varS, varR, c = "", "set ", [], 0
45
+ try :
46
+ for line in self.lst:
47
+ c += 1
48
+ l = line.strip()
49
+ # operate
50
+ l = self.delete_trailing_remarks(l) # Remove Trailing remarks
51
+ llen = len(l)
52
+ if l[:1] == "#" or self.right(l, 1) == "/" : continue # Remark lines - bypass
53
+ elif len(l) == 0 : continue # Empty lines - bypass
54
+ elif self.right(l, 1) == "{" : # Hierarchical config follows
55
+ varR.append(varL)
56
+ varL = varL.strip() + " " + l[:llen - 1]
57
+ elif self.right(l, 1) == "}" : # Hierarchical config ends
58
+ varL = varR[len(varR)-1]
59
+ varR.pop()
60
+ # elif self.right(l, 12) == " SECRET-DATA" : # Remove encrypted password remark
61
+ # self.output.append(varS + varL.strip() + " " + l[:llen - 17])
62
+ elif self.right(l, 1) == ";" : # Terminal lines
63
+ # Lines consisting Multi section parameters [ ]
64
+ if self.right(l[:llen-1].strip(), 1) == "]" :
65
+ bbs = l.find("[") + 1
66
+ bbe = l.find("]") + 1
67
+ text_string = self.mid(l, bbs + 2, bbe - bbs - 3)
68
+ wrdArray = text_string.split(" ")
69
+ varEX = l[:bbs - 1]
70
+ # Count of parameters inside []
71
+ for eachitem in wrdArray:
72
+ tmp_l = varS+varL.strip()+" "+varEX+" "+eachitem
73
+ self.output.append(tmp_l)
74
+ # Normal lines
75
+ else :
76
+ self.output.append(varS+varL.strip()+" "+l[:llen - 1])
77
+ else : # Uncategorized Lines
78
+ self.err = True
79
+ raise Exception(f"UndefinedTypeLine-{c}:{line}")
80
+ except :
81
+ self.err = True
82
+ raise Exception(f"ErrorParsingLine-{c}:{line}")
83
+
84
+ def read_input_list(self, input_list):
85
+ """Reads input list as input list
86
+ --> None
87
+
88
+ :param input_list: input in format of list or tuple
89
+ :type input_list: list, tuple
90
+ """
91
+ if isinstance(input_list, (list, tuple)):
92
+ self.lst = input_list
93
+ else:
94
+ raise Exception(f"InputListReadError")
95
+
96
+ def read_input_file(self, input_file):
97
+ """Reads input file and set input list
98
+ --> None
99
+
100
+ :param input_file: input text file i/o
101
+ :type input_file: i/o
102
+ """
103
+ try:
104
+ with open(input_file, "r") as f:
105
+ self.lst = f.readlines()
106
+ except:
107
+ raise Exception(f"InputFileReadError-{input_file}")
108
+ # ---------------------------------------------------------------------------- #
109
+
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.1
2
+ Name: nettoolkit
3
+ Version: 0.0.3
4
+ Summary: Tool Set for Networking Geeks
5
+ Home-page: https://github.com/alias1978/nettoolkit
6
+ Author: ALIASGAR - ALI
7
+ Author-email: aholo2000@gmail.com
8
+ License: UNKNOWN
9
+ Description: Tool Set for Networking Geeks
10
+ -------------------------------------------------------------------
11
+ JSet, IPv4, IPv6, addressing, Validation,
12
+ Default, Container, Numeric, STR, IO, LST, DIC, LOG, DB, IP,
13
+ DifferenceDict, DictMethods
14
+ -------------------------------------------------------------------
15
+ JSet convert juniper standard config to set config
16
+ IPv4 IPV4 Object, and its operations
17
+ IPv6 IPV4 Object, and its operations
18
+ addressing dynamic allocation of IPv4/IPv6 Objects
19
+ Validation Validate subnet
20
+ IpHelperUpdate DHCPv6 Helper update utility
21
+ Default default implementations of docstring
22
+ Container default identical dunder methods implementations
23
+ Numeric To be implemented later
24
+ STR String Operations static methods
25
+ IO Input/Output of text files Operations static methods
26
+ LST List Operations static methods
27
+ DIC Dictionary Operations static methods
28
+ DifferenceDict Differences between dictionaries
29
+ DictMethods Common Dictionary Methods
30
+ LOG Logging Operations static methods
31
+ DB Database Operations static methods
32
+ IP IP Addressing Operations static methods
33
+ ... and many more
34
+ -------------------------------------------------------------------
35
+
36
+ Platform: UNKNOWN
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Classifier: Operating System :: OS Independent
40
+ Requires-Python: >=3.7
41
+ Description-Content-Type: text/markdown
@@ -0,0 +1,12 @@
1
+ README.md
2
+ setup.py
3
+ nettoolkit/__init__.py
4
+ nettoolkit/addressing.py
5
+ nettoolkit/gpl.py
6
+ nettoolkit/hierarchy.py
7
+ nettoolkit/hierarchy_rules.py
8
+ nettoolkit/jset.py
9
+ nettoolkit.egg-info/PKG-INFO
10
+ nettoolkit.egg-info/SOURCES.txt
11
+ nettoolkit.egg-info/dependency_links.txt
12
+ nettoolkit.egg-info/top_level.txt