Skip to content

Commit 866c00e

Browse files
authored
Merge pull request #1099 from netbox-community/devel
Release 3.15.0
2 parents b77a6be + a7608ef commit 866c00e

File tree

124 files changed

+20926
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+20926
-537
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ jobs:
8282
NETBOX_DOCKER_VERSION: 2.5.3
8383
- VERSION: "v3.5"
8484
NETBOX_DOCKER_VERSION: 2.6.1
85+
- VERSION: "v3.6"
86+
NETBOX_DOCKER_VERSION: 2.7.0
8587
# If we want to integration test wiht all supported Python:
8688
#python-version: ["3.9", "3.10", "3.11"]
8789

changelogs/changelog.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,3 +818,16 @@ releases:
818818
- netbox_power_port - Add missing power port option [#1049](https://github.com/netbox-community/ansible_modules/pull/1049)
819819
- netbox_inventory_item - Add role to module [#1050](https://github.com/netbox-community/ansible_modules/pull/1050)
820820
release_date: '2023-08-18'
821+
3.15.0:
822+
changes:
823+
bugfixes:
824+
- netbox_ device - Adjust device_role to role for NetBox 3.6 [#1066](https://github.com/netbox-community/ansible_modules/pull/1066)
825+
minor_changes:
826+
- netbox_device - Add oob_ip to device [#1085](https://github.com/netbox-community/ansible_modules/pull/1085)
827+
- netbox_device_type - Add default_platform [#1092](https://github.com/netbox-community/ansible_modules/pull/1092)
828+
- netbox_config_template - New module [#1090](https://github.com/netbox-community/ansible_modules/pull/1090)
829+
modules:
830+
- description: Creates, updates, or removed a config template from NetBox
831+
name: netbox_config_template
832+
namesapce: ''
833+
release_date: '2023-10-18'

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
author = "Mikhail Yohman <@FragmentedPacket>"
2828

2929
# The full version, including alpha/beta/rc tags
30-
release = "3.14.0"
30+
release = "3.15.0"
3131

3232

3333
# -- General configuration ---------------------------------------------------

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
ansible
22
antsibull==0.48.0
33
sphinx==3.4.2
4+
Jinja2<3.1
5+
sphinx_rtd_theme

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace: netbox
1010
name: netbox
1111

1212
# The version of the collection. Must be compatible with semantic versioning
13-
version: 3.14.0
13+
version: 3.15.0
1414

1515
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1616
readme: README.md

hacking/local-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
ansible-galaxy collection install netbox-netbox-*.tar.gz -p .
1010

1111
# You can now cd into the installed version and run tests
12-
(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.6 && ansible-test sanity --requirements -v --python 3.6 --skip-test pep8 plugins/)
12+
(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.10 && ansible-test sanity --requirements -v --python 3.10 --skip-test pep8 plugins/)
1313
rm -rf ansible_collections

plugins/module_utils/netbox_dcim.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,15 @@ def run(self):
211211
)
212212

213213
# This is logic to handle interfaces on a VC
214-
if self.endpoint == "interfaces":
215-
if self.nb_object:
216-
device = self.nb.dcim.devices.get(self.nb_object.device.id)
217-
if (
218-
device["virtual_chassis"]
219-
and self.nb_object.device.id != self.data["device"]
220-
):
221-
if self.module.params.get("update_vc_child"):
222-
data["device"] = self.nb_object.device.id
223-
else:
224-
self._handle_errors(
225-
msg="Must set update_vc_child to True to allow child device interface modification"
226-
)
214+
if self.endpoint == "interfaces" and self.nb_object:
215+
child = self.nb.dcim.devices.get(self.nb_object.device.id)
216+
if child["virtual_chassis"] and child.id != data["device"]:
217+
if self.module.params.get("update_vc_child"):
218+
data["device"] = child.id
219+
else:
220+
self._handle_errors(
221+
msg="Must set update_vc_child to True to allow child device interface modification"
222+
)
227223

228224
if self.state == "present":
229225
self._ensure_object_exists(nb_endpoint, endpoint_name, name, data)

plugins/module_utils/netbox_extras.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
NB_EXPORT_TEMPLATES = "export_templates"
1919
NB_JOURNAL_ENTRIES = "journal_entries"
2020
NB_WEBHOOKS = "webhooks"
21+
NB_CONFIG_TEMPLATES = "config_templates"
2122

2223

2324
class NetboxExtrasModule(NetboxModule):
@@ -37,6 +38,7 @@ def run(self):
3738
to create/update/delete the endpoint objects
3839
Supported endpoints:
3940
- config_contexts
41+
- config_templates
4042
- tags
4143
- journal entries
4244
"""

plugins/module_utils/netbox_utils.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
],
8080
extras=[
8181
"config_contexts",
82+
"config_templates",
8283
"tags",
8384
"custom_fields",
8485
"custom_links",
@@ -125,6 +126,7 @@
125126
cluster_group="slug",
126127
cluster_type="slug",
127128
config_context="name",
129+
config_template="name",
128130
contact_group="name",
129131
contact_role="name",
130132
custom_field="name",
@@ -161,6 +163,7 @@
161163
primary_ip="address",
162164
primary_ip4="address",
163165
primary_ip6="address",
166+
oob_ip="address",
164167
provider="slug",
165168
provider_network="name",
166169
rack="name",
@@ -204,7 +207,9 @@
204207
"cluster_groups": "cluster_groups",
205208
"cluster_type": "cluster_types",
206209
"cluster_types": "cluster_types",
210+
"component": "interfaces",
207211
"config_context": "config_contexts",
212+
"config_template": "config_templates",
208213
"contact_groups": "contact_groups",
209214
"dcim.consoleport": "console_ports",
210215
"dcim.consoleserverport": "console_server_ports",
@@ -214,6 +219,7 @@
214219
"dcim.poweroutlet": "power_outlets",
215220
"dcim.powerport": "power_ports",
216221
"dcim.rearport": "rear_ports",
222+
"default_platform": "platforms",
217223
"device": "devices",
218224
"device_role": "device_roles",
219225
"device_type": "device_types",
@@ -253,6 +259,7 @@
253259
"primary_ip": "ip_addresses",
254260
"primary_ip4": "ip_addresses",
255261
"primary_ip6": "ip_addresses",
262+
"oob_ip": "ip_addresses",
256263
"provider": "providers",
257264
"provider_network": "provider_networks",
258265
"rack": "racks",
@@ -306,6 +313,7 @@
306313
"cluster_groups": "cluster_group",
307314
"cluster_types": "cluster_type",
308315
"config_contexts": "config_context",
316+
"config_templates": "config_template",
309317
"console_ports": "console_port",
310318
"console_port_templates": "console_port_template",
311319
"console_server_ports": "console_server_port",
@@ -386,6 +394,7 @@
386394
"cluster": set(["name", "type"]),
387395
"cluster_group": set(["slug"]),
388396
"cluster_type": set(["slug"]),
397+
"component": set(["name", "device"]),
389398
"config_context": set(
390399
[
391400
"name",
@@ -403,6 +412,7 @@
403412
"tags",
404413
]
405414
),
415+
"config_template": set(["name"]),
406416
"console_port": set(["name", "device"]),
407417
"console_port_template": set(["name", "device_type"]),
408418
"console_server_port": set(["name", "device"]),
@@ -437,7 +447,7 @@
437447
"interface_a": set(["name", "device"]),
438448
"interface_b": set(["name", "device"]),
439449
"interface_template": set(["name", "device_type"]),
440-
"inventory_item": set(["name", "device"]),
450+
"inventory_item": set(["name", "device", "component", "component_type"]),
441451
"inventory_item_role": set(["name"]),
442452
"ip_address": set(["address", "vrf", "device", "interface", "assigned_object"]),
443453
"ip_addresses": set(["address", "vrf", "device", "interface", "assigned_object"]),
@@ -472,6 +482,7 @@
472482
"prefix": set(["prefix", "vrf"]),
473483
"primary_ip4": set(["address", "vrf"]),
474484
"primary_ip6": set(["address", "vrf"]),
485+
"oob_ip": set(["address", "vrf"]),
475486
"provider": set(["slug"]),
476487
"provider_network": set(["name"]),
477488
"rack": set(["name", "site", "location"]),
@@ -561,7 +572,9 @@
561572
"circuit_type": "type",
562573
"cluster_type": "type",
563574
"cluster_group": "group",
575+
"component": "component_id",
564576
"contact_group": "group",
577+
"device_role": "role",
565578
"fhrp_group": "group",
566579
"inventory_item_role": "role",
567580
"parent_contact_group": "parent",
@@ -819,12 +832,18 @@ def _convert_identical_keys(self, data):
819832
if self._version_check_greater(self.version, "2.7", greater_or_equal=True):
820833
if data.get("form_factor"):
821834
temp_dict["type"] = data.pop("form_factor")
835+
822836
for key in data:
823837
if self.endpoint == "power_panels" and key == "rack_group":
824838
temp_dict[key] = data[key]
839+
# TODO: Remove this once the lowest supported Netbox version is 3.6 or greater as we can use default logic of CONVERT_KEYS moving forward.
840+
elif key == "device_role" and not self._version_check_greater(
841+
self.version, "3.6", greater_or_equal=True
842+
):
843+
temp_dict[key] = data[key]
825844
elif key in CONVERT_KEYS:
826845
# This will keep the original key for keys in list, but also convert it.
827-
if key in ("assigned_object", "scope"):
846+
if key in ("assigned_object", "scope", "component"):
828847
temp_dict[key] = data[key]
829848
new_key = CONVERT_KEYS[key]
830849
temp_dict[new_key] = data[key]
@@ -855,19 +874,18 @@ def _get_query_param_id(self, match, data):
855874
"""
856875
if isinstance(data.get(match), int):
857876
return data[match]
858-
else:
859-
endpoint = CONVERT_TO_ID[match]
860-
app = self._find_app(endpoint)
861-
nb_app = getattr(self.nb, app)
862-
nb_endpoint = getattr(nb_app, endpoint)
877+
endpoint = CONVERT_TO_ID[match]
878+
app = self._find_app(endpoint)
879+
nb_app = getattr(self.nb, app)
880+
nb_endpoint = getattr(nb_app, endpoint)
863881

864-
query_params = {QUERY_TYPES.get(match): data[match]}
865-
result = self._nb_endpoint_get(nb_endpoint, query_params, match)
882+
query_params = {QUERY_TYPES.get(match): data[match]}
883+
result = self._nb_endpoint_get(nb_endpoint, query_params, match)
866884

867-
if result:
868-
return result.id
869-
else:
870-
return data
885+
if result:
886+
return result.id
887+
else:
888+
return data
871889

872890
def _build_query_params(
873891
self, parent, module_data, user_query_params=None, child=None
@@ -909,6 +927,16 @@ def _build_query_params(
909927

910928
if parent == "vlan_group" and match == "site":
911929
query_dict.update({match: query_id})
930+
elif (
931+
parent == "interface"
932+
and "device" in module_data
933+
and self._version_check_greater(
934+
self.version, "3.6", greater_or_equal=True
935+
)
936+
):
937+
query_dict.update(
938+
{"virtual_chassis_member_id": module_data["device"]}
939+
)
912940
else:
913941
query_dict.update({match + "_id": query_id})
914942
else:
@@ -1118,6 +1146,8 @@ def _find_ids(self, data, user_query_params):
11181146
endpoint = CONVERT_TO_ID[data.get("termination_b_type")]
11191147
elif k == "assigned_object":
11201148
endpoint = "interfaces"
1149+
elif k == "component":
1150+
endpoint = CONVERT_TO_ID[data.get("component_type")]
11211151
elif k == "scope":
11221152
# Determine endpoint name for scope ID resolution
11231153
endpoint = SCOPE_TO_ENDPOINT[data["scope_type"]]

0 commit comments

Comments
 (0)