Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
135
noc
Commits
fab70d7c
Commit
fab70d7c
authored
Aug 22, 2020
by
Andrey Vertiprahov
Browse files
Merge branch 'confdb-eltex-mes' into 'master'
ConfDB Eltex.MES See merge request
noc/noc!4204
parents
70c9b9f1
abc4cfbd
Changes
9
Hide whitespace changes
Inline
Side-by-side
sa/profiles/Eltex/MES/confdb/normalizer.py
View file @
fab70d7c
# ----------------------------------------------------------------------
# Eltex.MES config normalizer
# ----------------------------------------------------------------------
# Copyright (C) 2007-20
19
The NOC Project
# Copyright (C) 2007-20
20
The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from
noc.core.confdb.normalizer.base
import
BaseNormalizer
,
match
,
ANY
,
REST
from
noc.core.text
import
ranges_to_list
from
noc.core.confdb.syntax.patterns
import
IP_ADDRESS
,
INTEGER
class
MESNormalizer
(
BaseNormalizer
):
def
normalize_interface_name
(
self
,
tokens
):
if
tokens
[
1
]
==
"vlan"
:
return
self
.
interface_name
(
tokens
[
1
],
tokens
[
2
])
else
:
return
self
.
interface_name
(
tokens
[
1
])
@
match
(
"hostname"
,
ANY
)
def
normalize_hostname
(
self
,
tokens
):
yield
self
.
make_hostname
(
tokens
[
1
])
@
match
(
"no"
,
"ip"
,
"http"
,
"server"
)
@
match
(
"ip"
,
"http"
,
"server"
)
def
normalize_http_server
(
self
,
tokens
):
yield
self
.
make_protocols_http
()
...
...
@@ -38,21 +45,27 @@ class MESNormalizer(BaseNormalizer):
self
.
set_context
(
"spanning_tree_disabled"
,
True
)
yield
self
.
make_global_spanning_tree_status
(
status
=
False
)
@
match
(
"spanning-tree"
,
"priority"
,
INTEGER
)
def
normalize_spanning_tree_priority
(
self
,
tokens
):
yield
self
.
make_spanning_tree_priority
(
priority
=
tokens
[
-
1
])
@
match
(
"interface"
,
ANY
)
@
match
(
"interface"
,
"vlan"
,
ANY
)
def
normalize_interface
(
self
,
tokens
):
if_name
=
self
.
interface_name
(
tokens
[
1
])
yield
self
.
make_interface
(
interface
=
if_name
)
yield
self
.
make_interface
(
interface
=
self
.
normalize_interface_name
(
tokens
))
@
match
(
"interface"
,
ANY
,
"shutdown"
)
@
match
(
"interface"
,
"vlan"
,
ANY
,
"shutdown"
)
def
normalize_interface_shutdown
(
self
,
tokens
):
yield
self
.
make_interface_admin_status
(
interface
=
self
.
interface_name
(
tokens
[
1
],
tokens
[
2
]
),
admin_status
=
"off"
interface
=
self
.
normalize_
interface_name
(
tokens
),
admin_status
=
"off"
)
@
match
(
"interface"
,
ANY
,
"description"
,
REST
)
@
match
(
"interface"
,
"vlan"
,
ANY
,
"name"
,
REST
)
def
normalize_interface_description
(
self
,
tokens
):
yield
self
.
make_interface_description
(
interface
=
self
.
interface_name
(
tokens
[
1
]
),
description
=
" "
.
join
(
tokens
[
2
:])
interface
=
self
.
normalize_
interface_name
(
tokens
),
description
=
" "
.
join
(
tokens
[
-
2
:])
)
@
match
(
"interface"
,
ANY
,
"port"
,
"security"
,
"max"
,
ANY
)
...
...
@@ -62,18 +75,24 @@ class MESNormalizer(BaseNormalizer):
)
@
match
(
"interface"
,
ANY
,
"broadcast"
,
"level"
,
"kpbs"
,
ANY
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"broadcast"
,
"kbps"
,
INTEGER
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"broadcast"
,
"kbps"
,
INTEGER
,
"shutdown"
)
def
normalize_port_storm_control_broadcast
(
self
,
tokens
):
yield
self
.
make_interface_storm_control_broadcast_level
(
interface
=
self
.
interface_name
(
tokens
[
1
]),
level
=
tokens
[
5
]
)
@
match
(
"interface"
,
ANY
,
"multicast"
,
"level"
,
"kpbs"
,
ANY
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"multicast"
,
"kbps"
,
INTEGER
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"multicast"
,
"kbps"
,
INTEGER
,
"shutdown"
)
def
normalize_port_storm_control_multicast
(
self
,
tokens
):
yield
self
.
make_interface_storm_control_multicast_level
(
interface
=
self
.
interface_name
(
tokens
[
1
]),
level
=
tokens
[
5
]
)
@
match
(
"interface"
,
ANY
,
"unknown-unicast"
,
"level"
,
"kpbs"
,
ANY
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"unknown-unicast"
,
"kbps"
,
INTEGER
)
@
match
(
"interface"
,
ANY
,
"storm-control"
,
"unknown-unicast"
,
"kbps"
,
INTEGER
,
"shutdown"
)
def
normalize_port_storm_control_unicast
(
self
,
tokens
):
yield
self
.
make_interface_storm_control_unicast_level
(
interface
=
self
.
interface_name
(
tokens
[
1
]),
level
=
tokens
[
5
]
...
...
@@ -97,6 +116,12 @@ class MESNormalizer(BaseNormalizer):
interface
=
self
.
interface_name
(
tokens
[
1
]),
enabled
=
True
)
@
match
(
"interface"
,
ANY
,
"spanning-tree"
,
"portfast"
)
def
normalize_interface_stp_mode
(
self
,
tokens
):
yield
self
.
make_spanning_tree_interface_mode
(
interface
=
self
.
interface_name
(
tokens
[
1
]),
mode
=
"portfast"
)
@
match
(
"interface"
,
ANY
,
"no"
,
"lldp"
,
ANY
)
def
normalize_interface_lldp_admin_status
(
self
,
tokens
):
if
not
self
.
get_context
(
"lldp_disabled"
):
...
...
@@ -138,15 +163,15 @@ class MESNormalizer(BaseNormalizer):
interface
=
if_name
,
unit
=
if_name
,
vlan_filter
=
tokens
[
5
]
)
#
@match("ip", "igmp", "vlan", ANY)
#
def normalize_igmp_snoopiing_vlan(self, tokens):
#
yield self.
@
match
(
"ip"
,
"igmp"
,
"snooping"
,
"vlan"
,
ANY
)
def
normalize_igmp_snoopiing_vlan
(
self
,
tokens
):
yield
self
.
make_igmp_snooping_multicast_router
(
vlan
=
tokens
[
-
1
])
@
match
(
"interface"
,
ANY
,
"ip"
,
"address"
,
ANY
,
ANY
)
@
match
(
"interface"
,
"vlan"
,
ANY
,
"ip"
,
"address"
,
ANY
,
ANY
)
def
normalize_vlan_ip
(
self
,
tokens
):
if_name
=
self
.
interface_name
(
tokens
[
1
])
if_name
=
self
.
interface_name
(
tokens
[
1
]
,
tokens
[
2
]
)
yield
self
.
make_unit_inet_address
(
interface
=
if_name
,
unit
=
if_name
,
address
=
self
.
to_prefix
(
tokens
[
4
],
tokens
[
5
])
interface
=
if_name
,
unit
=
if_name
,
address
=
self
.
to_prefix
(
tokens
[
-
2
],
tokens
[
-
1
])
)
@
match
(
"ip"
,
"default-gateway"
,
ANY
)
...
...
@@ -255,3 +280,11 @@ class MESNormalizer(BaseNormalizer):
@
match
(
"sntp"
,
"server"
,
ANY
,
ANY
,
ANY
,
ANY
)
def
normalize_ntp_server
(
self
,
tokens
):
yield
self
.
make_ntp_server_address
(
name
=
tokens
[
2
],
address
=
tokens
[
2
])
@
match
(
"ip"
,
"name-server"
,
IP_ADDRESS
)
def
normalize_dns_name_server
(
self
,
tokens
):
yield
self
.
make_protocols_dns_name_server
(
ip
=
tokens
[
-
1
])
@
match
(
"ip"
,
"domain"
,
"name"
,
ANY
)
def
normalize_dns_name_server_search_suffix
(
self
,
tokens
):
yield
self
.
make_protocols_dns_search_suffix
(
suffix
=
tokens
[
-
1
])
tests/confdb/profiles/Eltex/MES/default_gateway1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
ip default-gateway 192.168.0.1
!
result
:
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
route'
,
'
inet'
,
'
static'
,
'
0.0.0.0/0'
,
'
next-hop'
,
'
192.168.0.1'
]
tests/confdb/profiles/Eltex/MES/dns1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
ip domain name company.ru
ip name-server 192.168.0.1
!
result
:
-
[
'
protocols'
,
'
dns'
,
'
search'
,
'
company.ru'
]
-
[
'
protocols'
,
'
dns'
,
'
name-server'
,
'
192.168.0.1'
]
tests/confdb/profiles/Eltex/MES/hostname1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
hostname host-name
!
result
:
-
[
'
system'
,
'
hostname'
,
'
host-name'
,
{
'
replace'
:
True
}]
tests/confdb/profiles/Eltex/MES/spanning_tree1.yml
0 → 100644
View file @
fab70d7c
config
:
|
spanning-tree priority 8192
!
result
:
-
[
'
protocols'
,
'
spanning-tree'
,
'
priority'
,
8192
,
{
'
replace'
:
True
}]
tests/confdb/profiles/Eltex/MES/spanning_tree2.yml
0 → 100644
View file @
fab70d7c
config
:
|
no spanning-tree
!
result
:
-
[
'
hints'
,
'
protocols'
,
'
spanning-tree'
,
'
status'
,
False
,
{
'
replace'
:
True
}]
tests/confdb/profiles/Eltex/MES/ssh1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
ip ssh server
!
result
:
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
protocols'
,
'
ssh'
]
tests/confdb/profiles/Eltex/MES/user1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
username admin password encrypted DESishelmebegelme= privilege 15
!
result
:
-
[
'
system'
,
'
user'
,
'
admin'
,
'
authentication'
,
'
encrypted-password'
,
'
D
E
S
i
s
h
e
l
m
e
b
e
g
e
l
m
e
='
,
{
'
replace'
:
True
}]
-
[
'
system'
,
'
user'
,
'
admin'
,
'
class'
,
'
level-15'
]
tests/confdb/profiles/Eltex/MES/vlan1.yml
0 → 100644
View file @
fab70d7c
config
:
|
!
vlan database
vlan 2,5,101-106
vlan 2250-2255,2586-2588
exit
!
result
:
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
5
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
101
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
102
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
103
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
104
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
105
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
106
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2250
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2251
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2252
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2253
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2254
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2255
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2586
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2587
]
-
[
'
virtual-router'
,
'
default'
,
'
forwarding-instance'
,
'
default'
,
'
vlans'
,
2588
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment