diff --git a/development/docker-compose.yml b/development/docker-compose.yml index bfd000f6..a8597718 100644 --- a/development/docker-compose.yml +++ b/development/docker-compose.yml @@ -14,7 +14,7 @@ services: context: "../" target: "nautobot" dockerfile: "development/Dockerfile" - command: "nautobot-server runserver 0.0.0.0:8000 --insecure" + command: "nautobot-server runserver 0.0.0.0:8000 --insecure --nothreading" ports: - "8000:8000" depends_on: diff --git a/tests/integration/targets/inventory/files/test_2-3_gql.json b/tests/integration/targets/inventory/files/test_2-3_gql.json new file mode 100644 index 00000000..2be442d2 --- /dev/null +++ b/tests/integration/targets/inventory/files/test_2-3_gql.json @@ -0,0 +1,73 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "ansible_host": "R1-Device", + "name": "R1-Device" + }, + "Test Nexus Child One": { + "ansible_host": "Test Nexus Child One", + "name": "Test Nexus Child One" + }, + "Test Nexus One": { + "ansible_host": "172.16.180.11", + "name": "Test Nexus One", + "primary_ip4": { + "host": "172.16.180.11" + } + }, + "Test VM With Spaces": { + "ansible_host": "Test VM With Spaces", + "name": "Test VM With Spaces" + }, + "TestDeviceR1": { + "ansible_host": "TestDeviceR1", + "name": "TestDeviceR1" + }, + "test100": { + "ansible_host": "test100", + "name": "test100" + }, + "test100-vm": { + "ansible_host": "test100-vm", + "name": "test100-vm" + }, + "test101-vm": { + "ansible_host": "test101-vm", + "name": "test101-vm" + }, + "test102-vm": { + "ansible_host": "test102-vm", + "name": "test102-vm" + }, + "test103-vm": { + "ansible_host": "test103-vm", + "name": "test103-vm" + }, + "test104-vm": { + "ansible_host": "test104-vm", + "name": "test104-vm" + } + } + }, + "all": { + "children": [ + "ungrouped" + ] + }, + "ungrouped": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "Test VM With Spaces", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory/files/test_2-3_gql.yml b/tests/integration/targets/inventory/files/test_2-3_gql.yml new file mode 100644 index 00000000..5a0174be --- /dev/null +++ b/tests/integration/targets/inventory/files/test_2-3_gql.yml @@ -0,0 +1,4 @@ +plugin: networktocode.nautobot.gql_inventory +api_endpoint: "http://nautobot:8000" +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: False diff --git a/tests/integration/targets/inventory/files/test_2-3_gql_groupby.json b/tests/integration/targets/inventory/files/test_2-3_gql_groupby.json new file mode 100644 index 00000000..ae29e648 --- /dev/null +++ b/tests/integration/targets/inventory/files/test_2-3_gql_groupby.json @@ -0,0 +1,470 @@ +{ + "Active": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "Test VM With Spaces", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "Child_Child_Test_Location": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Child_Rack_Group": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Child_Test_Location": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "test100" + ] + }, + "Cisco": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "Cisco_Test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "Core_Switch": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "Main_Test_Rack": { + "hosts": [ + "R1-Device" + ] + }, + "Nexus_Child": { + "hosts": [ + "Test Nexus Child One" + ] + }, + "Nexus_Parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "Parent_Rack_Group": { + "hosts": [ + "R1-Device" + ] + }, + "Sub_Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "Test_Cluster_Group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_Type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "Test_Tenant": { + "hosts": [ + "test100" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "ansible_host": "R1-Device", + "device_type": { + "manufacturer": { + "name": "Cisco" + }, + "model": "Cisco Test" + }, + "location": { + "name": "Child Test Location" + }, + "name": "R1-Device", + "rack": { + "name": "Main Test Rack", + "rack_group": { + "name": "Parent Rack Group" + }, + "role": { + "name": "Test Rack Role" + } + }, + "role": { + "name": "Core Switch" + }, + "status": { + "name": "Active" + } + }, + "Test Nexus Child One": { + "ansible_host": "Test Nexus Child One", + "device_type": { + "manufacturer": { + "name": "Cisco" + }, + "model": "Nexus Child" + }, + "interfaces": [ + { + "name": "Ethernet2/1" + } + ], + "location": { + "name": "Child Test Location" + }, + "name": "Test Nexus Child One", + "role": { + "name": "Core Switch" + }, + "status": { + "name": "Active" + } + }, + "Test Nexus One": { + "ansible_host": "172.16.180.11", + "device_type": { + "manufacturer": { + "name": "Cisco" + }, + "model": "Nexus Parent" + }, + "interfaces": [ + { + "name": "Ethernet1/1" + } + ], + "location": { + "name": "Child Test Location" + }, + "name": "Test Nexus One", + "primary_ip4": { + "host": "172.16.180.11" + }, + "role": { + "name": "Core Switch" + }, + "services": [ + { + "name": "telnet" + } + ], + "status": { + "name": "Active" + } + }, + "Test VM With Spaces": { + "ansible_host": "Test VM With Spaces", + "cluster": { + "cluster_group": null, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": null, + "name": "Test Cluster 2" + }, + "interfaces": [ + { + "name": "Eth0" + }, + { + "name": "Eth1" + } + ], + "name": "Test VM With Spaces", + "services": [ + { + "name": "ssh" + } + ], + "status": { + "name": "Active" + } + }, + "TestDeviceR1": { + "ansible_host": "TestDeviceR1", + "device_type": { + "manufacturer": { + "name": "Cisco" + }, + "model": "Cisco Test" + }, + "location": { + "name": "Child-Child Test Location" + }, + "name": "TestDeviceR1", + "rack": { + "name": "Sub Test Rack", + "rack_group": { + "name": "Child Rack Group" + }, + "role": null + }, + "role": { + "name": "Core Switch" + }, + "status": { + "name": "Active" + } + }, + "test100": { + "_custom_field_data": { + "my_device_custom_field": "Test Device Custom Field Value" + }, + "ansible_host": "test100", + "config_context": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "device_type": { + "manufacturer": { + "name": "Cisco" + }, + "model": "Cisco Test" + }, + "interfaces": [ + { + "name": "GigabitEthernet1" + }, + { + "name": "GigabitEthernet2" + }, + { + "name": "GigabitEthernet3" + }, + { + "name": "GigabitEthernet4" + } + ], + "location": { + "name": "Child Test Location" + }, + "name": "test100", + "role": { + "name": "Core Switch" + }, + "services": [ + { + "name": "http" + }, + { + "name": "ssh" + } + ], + "status": { + "name": "Active" + }, + "tenant": { + "name": "Test Tenant" + } + }, + "test100-vm": { + "ansible_host": "test100-vm", + "cluster": { + "cluster_group": { + "name": "Test Cluster Group" + }, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": { + "name": "Child Test Location" + }, + "name": "Test Cluster" + }, + "interfaces": [ + { + "name": "Eth0" + }, + { + "name": "Eth1" + }, + { + "name": "Eth2" + }, + { + "name": "Eth3" + }, + { + "name": "Eth4" + } + ], + "name": "test100-vm", + "status": { + "name": "Active" + } + }, + "test101-vm": { + "ansible_host": "test101-vm", + "cluster": { + "cluster_group": { + "name": "Test Cluster Group" + }, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": { + "name": "Child Test Location" + }, + "name": "Test Cluster" + }, + "interfaces": [ + { + "name": "Eth0" + }, + { + "name": "Eth1" + }, + { + "name": "Eth2" + }, + { + "name": "Eth3" + }, + { + "name": "Eth4" + } + ], + "name": "test101-vm", + "status": { + "name": "Active" + } + }, + "test102-vm": { + "ansible_host": "test102-vm", + "cluster": { + "cluster_group": { + "name": "Test Cluster Group" + }, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": { + "name": "Child Test Location" + }, + "name": "Test Cluster" + }, + "name": "test102-vm", + "status": { + "name": "Active" + } + }, + "test103-vm": { + "ansible_host": "test103-vm", + "cluster": { + "cluster_group": { + "name": "Test Cluster Group" + }, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": { + "name": "Child Test Location" + }, + "name": "Test Cluster" + }, + "name": "test103-vm", + "status": { + "name": "Active" + } + }, + "test104-vm": { + "ansible_host": "test104-vm", + "cluster": { + "cluster_group": null, + "cluster_type": { + "name": "Test Cluster Type" + }, + "location": null, + "name": "Test Cluster 2" + }, + "name": "test104-vm", + "status": { + "name": "Active" + } + } + } + }, + "all": { + "children": [ + "Active", + "Child_Child_Test_Location", + "Child_Rack_Group", + "Child_Test_Location", + "Cisco", + "Cisco_Test", + "Core_Switch", + "Main_Test_Rack", + "Nexus_Child", + "Nexus_Parent", + "Parent_Rack_Group", + "Sub_Test_Rack", + "Test_Cluster", + "Test_Cluster_2", + "Test_Cluster_Group", + "Test_Cluster_Type", + "Test_Tenant", + "rack_role", + "ungrouped" + ] + }, + "rack_role": { + "hosts": [ + "R1-Device", + "TestDeviceR1" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory/files/test_2-3_gql_groupby.yml b/tests/integration/targets/inventory/files/test_2-3_gql_groupby.yml new file mode 100644 index 00000000..603ba391 --- /dev/null +++ b/tests/integration/targets/inventory/files/test_2-3_gql_groupby.yml @@ -0,0 +1,54 @@ +plugin: networktocode.nautobot.gql_inventory +api_endpoint: "http://nautobot:8000" +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: False + +query: + devices: + config_context: + _custom_field_data: + device_type: + manufacturer: name + model: + interfaces: name + location: name + platform: name + rack: + name: + rack_group: name + role: name + role: name + services: name + status: name + tags: name + tenant: name + virtual_machines: + cluster: + name: + cluster_group: name + cluster_type: name + location: name + config_context: + _custom_field_data: + interfaces: name + services: name + status: name + tags: name + tenant: name + +group_by: + - location.name + - tenant.name + - rack.name + - rack.rack_group.name + - rack.rack_role.name + - tag.name + - role.name + - device_type.manufacturer.name + - device_type.model + - platform.name + - cluster.name + - cluster.cluster_group.name + - cluster.cluster_type.name + - service.name + - status.name