Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update primary ipv4 address #124

Merged
merged 3 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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