Skip to content

Commit

Permalink
feat: Add the support for 'sub' includes in inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
BeArchiTek committed Jul 19, 2024
1 parent 2e9ec1d commit d31de9d
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 289 deletions.
16 changes: 8 additions & 8 deletions plugins/module_utils/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

try:
from infrahub_sdk.exceptions import (
FilterNotFound,
FilterNotFoundError,
GraphQLError,
SchemaNotFound,
ServerNotReacheableError,
SchemaNotFoundError,
ServerNotReachableError,
ServerNotResponsiveError,
)
except ImportError as imp_exc:
Expand All @@ -36,12 +36,12 @@ def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except GraphQLError:
raise Exception("Database not Responsive")
except SchemaNotFound:
pass # until we are able to return Generics Schema and Core Schema https://github.com/opsmill/infrahub/issues/1217
except FilterNotFound:
raise Exception(f"An error occurred while executing the GraphQL Query {kwargs}")
except SchemaNotFoundError:
raise Exception(f"Unable to find the schema {kwargs}")
except FilterNotFoundError:
raise Exception(f"Filters not Found {kwargs}")
except ServerNotReacheableError:
except ServerNotReachableError:
raise Exception("Server not Reacheable")
except ServerNotResponsiveError:
raise Exception("Server not Responsive")
Expand Down
161 changes: 111 additions & 50 deletions plugins/module_utils/infrahub_utils.py

Large diffs are not rendered by default.

216 changes: 0 additions & 216 deletions tests/integration/targets/inventory/output-test-inventory5.yml

This file was deleted.

4 changes: 2 additions & 2 deletions tests/integration/targets/inventory/test-inventory2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ nodes:
InfraDevice:

keyed_groups:
- prefix: site
key: site.name
- prefix: location
key: location.name
17 changes: 10 additions & 7 deletions tests/integration/targets/inventory/test-inventory3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
plugin: opsmill.infrahub.inventory
api_endpoint: "http://localhost:8000"

strict: false

nodes:
InfraDevice:
include:
- name
- primary_address
- platform
- site
- tags
- primary_address.address
- platform.ansible_network_os
- location.parent.name
- location.name
- role
- tags

compose:
hostname: name
platform: platform.ansible_network_os
ansible_host: primary_address.address | ansible.utils.ipaddr('address')
ansible_host: primary_address | ansible.utils.ipaddr('address')

keyed_groups:
- prefix: site
key: location.name | lower
- prefix: metro
key: location.parent.name | lower
2 changes: 1 addition & 1 deletion tests/integration/targets/inventory/test-inventory4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ strict: true
nodes:
InfraDevice:
exclude:
- site
- location
6 changes: 3 additions & 3 deletions tests/integration/targets/inventory/test-inventory5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nodes:
- name
- primary_address
- platform
- site
- location
- tags

compose:
Expand All @@ -24,7 +24,7 @@ compose:
ansible_host: primary_address.address | ansible.utils.ipaddr('address')

keyed_groups:
- prefix: site
key: site.name
- prefix: location
key: location.name
- prefix: platform
key: platform
4 changes: 2 additions & 2 deletions tests/integration/targets/inventory/test-inventory6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ branch: "jfk1-update-edge-ips"
nodes:
InfraDevice:
filters:
site__ids: "1791a399-7e43-13b5-3995-d8e9955c926e" # jfk1
location__ids: "1791a399-7e43-13b5-3995-d8e9955c926e" # jfk1
role__ids: "1791a399-31c4-c688-3992-d8ebd2cca61f" # edge
include:
- name
- primary_address
- platform
- site
- location
- interfaces

compose:
Expand Down

0 comments on commit d31de9d

Please sign in to comment.