annet 0.16.16__tar.gz → 0.16.17__tar.gz
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.
Potentially problematic release.
This version of annet might be problematic. Click here for more details.
- {annet-0.16.16/annet.egg-info → annet-0.16.17}/PKG-INFO +1 -1
- annet-0.16.17/annet/rulebook/cisco/misc.py +149 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/cisco.rul +1 -1
- {annet-0.16.16 → annet-0.16.17/annet.egg-info}/PKG-INFO +1 -1
- annet-0.16.16/annet/rulebook/cisco/misc.py +0 -57
- {annet-0.16.16 → annet-0.16.17}/AUTHORS +0 -0
- {annet-0.16.16 → annet-0.16.17}/LICENSE +0 -0
- {annet-0.16.16 → annet-0.16.17}/MANIFEST.in +0 -0
- {annet-0.16.16 → annet-0.16.17}/README.md +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/fetchers/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/fetchers/stub/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/fetchers/stub/fetcher.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/file/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/file/provider.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/client.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/manufacturer.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/models.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/query.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/status_client.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/common/storage_opts.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/provider.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/v24/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/v24/storage.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/v37/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/adapters/netbox/v37/storage.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annet.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/command.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/diff.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/errors.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/filter_acl.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/jsontools.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/lib.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/db.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/devdb/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/devdb/data/devdb.json +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/views/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/views/dump.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/netdev/views/hardware.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/output.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/patching.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/acl.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/deploying.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/ordering.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/platform.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rbparser/syntax.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rulebook/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/rulebook/common.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/tabparser.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/annlib/types.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/api/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/argparse.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/bgp_models.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/cli.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/cli_args.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/configs/context.yml +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/configs/logging.yaml +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/connectors.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/deploy.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/diff.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/executor.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/filtering.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/gen.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/base.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/common/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/common/initial.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/entire.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/exceptions.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/jsonfragment.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/partial.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/perf.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/ref.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/generators/result.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/hardware.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/implicit.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/lib.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/basemodel.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/device_models.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/executor.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/match_args.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/models_converter.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/peer_models.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/mesh/registry.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/output.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/parallel.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/patching.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/reference.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/arista/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/arista/iface.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/aruba/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/aruba/ap_env.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/aruba/misc.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/b4com/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/b4com/file.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/cisco/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/cisco/iface.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/cisco/vlandb.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/common.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/deploying.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/aaa.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/bgp.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/iface.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/misc.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/huawei/vlandb.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/juniper/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/nexus/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/nexus/iface.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/patching.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/ribbon/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/routeros/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/routeros/file.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/arista.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/arista.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/arista.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/aruba.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/aruba.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/aruba.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/b4com.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/b4com.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/b4com.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/cisco.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/cisco.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/huawei.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/huawei.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/huawei.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/juniper.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/nexus.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/nexus.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/nexus.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/nokia.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/optixtrans.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/optixtrans.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/optixtrans.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/pc.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/pc.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/pc.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/ribbon.deploy +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/ribbon.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/routeros.order +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/rulebook/texts/routeros.rul +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/storage.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/tabparser.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/text_term_format.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/tracing.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet/types.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet.egg-info/SOURCES.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet.egg-info/dependency_links.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet.egg-info/entry_points.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet.egg-info/requires.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet.egg-info/top_level.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/example/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/example/lldp.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/mesh_example/__init__.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/mesh_example/bgp.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/annet_generators/mesh_example/mesh_logic.py +0 -0
- {annet-0.16.16 → annet-0.16.17}/requirements.txt +0 -0
- {annet-0.16.16 → annet-0.16.17}/setup.cfg +0 -0
- {annet-0.16.16 → annet-0.16.17}/setup.py +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from collections import OrderedDict
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from annet.annlib.types import Op
|
|
6
|
+
|
|
7
|
+
from annet.rulebook import common
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def ssh_key(rule, key, diff, hw, **_):
|
|
11
|
+
"""
|
|
12
|
+
При включении ssh надо еще сгенерировать ключ. По конфигу никак не понять есть ли ключ на свитче или нет.
|
|
13
|
+
"""
|
|
14
|
+
if diff[Op.ADDED]:
|
|
15
|
+
added = sorted([x["row"] for x in diff[Op.ADDED]])
|
|
16
|
+
if added == ["ip ssh version 2"]:
|
|
17
|
+
# Отсыпаем mpdaemon-у подсказок для дополнительной команды при наливке
|
|
18
|
+
comment = rule["comment"]
|
|
19
|
+
rule["comment"] = ["!!suppress_errors!!", "!!timeout=240!!"]
|
|
20
|
+
if hw.Cisco.C2960:
|
|
21
|
+
yield (False, "crypto key generate rsa modulus 2048", None)
|
|
22
|
+
else:
|
|
23
|
+
yield (False, "crypto key generate rsa general-keys modulus 2048", None)
|
|
24
|
+
rule["comment"] = comment
|
|
25
|
+
yield from common.default(rule, key, diff)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def no_ipv6_nd_suppress_ra(rule, key, diff, **_):
|
|
29
|
+
"""
|
|
30
|
+
При конфигурации ipv6 nd на нексусах нужно добавлять
|
|
31
|
+
no ipv6 nd suppress-ra
|
|
32
|
+
иначе RA не будет включен.
|
|
33
|
+
К сожалению данной команды не видно в running-config.
|
|
34
|
+
Поэтому подмешиваем ее в патч вместо генератора
|
|
35
|
+
"""
|
|
36
|
+
if diff[Op.ADDED]:
|
|
37
|
+
yield (False, "no ipv6 nd suppress-ra", None)
|
|
38
|
+
yield from common.default(rule, key, diff)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def no_ntp_distribute(rule, key, diff, **_):
|
|
42
|
+
"""
|
|
43
|
+
Для того, чтобы удалить NTP из CFS, сначала нужно сбросить активные
|
|
44
|
+
NTP сессии.
|
|
45
|
+
"""
|
|
46
|
+
if diff[Op.REMOVED]:
|
|
47
|
+
yield (False, "clear ntp session", None)
|
|
48
|
+
yield from common.default(rule, key, diff)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def banner_login(rule, key, diff, **_):
|
|
52
|
+
if diff[Op.REMOVED]:
|
|
53
|
+
yield (False, "no banner login", None)
|
|
54
|
+
elif diff[Op.ADDED]:
|
|
55
|
+
# Убираем дополнительный экранирующий сиимвол
|
|
56
|
+
key = re.sub(r"\^C", "^", key[0])
|
|
57
|
+
yield (False, f"banner login {key}", None)
|
|
58
|
+
else:
|
|
59
|
+
yield from common.default(rule, key, diff)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def bgp_diff(old, new, diff_pre, _pops=(Op.AFFECTED,)):
|
|
63
|
+
"""
|
|
64
|
+
Some oder versions of Cisco IOS doesn't create subsection for address family block.
|
|
65
|
+
|
|
66
|
+
it looks like:
|
|
67
|
+
|
|
68
|
+
router bgp 65111
|
|
69
|
+
bgp router-id 1.1.1.1
|
|
70
|
+
bgp log-neighbor-changes
|
|
71
|
+
neighbor SPINE peer-group
|
|
72
|
+
!
|
|
73
|
+
address-family ipv4
|
|
74
|
+
neighbor SPINE send-community both
|
|
75
|
+
neighbor SPINE soft-reconfiguration inbound
|
|
76
|
+
neighbor SPINE route-map TOR_IMPORT_SPINE in
|
|
77
|
+
neighbor SPINE route-map TOR_EXPORT_SPINE out
|
|
78
|
+
exit-address-family
|
|
79
|
+
|
|
80
|
+
but should be
|
|
81
|
+
|
|
82
|
+
router bgp 65111
|
|
83
|
+
bgp router-id 1.1.1.1
|
|
84
|
+
bgp log-neighbor-changes
|
|
85
|
+
neighbor SPINE peer-group
|
|
86
|
+
!
|
|
87
|
+
address-family ipv4
|
|
88
|
+
neighbor SPINE send-community both
|
|
89
|
+
neighbor SPINE soft-reconfiguration inbound
|
|
90
|
+
neighbor SPINE route-map TOR_IMPORT_SPINE in
|
|
91
|
+
neighbor SPINE route-map TOR_EXPORT_SPINE out
|
|
92
|
+
exit-address-family
|
|
93
|
+
|
|
94
|
+
The diff_logic func do it before make diff.
|
|
95
|
+
"""
|
|
96
|
+
corrected_old = _create_subsections(old, "address-family")
|
|
97
|
+
|
|
98
|
+
yield from common.default_diff(corrected_old, new, diff_pre, _pops)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _create_subsections(data: OrderedDict[str, Any], sub_section_prefix: str) -> OrderedDict[str, Any]:
|
|
102
|
+
"""
|
|
103
|
+
Reorganizes the given OrderedDict to nest commands under their respective
|
|
104
|
+
sub_section_prefix keys.
|
|
105
|
+
|
|
106
|
+
This function traverses the entries in the provided OrderedDict and groups
|
|
107
|
+
together all entries that are between keys with sub_section_prefix under those
|
|
108
|
+
keys as nested OrderedDicts. The reorganization keeps the order of entries
|
|
109
|
+
stable, only adding nesting where appropriate.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
data (OrderedDict): The original configuration to be transformed.
|
|
113
|
+
sub_section_prefix (str): Prefix of subsection key
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
OrderedDict: A new OrderedDict with nested 'address-family' sections.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
result = OrderedDict()
|
|
120
|
+
sub_section = None
|
|
121
|
+
temp: OrderedDict = OrderedDict()
|
|
122
|
+
|
|
123
|
+
for key, value in data.items():
|
|
124
|
+
# make nested loop if found nested values
|
|
125
|
+
if value:
|
|
126
|
+
fixed_value: OrderedDict[str, Any] = _create_subsections(value, sub_section_prefix)
|
|
127
|
+
else:
|
|
128
|
+
fixed_value = value
|
|
129
|
+
if key.startswith(sub_section_prefix):
|
|
130
|
+
# in case of data has already had subsections
|
|
131
|
+
if value:
|
|
132
|
+
result[key] = fixed_value
|
|
133
|
+
continue
|
|
134
|
+
# if previous subsection present save collected data from temporary dict
|
|
135
|
+
if sub_section:
|
|
136
|
+
result[sub_section] = temp
|
|
137
|
+
# find a new subsection and initialize new dict
|
|
138
|
+
sub_section = key
|
|
139
|
+
temp = OrderedDict()
|
|
140
|
+
# put found data to temporary dict
|
|
141
|
+
elif sub_section:
|
|
142
|
+
temp[key] = fixed_value
|
|
143
|
+
else:
|
|
144
|
+
result[key] = fixed_value
|
|
145
|
+
# if data is finished save collected data from temporary dict
|
|
146
|
+
if sub_section:
|
|
147
|
+
result[sub_section] = temp
|
|
148
|
+
|
|
149
|
+
return result
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
from annet.annlib.types import Op
|
|
4
|
-
|
|
5
|
-
from annet.rulebook import common
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def ssh_key(rule, key, diff, hw, **_):
|
|
9
|
-
"""
|
|
10
|
-
При включении ssh надо еще сгенерировать ключ. По конфигу никак не понять есть ли ключ на свитче или нет.
|
|
11
|
-
"""
|
|
12
|
-
if diff[Op.ADDED]:
|
|
13
|
-
added = sorted([x["row"] for x in diff[Op.ADDED]])
|
|
14
|
-
if added == ["ip ssh version 2"]:
|
|
15
|
-
# Отсыпаем mpdaemon-у подсказок для дополнительной команды при наливке
|
|
16
|
-
comment = rule["comment"]
|
|
17
|
-
rule["comment"] = ["!!suppress_errors!!", "!!timeout=240!!"]
|
|
18
|
-
if hw.Cisco.C2960:
|
|
19
|
-
yield (False, "crypto key generate rsa modulus 2048", None)
|
|
20
|
-
else:
|
|
21
|
-
yield (False, "crypto key generate rsa general-keys modulus 2048", None)
|
|
22
|
-
rule["comment"] = comment
|
|
23
|
-
yield from common.default(rule, key, diff)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def no_ipv6_nd_suppress_ra(rule, key, diff, **_):
|
|
27
|
-
"""
|
|
28
|
-
При конфигурации ipv6 nd на нексусах нужно добавлять
|
|
29
|
-
no ipv6 nd suppress-ra
|
|
30
|
-
иначе RA не будет включен.
|
|
31
|
-
К сожалению данной команды не видно в running-config.
|
|
32
|
-
Поэтому подмешиваем ее в патч вместо генератора
|
|
33
|
-
"""
|
|
34
|
-
if diff[Op.ADDED]:
|
|
35
|
-
yield (False, "no ipv6 nd suppress-ra", None)
|
|
36
|
-
yield from common.default(rule, key, diff)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def no_ntp_distribute(rule, key, diff, **_):
|
|
40
|
-
"""
|
|
41
|
-
Для того, чтобы удалить NTP из CFS, сначала нужно сбросить активные
|
|
42
|
-
NTP сессии.
|
|
43
|
-
"""
|
|
44
|
-
if diff[Op.REMOVED]:
|
|
45
|
-
yield (False, "clear ntp session", None)
|
|
46
|
-
yield from common.default(rule, key, diff)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def banner_login(rule, key, diff, **_):
|
|
50
|
-
if diff[Op.REMOVED]:
|
|
51
|
-
yield (False, "no banner login", None)
|
|
52
|
-
elif diff[Op.ADDED]:
|
|
53
|
-
# Убираем дополнительный экранирующий сиимвол
|
|
54
|
-
key = re.sub(r"\^C", "^", key[0])
|
|
55
|
-
yield (False, f"banner login {key}", None)
|
|
56
|
-
else:
|
|
57
|
-
yield from common.default(rule, key, diff)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|