annet 0.16.0__py3-none-any.whl → 0.16.2__py3-none-any.whl
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.
- annet/adapters/netbox/common/models.py +7 -6
- annet/adapters/netbox/common/storage_opts.py +2 -2
- annet/adapters/netbox/provider.py +5 -3
- annet/annlib/netdev/devdb/data/devdb.json +1 -0
- annet/cli.py +2 -2
- annet/connectors.py +14 -10
- annet/deploy.py +1 -1
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/METADATA +1 -1
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/RECORD +14 -14
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/AUTHORS +0 -0
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/LICENSE +0 -0
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/WHEEL +0 -0
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/entry_points.txt +0 -0
- {annet-0.16.0.dist-info → annet-0.16.2.dist-info}/top_level.txt +0 -0
|
@@ -52,17 +52,17 @@ class DeviceIp(DumpableView):
|
|
|
52
52
|
class Prefix(DumpableView):
|
|
53
53
|
id: int
|
|
54
54
|
prefix: str
|
|
55
|
-
site: Entity
|
|
56
|
-
vrf: Entity
|
|
57
|
-
tenant: Entity
|
|
58
|
-
vlan: Entity
|
|
59
|
-
role: Entity
|
|
55
|
+
site: Optional[Entity]
|
|
56
|
+
vrf: Optional[Entity]
|
|
57
|
+
tenant: Optional[Entity]
|
|
58
|
+
vlan: Optional[Entity]
|
|
59
|
+
role: Optional[Entity]
|
|
60
60
|
status: Label
|
|
61
61
|
is_pool: bool
|
|
62
62
|
custom_fields: dict[str, Any]
|
|
63
63
|
created: datetime
|
|
64
64
|
last_updated: datetime
|
|
65
|
-
description: str
|
|
65
|
+
description: Optional[str] = ""
|
|
66
66
|
|
|
67
67
|
@property
|
|
68
68
|
def _dump__list_key(self):
|
|
@@ -123,6 +123,7 @@ class Interface(Entity):
|
|
|
123
123
|
display: str = ""
|
|
124
124
|
ip_addresses: List[IpAddress] = field(default_factory=list)
|
|
125
125
|
vrf: Optional[Entity] = None
|
|
126
|
+
mtu: int | None = None
|
|
126
127
|
|
|
127
128
|
|
|
128
129
|
@dataclass
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any, Optional
|
|
3
3
|
|
|
4
4
|
DEFAULT_URL = "http://localhost"
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ class NetboxStorageOpts:
|
|
|
10
10
|
self.token = token
|
|
11
11
|
|
|
12
12
|
@classmethod
|
|
13
|
-
def parse_params(cls, conf_params: dict[str, str]
|
|
13
|
+
def parse_params(cls, conf_params: Optional[dict[str, str]], cli_opts: Any):
|
|
14
14
|
url = os.getenv("NETBOX_URL") or conf_params.get("url") or DEFAULT_URL
|
|
15
15
|
token = os.getenv("NETBOX_TOKEN", "").strip() or conf_params.get("token") or ""
|
|
16
16
|
return cls(url=url, token=token)
|
|
@@ -31,8 +31,9 @@ class NetboxProvider(StorageProvider, AdapterWithName, AdapterWithConfig):
|
|
|
31
31
|
self.url = url
|
|
32
32
|
self.token = token
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
@classmethod
|
|
35
|
+
def with_config(cls, **kwargs: Dict[str, Any]) -> T:
|
|
36
|
+
return cls(**kwargs)
|
|
36
37
|
|
|
37
38
|
def storage(self):
|
|
38
39
|
return storage_factory
|
|
@@ -43,5 +44,6 @@ class NetboxProvider(StorageProvider, AdapterWithName, AdapterWithConfig):
|
|
|
43
44
|
def query(self):
|
|
44
45
|
return NetboxQuery
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
@classmethod
|
|
48
|
+
def name(cls) -> str:
|
|
47
49
|
return "netbox"
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"Huawei.CE.CE8800": " CE88\\d\\d",
|
|
53
53
|
"Huawei.CE.CE8800.CE8850": " CE8850",
|
|
54
54
|
"Huawei.CE.CE8800.CE8851": " CE8851",
|
|
55
|
+
"Huawei.CE.CE8800.CE8855": " CE8855",
|
|
55
56
|
"Huawei.CE.CE9800": " CE98\\d\\d",
|
|
56
57
|
"Huawei.Quidway": " (LS-)?S",
|
|
57
58
|
"Huawei.Quidway.S2x": "2\\d{3}",
|
annet/cli.py
CHANGED
|
@@ -8,7 +8,7 @@ import subprocess
|
|
|
8
8
|
import shutil
|
|
9
9
|
import sys
|
|
10
10
|
from contextlib import ExitStack, contextmanager
|
|
11
|
-
from typing import Tuple, Iterable
|
|
11
|
+
from typing import Optional, Tuple, Iterable
|
|
12
12
|
|
|
13
13
|
import tabulate
|
|
14
14
|
import yaml
|
|
@@ -129,7 +129,7 @@ def show_generators(args: cli_args.ShowGeneratorsOptions):
|
|
|
129
129
|
""" List applicable generators (for a device if query is set) """
|
|
130
130
|
arg_gens = cli_args.GenOptions(args)
|
|
131
131
|
with get_loader(arg_gens, args) as loader:
|
|
132
|
-
device: Device
|
|
132
|
+
device: Optional[Device] = None
|
|
133
133
|
devices = loader.devices
|
|
134
134
|
if len(devices) == 1:
|
|
135
135
|
device = devices[0]
|
annet/connectors.py
CHANGED
|
@@ -42,11 +42,11 @@ class Connector(ABC, Generic[T]):
|
|
|
42
42
|
res = self._classes[0]
|
|
43
43
|
return res(*args, **kwargs)
|
|
44
44
|
|
|
45
|
-
def get_all(self
|
|
45
|
+
def get_all(self) -> List[T]:
|
|
46
46
|
if self._classes is None:
|
|
47
47
|
self._classes = self._entry_point or [self._get_default()]
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return self._classes.copy()
|
|
50
50
|
|
|
51
51
|
def set(self, cls: Type[T]):
|
|
52
52
|
if self._classes is not None:
|
|
@@ -97,18 +97,20 @@ def load_entry_point_new(group: str) -> List:
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
class AdapterWithConfig(ABC, Generic[T]):
|
|
100
|
+
@classmethod
|
|
100
101
|
@abstractmethod
|
|
101
|
-
def with_config(
|
|
102
|
+
def with_config(cls, **kwargs: Dict[str, Any]) -> T:
|
|
102
103
|
pass
|
|
103
104
|
|
|
104
105
|
|
|
105
106
|
class AdapterWithName(ABC):
|
|
107
|
+
@classmethod
|
|
106
108
|
@abstractmethod
|
|
107
|
-
def name(
|
|
109
|
+
def name(cls) -> str:
|
|
108
110
|
pass
|
|
109
111
|
|
|
110
112
|
|
|
111
|
-
def get_connector_from_config(config_key: str, connectors: List[Connector]) -> Tuple[Connector, Dict[str, Any]]:
|
|
113
|
+
def get_connector_from_config(config_key: str, connectors: List[Type[Connector]]) -> Tuple[Connector, Dict[str, Any]]:
|
|
112
114
|
seen: list[str] = []
|
|
113
115
|
if not connectors:
|
|
114
116
|
raise Exception("empty connectors")
|
|
@@ -119,8 +121,8 @@ def get_connector_from_config(config_key: str, connectors: List[Connector]) -> T
|
|
|
119
121
|
connector_params = context_storage.get("params", {})
|
|
120
122
|
if adapter_name:
|
|
121
123
|
for con in connectors:
|
|
122
|
-
con_name = connector.
|
|
123
|
-
if
|
|
124
|
+
con_name = connector.__name__
|
|
125
|
+
if issubclass(con, AdapterWithName):
|
|
124
126
|
con_name = con.name()
|
|
125
127
|
seen.append(con_name)
|
|
126
128
|
if adapter_name == con_name:
|
|
@@ -136,8 +138,10 @@ def get_connector_from_config(config_key: str, connectors: List[Connector]) -> T
|
|
|
136
138
|
connector = connectors[0]
|
|
137
139
|
if len(connectors) > 1:
|
|
138
140
|
warnings.warn(f"Please specify '{config_key}'. Found more than one classes {connectors}", UserWarning)
|
|
139
|
-
if
|
|
140
|
-
|
|
141
|
+
if issubclass(connector, AdapterWithConfig):
|
|
142
|
+
connector_ins = connector.with_config(**connector_params)
|
|
143
|
+
else:
|
|
144
|
+
connector_ins = connector()
|
|
141
145
|
# return connector_params only for storage
|
|
142
146
|
# TODO: switch storage interface to AdapterWithConfig
|
|
143
|
-
return
|
|
147
|
+
return connector_ins, connector_params
|
annet/deploy.py
CHANGED
|
@@ -481,7 +481,7 @@ def make_cmd_params(rule: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
|
|
484
|
-
def make_apply_commands(rule: dict, hw: HardwareView, do_commit: bool, do_finalize: bool, path: str
|
|
484
|
+
def make_apply_commands(rule: dict, hw: HardwareView, do_commit: bool, do_finalize: bool, path: Optional[str] = None):
|
|
485
485
|
apply_logic = rule["attrs"]["apply_logic"]
|
|
486
486
|
before, after = apply_logic(hw, do_commit=do_commit, do_finalize=do_finalize, path=path)
|
|
487
487
|
return before, after
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
annet/__init__.py,sha256=k2dq8aOYjkjZszKoOlxEmR49uYoKh-8_HC2K8FeqLwA,2139
|
|
2
2
|
annet/annet.py,sha256=TMdEuM7GJQ4TjRVmuK3bCTZN-21lxjQ9sXqEdILUuBk,725
|
|
3
3
|
annet/argparse.py,sha256=v1MfhjR0B8qahza0WinmXClpR8UiDFhmwDDWtNroJPA,12855
|
|
4
|
-
annet/cli.py,sha256=
|
|
4
|
+
annet/cli.py,sha256=hDpjIr3w47lgQ_CvCQS1SXFDK-SJrf5slbT__5u6GIA,12342
|
|
5
5
|
annet/cli_args.py,sha256=KQlihxSl-Phhq1-9oJDdNSbIllEX55LlPfH6viEKOuw,13483
|
|
6
|
-
annet/connectors.py,sha256
|
|
7
|
-
annet/deploy.py,sha256=
|
|
6
|
+
annet/connectors.py,sha256=-Lghz3PtWCBU8Ohrp0KKQcmm1AUZtN0EnOaZ6IQgCQI,5105
|
|
7
|
+
annet/deploy.py,sha256=pM7r8ipk7y-b4OIenc8FMqZpy5F6TmKdo8DDUJNRBlY,18956
|
|
8
8
|
annet/diff.py,sha256=zLcaCnb4lZRUb7frpH1CstQ3kacRcCblZs1uLG8J5lk,3391
|
|
9
9
|
annet/executor.py,sha256=FrYAUuh2TpSVX42SlTN_PhuSHmXG4Wj1nieY9Wqv9so,19122
|
|
10
10
|
annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
|
|
@@ -23,14 +23,14 @@ annet/tracing.py,sha256=ndpM-au1c88uBBpOuH_z52qWZL773edYozNyys_wA68,4044
|
|
|
23
23
|
annet/types.py,sha256=f2HwqoKa6AucwFwDMszoouB6m1B8n6VmdjHMktO30Kc,7175
|
|
24
24
|
annet/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
annet/adapters/netbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
annet/adapters/netbox/provider.py,sha256=
|
|
26
|
+
annet/adapters/netbox/provider.py,sha256=IIs37QFHuJHxq4A0WfBS4JENk--v3BxqgNPal1Or4Xc,1470
|
|
27
27
|
annet/adapters/netbox/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
annet/adapters/netbox/common/client.py,sha256=-lWZmphD-OPuLIHNKhW_h2bnjrVaiyKYAD_MUPasEbo,2483
|
|
29
29
|
annet/adapters/netbox/common/manufacturer.py,sha256=WZsBfHq6kohbbkszxPARjMdXB5rWGBO4Gz1rA-IlqL8,1555
|
|
30
|
-
annet/adapters/netbox/common/models.py,sha256=
|
|
30
|
+
annet/adapters/netbox/common/models.py,sha256=zWxsChKZiJ_VQ5_K-l_o-iyDQgxNLvYpk4EvVSoga5o,3316
|
|
31
31
|
annet/adapters/netbox/common/query.py,sha256=ziUFM7cUEbEIf3k1szTll4aO-OCUa-2Ogxbebi7Tegs,646
|
|
32
32
|
annet/adapters/netbox/common/status_client.py,sha256=W4nTb2yvBlJ2UkWUmUhKQ2PaSQb1shjhHj5ebb4s2s4,591
|
|
33
|
-
annet/adapters/netbox/common/storage_opts.py,sha256=
|
|
33
|
+
annet/adapters/netbox/common/storage_opts.py,sha256=iadgWGMb-rfSp3SnFAw8SH5bMKjwvcAsJ74v_z0CCXQ,507
|
|
34
34
|
annet/adapters/netbox/v24/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
annet/adapters/netbox/v24/storage.py,sha256=THI592VLx3ehixsPZQ1Ko3mYIAZQbnDY-toIziqBbL8,6005
|
|
36
36
|
annet/adapters/netbox/v37/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -49,7 +49,7 @@ annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
|
|
|
49
49
|
annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
50
|
annet/annlib/netdev/db.py,sha256=fI_u5aya4l61mbYSjj4JwlVfi3s7obt2jqERSuXGRUI,1634
|
|
51
51
|
annet/annlib/netdev/devdb/__init__.py,sha256=aKYjjLbJebdKBjnGDpVLQdSqrV2JL24spGm58tmMWVU,892
|
|
52
|
-
annet/annlib/netdev/devdb/data/devdb.json,sha256=
|
|
52
|
+
annet/annlib/netdev/devdb/data/devdb.json,sha256=Qph7WxZBEbgBqbCFeYu6ZM0qkEBn80WmJEjfJkcaZ-0,5940
|
|
53
53
|
annet/annlib/netdev/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
annet/annlib/netdev/views/dump.py,sha256=rIlyvnA3uM8bB_7oq1nS2KDxTp6dQh2hz-FbNhYIpOU,4630
|
|
55
55
|
annet/annlib/netdev/views/hardware.py,sha256=1JdTkrumOTYd5GKz4_LKg8G-B6ccrzl5VdNT-JhX40A,3495
|
|
@@ -133,10 +133,10 @@ annet/rulebook/texts/routeros.rul,sha256=ipfxjj0mjFef6IsUlupqx4BY_Je_OUb8u_U1019
|
|
|
133
133
|
annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
134
|
annet_generators/example/__init__.py,sha256=zVd8_DrXuOASrNzg2Ab94rPyvJff83L-_HppDFxnUjM,228
|
|
135
135
|
annet_generators/example/lldp.py,sha256=24bGvShxbio-JxUdaehyPRu31LhH9YwSwFDrWVRn6yo,2100
|
|
136
|
-
annet-0.16.
|
|
137
|
-
annet-0.16.
|
|
138
|
-
annet-0.16.
|
|
139
|
-
annet-0.16.
|
|
140
|
-
annet-0.16.
|
|
141
|
-
annet-0.16.
|
|
142
|
-
annet-0.16.
|
|
136
|
+
annet-0.16.2.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
|
|
137
|
+
annet-0.16.2.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
|
|
138
|
+
annet-0.16.2.dist-info/METADATA,sha256=YdQdLWLVxedQwFGAEbcsgOd3arNJ0M2DdRV8K9NxE_k,694
|
|
139
|
+
annet-0.16.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
140
|
+
annet-0.16.2.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
|
|
141
|
+
annet-0.16.2.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
|
|
142
|
+
annet-0.16.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|