Skip to content

Commit

Permalink
Inventory - GraphQL: Update primary ipv4 address to not include CIDR (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qduk authored Mar 21, 2022
1 parent 97c72ce commit 40d8f40
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/inventory/gql_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def add_variable(self, host: str, var: str, var_type: str):
def add_ipv4_address(self, device):
"""Add primary IPv4 address to host."""
if device["primary_ip4"]:
self.add_variable(device["name"], device["primary_ip4"]["address"], "ansible_host")
self.add_variable(device["name"], device["primary_ip4"]["host"], "ansible_host")
else:
self.add_variable(device["name"], device["name"], "ansible_host")

Expand Down
2 changes: 1 addition & 1 deletion plugins/templates/graphql_default_query.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ devices {% include "graphql_filters.j2" %} {
name
}
primary_ip4 {
address
host
}
device_role {
name
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nautobot_ansible_modules"
version = "3.3.1"
version = "3.3.2"
description = "Ansible collection to interact with Nautobot's API"
authors = ["Network to Code <opensource@networktocode.com"]
license = "Apache 2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Active"
},
"primary_ip4": {
"address": "10.10.10.10/32"
"host": "10.10.10.10"
},
"device_role": {
"name": "edge",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/inventory/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_add_ipv4(inventory_fixture, device_data):
inventory_fixture.create_groups(device_data)
inventory_fixture.add_ipv4_address(device_data)
mydevice_host = inventory_fixture.inventory.get_host("mydevice")
assert mydevice_host.vars.get("ansible_host") == "10.10.10.10/32"
assert mydevice_host.vars.get("ansible_host") == "10.10.10.10"


def test_ansible_platform(inventory_fixture, device_data):
Expand Down

0 comments on commit 40d8f40

Please sign in to comment.