annet 0.10__tar.gz → 0.12__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.10/annet.egg-info → annet-0.12}/PKG-INFO +1 -1
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/models.py +10 -3
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/status_client.py +2 -1
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v24/api_models.py +4 -3
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v24/storage.py +12 -6
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v37/api_models.py +3 -2
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v37/storage.py +11 -5
- {annet-0.10 → annet-0.12}/annet/annlib/jsontools.py +6 -2
- {annet-0.10 → annet-0.12}/annet/api/__init__.py +167 -159
- {annet-0.10 → annet-0.12}/annet/cli.py +96 -55
- {annet-0.10 → annet-0.12}/annet/cli_args.py +9 -9
- {annet-0.10 → annet-0.12}/annet/connectors.py +28 -15
- {annet-0.10 → annet-0.12}/annet/gen.py +140 -144
- annet-0.12/annet/generators/__init__.py +435 -0
- annet-0.12/annet/generators/base.py +136 -0
- {annet-0.10 → annet-0.12}/annet/generators/common/initial.py +1 -1
- annet-0.12/annet/generators/entire.py +97 -0
- annet-0.12/annet/generators/exceptions.py +10 -0
- annet-0.12/annet/generators/jsonfragment.py +125 -0
- annet-0.12/annet/generators/partial.py +119 -0
- annet-0.12/annet/generators/perf.py +79 -0
- annet-0.12/annet/generators/ref.py +15 -0
- annet-0.12/annet/generators/result.py +127 -0
- {annet-0.10 → annet-0.12}/annet/output.py +4 -9
- {annet-0.10 → annet-0.12}/annet/storage.py +7 -3
- {annet-0.10 → annet-0.12}/annet/types.py +0 -2
- {annet-0.10 → annet-0.12/annet.egg-info}/PKG-INFO +1 -1
- {annet-0.10 → annet-0.12}/annet.egg-info/SOURCES.txt +8 -0
- annet-0.10/annet/generators/__init__.py +0 -1021
- {annet-0.10 → annet-0.12}/AUTHORS +0 -0
- {annet-0.10 → annet-0.12}/LICENSE +0 -0
- {annet-0.10 → annet-0.12}/MANIFEST.in +0 -0
- {annet-0.10 → annet-0.12}/README.md +0 -0
- {annet-0.10 → annet-0.12}/annet/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/client.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/manufacturer.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/query.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/common/storage_opts.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/provider.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v24/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v24/client.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v37/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/adapters/netbox/v37/client.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annet.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/command.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/diff.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/errors.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/filter_acl.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/lib.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/db.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/devdb/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/devdb/data/devdb.json +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/views/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/views/dump.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/netdev/views/hardware.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/output.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/patching.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/acl.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/deploying.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/ordering.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/platform.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rbparser/syntax.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rulebook/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/rulebook/common.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/tabparser.py +0 -0
- {annet-0.10 → annet-0.12}/annet/annlib/types.py +0 -0
- {annet-0.10 → annet-0.12}/annet/argparse.py +0 -0
- {annet-0.10 → annet-0.12}/annet/configs/context.yml +0 -0
- {annet-0.10 → annet-0.12}/annet/configs/logging.yaml +0 -0
- {annet-0.10 → annet-0.12}/annet/deploy.py +0 -0
- {annet-0.10 → annet-0.12}/annet/diff.py +0 -0
- {annet-0.10 → annet-0.12}/annet/executor.py +0 -0
- {annet-0.10 → annet-0.12}/annet/filtering.py +0 -0
- {annet-0.10 → annet-0.12}/annet/generators/common/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/hardware.py +0 -0
- {annet-0.10 → annet-0.12}/annet/implicit.py +0 -0
- {annet-0.10 → annet-0.12}/annet/lib.py +0 -0
- {annet-0.10 → annet-0.12}/annet/parallel.py +0 -0
- {annet-0.10 → annet-0.12}/annet/patching.py +0 -0
- {annet-0.10 → annet-0.12}/annet/reference.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/arista/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/arista/iface.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/aruba/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/aruba/ap_env.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/aruba/misc.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/cisco/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/cisco/iface.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/cisco/misc.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/cisco/vlandb.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/common.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/deploying.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/aaa.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/bgp.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/iface.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/misc.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/huawei/vlandb.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/juniper/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/nexus/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/nexus/iface.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/patching.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/ribbon/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/arista.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/arista.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/arista.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/aruba.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/aruba.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/aruba.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/cisco.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/cisco.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/cisco.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/huawei.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/huawei.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/huawei.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/juniper.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/nexus.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/nexus.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/nexus.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/nokia.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/pc.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/pc.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/ribbon.deploy +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/ribbon.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/routeros.order +0 -0
- {annet-0.10 → annet-0.12}/annet/rulebook/texts/routeros.rul +0 -0
- {annet-0.10 → annet-0.12}/annet/tabparser.py +0 -0
- {annet-0.10 → annet-0.12}/annet/text_term_format.py +0 -0
- {annet-0.10 → annet-0.12}/annet/tracing.py +0 -0
- {annet-0.10 → annet-0.12}/annet.egg-info/dependency_links.txt +0 -0
- {annet-0.10 → annet-0.12}/annet.egg-info/entry_points.txt +0 -0
- {annet-0.10 → annet-0.12}/annet.egg-info/requires.txt +0 -0
- {annet-0.10 → annet-0.12}/annet.egg-info/top_level.txt +0 -0
- {annet-0.10 → annet-0.12}/annet_generators/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet_generators/example/__init__.py +0 -0
- {annet-0.10 → annet-0.12}/annet_generators/example/lldp.py +0 -0
- {annet-0.10 → annet-0.12}/requirements.txt +0 -0
- {annet-0.10 → annet-0.12}/setup.cfg +0 -0
- {annet-0.10 → annet-0.12}/setup.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from typing import List, Optional, Any
|
|
3
|
+
from typing import List, Optional, Any, Dict
|
|
4
4
|
|
|
5
5
|
from annet.annlib.netdev.views.hardware import HardwareView
|
|
6
|
+
from annet.storage import Storage
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
@dataclass
|
|
@@ -61,6 +62,8 @@ class Interface(Entity):
|
|
|
61
62
|
|
|
62
63
|
@dataclass
|
|
63
64
|
class NetboxDevice(Entity):
|
|
65
|
+
url: str
|
|
66
|
+
storage: Storage
|
|
64
67
|
neighbours_ids: List[int]
|
|
65
68
|
|
|
66
69
|
display: str
|
|
@@ -79,7 +82,7 @@ class NetboxDevice(Entity):
|
|
|
79
82
|
primary_ip4: Optional[DeviceIp]
|
|
80
83
|
primary_ip6: Optional[DeviceIp]
|
|
81
84
|
tags: List[Entity]
|
|
82
|
-
custom_fields:
|
|
85
|
+
custom_fields: Dict[str, Any]
|
|
83
86
|
created: datetime
|
|
84
87
|
last_updated: datetime
|
|
85
88
|
|
|
@@ -91,8 +94,12 @@ class NetboxDevice(Entity):
|
|
|
91
94
|
interfaces: List[Interface]
|
|
92
95
|
|
|
93
96
|
# compat
|
|
97
|
+
|
|
94
98
|
def __hash__(self):
|
|
95
|
-
return hash(self.id)
|
|
99
|
+
return hash((self.id, type(self)))
|
|
100
|
+
|
|
101
|
+
def __eq__(self, other):
|
|
102
|
+
return type(self) is type(other) and self.url == other.url
|
|
96
103
|
|
|
97
104
|
def is_pc(self):
|
|
98
105
|
return self.device_type.manufacturer.name == "Mellanox"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
+
from typing import Dict
|
|
2
3
|
|
|
3
4
|
from adaptix import Retort, name_mapping, NameStyle
|
|
4
5
|
from dataclass_rest import get
|
|
@@ -10,7 +11,7 @@ from .client import BaseNetboxClient
|
|
|
10
11
|
@dataclass
|
|
11
12
|
class Status:
|
|
12
13
|
netbox_version: str
|
|
13
|
-
plugins:
|
|
14
|
+
plugins: Dict[str, str]
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class NetboxStatusClient(BaseNetboxClient):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from typing import List, Optional, Any
|
|
3
|
+
from typing import List, Optional, Any, Dict
|
|
4
4
|
|
|
5
5
|
from annet.adapters.netbox.common.models import Entity, DeviceType
|
|
6
6
|
|
|
@@ -20,6 +20,7 @@ class DeviceIp:
|
|
|
20
20
|
|
|
21
21
|
@dataclass
|
|
22
22
|
class Device(Entity):
|
|
23
|
+
url: str
|
|
23
24
|
display_name: str
|
|
24
25
|
device_type: DeviceType
|
|
25
26
|
device_role: Entity
|
|
@@ -36,7 +37,7 @@ class Device(Entity):
|
|
|
36
37
|
primary_ip4: Optional[DeviceIp]
|
|
37
38
|
primary_ip6: Optional[DeviceIp]
|
|
38
39
|
tags: List[str]
|
|
39
|
-
custom_fields:
|
|
40
|
+
custom_fields: Dict[str, Any]
|
|
40
41
|
created: datetime
|
|
41
42
|
last_updated: datetime
|
|
42
43
|
|
|
@@ -61,7 +62,7 @@ class IpAddress:
|
|
|
61
62
|
tenant: Any # ???
|
|
62
63
|
status: Label
|
|
63
64
|
description: Optional[str]
|
|
64
|
-
custom_fields:
|
|
65
|
+
custom_fields: Dict[str, Any]
|
|
65
66
|
tags: List[str]
|
|
66
67
|
created: datetime
|
|
67
68
|
last_updated: datetime
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from logging import getLogger
|
|
2
|
-
from typing import Optional, List
|
|
2
|
+
from typing import Optional, List, Union
|
|
3
3
|
|
|
4
4
|
from annet.adapters.netbox.common import models
|
|
5
5
|
from annet.adapters.netbox.common.manufacturer import (
|
|
@@ -39,12 +39,13 @@ def extend_label(
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def extend_device(
|
|
42
|
-
device: api_models.Device,
|
|
42
|
+
device: api_models.Device, storage: Storage,
|
|
43
43
|
) -> models.NetboxDevice:
|
|
44
44
|
manufacturer = device.device_type.manufacturer.name
|
|
45
45
|
model = device.device_type.model
|
|
46
46
|
|
|
47
47
|
return models.NetboxDevice(
|
|
48
|
+
url=device.url,
|
|
48
49
|
id=device.id,
|
|
49
50
|
name=device.name,
|
|
50
51
|
display=device.display_name,
|
|
@@ -73,6 +74,7 @@ def extend_device(
|
|
|
73
74
|
breed=get_breed(manufacturer, model),
|
|
74
75
|
interfaces=[],
|
|
75
76
|
neighbours_ids=[],
|
|
77
|
+
storage=storage,
|
|
76
78
|
)
|
|
77
79
|
|
|
78
80
|
|
|
@@ -129,14 +131,16 @@ class NetboxStorageV24(Storage):
|
|
|
129
131
|
|
|
130
132
|
def make_devices(
|
|
131
133
|
self,
|
|
132
|
-
query: NetboxQuery,
|
|
134
|
+
query: Union[NetboxQuery, list],
|
|
133
135
|
preload_neighbors=False,
|
|
134
136
|
use_mesh=None,
|
|
135
137
|
preload_extra_fields=False,
|
|
136
138
|
**kwargs,
|
|
137
|
-
) ->
|
|
139
|
+
) -> List[models.NetboxDevice]:
|
|
140
|
+
if isinstance(query, list):
|
|
141
|
+
query = NetboxQuery.new(query)
|
|
138
142
|
device_ids = {
|
|
139
|
-
device.id: extend_device(device=device)
|
|
143
|
+
device.id: extend_device(device=device, storage=self)
|
|
140
144
|
for device in self._load_devices(query)
|
|
141
145
|
}
|
|
142
146
|
if not device_ids:
|
|
@@ -148,6 +152,8 @@ class NetboxStorageV24(Storage):
|
|
|
148
152
|
return list(device_ids.values())
|
|
149
153
|
|
|
150
154
|
def _load_devices(self, query: NetboxQuery) -> List[api_models.Device]:
|
|
155
|
+
if not query.globs:
|
|
156
|
+
return []
|
|
151
157
|
return [
|
|
152
158
|
device
|
|
153
159
|
for device in self.netbox.all_devices().results
|
|
@@ -175,7 +181,7 @@ class NetboxStorageV24(Storage):
|
|
|
175
181
|
**kwargs,
|
|
176
182
|
) -> models.NetboxDevice:
|
|
177
183
|
device = self.netbox.get_device(obj_id)
|
|
178
|
-
res = extend_device(device=device)
|
|
184
|
+
res = extend_device(device=device, storage=self)
|
|
179
185
|
res.interfaces = self._load_interfaces([device.id])
|
|
180
186
|
return res
|
|
181
187
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from typing import List, Optional, Any
|
|
3
|
+
from typing import List, Optional, Any, Dict
|
|
4
4
|
|
|
5
5
|
from annet.adapters.netbox.common.models import (
|
|
6
6
|
Entity, Label, DeviceType, DeviceIp,
|
|
@@ -16,6 +16,7 @@ class Interface(Entity):
|
|
|
16
16
|
|
|
17
17
|
@dataclass
|
|
18
18
|
class Device(Entity):
|
|
19
|
+
url: str
|
|
19
20
|
display: str # renamed in 3.x from display_name
|
|
20
21
|
device_type: DeviceType
|
|
21
22
|
device_role: Entity
|
|
@@ -32,6 +33,6 @@ class Device(Entity):
|
|
|
32
33
|
primary_ip4: Optional[DeviceIp]
|
|
33
34
|
primary_ip6: Optional[DeviceIp]
|
|
34
35
|
tags: List[Entity]
|
|
35
|
-
custom_fields:
|
|
36
|
+
custom_fields: Dict[str, Any]
|
|
36
37
|
created: datetime
|
|
37
38
|
last_updated: datetime
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from logging import getLogger
|
|
2
|
-
from typing import Optional, List
|
|
2
|
+
from typing import Optional, List, Union
|
|
3
3
|
|
|
4
4
|
from adaptix import P
|
|
5
5
|
from adaptix.conversion import impl_converter, link
|
|
@@ -27,13 +27,14 @@ def extend_device_base(
|
|
|
27
27
|
interfaces: List[models.Interface],
|
|
28
28
|
hw: Optional[HardwareView],
|
|
29
29
|
breed: str,
|
|
30
|
+
storage: Storage,
|
|
30
31
|
neighbours_ids: List[int],
|
|
31
32
|
) -> models.NetboxDevice:
|
|
32
33
|
...
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def extend_device(
|
|
36
|
-
device: api_models.Device,
|
|
37
|
+
device: api_models.Device, storage: Storage,
|
|
37
38
|
) -> models.NetboxDevice:
|
|
38
39
|
return extend_device_base(
|
|
39
40
|
device=device,
|
|
@@ -47,6 +48,7 @@ def extend_device(
|
|
|
47
48
|
device.device_type.model,
|
|
48
49
|
),
|
|
49
50
|
neighbours_ids=[],
|
|
51
|
+
storage=storage,
|
|
50
52
|
)
|
|
51
53
|
|
|
52
54
|
|
|
@@ -82,14 +84,16 @@ class NetboxStorageV37(Storage):
|
|
|
82
84
|
|
|
83
85
|
def make_devices(
|
|
84
86
|
self,
|
|
85
|
-
query: NetboxQuery,
|
|
87
|
+
query: Union[NetboxQuery, list],
|
|
86
88
|
preload_neighbors=False,
|
|
87
89
|
use_mesh=None,
|
|
88
90
|
preload_extra_fields=False,
|
|
89
91
|
**kwargs,
|
|
90
92
|
) -> List[models.NetboxDevice]:
|
|
93
|
+
if isinstance(query, list):
|
|
94
|
+
query = NetboxQuery.new(query)
|
|
91
95
|
device_ids = {
|
|
92
|
-
device.id: extend_device(device=device)
|
|
96
|
+
device.id: extend_device(device=device, storage=self)
|
|
93
97
|
for device in self._load_devices(query)
|
|
94
98
|
}
|
|
95
99
|
if not device_ids:
|
|
@@ -101,6 +105,8 @@ class NetboxStorageV37(Storage):
|
|
|
101
105
|
return list(device_ids.values())
|
|
102
106
|
|
|
103
107
|
def _load_devices(self, query: NetboxQuery) -> List[api_models.Device]:
|
|
108
|
+
if not query.globs:
|
|
109
|
+
return []
|
|
104
110
|
return [
|
|
105
111
|
device
|
|
106
112
|
for device in self.netbox.all_devices(
|
|
@@ -128,7 +134,7 @@ class NetboxStorageV37(Storage):
|
|
|
128
134
|
**kwargs,
|
|
129
135
|
) -> models.NetboxDevice:
|
|
130
136
|
device = self.netbox.get_device(obj_id)
|
|
131
|
-
res = extend_device(device=device)
|
|
137
|
+
res = extend_device(device=device, storage=self)
|
|
132
138
|
res.interfaces = self._load_interfaces([device.id])
|
|
133
139
|
return res
|
|
134
140
|
|
|
@@ -92,7 +92,11 @@ def apply_patch(content: Optional[bytes], patch_bytes: bytes) -> bytes:
|
|
|
92
92
|
def apply_acl_filters(content: Dict[str, Any], filters: List[str]) -> Dict[str, Any]:
|
|
93
93
|
result = {}
|
|
94
94
|
for f in filters:
|
|
95
|
-
|
|
95
|
+
filter_text = f.strip()
|
|
96
|
+
if not filter_text:
|
|
97
|
+
continue
|
|
98
|
+
|
|
99
|
+
pointer = jsonpointer.JsonPointer(filter_text)
|
|
96
100
|
|
|
97
101
|
try:
|
|
98
102
|
part = pointer.get(copy.deepcopy(content))
|
|
@@ -103,7 +107,7 @@ def apply_acl_filters(content: Dict[str, Any], filters: List[str]) -> Dict[str,
|
|
|
103
107
|
sub_tree[i] = {}
|
|
104
108
|
sub_tree = sub_tree[i]
|
|
105
109
|
|
|
106
|
-
patch = jsonpatch.JsonPatch([{"op": "add", "path":
|
|
110
|
+
patch = jsonpatch.JsonPatch([{"op": "add", "path": filter_text, "value": part}])
|
|
107
111
|
result = patch.apply(result)
|
|
108
112
|
except jsonpointer.JsonPointerException:
|
|
109
113
|
# no value found in content by the pointer, skip the ACL item
|