annet 0.11__tar.gz → 0.12.1__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.

Files changed (145) hide show
  1. {annet-0.11/annet.egg-info → annet-0.12.1}/PKG-INFO +1 -1
  2. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/models.py +10 -3
  3. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/status_client.py +2 -1
  4. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v24/api_models.py +4 -3
  5. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v24/storage.py +12 -6
  6. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v37/api_models.py +3 -2
  7. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v37/storage.py +11 -5
  8. {annet-0.11 → annet-0.12.1}/annet/api/__init__.py +167 -159
  9. {annet-0.11 → annet-0.12.1}/annet/cli.py +96 -55
  10. {annet-0.11 → annet-0.12.1}/annet/cli_args.py +15 -15
  11. {annet-0.11 → annet-0.12.1}/annet/connectors.py +28 -15
  12. {annet-0.11 → annet-0.12.1}/annet/gen.py +126 -129
  13. annet-0.12.1/annet/generators/__init__.py +435 -0
  14. annet-0.12.1/annet/generators/base.py +136 -0
  15. {annet-0.11 → annet-0.12.1}/annet/generators/common/initial.py +1 -1
  16. annet-0.12.1/annet/generators/entire.py +97 -0
  17. annet-0.12.1/annet/generators/exceptions.py +10 -0
  18. annet-0.12.1/annet/generators/jsonfragment.py +125 -0
  19. annet-0.12.1/annet/generators/partial.py +119 -0
  20. annet-0.12.1/annet/generators/perf.py +79 -0
  21. annet-0.12.1/annet/generators/ref.py +15 -0
  22. annet-0.12.1/annet/generators/result.py +127 -0
  23. {annet-0.11 → annet-0.12.1}/annet/output.py +4 -9
  24. {annet-0.11 → annet-0.12.1}/annet/storage.py +7 -3
  25. {annet-0.11 → annet-0.12.1}/annet/types.py +0 -2
  26. {annet-0.11 → annet-0.12.1/annet.egg-info}/PKG-INFO +1 -1
  27. {annet-0.11 → annet-0.12.1}/annet.egg-info/SOURCES.txt +8 -0
  28. annet-0.11/annet/generators/__init__.py +0 -1021
  29. {annet-0.11 → annet-0.12.1}/AUTHORS +0 -0
  30. {annet-0.11 → annet-0.12.1}/LICENSE +0 -0
  31. {annet-0.11 → annet-0.12.1}/MANIFEST.in +0 -0
  32. {annet-0.11 → annet-0.12.1}/README.md +0 -0
  33. {annet-0.11 → annet-0.12.1}/annet/__init__.py +0 -0
  34. {annet-0.11 → annet-0.12.1}/annet/adapters/__init__.py +0 -0
  35. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/__init__.py +0 -0
  36. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/__init__.py +0 -0
  37. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/client.py +0 -0
  38. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/manufacturer.py +0 -0
  39. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/query.py +0 -0
  40. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/common/storage_opts.py +0 -0
  41. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/provider.py +0 -0
  42. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v24/__init__.py +0 -0
  43. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v24/client.py +0 -0
  44. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v37/__init__.py +0 -0
  45. {annet-0.11 → annet-0.12.1}/annet/adapters/netbox/v37/client.py +0 -0
  46. {annet-0.11 → annet-0.12.1}/annet/annet.py +0 -0
  47. {annet-0.11 → annet-0.12.1}/annet/annlib/__init__.py +0 -0
  48. {annet-0.11 → annet-0.12.1}/annet/annlib/command.py +0 -0
  49. {annet-0.11 → annet-0.12.1}/annet/annlib/diff.py +0 -0
  50. {annet-0.11 → annet-0.12.1}/annet/annlib/errors.py +0 -0
  51. {annet-0.11 → annet-0.12.1}/annet/annlib/filter_acl.py +0 -0
  52. {annet-0.11 → annet-0.12.1}/annet/annlib/jsontools.py +0 -0
  53. {annet-0.11 → annet-0.12.1}/annet/annlib/lib.py +0 -0
  54. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/__init__.py +0 -0
  55. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/db.py +0 -0
  56. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/devdb/__init__.py +0 -0
  57. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/devdb/data/devdb.json +0 -0
  58. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/views/__init__.py +0 -0
  59. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/views/dump.py +0 -0
  60. {annet-0.11 → annet-0.12.1}/annet/annlib/netdev/views/hardware.py +0 -0
  61. {annet-0.11 → annet-0.12.1}/annet/annlib/output.py +0 -0
  62. {annet-0.11 → annet-0.12.1}/annet/annlib/patching.py +0 -0
  63. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/__init__.py +0 -0
  64. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/acl.py +0 -0
  65. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/deploying.py +0 -0
  66. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/ordering.py +0 -0
  67. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/platform.py +0 -0
  68. {annet-0.11 → annet-0.12.1}/annet/annlib/rbparser/syntax.py +0 -0
  69. {annet-0.11 → annet-0.12.1}/annet/annlib/rulebook/__init__.py +0 -0
  70. {annet-0.11 → annet-0.12.1}/annet/annlib/rulebook/common.py +0 -0
  71. {annet-0.11 → annet-0.12.1}/annet/annlib/tabparser.py +0 -0
  72. {annet-0.11 → annet-0.12.1}/annet/annlib/types.py +0 -0
  73. {annet-0.11 → annet-0.12.1}/annet/argparse.py +0 -0
  74. {annet-0.11 → annet-0.12.1}/annet/configs/context.yml +0 -0
  75. {annet-0.11 → annet-0.12.1}/annet/configs/logging.yaml +0 -0
  76. {annet-0.11 → annet-0.12.1}/annet/deploy.py +0 -0
  77. {annet-0.11 → annet-0.12.1}/annet/diff.py +0 -0
  78. {annet-0.11 → annet-0.12.1}/annet/executor.py +0 -0
  79. {annet-0.11 → annet-0.12.1}/annet/filtering.py +0 -0
  80. {annet-0.11 → annet-0.12.1}/annet/generators/common/__init__.py +0 -0
  81. {annet-0.11 → annet-0.12.1}/annet/hardware.py +0 -0
  82. {annet-0.11 → annet-0.12.1}/annet/implicit.py +0 -0
  83. {annet-0.11 → annet-0.12.1}/annet/lib.py +0 -0
  84. {annet-0.11 → annet-0.12.1}/annet/parallel.py +0 -0
  85. {annet-0.11 → annet-0.12.1}/annet/patching.py +0 -0
  86. {annet-0.11 → annet-0.12.1}/annet/reference.py +0 -0
  87. {annet-0.11 → annet-0.12.1}/annet/rulebook/__init__.py +0 -0
  88. {annet-0.11 → annet-0.12.1}/annet/rulebook/arista/__init__.py +0 -0
  89. {annet-0.11 → annet-0.12.1}/annet/rulebook/arista/iface.py +0 -0
  90. {annet-0.11 → annet-0.12.1}/annet/rulebook/aruba/__init__.py +0 -0
  91. {annet-0.11 → annet-0.12.1}/annet/rulebook/aruba/ap_env.py +0 -0
  92. {annet-0.11 → annet-0.12.1}/annet/rulebook/aruba/misc.py +0 -0
  93. {annet-0.11 → annet-0.12.1}/annet/rulebook/cisco/__init__.py +0 -0
  94. {annet-0.11 → annet-0.12.1}/annet/rulebook/cisco/iface.py +0 -0
  95. {annet-0.11 → annet-0.12.1}/annet/rulebook/cisco/misc.py +0 -0
  96. {annet-0.11 → annet-0.12.1}/annet/rulebook/cisco/vlandb.py +0 -0
  97. {annet-0.11 → annet-0.12.1}/annet/rulebook/common.py +0 -0
  98. {annet-0.11 → annet-0.12.1}/annet/rulebook/deploying.py +0 -0
  99. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/__init__.py +0 -0
  100. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/aaa.py +0 -0
  101. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/bgp.py +0 -0
  102. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/iface.py +0 -0
  103. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/misc.py +0 -0
  104. {annet-0.11 → annet-0.12.1}/annet/rulebook/huawei/vlandb.py +0 -0
  105. {annet-0.11 → annet-0.12.1}/annet/rulebook/juniper/__init__.py +0 -0
  106. {annet-0.11 → annet-0.12.1}/annet/rulebook/nexus/__init__.py +0 -0
  107. {annet-0.11 → annet-0.12.1}/annet/rulebook/nexus/iface.py +0 -0
  108. {annet-0.11 → annet-0.12.1}/annet/rulebook/patching.py +0 -0
  109. {annet-0.11 → annet-0.12.1}/annet/rulebook/ribbon/__init__.py +0 -0
  110. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/arista.deploy +0 -0
  111. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/arista.order +0 -0
  112. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/arista.rul +0 -0
  113. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/aruba.deploy +0 -0
  114. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/aruba.order +0 -0
  115. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/aruba.rul +0 -0
  116. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/cisco.deploy +0 -0
  117. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/cisco.order +0 -0
  118. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/cisco.rul +0 -0
  119. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/huawei.deploy +0 -0
  120. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/huawei.order +0 -0
  121. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/huawei.rul +0 -0
  122. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/juniper.rul +0 -0
  123. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/nexus.deploy +0 -0
  124. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/nexus.order +0 -0
  125. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/nexus.rul +0 -0
  126. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/nokia.rul +0 -0
  127. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/pc.order +0 -0
  128. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/pc.rul +0 -0
  129. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/ribbon.deploy +0 -0
  130. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/ribbon.rul +0 -0
  131. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/routeros.order +0 -0
  132. {annet-0.11 → annet-0.12.1}/annet/rulebook/texts/routeros.rul +0 -0
  133. {annet-0.11 → annet-0.12.1}/annet/tabparser.py +0 -0
  134. {annet-0.11 → annet-0.12.1}/annet/text_term_format.py +0 -0
  135. {annet-0.11 → annet-0.12.1}/annet/tracing.py +0 -0
  136. {annet-0.11 → annet-0.12.1}/annet.egg-info/dependency_links.txt +0 -0
  137. {annet-0.11 → annet-0.12.1}/annet.egg-info/entry_points.txt +0 -0
  138. {annet-0.11 → annet-0.12.1}/annet.egg-info/requires.txt +0 -0
  139. {annet-0.11 → annet-0.12.1}/annet.egg-info/top_level.txt +0 -0
  140. {annet-0.11 → annet-0.12.1}/annet_generators/__init__.py +0 -0
  141. {annet-0.11 → annet-0.12.1}/annet_generators/example/__init__.py +0 -0
  142. {annet-0.11 → annet-0.12.1}/annet_generators/example/lldp.py +0 -0
  143. {annet-0.11 → annet-0.12.1}/requirements.txt +0 -0
  144. {annet-0.11 → annet-0.12.1}/setup.cfg +0 -0
  145. {annet-0.11 → annet-0.12.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.11
3
+ Version: 0.12.1
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -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: dict[str, Any]
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: dict[str, str]
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: dict[str, Any]
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: dict[str, Any]
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
- ) -> list[models.NetboxDevice]:
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: dict[str, Any]
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