Skip to content

Commit

Permalink
Merge pull request #1099 from netbox-community/devel
Browse files Browse the repository at this point in the history
Release 3.15.0
  • Loading branch information
rodvand authored Oct 18, 2023
2 parents b77a6be + a7608ef commit 866c00e
Show file tree
Hide file tree
Showing 124 changed files with 20,926 additions and 537 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ jobs:
NETBOX_DOCKER_VERSION: 2.5.3
- VERSION: "v3.5"
NETBOX_DOCKER_VERSION: 2.6.1
- VERSION: "v3.6"
NETBOX_DOCKER_VERSION: 2.7.0
# If we want to integration test wiht all supported Python:
#python-version: ["3.9", "3.10", "3.11"]

Expand Down
13 changes: 13 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,16 @@ releases:
- netbox_power_port - Add missing power port option [#1049](https://github.com/netbox-community/ansible_modules/pull/1049)
- netbox_inventory_item - Add role to module [#1050](https://github.com/netbox-community/ansible_modules/pull/1050)
release_date: '2023-08-18'
3.15.0:
changes:
bugfixes:
- netbox_ device - Adjust device_role to role for NetBox 3.6 [#1066](https://github.com/netbox-community/ansible_modules/pull/1066)
minor_changes:
- netbox_device - Add oob_ip to device [#1085](https://github.com/netbox-community/ansible_modules/pull/1085)
- netbox_device_type - Add default_platform [#1092](https://github.com/netbox-community/ansible_modules/pull/1092)
- netbox_config_template - New module [#1090](https://github.com/netbox-community/ansible_modules/pull/1090)
modules:
- description: Creates, updates, or removed a config template from NetBox
name: netbox_config_template
namesapce: ''
release_date: '2023-10-18'
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author = "Mikhail Yohman <@FragmentedPacket>"

# The full version, including alpha/beta/rc tags
release = "3.14.0"
release = "3.15.0"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansible
antsibull==0.48.0
sphinx==3.4.2
Jinja2<3.1
sphinx_rtd_theme
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: netbox
name: netbox

# The version of the collection. Must be compatible with semantic versioning
version: 3.14.0
version: 3.15.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
2 changes: 1 addition & 1 deletion hacking/local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
ansible-galaxy collection install netbox-netbox-*.tar.gz -p .

# You can now cd into the installed version and run tests
(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.6 && ansible-test sanity --requirements -v --python 3.6 --skip-test pep8 plugins/)
(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.10 && ansible-test sanity --requirements -v --python 3.10 --skip-test pep8 plugins/)
rm -rf ansible_collections
22 changes: 9 additions & 13 deletions plugins/module_utils/netbox_dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,15 @@ def run(self):
)

# This is logic to handle interfaces on a VC
if self.endpoint == "interfaces":
if self.nb_object:
device = self.nb.dcim.devices.get(self.nb_object.device.id)
if (
device["virtual_chassis"]
and self.nb_object.device.id != self.data["device"]
):
if self.module.params.get("update_vc_child"):
data["device"] = self.nb_object.device.id
else:
self._handle_errors(
msg="Must set update_vc_child to True to allow child device interface modification"
)
if self.endpoint == "interfaces" and self.nb_object:
child = self.nb.dcim.devices.get(self.nb_object.device.id)
if child["virtual_chassis"] and child.id != data["device"]:
if self.module.params.get("update_vc_child"):
data["device"] = child.id
else:
self._handle_errors(
msg="Must set update_vc_child to True to allow child device interface modification"
)

if self.state == "present":
self._ensure_object_exists(nb_endpoint, endpoint_name, name, data)
Expand Down
2 changes: 2 additions & 0 deletions plugins/module_utils/netbox_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
NB_EXPORT_TEMPLATES = "export_templates"
NB_JOURNAL_ENTRIES = "journal_entries"
NB_WEBHOOKS = "webhooks"
NB_CONFIG_TEMPLATES = "config_templates"


class NetboxExtrasModule(NetboxModule):
Expand All @@ -37,6 +38,7 @@ def run(self):
to create/update/delete the endpoint objects
Supported endpoints:
- config_contexts
- config_templates
- tags
- journal entries
"""
Expand Down
56 changes: 43 additions & 13 deletions plugins/module_utils/netbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
],
extras=[
"config_contexts",
"config_templates",
"tags",
"custom_fields",
"custom_links",
Expand Down Expand Up @@ -125,6 +126,7 @@
cluster_group="slug",
cluster_type="slug",
config_context="name",
config_template="name",
contact_group="name",
contact_role="name",
custom_field="name",
Expand Down Expand Up @@ -161,6 +163,7 @@
primary_ip="address",
primary_ip4="address",
primary_ip6="address",
oob_ip="address",
provider="slug",
provider_network="name",
rack="name",
Expand Down Expand Up @@ -204,7 +207,9 @@
"cluster_groups": "cluster_groups",
"cluster_type": "cluster_types",
"cluster_types": "cluster_types",
"component": "interfaces",
"config_context": "config_contexts",
"config_template": "config_templates",
"contact_groups": "contact_groups",
"dcim.consoleport": "console_ports",
"dcim.consoleserverport": "console_server_ports",
Expand All @@ -214,6 +219,7 @@
"dcim.poweroutlet": "power_outlets",
"dcim.powerport": "power_ports",
"dcim.rearport": "rear_ports",
"default_platform": "platforms",
"device": "devices",
"device_role": "device_roles",
"device_type": "device_types",
Expand Down Expand Up @@ -253,6 +259,7 @@
"primary_ip": "ip_addresses",
"primary_ip4": "ip_addresses",
"primary_ip6": "ip_addresses",
"oob_ip": "ip_addresses",
"provider": "providers",
"provider_network": "provider_networks",
"rack": "racks",
Expand Down Expand Up @@ -306,6 +313,7 @@
"cluster_groups": "cluster_group",
"cluster_types": "cluster_type",
"config_contexts": "config_context",
"config_templates": "config_template",
"console_ports": "console_port",
"console_port_templates": "console_port_template",
"console_server_ports": "console_server_port",
Expand Down Expand Up @@ -386,6 +394,7 @@
"cluster": set(["name", "type"]),
"cluster_group": set(["slug"]),
"cluster_type": set(["slug"]),
"component": set(["name", "device"]),
"config_context": set(
[
"name",
Expand All @@ -403,6 +412,7 @@
"tags",
]
),
"config_template": set(["name"]),
"console_port": set(["name", "device"]),
"console_port_template": set(["name", "device_type"]),
"console_server_port": set(["name", "device"]),
Expand Down Expand Up @@ -437,7 +447,7 @@
"interface_a": set(["name", "device"]),
"interface_b": set(["name", "device"]),
"interface_template": set(["name", "device_type"]),
"inventory_item": set(["name", "device"]),
"inventory_item": set(["name", "device", "component", "component_type"]),
"inventory_item_role": set(["name"]),
"ip_address": set(["address", "vrf", "device", "interface", "assigned_object"]),
"ip_addresses": set(["address", "vrf", "device", "interface", "assigned_object"]),
Expand Down Expand Up @@ -472,6 +482,7 @@
"prefix": set(["prefix", "vrf"]),
"primary_ip4": set(["address", "vrf"]),
"primary_ip6": set(["address", "vrf"]),
"oob_ip": set(["address", "vrf"]),
"provider": set(["slug"]),
"provider_network": set(["name"]),
"rack": set(["name", "site", "location"]),
Expand Down Expand Up @@ -561,7 +572,9 @@
"circuit_type": "type",
"cluster_type": "type",
"cluster_group": "group",
"component": "component_id",
"contact_group": "group",
"device_role": "role",
"fhrp_group": "group",
"inventory_item_role": "role",
"parent_contact_group": "parent",
Expand Down Expand Up @@ -819,12 +832,18 @@ def _convert_identical_keys(self, data):
if self._version_check_greater(self.version, "2.7", greater_or_equal=True):
if data.get("form_factor"):
temp_dict["type"] = data.pop("form_factor")

for key in data:
if self.endpoint == "power_panels" and key == "rack_group":
temp_dict[key] = data[key]
# 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.
elif key == "device_role" and not self._version_check_greater(
self.version, "3.6", greater_or_equal=True
):
temp_dict[key] = data[key]
elif key in CONVERT_KEYS:
# This will keep the original key for keys in list, but also convert it.
if key in ("assigned_object", "scope"):
if key in ("assigned_object", "scope", "component"):
temp_dict[key] = data[key]
new_key = CONVERT_KEYS[key]
temp_dict[new_key] = data[key]
Expand Down Expand Up @@ -855,19 +874,18 @@ def _get_query_param_id(self, match, data):
"""
if isinstance(data.get(match), int):
return data[match]
else:
endpoint = CONVERT_TO_ID[match]
app = self._find_app(endpoint)
nb_app = getattr(self.nb, app)
nb_endpoint = getattr(nb_app, endpoint)
endpoint = CONVERT_TO_ID[match]
app = self._find_app(endpoint)
nb_app = getattr(self.nb, app)
nb_endpoint = getattr(nb_app, endpoint)

query_params = {QUERY_TYPES.get(match): data[match]}
result = self._nb_endpoint_get(nb_endpoint, query_params, match)
query_params = {QUERY_TYPES.get(match): data[match]}
result = self._nb_endpoint_get(nb_endpoint, query_params, match)

if result:
return result.id
else:
return data
if result:
return result.id
else:
return data

def _build_query_params(
self, parent, module_data, user_query_params=None, child=None
Expand Down Expand Up @@ -909,6 +927,16 @@ def _build_query_params(

if parent == "vlan_group" and match == "site":
query_dict.update({match: query_id})
elif (
parent == "interface"
and "device" in module_data
and self._version_check_greater(
self.version, "3.6", greater_or_equal=True
)
):
query_dict.update(
{"virtual_chassis_member_id": module_data["device"]}
)
else:
query_dict.update({match + "_id": query_id})
else:
Expand Down Expand Up @@ -1118,6 +1146,8 @@ def _find_ids(self, data, user_query_params):
endpoint = CONVERT_TO_ID[data.get("termination_b_type")]
elif k == "assigned_object":
endpoint = "interfaces"
elif k == "component":
endpoint = CONVERT_TO_ID[data.get("component_type")]
elif k == "scope":
# Determine endpoint name for scope ID resolution
endpoint = SCOPE_TO_ENDPOINT[data["scope_type"]]
Expand Down
Loading

0 comments on commit 866c00e

Please sign in to comment.