diff --git a/.bandit.yml b/.bandit.yml index 55c6741b..59d961d8 100644 --- a/.bandit.yml +++ b/.bandit.yml @@ -1,5 +1,7 @@ --- skips: [] -# No need to check for security issues in the test scripts! exclude_dirs: + # No need to check for security issues in the test scripts! - "./tests/" + # Ignore locally installed collection + - "./collections/" diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 6f6e5e7c..70596682 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -6,7 +6,7 @@ on: # yamllint disable runs-on: description: "The OS to run the job on" required: false - default: "ubuntu-22.04" + default: "ubuntu-24.04" type: string python-version: description: "The Python version to use" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56fb0965..a1a490cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ on: # yamllint disable runs-on: description: "The OS to run the job on" required: false - default: "ubuntu-22.04" + default: "ubuntu-24.04" type: string full-integration: description: "Run full integration tests" @@ -30,8 +30,8 @@ jobs: fail-fast: false matrix: python-version: - - "3.10" - "3.11" + - "3.12" env: INVOKE_NAUTOBOT_ANSIBLE_PYTHON_VER: "${{ matrix.python-version }}" steps: @@ -51,12 +51,12 @@ jobs: fail-fast: false matrix: python-version: - - "3.11" + - "3.12" nautobot-version: - "2.3" ansible-version: - - "2.16" - "2.17" + - "2.18" with: python-version: "${{ matrix.python-version }}" nautobot-version: "${{ matrix.nautobot-version }}" @@ -70,8 +70,8 @@ jobs: fail-fast: false matrix: python-version: - - "3.10" - "3.11" + - "3.12" nautobot-version: - "2.0" - "2.1" @@ -80,6 +80,14 @@ jobs: ansible-version: - "2.16" - "2.17" + - "2.18" + exclude: + - python-version: "3.12" + nautobot-version: "2.0" + - python-version: "3.12" + nautobot-version: "2.1" + - python-version: "3.12" + nautobot-version: "2.2" with: python-version: "${{ matrix.python-version }}" nautobot-version: "${{ matrix.nautobot-version }}" diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index 3d776cf0..7ed013cb 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -6,7 +6,7 @@ on: # yamllint disable jobs: lint: - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" steps: - name: "Check out repository code" uses: "actions/checkout@v4" @@ -15,13 +15,13 @@ jobs: - name: "Linting" run: "invoke lint" unit: - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" strategy: fail-fast: false matrix: python-version: - - "3.10" - "3.11" + - "3.12" env: INVOKE_NAUTOBOT_ANSIBLE_PYTHON_VER: "${{ matrix.python-version }}" steps: @@ -39,8 +39,8 @@ jobs: fail-fast: false matrix: python-version: - - "3.10" - "3.11" + - "3.12" nautobot-version: - "2.0" - "2.1" @@ -49,6 +49,14 @@ jobs: ansible-version: - "2.16" - "2.17" + - "2.18" + exclude: + - python-version: "3.12" + nautobot-version: "2.0" + - python-version: "3.12" + nautobot-version: "2.1" + - python-version: "3.12" + nautobot-version: "2.2" with: python-version: "${{ matrix.python-version }}" nautobot-version: "${{ matrix.nautobot-version }}" @@ -57,7 +65,7 @@ jobs: - "unit" publish_github: name: "Publish to GitHub" - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" if: "startsWith(github.ref, 'refs/tags/v')" steps: - name: "Check out repository code" @@ -65,7 +73,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v5" with: - python-version: "3.10" + python-version: "3.11" - name: "Install Python Packages" run: "pip install ansible-core" - name: "Build the collection" @@ -82,7 +90,7 @@ jobs: - "integration" publish_galaxy: name: "Publish to Ansible Galaxy" - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" if: "startsWith(github.ref, 'refs/tags/v')" steps: - name: "Check out repository code" @@ -90,7 +98,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v5" with: - python-version: "3.10" + python-version: "3.11" - name: "Install Python Packages" run: "pip install ansible-core" - name: "Create the ansible.cfg file" diff --git a/.readthedocs.yml b/.readthedocs.yml index d392bf57..58c5fc86 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,9 +8,9 @@ version: 2 # Set the version of Python in the build environment. build: - os: "ubuntu-22.04" + os: "ubuntu-24.04" tools: - python: "3.10" + python: "3.11" jobs: post_install: - "ansible-galaxy collection install . --force" diff --git a/CHANGELOG.md b/CHANGELOG.md index 07fb0f3e..0e7c1c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,48 @@ # networktocode.nautobot Release Notes +v5.5.0 +====== + +New Modules +----------- + +- networktocode.nautobot.job_button - Creates or removes job buttons from Nautobot +- networktocode.nautobot.dynamic_group - Creates or removes dynamic groups from Nautobot +- networktocode.nautobot.static_group_association - Creates or removes static group associations from Nautobot +- networktocode.nautobot.metadata_type - Creates or removes metadata types from Nautobot +- networktocode.nautobot.metadata_choice - Creates or removes metadata choices from Nautobot +- networktocode.nautobot.object_metadata - Creates or removes object metadata from Nautobot + +Minor Changes +------------- +- (#464) Added full support for caching to GraphQL Inventory plugin +- (#465) Changed `parent_location_type` to allow for explicit name attribute lookup + +v5.4.0 +====== + +New Modules +----------- + +- networktocode.nautobot.cloud_account - Creates or removes cloud accounts from Nautobot +- networktocode.nautobot.cloud_network - Creates or removes cloud networks from Nautobot +- networktocode.nautobot.cloud_resource_type - Creates or removes cloud resource types from Nautobot +- networktocode.nautobot.cloud_service - Creates or removes cloud services from Nautobot +- networktocode.nautobot.cloud_service_network_assignment - Creates or removes cloud service network assignments from Nautobot +- networktocode.nautobot.cloud_network_prefix_assignment - Creates or removes cloud network prefix assignments from Nautobot +- networktocode.nautobot.module - Creates or removes modules from Nautobot +- networktocode.nautobot.module_type - Creates or removes module types from Nautobot +- networktocode.nautobot.module_bay - Creates or removes module bays from Nautobot +- networktocode.nautobot.module_bay_template - Creates or removes module bay templates from Nautobot + +Minor Changes +------------- +- (#431) Added tags and custom fields options to `cable` module +- (#433) Added role option to `device_interface` module +- (#438) Added cloud_network option to `circuit_termination` module +- (#446) Added module option to multiple existing modules +- (#449) Changed lookup plugin to allow for multiple `id` filters + v5.3.1 ====== diff --git a/Dockerfile b/Dockerfile index 5e0b4be0..99558f85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,11 @@ # # This base stage just installs the dependencies required for production # without any development deps. -ARG PYTHON_VER=3.10 +ARG PYTHON_VER=3.11 FROM python:${PYTHON_VER} AS base # Allow for flexible Python versions, for broader testing -ARG PYTHON_VER=3.10 +ARG PYTHON_VER=3.11 ENV PYTHON_VERSION=${PYTHON_VER} ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq shellcheck && apt-get clean @@ -60,7 +60,7 @@ FROM lint AS unittests ARG ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections ENV ANSIBLE_COLLECTIONS_PATH=${ANSIBLE_COLLECTIONS_PATH} -ARG PYTHON_VER=3.10 +ARG PYTHON_VER=3.11 ENV PYTHON_VERSION=${PYTHON_VER} # Allows for custom command line arguments to be passed to ansible-test (like -vvv) @@ -89,7 +89,7 @@ RUN ansible-test sanity $ANSIBLE_SANITY_ARGS \ plugins/ # Run unit tests -RUN ansible-test units $ANSIBLE_UNIT_ARGS --coverage --python ${PYTHON_VERSION} +RUN ansible-test units $ANSIBLE_UNIT_ARGS --coverage --requirements --python ${PYTHON_VERSION} ############ # Integration Tests diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ec27a261..2aca2154 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -482,3 +482,66 @@ releases: minor_changes: - (#422) Fixed `admin_permission` module to properly convert list of groups to UUIDs - (#427) Fixed setting of `default_ip_version` option. Fixed logic in `add_ip_address` that sets Ansible `host` values + 5.4.0: + modules: + - description: Creates or removes cloud accounts from Nautobot + name: cloud_account + namespace: '' + - description: Creates or removes cloud networks from Nautobot + name: cloud_network + namespace: '' + - description: Creates or removes cloud resource types from Nautobot + name: cloud_resource_type + namespace: '' + - description: Creates or removes cloud services from Nautobot + name: cloud_service + namespace: '' + - description: Creates or removes cloud service network assignments from Nautobot + name: cloud_service_network_assignment + namespace: '' + - description: Creates or removes cloud network prefix assignments from Nautobot + name: cloud_network_prefix_assignment + namespace: '' + - description: Creates or removes modules from Nautobot + name: module + namespace: '' + - description: Creates or removes module types from Nautobot + name: module_type + namespace: '' + - description: Creates or removes module bays from Nautobot + name: module_bay + namespace: '' + - description: Creates or removes module bay templates from Nautobot + name: module_bay_template + namespace: '' + changes: + minor_changes: + - (#431) Added tags and custom fields options to `cable` module + - (#433) Added role option to `device_interface` module + - (#438) Added cloud_network option to `circuit_termination` module + - (#446) Added module option to multiple existing modules + - (#449) Changed lookup plugin to allow for multiple `id` filters + 5.5.0: + modules: + - description: Creates or removes job buttons from Nautobot + name: job_button + namespace: '' + - description: Creates or removes dynamic groups from Nautobot + name: dynamic_group + namespace: '' + - description: Creates or removes static group associations from Nautobot + name: static_group_association + namespace: '' + - description: Creates or removes metadata types from Nautobot + name: metadata_type + namespace: '' + - description: Creates or removes metadata choices from Nautobot + name: metadata_choice + namespace: '' + - description: Creates or removes object metadata from Nautobot + name: object_metadata + namespace: '' + changes: + minor_changes: + - (#464) Added full support for caching to GraphQL Inventory plugin + - (#465) Changed `parent_location_type` to allow for explicit name attribute lookup diff --git a/development/Dockerfile b/development/Dockerfile index 0bc5d98e..c386bbb1 100644 --- a/development/Dockerfile +++ b/development/Dockerfile @@ -4,10 +4,13 @@ ARG PYTHON_VER FROM ghcr.io/nautobot/nautobot:${NAUTOBOT_VER}-py${PYTHON_VER} as nautobot # Copy in the requirements file -COPY ./development/requirements.txt /opt/nautobot/requirements.txt +COPY --chown=nautobot:nautobot ./development/requirements.txt /opt/nautobot/requirements.txt # Install the requirements RUN pip install -r /opt/nautobot/requirements.txt +# Copy in the jobs +COPY --chown=nautobot:nautobot ./development/jobs /opt/nautobot/jobs + # Copy in the development configuration file -COPY ./development/nautobot_config.py /opt/nautobot/nautobot_config.py +COPY --chown=nautobot:nautobot ./development/nautobot_config.py /opt/nautobot/nautobot_config.py diff --git a/development/dev.env b/development/dev.env index 79d49669..4860c015 100644 --- a/development/dev.env +++ b/development/dev.env @@ -21,6 +21,10 @@ NAUTOBOT_REDIS_PORT=6379 # NAUTOBOT_REDIS_SSL=True NAUTOBOT_SECRET_KEY=0123456789abcdef0123456789abcdef01234567 +NAUTOBOT_DEBUG=True +NAUTOBOT_LOG_DEPRECATION_WARNINGS=True +NAUTOBOT_LOG_LEVEL=DEBUG + # Needed for Postgres should match the values for Nautobot above PGPASSWORD=decinablesprewad POSTGRES_DB=nautobot diff --git a/development/docker-compose.yml b/development/docker-compose.yml index 55ce96cf..bfd000f6 100644 --- a/development/docker-compose.yml +++ b/development/docker-compose.yml @@ -23,8 +23,23 @@ services: <<: *nautobot-base worker: entrypoint: "nautobot-server rqworker" + #### ENABLE CELERY ###### + # This is what is required to add a celery worker. This broke CI so is disabled for now. + # - "sh" + # - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env + # - "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose + # depends_on: + # nautobot: + # condition: "service_healthy" + # healthcheck: + # interval: "30s" + # timeout: "10s" + # start_period: "30s" + # retries: 3 + # test: ["CMD", "bash", "-c", "nautobot-server celery inspect ping --destination celery@$$HOSTNAME"] ## $$ because of docker-compose + ########################### depends_on: - - "nautobot" + - "nautobot" <<: *nautobot-base postgres: image: "postgres:13" diff --git a/development/jobs/example_job_button_receiver.py b/development/jobs/example_job_button_receiver.py new file mode 100644 index 00000000..1735f5ee --- /dev/null +++ b/development/jobs/example_job_button_receiver.py @@ -0,0 +1,13 @@ +from nautobot.apps.jobs import JobButtonReceiver, register_jobs + + +class ExampleSimpleJobButtonReceiver(JobButtonReceiver): + class Meta: + name = "Example Simple Job Button Receiver" + + def receive_job_button(self, obj): + self.logger.info("Running Job Button Receiver.", extra={"object": obj}) + # Add job logic here + + +register_jobs(ExampleSimpleJobButtonReceiver) diff --git a/development/requirements.txt b/development/requirements.txt index d2be6f8d..00e1c8bd 100644 --- a/development/requirements.txt +++ b/development/requirements.txt @@ -1 +1 @@ -nautobot-bgp-models==0.20.0 \ No newline at end of file +nautobot-bgp-models==2.3.0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d8a4c7e3..4f9ec233 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,8 @@ x-args: &args PYTHON_VER: ${PYTHON_VER} + ANSIBLE_SANITY_ARGS: ${ANSIBLE_SANITY_ARGS:-} + ANSIBLE_UNIT_ARGS: ${ANSIBLE_UNIT_ARGS:-} # Build block with context and target default x-build: &build @@ -14,7 +16,8 @@ x-service: ANSIBLE_INTEGRATION_ARGS: ${ANSIBLE_INTEGRATION_ARGS:-} ANSIBLE_SANITY_ARGS: ${ANSIBLE_SANITY_ARGS:-} ANSIBLE_UNIT_ARGS: ${ANSIBLE_UNIT_ARGS:-} - NAUTOBOT_VER: ${INVOKE_NAUTOBOT_ANSIBLE_NAUTOBOT_VER:-} + NAUTOBOT_VER: ${NAUTOBOT_VER:-} + OUTPUT_INVENTORY_JSON: ${OUTPUT_INVENTORY_JSON:-} services: unit: @@ -33,3 +36,6 @@ services: build: <<: *build target: integration + volumes: + # This allows us to update the inventory files from inside the container + - ${PWD}/tests/integration/targets/inventory/files/:/tmp/inventory_files/ diff --git a/docs/getting_started/how-to-use/inventory.md b/docs/getting_started/how-to-use/inventory.md index a8fd3cbe..b9fe6ce6 100644 --- a/docs/getting_started/how-to-use/inventory.md +++ b/docs/getting_started/how-to-use/inventory.md @@ -11,6 +11,16 @@ compose: ansible_network_os: platform.network_driver ``` +You can also use custom fields on the device or a nested object. + +```yaml +--- +plugin: networktocode.nautobot.inventory +compose: + device_owner: custom_fields.device_owner + ansible_network_os: platforms.custom_fields.ansible_network_os +``` + ## Using Keyed Groups to set `ansible_network_os` to Platform Network Driver ```yaml diff --git a/docs/requirements.txt b/docs/requirements.txt index 96120465..bee6c684 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -ansible-core==2.15.12 +ansible-core==2.18 mkdocs==1.6.1 mkdocs-ansible-collection==0.2.0 mkdocs-material==9.5.30 diff --git a/galaxy.yml b/galaxy.yml index f770c2ae..5b0ddead 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: networktocode name: nautobot # The version of the collection. Must be compatible with semantic versioning -version: 5.3.1 +version: 5.5.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/hacking/local-test.sh b/hacking/local-test.sh index 2c6963e1..1a12affb 100755 --- a/hacking/local-test.sh +++ b/hacking/local-test.sh @@ -1,13 +1,18 @@ #!/usr/bin/env bash -# Usage: ./hacking/local-test.sh +################################################################################ +# DEPRECATED +# Run `invoke unit` or `invoke integration` to run the tests locally instead! +################################################################################ -# Run build, which will remove previously installed versions -./hacking/build.sh +# # Usage: ./hacking/local-test.sh -# Install new built version -ansible-galaxy collection install networktocode-nautobot-*.tar.gz -p . +# # Run build, which will remove previously installed versions +# ./hacking/build.sh -# You can now cd into the installed version and run tests -(cd ansible_collections/networktocode/nautobot/ && ansible-test units -v --python 3.9 && ansible-test sanity --requirements -v --python 3.9 --skip-test pep8 plugins/) -rm -rf ansible_collections +# # Install new built version +# ansible-galaxy collection install networktocode-nautobot-*.tar.gz -p . + +# # You can now cd into the installed version and run tests +# (cd ansible_collections/networktocode/nautobot/ && ansible-test units -v --python 3.9 && ansible-test sanity --requirements -v --python 3.9 --skip-test pep8 plugins/) +# rm -rf ansible_collections diff --git a/hacking/make-docs.sh b/hacking/make-docs.sh index 75594a9f..fa11c5a6 100755 --- a/hacking/make-docs.sh +++ b/hacking/make-docs.sh @@ -1,12 +1,17 @@ #!/usr/bin/env bash -# Usage: ./hacking/make-docs.sh +################################################################################ +# DEPRECATED +# Run `invoke docs` to host the docs locally instead! +################################################################################ -# Run build, which will remove previously installed versions -./hacking/build.sh +# # Usage: ./hacking/make-docs.sh -# Install new built version -ansible-galaxy collection install networktocode-nautobot-*.tar.gz -f +# # Run build, which will remove previously installed versions +# ./hacking/build.sh -# Run antisbull-docs now -antsibull-docs collection --use-current --squash-hierarchy --dest-dir docs/plugins/ networktocode.nautobot \ No newline at end of file +# # Install new built version +# ansible-galaxy collection install networktocode-nautobot-*.tar.gz -f + +# # Run antisbull-docs now +# antsibull-docs collection --use-current --squash-hierarchy --dest-dir docs/plugins/ networktocode.nautobot \ No newline at end of file diff --git a/hacking/update_test_inventories.sh b/hacking/update_test_inventories.sh index 9fb27f81..119c2b30 100755 --- a/hacking/update_test_inventories.sh +++ b/hacking/update_test_inventories.sh @@ -1,26 +1,31 @@ #!/usr/bin/env bash -# Stop on failure - if unit tests fail the inventory will not be updated -set -e +################################################################################ +# DEPRECATED +# Run `invoke integration --update-inventories` instead! +################################################################################ -# - Build Nautobot via development environment -# - Fill with test data, run ./tests/integration/nautobot-populate.py -# - Add '127.0.0.1 nautobot' to /etc/hosts -# - Run ./hacking/update_test_inventories.sh -# - Manually verify the diff of new JSON is correct, to prevent introducing a regression. +# # Stop on failure - if unit tests fail the inventory will not be updated +# set -e -# Install locally -export ANSIBLE_COLLECTIONS_PATHS=. -export OUTPUT_INVENTORY_JSON=tests/integration/targets/inventory/files +# # - Build Nautobot via development environment +# # - Fill with test data, run ./tests/integration/nautobot-populate.py +# # - Add '127.0.0.1 nautobot' to /etc/hosts +# # - Run ./hacking/update_test_inventories.sh +# # - Manually verify the diff of new JSON is correct, to prevent introducing a regression. -# Remove local cache -rm -rf /tmp/inventory_nautobot/ +# # Install locally +# export ANSIBLE_COLLECTIONS_PATHS=. +# export OUTPUT_INVENTORY_JSON=tests/integration/targets/inventory/files -# Clean and install the built collection -./hacking/build.sh +# # Remove local cache +# rm -rf /tmp/inventory_nautobot/ -# Install new built version -ansible-galaxy collection install networktocode-nautobot-*.tar.gz -p . +# # Clean and install the built collection +# ./hacking/build.sh -# Run the same script used by integration tests, but save the results -./tests/integration/targets/inventory/runme.sh +# # Install new built version +# ansible-galaxy collection install networktocode-nautobot-*.tar.gz -p . + +# # Run the same script used by integration tests, but save the results +# ./tests/integration/targets/inventory/runme.sh diff --git a/plugins/inventory/gql_inventory.py b/plugins/inventory/gql_inventory.py index 3f912dc3..35a6400f 100644 --- a/plugins/inventory/gql_inventory.py +++ b/plugins/inventory/gql_inventory.py @@ -374,10 +374,27 @@ def create_tag_groups(self, device, tag_attr): else: self.display.display(f"Could not find value for tags.{tag_attr} on device {device_name}") - def main(self): - """Main function.""" - if not HAS_NETUTILS: - raise AnsibleError("networktocode.nautobot.gql_inventory requires netutils. Please pip install netutils.") + def get_results(self): + """Check the cache for the results and return it if it exists, otherwise query the API and return the results.""" + json_data = None + cache_key = self.get_cache_key(self.api_endpoint) + + user_cache_setting = self.get_option("cache") + attempt_to_read_cache = user_cache_setting and self.use_cache + + need_to_fetch = True + if attempt_to_read_cache: + try: + json_data = self._cache[cache_key] + # Successfully read the cache, so we don't need to fetch the data + need_to_fetch = False + except KeyError: + self.display.v("Cache key not found in cache or it was expired.") + + if not need_to_fetch: + self.display.v("Using cached results.") + self.display.vvvv(f"Cached response: {json_data}") + return json_data base_query = { "query": { @@ -422,6 +439,19 @@ def main(self): if "errors" in json_data: raise AnsibleParserError(to_native(json_data["errors"][0]["message"])) + if user_cache_setting: + # If we got here and the user has caching enabled, we need to cache the results + self._cache[cache_key] = json_data + + return json_data + + def main(self): + """Main function.""" + if not HAS_NETUTILS: + raise AnsibleError("networktocode.nautobot.gql_inventory requires netutils. Please pip install netutils.") + + json_data = self.get_results() + for device in json_data["data"].get("devices", []) + json_data["data"].get("virtual_machines", []): hostname = device["name"] self.inventory.add_host(host=hostname) diff --git a/plugins/inventory/inventory.py b/plugins/inventory/inventory.py index 9e6d2a28..ede235d4 100644 --- a/plugins/inventory/inventory.py +++ b/plugins/inventory/inventory.py @@ -238,6 +238,9 @@ foo: last_updated bar: display nested_variable: rack.display + # You can also use custom fields on the device or a nested object + device_owner: custom_fields.device_owner + ansible_network_os: platforms.custom_fields.ansible_network_os # You can use keyed_groups to group on properties of devices or VMs. # NOTE: It's only possible to key off direct items on the device/VM objects. diff --git a/plugins/lookup/lookup.py b/plugins/lookup/lookup.py index 71e7aa41..c17d7468 100644 --- a/plugins/lookup/lookup.py +++ b/plugins/lookup/lookup.py @@ -197,6 +197,7 @@ def get_endpoint(nautobot, term): "device-types": {"endpoint": nautobot.dcim.device_types}, "device-redundancy-groups": {"endpoint": nautobot.dcim.device_redundancy_groups}, "devices": {"endpoint": nautobot.dcim.devices}, + "dynamic-groups": {"endpoint": nautobot.extras.dynamic_groups}, "export-templates": {"endpoint": nautobot.dcim.export_templates}, "front-port-templates": {"endpoint": nautobot.dcim.front_port_templates}, "front-ports": {"endpoint": nautobot.dcim.front_ports}, @@ -208,15 +209,20 @@ def get_endpoint(nautobot, term): "inventory-items": {"endpoint": nautobot.dcim.inventory_items}, "ip-addresses": {"endpoint": nautobot.ipam.ip_addresses}, "ip-address-to-interface": {"endpoint": nautobot.ipam.ip_address_to_interface}, + "job-buttons": {"endpoint": nautobot.extras.job_buttons}, + "jobs": {"endpoint": nautobot.extras.jobs}, "locations": {"endpoint": nautobot.dcim.locations}, "location-types": {"endpoint": nautobot.dcim.location_types}, "manufacturers": {"endpoint": nautobot.dcim.manufacturers}, + "metadata-choices": {"endpoint": nautobot.extras.metadata_choices}, + "metadata-types": {"endpoint": nautobot.extras.metadata_types}, "module-bay-templates": {"endpoint": nautobot.dcim.module_bay_templates}, "module-bays": {"endpoint": nautobot.dcim.module_bays}, "module-types": {"endpoint": nautobot.dcim.module_types}, "modules": {"endpoint": nautobot.dcim.modules}, "namespaces": {"endpoint": nautobot.ipam.namespaces}, "object-changes": {"endpoint": nautobot.extras.object_changes}, + "object-metadata": {"endpoint": nautobot.extras.object_metadata}, "platforms": {"endpoint": nautobot.dcim.platforms}, "power-connections": {"endpoint": nautobot.dcim.power_connections}, "power-outlet-templates": {"endpoint": nautobot.dcim.power_outlet_templates}, @@ -239,6 +245,7 @@ def get_endpoint(nautobot, term): "secrets": {"endpoint": nautobot.extras.secrets}, "secrets-groups": {"endpoint": nautobot.extras.secrets_groups}, "services": {"endpoint": nautobot.ipam.services}, + "static-group-associations": {"endpoint": nautobot.extras.static_group_associations}, "statuses": {"endpoint": nautobot.extras.statuses}, "tags": {"endpoint": nautobot.extras.tags}, "teams": {"endpoint": nautobot.extras.teams}, @@ -339,6 +346,8 @@ def run(self, terms, variables=None, **kwargs): api_token = kwargs.get("token") or os.getenv("NAUTOBOT_TOKEN") api_endpoint = kwargs.get("api_endpoint") or os.getenv("NAUTOBOT_URL") + if not api_endpoint or not api_token: + raise AnsibleError("Both api_endpoint and token are required") if kwargs.get("validate_certs") is not None: ssl_verify = kwargs.get("validate_certs") elif os.getenv("NAUTOBOT_VALIDATE_CERTS") is not None: @@ -347,6 +356,8 @@ def run(self, terms, variables=None, **kwargs): ssl_verify = True num_retries = kwargs.get("num_retries", "0") api_filter = kwargs.get("api_filter") + if api_filter: + api_filter = self._templar.do_template(api_filter) raw_return = kwargs.get("raw_data") plugin = kwargs.get("plugin") api_version = kwargs.get("api_version") @@ -355,7 +366,6 @@ def run(self, terms, variables=None, **kwargs): terms = [terms] nautobot = pynautobot.api(api_endpoint, token=api_token if api_token else None, api_version=api_version, verify=ssl_verify, retries=num_retries) - results = [] for term in terms: if plugin: diff --git a/plugins/lookup/lookup_graphql.py b/plugins/lookup/lookup_graphql.py index 8d4deaf2..701cc580 100644 --- a/plugins/lookup/lookup_graphql.py +++ b/plugins/lookup/lookup_graphql.py @@ -80,7 +80,7 @@ graph_variables: location_name: DEN query_string: | - query ($location_name:String!) { + query ($location_name:[String]) { locations (name: $location_name) { id name diff --git a/plugins/module_utils/extras.py b/plugins/module_utils/extras.py index a104c7ac..f0cdc8fa 100644 --- a/plugins/module_utils/extras.py +++ b/plugins/module_utils/extras.py @@ -10,13 +10,19 @@ ENDPOINT_NAME_MAPPING, ) +NB_DYNAMIC_GROUPS = "dynamic_groups" NB_TAGS = "tags" NB_STATUS = "statuses" NB_RELATIONSHIP_ASSOCIATIONS = "relationship_associations" +NB_STATIC_GROUP_ASSOCIATIONS = "static_group_associations" NB_CUSTOM_FIELDS = "custom_fields" NB_CUSTOM_FIELD_CHOICES = "custom_field_choices" NB_CONTACT = "contacts" NB_TEAM = "teams" +NB_JOB_BUTTONS = "job_buttons" +NB_OBJECT_METADATA = "object_metadata" +NB_METADATA_CHOICES = "metadata_choices" +NB_METADATA_TYPES = "metadata_types" class NautobotExtrasModule(NautobotModule): @@ -46,10 +52,14 @@ def run(self): name = data["name"] elif endpoint_name == "relationship_associations": name = f"{data['source_type']} -> {data['destination_type']}" + elif endpoint_name == "static_group_association": + name = f"{data['dynamic_group']} -> {data['associated_object_id']}" elif endpoint_name == "custom_field": name = data["label"] - elif endpoint_name == "custom_field_choice": + elif endpoint_name in ["custom_field_choice", "metadata_choice"]: name = data["value"] + elif endpoint_name in ["object_metadata"]: + name = data.get("value", data.get("contact", data.get("team"))) else: name = data.get("id") diff --git a/plugins/module_utils/utils.py b/plugins/module_utils/utils.py index 3a054ef1..f98a5552 100644 --- a/plugins/module_utils/utils.py +++ b/plugins/module_utils/utils.py @@ -83,8 +83,15 @@ "contacts", "custom_fields", "custom_field_choices", + "metadata_choices", + "metadata_types", + "object_metadata", + "dynamic_groups", + "jobs", + "job_buttons", "relationship_associations", "roles", + "static_group_associations", "statuses", "tags", "teams", @@ -125,6 +132,7 @@ controller="name", controller_managed_device_group="name", device="name", + dynamic_group="name", role="name", device_type="model", export_targets="name", @@ -201,6 +209,7 @@ "dcim.rearport": "rear_ports", "device": "devices", "device_type": "device_types", + "dynamic_group": "dynamic_groups", "export_targets": "route_targets", "group": "tenant_groups", "groups": "groups", @@ -210,10 +219,12 @@ "interface_template": "interface_templates", "ip_addresses": "ip_addresses", "ipaddresses": "ip_addresses", + "job": "jobs", "lag": "interfaces", "location": "locations", "location_type": "location_types", "manufacturer": "manufacturers", + "metadata_type": "metadata_types", "module_bay_template": "module_bay_templates", "module_bay": "module_bays", "module_type": "module_types", @@ -291,6 +302,7 @@ "devices": "device", "device_types": "device_type", "device_redundancy_groups": "device_redundancy_group", + "dynamic_groups": "dynamic_group", "front_ports": "front_port", "front_port_templates": "front_port_template", "groups": "group", @@ -299,14 +311,18 @@ "inventory_items": "inventory_item", "ip_addresses": "ip_address", "ip_address_to_interface": "ip_address_to_interface", + "job_buttons": "job_button", "locations": "location", "location_types": "location_type", "manufacturers": "manufacturer", + "metadata_choices": "metadata_choice", + "metadata_types": "metadata_type", "module_bay_templates": "module_bay_template", "module_bays": "module_bay", "module_types": "module_type", "modules": "module", "namespaces": "namespace", + "object_metadata": "object_metadata", "permissions": "permission", "platforms": "platform", "power_feeds": "power_feed", @@ -326,6 +342,7 @@ "roles": "role", "route_targets": "route_target", "services": "services", + "static_group_associations": "static_group_association", "statuses": "statuses", "tags": "tags", "teams": "team", @@ -378,6 +395,7 @@ "device": set(["name"]), "device_redundancy_group": set(["name"]), "device_type": set(["model"]), + "dynamic_group": set(["name"]), "front_port": set(["name", "device", "rear_port"]), "front_port_template": set(["name", "device_type", "rear_port_template"]), "group": set(["name"]), @@ -390,17 +408,22 @@ "ip_addresses": set(["address", "namespace", "device", "interfaces", "vm_interfaces"]), "ipaddresses": set(["address", "namespace", "device", "interfaces", "vm_interfaces"]), "ip_address_to_interface": set(["ip_address", "interface", "vm_interface"]), + "job_button": set(["name"]), "lag": set(["name"]), "location": set(["name", "id", "parent"]), "location_type": set(["name"]), "manufacturer": set(["name"]), "master": set(["name"]), + "metadata_choice": set(["value", "metadata_type"]), + "metadata_type": set(["name"]), "module_bay_template": set(["name"]), "module_bay": set(["name", "parent_device", "parent_module"]), "module_type": set(["model"]), "module": set(["module_type", "parent_module_bay", "location"]), "namespace": set(["name"]), "nat_inside": set(["namespace", "address"]), + "object_metadata": set(["metadata_type", "assigned_object_type", "assigned_object_id", "value"]), + "parent_location_type": set(["name"]), "parent_module_bay": set(["name", "parent_device", "parent_module"]), "parent_module": set(["module_type", "parent_module_bay"]), "parent_rack_group": set(["name"]), @@ -426,6 +449,7 @@ "role": set(["name"]), "route_target": set(["name"]), "services": set(["device", "virtual_machine", "name", "port", "protocol"]), + "static_group_association": set(["dynamic_group", "associated_object_type", "associated_object_id"]), "statuses": set(["name"]), "tags": set(["name"]), "tagged_vlans": set(["group", "name", "location", "vid", "vlan_group", "tenant"]), diff --git a/plugins/modules/device_interface.py b/plugins/modules/device_interface.py index c7b95b3f..0deb7803 100644 --- a/plugins/modules/device_interface.py +++ b/plugins/modules/device_interface.py @@ -61,6 +61,7 @@ Form factor of the interface: ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE) This has to be specified exactly as what is found within UI + - Required if I(state=present) and the interface does not exist yet required: false type: str version_added: "3.0.0" diff --git a/plugins/modules/dynamic_group.py b/plugins/modules/dynamic_group.py new file mode 100644 index 00000000..06e99205 --- /dev/null +++ b/plugins/modules/dynamic_group.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2024, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: dynamic_group +short_description: Creates or removes dynamic groups from Nautobot +description: + - Creates or removes dynamic groups from Nautobot +notes: + - Tags should be defined as a YAML list + - This should be ran with connection C(local) and hosts C(localhost) +author: + - Travis Smith (@tsm1th) +requirements: + - pynautobot +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base + - networktocode.nautobot.fragments.tags + - networktocode.nautobot.fragments.custom_fields +options: + name: + description: + - The name of the dynamic group + required: true + type: str + description: + description: + - The description of the dynamic group + required: false + type: str + group_type: + description: + - Required if I(state=present) and the dynamic group does not exist yet + choices: [ dynamic-filter, dynamic-set, static ] + required: false + type: str + content_type: + description: + - Required if I(state=present) and the dynamic group does not exist yet + - The app_label.model for the objects in the group + required: false + type: str + tenant: + description: + - The tenant that the dynamic group will be assigned to + required: false + type: raw + filter: + description: + - A dictionary of filter parameters defining membership of this group + required: false + type: dict +""" + +EXAMPLES = r""" +--- +- name: Create a dynamic group + networktocode.nautobot.dynamic_group: + url: http://nautobot.local + token: thisIsMyToken + name: TestFilterGroup + group_type: dynamic-filter + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + state: present + +- name: Delete a dynamic group + networktocode.nautobot.dynamic_group: + url: http://nautobot.local + token: thisIsMyToken + name: TestFilterGroup + state: absent +""" + +RETURN = r""" +dynamic_group: + description: Serialized object as created or already existent within Nautobot + returned: success (when I(state=present)) + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import ( + NAUTOBOT_ARG_SPEC, + TAGS_ARG_SPEC, + CUSTOM_FIELDS_ARG_SPEC, +) +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_DYNAMIC_GROUPS, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update(deepcopy(TAGS_ARG_SPEC)) + argument_spec.update(deepcopy(CUSTOM_FIELDS_ARG_SPEC)) + argument_spec.update( + dict( + name=dict(required=True, type="str"), + description=dict(required=False, type="str"), + group_type=dict(required=False, type="str", choices=["dynamic-filter", "dynamic-set", "static"]), + content_type=dict(required=False, type="str"), + tenant=dict(required=False, type="raw"), + filter=dict(required=False, type="dict"), + ) + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + dynamic_group = NautobotExtrasModule(module, NB_DYNAMIC_GROUPS) + dynamic_group.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/job_button.py b/plugins/modules/job_button.py new file mode 100644 index 00000000..b72bfd40 --- /dev/null +++ b/plugins/modules/job_button.py @@ -0,0 +1,149 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2023, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: job_button +short_description: Creates or removes job buttons from Nautobot +description: + - Creates or removes job buttons from Nautobot +notes: + - This should be ran with connection C(local) and hosts C(localhost) +author: + - Travis Smith (@tsm1th) +requirements: + - pynautobot +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base +options: + name: + description: + - The name of the job button + required: true + type: str + content_types: + description: + - The content types to associate the job button with + - Required if I(state=present) and the job button does not exist yet + required: false + type: list + elements: str + job: + description: + - The job receiver to associate job with + - Required if I(state=present) and the job button does not exist yet + required: false + type: raw + enabled: + description: + - Whether or not the button is enabled + required: false + type: bool + text: + description: + - The text to display on the button + - Required if I(state=present) and the job button does not exist yet + required: false + type: str + weight: + description: + - Position this field should be displayed in + required: false + type: int + group_name: + description: + - Buttons in the same group will appear in a dropdown menu + required: false + type: str + button_class: + description: + - Button class of this button + - Required if I(state=present) and the job button does not exist yet + required: false + choices: + - default + - primary + - success + - info + - warning + - danger + - link + type: str + confirmation: + description: + - Whether or not a confirmation pop-up box will appear + required: false + type: bool +""" + +EXAMPLES = r""" +- name: Create job button within Nautobot with only required information + networktocode.nautobot.job_button: + url: http://nautobot.local + token: thisIsMyToken + name: MyJobButton + content_types: + - dcim.device + job: MyJob + text: SubmitMe + state: present + +- name: Delete job button within Nautobot + networktocode.nautobot.job_button: + url: http://nautobot.local + token: thisIsMyToken + name: MyJobButton + state: absent +""" + +RETURN = r""" +job_button: + description: Serialized object as created or already existent within Nautobot + returned: success (when I(state=present)) + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import NAUTOBOT_ARG_SPEC +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_JOB_BUTTONS, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """Execute job button module.""" + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update( + dict( + name=dict(required=True, type="str"), + content_types=dict(required=False, type="list", elements="str"), + job=dict(required=False, type="raw"), + enabled=dict(required=False, type="bool"), + text=dict(required=False, type="str"), + weight=dict(required=False, type="int"), + group_name=dict(required=False, type="str"), + button_class=dict(required=False, choices=["default", "primary", "success", "info", "warning", "danger", "link"], type="str"), + confirmation=dict(required=False, type="bool"), + ) + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + job_button = NautobotExtrasModule(module, NB_JOB_BUTTONS) + job_button.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/metadata_choice.py b/plugins/modules/metadata_choice.py new file mode 100644 index 00000000..a66eed3a --- /dev/null +++ b/plugins/modules/metadata_choice.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2024, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: metadata_choice +short_description: Create, update or delete metadata choices within Nautobot +description: + - Creates, updates or removes metadata choices from Nautobot +notes: + - This should be ran with connection C(local) and hosts C(localhost) +author: + - Travis Smith (@tsm1th) +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base +options: + metadata_type: + description: + - The name of the metadata type + required: true + type: str + value: + description: + - The value of the metadata choice + required: true + type: str + weight: + description: + - Weight of this choice + required: false + type: int +""" + +EXAMPLES = r""" +- name: Create a metadata choice + networktocode.nautobot.metadata_choice: + url: http://nautobot.local + token: thisIsMyToken + value: "Choice 1" + weight: 100 + metadata_type: "TopSecretInfo" + state: present + +- name: Delete a metadata choice + networktocode.nautobot.metadata_choice: + url: http://nautobot.local + token: thisIsMyToken + value: "Choice 1" + metadata_type: "TopSecretInfo" + state: absent +""" + +RETURN = r""" +metadata_choice: + description: Serialized object as created or already existent within Nautobot + returned: success (when I(state=present)) + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import NAUTOBOT_ARG_SPEC +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_METADATA_CHOICES, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update( + dict( + metadata_type=dict(required=True, type="str"), + value=dict(required=True, type="str"), + weight=dict(required=False, type="int"), + ) + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + metadata_choice = NautobotExtrasModule(module, NB_METADATA_CHOICES) + metadata_choice.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/metadata_type.py b/plugins/modules/metadata_type.py new file mode 100644 index 00000000..f0107a59 --- /dev/null +++ b/plugins/modules/metadata_type.py @@ -0,0 +1,132 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2024, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: metadata_type +short_description: Create, update or delete metadata types within Nautobot +description: + - Creates, updates or removes metadata types from Nautobot +notes: + - This should be ran with connection C(local) and hosts C(localhost) +author: + - Travis Smith (@tsm1th) +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base + - networktocode.nautobot.fragments.custom_fields +options: + name: + description: + - The name of the metadata type + required: true + type: str + description: + description: + - The description of the metdata type + required: false + type: str + data_type: + description: + - Data type of this field + - Required if I(state=present) and the metadata type does not exist yet + required: false + choices: + - text + - integer + - boolean + - date + - url + - select + - multi-select + - json + - markdown + - contact-or-team + - datetime + - float + type: str + content_types: + description: + - Content types that this metadata type should be available for + - Required if I(state=present) and the metadata type does not exist yet + required: false + type: list + elements: str +""" + +EXAMPLES = r""" +- name: Create a metadata type + networktocode.nautobot.metadata_type: + url: http://nautobot.local + token: thisIsMyToken + name: TopSecretInfo + description: The topest secretest info + data_type: text + content_types: + - dcim.device + state: present + +- name: Delete a metadata type + networktocode.nautobot.metadata_type: + url: http://nautobot.local + token: thisIsMyToken + name: TopSecretInfo + state: absent +""" + +RETURN = r""" +metadata_type: + description: Serialized object as created or already existent within Nautobot + returned: success (when I(state=present)) + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import ( + NAUTOBOT_ARG_SPEC, + CUSTOM_FIELDS_ARG_SPEC, +) +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_METADATA_TYPES, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update(deepcopy(CUSTOM_FIELDS_ARG_SPEC)) + argument_spec.update( + dict( + name=dict(required=True, type="str"), + description=dict(required=False, type="str"), + data_type=dict( + required=False, + choices=["text", "integer", "boolean", "date", "url", "select", "multi-select", "json", "markdown", "contact-or-team", "datetime", "float"], + type="str", + ), + content_types=dict(required=False, type="list", elements="str"), + ) + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + metadata_type = NautobotExtrasModule(module, NB_METADATA_TYPES) + metadata_type.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/object_metadata.py b/plugins/modules/object_metadata.py new file mode 100644 index 00000000..9eacfad4 --- /dev/null +++ b/plugins/modules/object_metadata.py @@ -0,0 +1,146 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2022, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: object_metadata +short_description: Creates or removes object metadata from Nautobot +description: + - Creates or removes object metadata from Nautobot +author: + - Network to Code (@networktocode) + - Travis Smith (@tsm1th) +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base +options: + metadata_type: + description: + - The name of the metadata type + required: true + type: raw + assigned_object_type: + description: + - The app_label.model for the object in the relationship + required: true + type: str + assigned_object_id: + description: + - The UUID of the object in the relationship + required: true + type: str + value: + description: + - The value of the metadata + required: false + type: str + contact: + description: + - The contact of the metadata + required: false + type: raw + team: + description: + - The team of the metadata + required: false + type: raw + scoped_fields: + description: + - List of scoped fields, only direct fields on the model + required: false + type: list + elements: str +""" + +EXAMPLES = r""" +- name: "Test object metadata creation/deletion" + connection: local + hosts: localhost + gather_facts: False + tasks: + - name: Create object metadata + networktocode.nautobot.object_metadata: + url: http://nautobot.local + token: thisIsMyToken + metadata_type: "TopSecretInfo" + assigned_object_type: dcim.device + assigned_object_id: abcdefgh-0123-abcd-0123-abcdefghijkl + value: foobar + scoped_fields: + - name + - name: Delete object metadata + networktocode.nautobot.object_metadata: + url: http://nautobot.local + token: thisIsMyToken + metadata_type: "TopSecretInfo" + assigned_object_type: dcim.device + assigned_object_id: abcdefgh-0123-abcd-0123-abcdefghijkl + value: foobar + scoped_fields: + - name + state: absent +""" + +RETURN = r""" +object_metadata: + description: Serialized object as created/existent/updated/deleted within Nautobot + returned: always + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import NAUTOBOT_ARG_SPEC +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_OBJECT_METADATA, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update( + dict( + metadata_type=dict(required=True, type="raw"), + assigned_object_type=dict(required=True, type="str"), + assigned_object_id=dict(required=True, type="str"), + value=dict(required=False, type="str"), + contact=dict(required=False, type="raw"), + team=dict(required=False, type="raw"), + scoped_fields=dict(required=False, type="list", elements="str"), + ) + ) + + required_one_of = [ + ("value", "contact", "team"), + ] + mutually_exclusive = [ + ("value", "contact", "team"), + ] + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + ) + + object_metadata = NautobotExtrasModule(module, NB_OBJECT_METADATA) + object_metadata.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/static_group_association.py b/plugins/modules/static_group_association.py new file mode 100644 index 00000000..930338a4 --- /dev/null +++ b/plugins/modules/static_group_association.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2022, Network to Code (@networktocode) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: static_group_association +short_description: Creates or removes a static group association from Nautobot +description: + - Creates or removes a static group association from Nautobot +author: + - Network to Code (@networktocode) + - Travis Smith (@tsm1th) +version_added: "5.5.0" +extends_documentation_fragment: + - networktocode.nautobot.fragments.base + - networktocode.nautobot.fragments.custom_fields +options: + dynamic_group: + description: + - The dynamic group to add the association to + required: true + type: raw + associated_object_type: + description: + - The app_label.model for the object in the relationship + required: true + type: str + associated_object_id: + description: + - The UUID of the object in the relationship + required: true + type: str +""" + +EXAMPLES = r""" +- name: "Test static group association creation/deletion" + connection: local + hosts: localhost + gather_facts: False + tasks: + - name: Create static group association + networktocode.nautobot.static_group_association: + url: http://nautobot.local + token: thisIsMyToken + dynamic_group: 01234567-abcd-0123-abcd-012345678901 + associated_object_type: dcim.device + associated_object_id: abcdefgh-0123-abcd-0123-abcdefghijkl + + - name: Delete static group association + networktocode.nautobot.static_group_association: + url: http://nautobot.local + token: thisIsMyToken + dynamic_group: 01234567-abcd-0123-abcd-012345678901 + associated_object_type: dcim.device + associated_object_id: abcdefgh-0123-abcd-0123-abcdefghijkl + state: absent +""" + +RETURN = r""" +static_group_association: + description: Serialized object as created/existent/updated/deleted within Nautobot + returned: always + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import ( + NAUTOBOT_ARG_SPEC, + CUSTOM_FIELDS_ARG_SPEC, +) +from ansible_collections.networktocode.nautobot.plugins.module_utils.extras import ( + NautobotExtrasModule, + NB_STATIC_GROUP_ASSOCIATIONS, +) +from ansible.module_utils.basic import AnsibleModule +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) + argument_spec.update(deepcopy(CUSTOM_FIELDS_ARG_SPEC)) + argument_spec.update( + dict( + dynamic_group=dict(required=True, type="raw"), + associated_object_type=dict(required=True, type="str"), + associated_object_id=dict(required=True, type="str"), + ) + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + static_group_association = NautobotExtrasModule(module, NB_STATIC_GROUP_ASSOCIATIONS) + static_group_association.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/poetry.lock b/poetry.lock index ec9f38a2..184b01e9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,14 +1,14 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "ansible-core" -version = "2.17.6" +version = "2.18.1" description = "Radically simple IT automation" optional = false -python-versions = ">=3.10" +python-versions = ">=3.11" files = [ - {file = "ansible_core-2.17.6-py3-none-any.whl", hash = "sha256:dab09cd49fe7e17003e13188ce1ab52a0a6e5b88bc4bf29ff101cfdcb2862395"}, - {file = "ansible_core-2.17.6.tar.gz", hash = "sha256:3e53970b7cebfe2adb39b711c1e2f8bbfcbedac828da51dc0357a19070638e95"}, + {file = "ansible_core-2.18.1-py3-none-any.whl", hash = "sha256:4a312e416e09c7271188d6b8e2b1062fc6834fefd6a1814d0e02fb8aadb3e1ba"}, + {file = "ansible_core-2.18.1.tar.gz", hash = "sha256:14cac1f92bbdae881cb0616eddeb17925e8cb507e486087975e724533d9de74f"}, ] [package.dependencies] @@ -20,33 +20,30 @@ resolvelib = ">=0.5.3,<1.1.0" [[package]] name = "astroid" -version = "3.3.5" +version = "3.3.6" description = "An abstract syntax tree for Python with inference support." optional = false python-versions = ">=3.9.0" files = [ - {file = "astroid-3.3.5-py3-none-any.whl", hash = "sha256:a9d1c946ada25098d790e079ba2a1b112157278f3fb7e718ae6a9252f5835dc8"}, - {file = "astroid-3.3.5.tar.gz", hash = "sha256:5cfc40ae9f68311075d27ef68a4841bdc5cc7f6cf86671b49f00607d30188e2d"}, + {file = "astroid-3.3.6-py3-none-any.whl", hash = "sha256:db676dc4f3ae6bfe31cda227dc60e03438378d7a896aec57422c95634e8d722f"}, + {file = "astroid-3.3.6.tar.gz", hash = "sha256:6aaea045f938c735ead292204afdb977a36e989522b7833ef6fea94de743f442"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} - [[package]] name = "attrs" -version = "24.2.0" +version = "24.3.0" description = "Classes Without Boilerplate" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "attrs-24.2.0-py3-none-any.whl", hash = "sha256:81921eb96de3191c8258c199618104dd27ac608d9366f5e35d011eae1867ede2"}, - {file = "attrs-24.2.0.tar.gz", hash = "sha256:5cfb1b9148b5b086569baec03f20d7b6bf3bcacc9a42bebf87ffaaca362f6346"}, + {file = "attrs-24.3.0-py3-none-any.whl", hash = "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308"}, + {file = "attrs-24.3.0.tar.gz", hash = "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff"}, ] [package.extras] benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] @@ -67,13 +64,13 @@ dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] [[package]] name = "bandit" -version = "1.7.10" +version = "1.8.0" description = "Security oriented static analyser for python code." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "bandit-1.7.10-py3-none-any.whl", hash = "sha256:665721d7bebbb4485a339c55161ac0eedde27d51e638000d91c8c2d68343ad02"}, - {file = "bandit-1.7.10.tar.gz", hash = "sha256:59ed5caf5d92b6ada4bf65bc6437feea4a9da1093384445fed4d472acc6cff7b"}, + {file = "bandit-1.8.0-py3-none-any.whl", hash = "sha256:b1a61d829c0968aed625381e426aa378904b996529d048f8d908fa28f6b13e38"}, + {file = "bandit-1.8.0.tar.gz", hash = "sha256:b5bfe55a095abd9fe20099178a7c6c060f844bfd4fe4c76d28e35e4c52b9d31e"}, ] [package.dependencies] @@ -126,8 +123,6 @@ mypy-extensions = ">=0.4.3" packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] @@ -137,13 +132,13 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" -version = "2024.8.30" +version = "2024.12.14" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, - {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, + {file = "certifi-2024.12.14-py3-none-any.whl", hash = "sha256:1275f7a45be9464efc1173084eaa30f866fe2e47d389406136d332ed4967ec56"}, + {file = "certifi-2024.12.14.tar.gz", hash = "sha256:b650d30f370c2b724812bee08008be0c4163b163ddaec3f2546c1caf65f191db"}, ] [[package]] @@ -364,117 +359,53 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -[[package]] -name = "coverage" -version = "7.3.2" -description = "Code coverage measurement for Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "coverage-7.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d872145f3a3231a5f20fd48500274d7df222e291d90baa2026cc5152b7ce86bf"}, - {file = "coverage-7.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:310b3bb9c91ea66d59c53fa4989f57d2436e08f18fb2f421a1b0b6b8cc7fffda"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f47d39359e2c3779c5331fc740cf4bce6d9d680a7b4b4ead97056a0ae07cb49a"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aa72dbaf2c2068404b9870d93436e6d23addd8bbe9295f49cbca83f6e278179c"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:beaa5c1b4777f03fc63dfd2a6bd820f73f036bfb10e925fce067b00a340d0f3f"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:dbc1b46b92186cc8074fee9d9fbb97a9dd06c6cbbef391c2f59d80eabdf0faa6"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:315a989e861031334d7bee1f9113c8770472db2ac484e5b8c3173428360a9148"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d1bc430677773397f64a5c88cb522ea43175ff16f8bfcc89d467d974cb2274f9"}, - {file = "coverage-7.3.2-cp310-cp310-win32.whl", hash = "sha256:a889ae02f43aa45032afe364c8ae84ad3c54828c2faa44f3bfcafecb5c96b02f"}, - {file = "coverage-7.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:c0ba320de3fb8c6ec16e0be17ee1d3d69adcda99406c43c0409cb5c41788a611"}, - {file = "coverage-7.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ac8c802fa29843a72d32ec56d0ca792ad15a302b28ca6203389afe21f8fa062c"}, - {file = "coverage-7.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:89a937174104339e3a3ffcf9f446c00e3a806c28b1841c63edb2b369310fd074"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e267e9e2b574a176ddb983399dec325a80dbe161f1a32715c780b5d14b5f583a"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2443cbda35df0d35dcfb9bf8f3c02c57c1d6111169e3c85fc1fcc05e0c9f39a3"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4175e10cc8dda0265653e8714b3174430b07c1dca8957f4966cbd6c2b1b8065a"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0cbf38419fb1a347aaf63481c00f0bdc86889d9fbf3f25109cf96c26b403fda1"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5c913b556a116b8d5f6ef834038ba983834d887d82187c8f73dec21049abd65c"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1981f785239e4e39e6444c63a98da3a1db8e971cb9ceb50a945ba6296b43f312"}, - {file = "coverage-7.3.2-cp311-cp311-win32.whl", hash = "sha256:43668cabd5ca8258f5954f27a3aaf78757e6acf13c17604d89648ecc0cc66640"}, - {file = "coverage-7.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10c39c0452bf6e694511c901426d6b5ac005acc0f78ff265dbe36bf81f808a2"}, - {file = "coverage-7.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:4cbae1051ab791debecc4a5dcc4a1ff45fc27b91b9aee165c8a27514dd160836"}, - {file = "coverage-7.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12d15ab5833a997716d76f2ac1e4b4d536814fc213c85ca72756c19e5a6b3d63"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c7bba973ebee5e56fe9251300c00f1579652587a9f4a5ed8404b15a0471f216"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe494faa90ce6381770746077243231e0b83ff3f17069d748f645617cefe19d4"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6e9589bd04d0461a417562649522575d8752904d35c12907d8c9dfeba588faf"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d51ac2a26f71da1b57f2dc81d0e108b6ab177e7d30e774db90675467c847bbdf"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:99b89d9f76070237975b315b3d5f4d6956ae354a4c92ac2388a5695516e47c84"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fa28e909776dc69efb6ed975a63691bc8172b64ff357e663a1bb06ff3c9b589a"}, - {file = "coverage-7.3.2-cp312-cp312-win32.whl", hash = "sha256:289fe43bf45a575e3ab10b26d7b6f2ddb9ee2dba447499f5401cfb5ecb8196bb"}, - {file = "coverage-7.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:7dbc3ed60e8659bc59b6b304b43ff9c3ed858da2839c78b804973f613d3e92ed"}, - {file = "coverage-7.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f94b734214ea6a36fe16e96a70d941af80ff3bfd716c141300d95ebc85339738"}, - {file = "coverage-7.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:af3d828d2c1cbae52d34bdbb22fcd94d1ce715d95f1a012354a75e5913f1bda2"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630b13e3036e13c7adc480ca42fa7afc2a5d938081d28e20903cf7fd687872e2"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c9eacf273e885b02a0273bb3a2170f30e2d53a6d53b72dbe02d6701b5296101c"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8f17966e861ff97305e0801134e69db33b143bbfb36436efb9cfff6ec7b2fd9"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b4275802d16882cf9c8b3d057a0839acb07ee9379fa2749eca54efbce1535b82"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:72c0cfa5250f483181e677ebc97133ea1ab3eb68645e494775deb6a7f6f83901"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:cb536f0dcd14149425996821a168f6e269d7dcd2c273a8bff8201e79f5104e76"}, - {file = "coverage-7.3.2-cp38-cp38-win32.whl", hash = "sha256:307adb8bd3abe389a471e649038a71b4eb13bfd6b7dd9a129fa856f5c695cf92"}, - {file = "coverage-7.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:88ed2c30a49ea81ea3b7f172e0269c182a44c236eb394718f976239892c0a27a"}, - {file = "coverage-7.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b631c92dfe601adf8f5ebc7fc13ced6bb6e9609b19d9a8cd59fa47c4186ad1ce"}, - {file = "coverage-7.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d3d9df4051c4a7d13036524b66ecf7a7537d14c18a384043f30a303b146164e9"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f7363d3b6a1119ef05015959ca24a9afc0ea8a02c687fe7e2d557705375c01f"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f11cc3c967a09d3695d2a6f03fb3e6236622b93be7a4b5dc09166a861be6d25"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:149de1d2401ae4655c436a3dced6dd153f4c3309f599c3d4bd97ab172eaf02d9"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3a4006916aa6fee7cd38db3bfc95aa9c54ebb4ffbfc47c677c8bba949ceba0a6"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9028a3871280110d6e1aa2df1afd5ef003bab5fb1ef421d6dc748ae1c8ef2ebc"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9f805d62aec8eb92bab5b61c0f07329275b6f41c97d80e847b03eb894f38d083"}, - {file = "coverage-7.3.2-cp39-cp39-win32.whl", hash = "sha256:d1c88ec1a7ff4ebca0219f5b1ef863451d828cccf889c173e1253aa84b1e07ce"}, - {file = "coverage-7.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b4767da59464bb593c07afceaddea61b154136300881844768037fd5e859353f"}, - {file = "coverage-7.3.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:ae97af89f0fbf373400970c0a21eef5aa941ffeed90aee43650b81f7d7f47637"}, - {file = "coverage-7.3.2.tar.gz", hash = "sha256:be32ad29341b0170e795ca590e1c07e81fc061cb5b10c74ce7203491484404ef"}, -] - -[package.extras] -toml = ["tomli"] - [[package]] name = "cryptography" -version = "43.0.3" +version = "44.0.0" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false -python-versions = ">=3.7" -files = [ - {file = "cryptography-43.0.3-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:bf7a1932ac4176486eab36a19ed4c0492da5d97123f1406cf15e41b05e787d2e"}, - {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63efa177ff54aec6e1c0aefaa1a241232dcd37413835a9b674b6e3f0ae2bfd3e"}, - {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e1ce50266f4f70bf41a2c6dc4358afadae90e2a1e5342d3c08883df1675374f"}, - {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:443c4a81bb10daed9a8f334365fe52542771f25aedaf889fd323a853ce7377d6"}, - {file = "cryptography-43.0.3-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:74f57f24754fe349223792466a709f8e0c093205ff0dca557af51072ff47ab18"}, - {file = "cryptography-43.0.3-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:9762ea51a8fc2a88b70cf2995e5675b38d93bf36bd67d91721c309df184f49bd"}, - {file = "cryptography-43.0.3-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:81ef806b1fef6b06dcebad789f988d3b37ccaee225695cf3e07648eee0fc6b73"}, - {file = "cryptography-43.0.3-cp37-abi3-win32.whl", hash = "sha256:cbeb489927bd7af4aa98d4b261af9a5bc025bd87f0e3547e11584be9e9427be2"}, - {file = "cryptography-43.0.3-cp37-abi3-win_amd64.whl", hash = "sha256:f46304d6f0c6ab8e52770addfa2fc41e6629495548862279641972b6215451cd"}, - {file = "cryptography-43.0.3-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:8ac43ae87929a5982f5948ceda07001ee5e83227fd69cf55b109144938d96984"}, - {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:846da004a5804145a5f441b8530b4bf35afbf7da70f82409f151695b127213d5"}, - {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f996e7268af62598f2fc1204afa98a3b5712313a55c4c9d434aef49cadc91d4"}, - {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f7b178f11ed3664fd0e995a47ed2b5ff0a12d893e41dd0494f406d1cf555cab7"}, - {file = "cryptography-43.0.3-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:c2e6fc39c4ab499049df3bdf567f768a723a5e8464816e8f009f121a5a9f4405"}, - {file = "cryptography-43.0.3-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:e1be4655c7ef6e1bbe6b5d0403526601323420bcf414598955968c9ef3eb7d16"}, - {file = "cryptography-43.0.3-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:df6b6c6d742395dd77a23ea3728ab62f98379eff8fb61be2744d4679ab678f73"}, - {file = "cryptography-43.0.3-cp39-abi3-win32.whl", hash = "sha256:d56e96520b1020449bbace2b78b603442e7e378a9b3bd68de65c782db1507995"}, - {file = "cryptography-43.0.3-cp39-abi3-win_amd64.whl", hash = "sha256:0c580952eef9bf68c4747774cde7ec1d85a6e61de97281f2dba83c7d2c806362"}, - {file = "cryptography-43.0.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d03b5621a135bffecad2c73e9f4deb1a0f977b9a8ffe6f8e002bf6c9d07b918c"}, - {file = "cryptography-43.0.3-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:a2a431ee15799d6db9fe80c82b055bae5a752bef645bba795e8e52687c69efe3"}, - {file = "cryptography-43.0.3-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:281c945d0e28c92ca5e5930664c1cefd85efe80e5c0d2bc58dd63383fda29f83"}, - {file = "cryptography-43.0.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:f18c716be16bc1fea8e95def49edf46b82fccaa88587a45f8dc0ff6ab5d8e0a7"}, - {file = "cryptography-43.0.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:4a02ded6cd4f0a5562a8887df8b3bd14e822a90f97ac5e544c162899bc467664"}, - {file = "cryptography-43.0.3-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:53a583b6637ab4c4e3591a15bc9db855b8d9dee9a669b550f311480acab6eb08"}, - {file = "cryptography-43.0.3-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:1ec0bcf7e17c0c5669d881b1cd38c4972fade441b27bda1051665faaa89bdcaa"}, - {file = "cryptography-43.0.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2ce6fae5bdad59577b44e4dfed356944fbf1d925269114c28be377692643b4ff"}, - {file = "cryptography-43.0.3.tar.gz", hash = "sha256:315b9001266a492a6ff443b61238f956b214dbec9910a081ba5b6646a055a805"}, +python-versions = "!=3.9.0,!=3.9.1,>=3.7" +files = [ + {file = "cryptography-44.0.0-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:84111ad4ff3f6253820e6d3e58be2cc2a00adb29335d4cacb5ab4d4d34f2a123"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b15492a11f9e1b62ba9d73c210e2416724633167de94607ec6069ef724fad092"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:831c3c4d0774e488fdc83a1923b49b9957d33287de923d58ebd3cec47a0ae43f"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:761817a3377ef15ac23cd7834715081791d4ec77f9297ee694ca1ee9c2c7e5eb"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3c672a53c0fb4725a29c303be906d3c1fa99c32f58abe008a82705f9ee96f40b"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:4ac4c9f37eba52cb6fbeaf5b59c152ea976726b865bd4cf87883a7e7006cc543"}, + {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ed3534eb1090483c96178fcb0f8893719d96d5274dfde98aa6add34614e97c8e"}, + {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f3f6fdfa89ee2d9d496e2c087cebef9d4fcbb0ad63c40e821b39f74bf48d9c5e"}, + {file = "cryptography-44.0.0-cp37-abi3-win32.whl", hash = "sha256:eb33480f1bad5b78233b0ad3e1b0be21e8ef1da745d8d2aecbb20671658b9053"}, + {file = "cryptography-44.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:abc998e0c0eee3c8a1904221d3f67dcfa76422b23620173e28c11d3e626c21bd"}, + {file = "cryptography-44.0.0-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:660cb7312a08bc38be15b696462fa7cc7cd85c3ed9c576e81f4dc4d8b2b31591"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1923cb251c04be85eec9fda837661c67c1049063305d6be5721643c22dd4e2b7"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:404fdc66ee5f83a1388be54300ae978b2efd538018de18556dde92575e05defc"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:c5eb858beed7835e5ad1faba59e865109f3e52b3783b9ac21e7e47dc5554e289"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f53c2c87e0fb4b0c00fa9571082a057e37690a8f12233306161c8f4b819960b7"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:9e6fc8a08e116fb7c7dd1f040074c9d7b51d74a8ea40d4df2fc7aa08b76b9e6c"}, + {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d2436114e46b36d00f8b72ff57e598978b37399d2786fd39793c36c6d5cb1c64"}, + {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a01956ddfa0a6790d594f5b34fc1bfa6098aca434696a03cfdbe469b8ed79285"}, + {file = "cryptography-44.0.0-cp39-abi3-win32.whl", hash = "sha256:eca27345e1214d1b9f9490d200f9db5a874479be914199194e746c893788d417"}, + {file = "cryptography-44.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:708ee5f1bafe76d041b53a4f95eb28cdeb8d18da17e597d46d7833ee59b97ede"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:37d76e6863da3774cd9db5b409a9ecfd2c71c981c38788d3fcfaf177f447b731"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:f677e1268c4e23420c3acade68fac427fffcb8d19d7df95ed7ad17cdef8404f4"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:f5e7cb1e5e56ca0933b4873c0220a78b773b24d40d186b6738080b73d3d0a756"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-manylinux_2_34_aarch64.whl", hash = "sha256:8b3e6eae66cf54701ee7d9c83c30ac0a1e3fa17be486033000f2a73a12ab507c"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-manylinux_2_34_x86_64.whl", hash = "sha256:be4ce505894d15d5c5037167ffb7f0ae90b7be6f2a98f9a5c3442395501c32fa"}, + {file = "cryptography-44.0.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:62901fb618f74d7d81bf408c8719e9ec14d863086efe4185afd07c352aee1d2c"}, + {file = "cryptography-44.0.0.tar.gz", hash = "sha256:cd4e834f340b4293430701e772ec543b0fbe6c2dea510a5286fe0acabe153a02"}, ] [package.dependencies] cffi = {version = ">=1.12", markers = "platform_python_implementation != \"PyPy\""} [package.extras] -docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.1.1)"] -docstest = ["pyenchant (>=1.6.11)", "readme-renderer", "sphinxcontrib-spelling (>=4.0.1)"] -nox = ["nox"] -pep8test = ["check-sdist", "click", "mypy", "ruff"] -sdist = ["build"] +docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=3.0.0)"] +docstest = ["pyenchant (>=3)", "readme-renderer (>=30.0)", "sphinxcontrib-spelling (>=7.3.1)"] +nox = ["nox (>=2024.4.15)", "nox[uv] (>=2024.3.2)"] +pep8test = ["check-sdist", "click (>=8.0.1)", "mypy (>=1.4)", "ruff (>=0.3.6)"] +sdist = ["build (>=1.0.0)"] ssh = ["bcrypt (>=3.1.5)"] -test = ["certifi", "cryptography-vectors (==43.0.3)", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] +test = ["certifi (>=2024)", "cryptography-vectors (==44.0.0)", "pretend (>=0.7)", "pytest (>=7.4.0)", "pytest-benchmark (>=4.0)", "pytest-cov (>=2.10.1)", "pytest-xdist (>=3.5.0)"] test-randomorder = ["pytest-randomly"] [[package]] @@ -492,20 +423,6 @@ files = [ graph = ["objgraph (>=1.7.2)"] profile = ["gprof2dot (>=2022.7.29)"] -[[package]] -name = "exceptiongroup" -version = "1.2.2" -description = "Backport of PEP 654 (exception groups)" -optional = false -python-versions = ">=3.7" -files = [ - {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, - {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, -] - -[package.extras] -test = ["pytest (>=6)"] - [[package]] name = "execnet" version = "2.1.1" @@ -539,25 +456,24 @@ dev = ["flake8", "markdown", "twine", "wheel"] [[package]] name = "hypothesis" -version = "6.118.0" +version = "6.122.5" description = "A library for property-based testing" optional = false python-versions = ">=3.9" files = [ - {file = "hypothesis-6.118.0-py3-none-any.whl", hash = "sha256:40e27343570cbb65d14a4d6da5ee38286995100d4fb93d4b8038ba3669e240e5"}, - {file = "hypothesis-6.118.0.tar.gz", hash = "sha256:5568bae62a2b29c92e579589befa7773f685e3ca76ca4b9ec0b2e356dbf8541e"}, + {file = "hypothesis-6.122.5-py3-none-any.whl", hash = "sha256:c50b104d9d5163ebdeb09ccd93626343664942570bcb067c41adf10394a81caf"}, + {file = "hypothesis-6.122.5.tar.gz", hash = "sha256:e0994f04331251d51e18040f497c839a52b37669b422fe4cfef85a54d41405bf"}, ] [package.dependencies] attrs = ">=22.2.0" -exceptiongroup = {version = ">=1.0.0", markers = "python_version < \"3.11\""} sortedcontainers = ">=2.1.0,<3.0.0" [package.extras] -all = ["black (>=19.10b0)", "click (>=7.0)", "crosshair-tool (>=0.0.74)", "django (>=4.2)", "dpcontracts (>=0.4)", "hypothesis-crosshair (>=0.0.16)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.19.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2024.2)"] +all = ["black (>=19.10b0)", "click (>=7.0)", "crosshair-tool (>=0.0.78)", "django (>=4.2)", "dpcontracts (>=0.4)", "hypothesis-crosshair (>=0.0.18)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.19.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2024.2)"] cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] codemods = ["libcst (>=0.3.16)"] -crosshair = ["crosshair-tool (>=0.0.74)", "hypothesis-crosshair (>=0.0.16)"] +crosshair = ["crosshair-tool (>=0.0.78)", "hypothesis-crosshair (>=0.0.18)"] dateutil = ["python-dateutil (>=1.4)"] django = ["django (>=4.2)"] dpcontracts = ["dpcontracts (>=0.4)"] @@ -1117,27 +1033,25 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pylint" -version = "3.3.1" +version = "3.3.2" description = "python code static checker" optional = false python-versions = ">=3.9.0" files = [ - {file = "pylint-3.3.1-py3-none-any.whl", hash = "sha256:2f846a466dd023513240bc140ad2dd73bfc080a5d85a710afdb728c420a5a2b9"}, - {file = "pylint-3.3.1.tar.gz", hash = "sha256:9f3dcc87b1203e612b78d91a896407787e708b3f189b5fa0b307712d49ff0c6e"}, + {file = "pylint-3.3.2-py3-none-any.whl", hash = "sha256:77f068c287d49b8683cd7c6e624243c74f92890f767f106ffa1ddf3c0a54cb7a"}, + {file = "pylint-3.3.2.tar.gz", hash = "sha256:9ec054ec992cd05ad30a6df1676229739a73f8feeabf3912c995d17601052b01"}, ] [package.dependencies] -astroid = ">=3.3.4,<=3.4.0-dev0" +astroid = ">=3.3.5,<=3.4.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ - {version = ">=0.2", markers = "python_version < \"3.11\""}, {version = ">=0.3.7", markers = "python_version >= \"3.12\""}, {version = ">=0.3.6", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, ] isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" mccabe = ">=0.6,<0.8" platformdirs = ">=2.2.0" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} tomlkit = ">=0.10.1" [package.extras] @@ -1164,13 +1078,13 @@ extra = ["pygments (>=2.12)"] [[package]] name = "pynautobot" -version = "2.4.1" +version = "2.4.2" description = "Nautobot API client library" optional = false python-versions = "<4.0.0,>=3.8.1" files = [ - {file = "pynautobot-2.4.1-py3-none-any.whl", hash = "sha256:b40761e6429f02716720b811cda5c5bb184f3876a49bb2d4211b3c017ead9231"}, - {file = "pynautobot-2.4.1.tar.gz", hash = "sha256:239c4fd6b1daa00013bef19a473467504d3e1e7495220d0fb6a89f728dbbceaf"}, + {file = "pynautobot-2.4.2-py3-none-any.whl", hash = "sha256:65b30e9438c498c3fbbe591dd293c1a33158ba9f6d0e6ff3ebeff3c49405b559"}, + {file = "pynautobot-2.4.2.tar.gz", hash = "sha256:24de5a1a0587df18bb07b0d5f3dcbf78e883f37fa8b3825c9b7b4c5b9a1c62ec"}, ] [package.dependencies] @@ -1180,22 +1094,20 @@ urllib3 = ">=2.2.3,<3.0.0" [[package]] name = "pytest" -version = "8.3.3" +version = "8.3.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, - {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, + {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, ] [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} -exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" pluggy = ">=1.5,<2" -tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] @@ -1510,20 +1422,19 @@ files = [ [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" -typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.11\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "six" -version = "1.16.0" +version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, + {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, + {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, ] [[package]] @@ -1539,29 +1450,18 @@ files = [ [[package]] name = "stevedore" -version = "5.3.0" +version = "5.4.0" description = "Manage dynamic plugins for Python applications" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "stevedore-5.3.0-py3-none-any.whl", hash = "sha256:1efd34ca08f474dad08d9b19e934a22c68bb6fe416926479ba29e5013bcc8f78"}, - {file = "stevedore-5.3.0.tar.gz", hash = "sha256:9a64265f4060312828151c204efbe9b7a9852a0d9228756344dbc7e4023e375a"}, + {file = "stevedore-5.4.0-py3-none-any.whl", hash = "sha256:b0be3c4748b3ea7b854b265dcb4caa891015e442416422be16f8b31756107857"}, + {file = "stevedore-5.4.0.tar.gz", hash = "sha256:79e92235ecb828fe952b6b8b0c6c87863248631922c8e8e0fa5b17b232c4514d"}, ] [package.dependencies] pbr = ">=2.0.0" -[[package]] -name = "tomli" -version = "2.0.2" -description = "A lil' TOML parser" -optional = false -python-versions = ">=3.8" -files = [ - {file = "tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38"}, - {file = "tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed"}, -] - [[package]] name = "tomlkit" version = "0.13.2" @@ -1573,17 +1473,6 @@ files = [ {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, ] -[[package]] -name = "typing-extensions" -version = "4.12.2" -description = "Backported and Experimental Type Hints for Python 3.8+" -optional = false -python-versions = ">=3.8" -files = [ - {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, - {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, -] - [[package]] name = "urllib3" version = "2.2.3" @@ -1645,13 +1534,13 @@ watchmedo = ["PyYAML (>=3.10)"] [[package]] name = "zipp" -version = "3.20.2" +version = "3.21.0" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "zipp-3.20.2-py3-none-any.whl", hash = "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350"}, - {file = "zipp-3.20.2.tar.gz", hash = "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29"}, + {file = "zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931"}, + {file = "zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4"}, ] [package.extras] @@ -1664,5 +1553,5 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" -python-versions = ">=3.10,<4.0" -content-hash = "3fc93022c2aec03aa50a4a6ee9ddb7f8c4f7d2e926974875c5a363607158aef2" +python-versions = ">=3.11,<4.0" +content-hash = "0a5ef737bfd2396db04a3e4ce3c73f7773d3f931dcefc9f19194e2fa75d0b19e" diff --git a/pyproject.toml b/pyproject.toml index d4ecf35a..b35db999 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,20 +1,19 @@ [tool.poetry] name = "nautobot_ansible_modules" -version = "5.3.1" +version = "5.5.0" description = "Ansible collection to interact with Nautobot's API" authors = ["Network to Code "] license = "Apache 2.0" package-mode = false [tool.poetry.dependencies] -python = ">=3.10,<4.0" +python = ">=3.11,<4.0" netutils = "^1.2" -pynautobot = "^2.4.1" +pynautobot = "^2.4.2" ansible-core = "^2.16" [tool.poetry.dev-dependencies] black = "*" -coverage = "7.3.2" cryptography = "*" jinja2 = "*" jmespath = "*" diff --git a/tasks.py b/tasks.py index ece48055..9f6601aa 100644 --- a/tasks.py +++ b/tasks.py @@ -34,7 +34,7 @@ def is_truthy(arg): "nautobot_ansible": { "nautobot_ver": "2.0.0", "project_name": "nautobot_ansible", - "python_ver": "3.10", + "python_ver": "3.11", "local": False, "compose_dir": os.path.join(os.path.dirname(__file__), "development"), "compose_files": ["docker-compose.yml"], @@ -226,8 +226,8 @@ def post_upgrade(context): def lint(context): """Run linting tools""" context.run( - "docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from lint lint", - env={"PYTHON_VER": context["nautobot_ansible"]["python_ver"]}, + f"docker compose --project-name {context.nautobot_ansible.project_name} up --build --force-recreate --exit-code-from lint lint", + env={"PYTHON_VER": context.nautobot_ansible.python_ver}, ) @@ -239,27 +239,34 @@ def lint(context): ) def unit(context, verbose=0): """Run unit tests""" - env = {"PYTHON_VER": context["nautobot_ansible"]["python_ver"]} + env = {"PYTHON_VER": context.nautobot_ansible.python_ver} if verbose: + env["ANSIBLE_SANITY_ARGS"] = f"-{'v' * verbose}" env["ANSIBLE_UNIT_ARGS"] = f"-{'v' * verbose}" - context.run("docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from unit unit", env=env) + context.run(f"docker compose --project-name {context.nautobot_ansible.project_name} up --build --force-recreate --exit-code-from unit unit", env=env) + # Clean up after the tests + context.run(f"docker compose --project-name {context.nautobot_ansible.project_name} down") @task( help={ "verbose": "Run the tests with verbose output; can be provided multiple times for more verbosity (e.g. -v, -vv, -vvv)", "tags": "Run specific test tags (e.g. 'device' or 'location'); can be provided multiple times (e.g. --tags device --tags location)", + "update_inventories": "Update the inventory integration test JSON files with the latest data", }, iterable=["tags"], incrementable=["verbose"], ) -def integration(context, verbose=0, tags=None): +def integration(context, verbose=0, tags=None, update_inventories=False): """Run all tests including integration tests""" build(context) # Destroy any existing containers and volumes that may be left over from a previous run destroy(context) start(context) - env = {"PYTHON_VER": context["nautobot_ansible"]["python_ver"]} + env = { + "PYTHON_VER": context.nautobot_ansible.python_ver, + "NAUTOBOT_VER": context.nautobot_ansible.nautobot_ver, + } ansible_args = [] if verbose: ansible_args.append(f"-{'v' * verbose}") @@ -267,8 +274,10 @@ def integration(context, verbose=0, tags=None): ansible_args.append(f"--tags {','.join(tags)}") if ansible_args: env["ANSIBLE_INTEGRATION_ARGS"] = " ".join(ansible_args) + if update_inventories: + env["OUTPUT_INVENTORY_JSON"] = "/tmp/inventory_files" # nosec B108 context.run( - "docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from integration integration", + f"docker compose --project-name {context.nautobot_ansible.project_name} up --build --force-recreate --exit-code-from integration integration", env=env, ) # Clean up after the tests diff --git a/tests/integration/entrypoint.sh b/tests/integration/entrypoint.sh index 4d8a964a..24954d0c 100755 --- a/tests/integration/entrypoint.sh +++ b/tests/integration/entrypoint.sh @@ -34,10 +34,10 @@ function main { echo "# Running..." # shellcheck disable=SC2086 - ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --python "$PYTHON_VERSION" inventory "$@" - ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --python "$PYTHON_VERSION" regression-latest "$@" - ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --python "$PYTHON_VERSION" latest "$@" - ansible-test coverage report + ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --requirements --python "$PYTHON_VERSION" inventory "$@" + ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --requirements --python "$PYTHON_VERSION" regression-latest "$@" + ansible-test integration $ANSIBLE_INTEGRATION_ARGS --coverage --requirements --python "$PYTHON_VERSION" latest "$@" + ansible-test coverage report --requirements } main "$@" \ No newline at end of file diff --git a/tests/integration/nautobot-populate.py b/tests/integration/nautobot-populate.py index 9a4ddc57..9cd38afd 100755 --- a/tests/integration/nautobot-populate.py +++ b/tests/integration/nautobot-populate.py @@ -9,10 +9,6 @@ import pynautobot from packaging import version -# NOTE: If anything depends on specific versions of Nautobot, can check INTEGRATION_TESTS in env -# os.environ["INTEGRATION_TESTS"] - - # Set nb variable to connect to Nautobot and use the variable in future calls nb_host = os.getenv("NAUTOBOT_URL", "http://nautobot:8000") nb_token = os.getenv("NAUTOBOT_TOKEN", "0123456789abcdef0123456789abcdef01234567") @@ -76,6 +72,8 @@ def make_nautobot_calls(endpoint, payload): if nautobot_version >= version.parse("2.2"): tags.append({"name": "Controller Tag", "content_types": ["dcim.controller"]}) +if nautobot_version >= version.parse("2.3"): + tags.append({"name": "Dynamic Group Tag", "content_types": ["extras.dynamicgroup"]}) create_tags = make_nautobot_calls(nb.extras.tags, tags) @@ -621,9 +619,36 @@ def make_nautobot_calls(endpoint, payload): "type": "text", "content_types": ["circuits.circuit"], }, + { + "label": "My Device Custom Field", + "key": "my_device_custom_field", + "type": "text", + "content_types": ["dcim.device"], + }, + { + "label": "My Location Custom Field", + "key": "my_location_custom_field", + "type": "text", + "content_types": ["dcim.location"], + }, ] created_custom_fields = make_nautobot_calls(nb.extras.custom_fields, custom_fields) +# Set a custom field on a device +test100 = nb.dcim.devices.get(name="test100") +test100.custom_fields = {"my_device_custom_field": "Test Device Custom Field Value"} +test100.save() + +# Set a custom field on the location for the device +test100_location = nb.dcim.locations.get(id=test100.location.id) +test100_location.custom_fields = {"my_location_custom_field": "Test Location Custom Field Value"} +test100_location.save() + +# Enable example job for job tests +example_job_receiver = nb.extras.jobs.get(name="Example Simple Job Button Receiver") +example_job_receiver.enabled = True +example_job_receiver.save() + ############### # v2.2+ items # ############### @@ -697,6 +722,18 @@ def make_nautobot_calls(endpoint, payload): ] created_device_interface_roles = make_nautobot_calls(nb.extras.roles, device_interface_roles) + # Create metadata_type for metadata_choices + metadata_types = [ + {"name": "TestMetadataType", "data_type": "multi-select", "content_types": ["dcim.device"]}, + {"name": "TestMetadataContactType", "data_type": "contact-or-team", "content_types": ["dcim.device"]}, + {"name": "TestMetadataTextType", "data_type": "text", "content_types": ["dcim.device"]}, + ] + created_metadata_types = make_nautobot_calls(nb.extras.metadata_types, metadata_types) + + # Create dynamic group of type static assignment + dynamic_groups = [{"name": "TestStaticAssociations", "content_type": "dcim.device", "group_type": "static"}] + created_dynamic_groups = make_nautobot_calls(nb.extras.dynamic_groups, dynamic_groups) + if ERRORS: sys.exit("Errors have occurred when creating objects, and should have been printed out. Check previous output.") diff --git a/tests/integration/targets/inventory/README.md b/tests/integration/targets/inventory/README.md index 39e98fb7..3c31bab3 100644 --- a/tests/integration/targets/inventory/README.md +++ b/tests/integration/targets/inventory/README.md @@ -37,3 +37,13 @@ We use `sort` - using the `-V` flag to designate we are sorting version numbers ``` > Note: We expand the **current** version to the full major.minor.patch version automatically in CI so the sorting works correctly with this pattern. If you verify with printf, make sure you use the full version number for the current version, but the short versions for the min and max to match what automation will do. + +## Updating Inventory JSON Files + +To update the inventory JSON files, you can run the `invoke integration` task with the `--update-inventories` flag. + +```bash +invoke integration --update-inventories +``` + +> WARNING: This does not diff the files against any expected output, it simply overwrites the files with the latest data. You will need to manually verify the output is correct! diff --git a/tests/integration/targets/inventory/compare_inventory_json.py b/tests/integration/targets/inventory/compare_inventory_json.py index 3216e328..bb96a33d 100755 --- a/tests/integration/targets/inventory/compare_inventory_json.py +++ b/tests/integration/targets/inventory/compare_inventory_json.py @@ -15,17 +15,9 @@ # Nautobot includes "created" and "last_updated" times on objects. These end up in the interfaces objects that are included verbatim from the Nautobot API. # "url" may be different if local tests use a different host/port +# "natural_slug" will be different whenever we update the test data, which just causes noise in the diffs # Remove these from files saved in git as test data -KEYS_REMOVE = frozenset(["created", "id", "last_updated", "rack_id", "url", "notes_url"]) - -# Ignore these when performing diffs as they will be different for each test run -KEYS_IGNORE = frozenset(["natural_slug"]) - - -def all_keys_to_ignore(): - keys = KEYS_REMOVE.union(KEYS_IGNORE) - - return keys +KEYS_REMOVE = frozenset(["created", "id", "last_updated", "rack_id", "url", "notes_url", "natural_slug"]) # Assume the object will not be recursive, as it originally came from JSON @@ -121,42 +113,44 @@ def main(): args = parser.parse_args() - data_a = read_json(args.filename_a) - if args.write: - # When writing test data, only remove "remove_keys" that will change on every git commit. - # This makes diffs more easily readable to ensure changes to test data look correct. - remove_keys(data_a, KEYS_REMOVE) - sort_hostvar_arrays(data_a) - sort_groups(data_a) - write_json(args.filename_b, data_a) - - else: + # Read in the new file output by the ansible-inventory command data_b = read_json(args.filename_b) - # Ignore keys that we don't want to diff, in addition to the ones removed that change on every commit - keys = all_keys_to_ignore() - remove_keys(data_a, keys) - remove_keys(data_b, keys) - - sort_hostvar_arrays(data_a) + # Remove keys that we don't want to diff, in addition to the ones removed that change on every commit + remove_keys(data_b, KEYS_REMOVE) sort_hostvar_arrays(data_b) - - sort_groups(data_a) sort_groups(data_b) + # Write the cleaned data back to the file + write_json(args.filename_b, data_b) + # If we are writing new test data, we should always fail the test so we don't get false positives + sys.exit(1) + + data_a = read_json(args.filename_a) + data_b = read_json(args.filename_b) + + # Remove keys that we don't want to diff, in addition to the ones removed that change on every commit + remove_keys(data_a, KEYS_REMOVE) + remove_keys(data_b, KEYS_REMOVE) - # Perform the diff - # syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete" - # marshal=True removes any special types, allowing to be dumped as json - result = diff(data_a, data_b, marshal=True, syntax="symmetric") - - if result: - # Dictionary is not empty - print differences - print(json.dumps(result, sort_keys=True, indent=4)) - sys.exit(1) - else: - # Success, no differences - sys.exit(0) + sort_hostvar_arrays(data_a) + sort_hostvar_arrays(data_b) + + sort_groups(data_a) + sort_groups(data_b) + + # Perform the diff + # syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete" + # marshal=True removes any special types, allowing to be dumped as json + result = diff(data_a, data_b, marshal=True, syntax="symmetric") + + if result: + # Dictionary is not empty - print differences + print(json.dumps(result, sort_keys=True, indent=4)) + sys.exit(1) + else: + # Success, no differences + sys.exit(0) if __name__ == "__main__": diff --git a/tests/integration/targets/inventory/files/test_2-2.2.json b/tests/integration/targets/inventory/files/test_2-2.2.json index 6117f988..c41f7d86 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2.json +++ b/tests/integration/targets/inventory/files/test_2-2.2.json @@ -3,7 +3,9 @@ "hostvars": { "R1-Device": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -26,7 +28,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -34,7 +35,9 @@ "Test Nexus One": { "ansible_host": "172.16.180.11", "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Nexus Parent", "dns_name": "nexus.example.com", "interfaces": [ @@ -52,7 +55,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -68,7 +73,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -108,7 +112,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_59b6", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -124,10 +127,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -141,7 +142,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -158,7 +158,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -173,7 +172,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a314", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -182,7 +180,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -208,7 +205,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -224,7 +223,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_d562", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -262,7 +260,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_f322", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -278,10 +275,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -295,7 +290,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -312,7 +306,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -327,7 +320,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_be66", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -336,7 +328,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -366,7 +357,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -382,7 +375,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -410,7 +402,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_758f", "object_type": "ipam.service", "ports": [ 23 @@ -429,7 +420,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -451,7 +441,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0a6c", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -460,7 +449,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -480,7 +468,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -505,7 +492,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_45be", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -514,7 +500,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -534,7 +519,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -559,7 +543,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_2cf8", "object_type": "ipam.service", "ports": [ 22 @@ -583,7 +566,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -603,14 +585,15 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -634,7 +617,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -645,7 +627,9 @@ "pool.ntp.org" ] }, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_type": "Cisco Test", "interfaces": [ { @@ -662,7 +646,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -682,7 +668,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -720,7 +705,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -736,10 +720,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -753,7 +735,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -770,7 +751,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -785,7 +765,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_0bc5", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -794,7 +773,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -820,7 +798,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -840,7 +820,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -878,7 +857,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -894,10 +872,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8659", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -911,7 +887,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -928,7 +903,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -943,7 +917,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_be95", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -952,7 +925,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -978,7 +950,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -998,7 +972,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1032,7 +1005,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_135e", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1041,7 +1013,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1067,7 +1038,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1087,7 +1060,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1121,7 +1093,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_5982", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1130,7 +1101,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1164,7 +1134,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1184,7 +1156,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1225,7 +1196,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1254,7 +1224,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1269,7 +1238,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_a068", "object_type": "ipam.service", "ports": [ 80 @@ -1288,7 +1256,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1308,7 +1278,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1334,7 +1303,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_aac7", "object_type": "ipam.service", "ports": [ 22 @@ -1353,7 +1321,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -1378,7 +1345,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_7ee5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1387,7 +1353,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1407,7 +1372,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1432,7 +1396,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_4371", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1441,7 +1404,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1461,7 +1423,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1486,7 +1447,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_f824", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1495,7 +1455,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1515,7 +1474,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1540,7 +1498,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_3bb5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1549,7 +1506,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1569,7 +1525,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1594,7 +1549,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0ba2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1603,7 +1557,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1623,7 +1576,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1651,7 +1603,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1674,7 +1625,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_87dc", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1683,7 +1633,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1703,7 +1652,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1728,7 +1676,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_9cfb", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1737,7 +1684,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1757,7 +1703,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1782,7 +1727,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_8aee", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1791,7 +1735,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1811,7 +1754,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1836,7 +1778,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4f29", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1845,7 +1786,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1865,7 +1805,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1890,7 +1829,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_d390", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1899,7 +1837,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1919,7 +1856,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1947,7 +1883,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1972,7 +1907,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1997,7 +1931,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -2017,7 +1950,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2-2.2_legacy.json b/tests/integration/targets/inventory/files/test_2-2.2_legacy.json index 1dcf9527..3de0f8be 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_legacy.json +++ b/tests/integration/targets/inventory/files/test_2-2.2_legacy.json @@ -2,7 +2,9 @@ "_meta": { "hostvars": { "R1-Device": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -35,14 +37,15 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] }, "Test Nexus One": { "ansible_host": "172.16.180.11", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -70,7 +73,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -86,7 +91,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -114,7 +118,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_758f", "object_type": "ipam.service", "ports": [ 23 @@ -133,7 +136,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -155,7 +157,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_2cf8", "object_type": "ipam.service", "ports": [ 22 @@ -179,7 +180,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -199,13 +199,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -239,13 +240,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] }, "test100": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_roles": [ "Core Switch" ], @@ -276,7 +278,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -296,7 +300,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -337,7 +340,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -366,7 +368,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -381,7 +382,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_a068", "object_type": "ipam.service", "ports": [ 80 @@ -400,7 +400,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -420,7 +422,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -446,7 +447,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_aac7", "object_type": "ipam.service", "ports": [ 22 @@ -465,7 +465,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -495,7 +494,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -521,7 +519,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -547,7 +544,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -573,7 +569,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -594,7 +589,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2-2.2_options.json b/tests/integration/targets/inventory/files/test_2-2.2_options.json index f4e7bba2..9e82b75b 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_options.json +++ b/tests/integration/targets/inventory/files/test_2-2.2_options.json @@ -2,7 +2,9 @@ "_meta": { "hostvars": { "R1-Device": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "display": "R1-Device", "is_virtual": false, @@ -24,10 +26,11 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "Test Location Custom Field Value" }, "Test VM With Spaces": { "cluster": "Test Cluster 2", @@ -42,13 +45,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "display": "TestDeviceR1", "is_virtual": false, @@ -71,14 +75,17 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "" }, "VC1": { "ansible_host": "nexus.example.com", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Nexus Parent", "display": "Test Nexus One", "dns_name": "nexus.example.com", @@ -97,13 +104,16 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "Test Location Custom Field Value" }, "test100": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_type": "Cisco Test", "display": "test100", "is_virtual": false, @@ -125,12 +135,13 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], "tenant": "Test Tenant", - "tenant_group": "Test Tenant Group" + "tenant_group": "Test Tenant Group", + "testing_device_cf": "Test Device Custom Field Value", + "testing_location_cf": "Test Location Custom Field Value" }, "test100-vm": { "cluster": "Test Cluster", @@ -150,7 +161,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -173,7 +183,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -196,7 +205,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -219,7 +227,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -237,7 +244,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2-2.2_options.yml b/tests/integration/targets/inventory/files/test_2-2.2_options.yml index 50875085..a2eff86d 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_options.yml +++ b/tests/integration/targets/inventory/files/test_2-2.2_options.yml @@ -51,6 +51,8 @@ compose: display: display rack_id: rack.id ntp_servers: config_context.ntp_servers + testing_device_cf: custom_fields.my_device_custom_field + testing_location_cf: location.custom_fields.my_location_custom_field keyed_groups: - prefix: rack diff --git a/tests/integration/targets/inventory/files/test_2-2.2_options_flatten.json b/tests/integration/targets/inventory/files/test_2-2.2_options_flatten.json index cc1fcbe9..5fe349b0 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_options_flatten.json +++ b/tests/integration/targets/inventory/files/test_2-2.2_options_flatten.json @@ -11,6 +11,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Main Test Rack", "rack_groups": [ "Parent Rack Group" @@ -24,7 +25,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -48,7 +48,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -64,7 +66,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -104,7 +105,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_59b6", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -120,10 +120,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -137,7 +135,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -154,7 +151,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -169,7 +165,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a314", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -178,7 +173,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -204,7 +198,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -220,7 +216,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_d562", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -258,7 +253,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_f322", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -274,10 +268,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -291,7 +283,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -308,7 +299,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -323,7 +313,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_be66", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -332,7 +321,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -352,6 +340,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "primary_ip4": "172.16.180.11", "role": "Core Switch", "services": [ @@ -362,7 +351,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -378,7 +369,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -406,7 +396,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_758f", "object_type": "ipam.service", "ports": [ 23 @@ -425,7 +414,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -445,7 +433,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0a6c", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -454,7 +441,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -474,7 +460,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -499,7 +484,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_45be", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -508,7 +492,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -528,7 +511,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -553,7 +535,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_2cf8", "object_type": "ipam.service", "ports": [ 22 @@ -577,7 +558,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -597,7 +577,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -613,6 +592,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Sub Test Rack", "rack_groups": [ "Child Rack Group", @@ -626,7 +606,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -648,7 +627,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -668,7 +649,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -706,7 +686,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -722,10 +701,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -739,7 +716,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -756,7 +732,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -771,7 +746,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_0bc5", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -780,7 +754,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -806,7 +779,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -826,7 +801,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -864,7 +838,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -880,10 +853,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8659", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -897,7 +868,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -914,7 +884,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -929,7 +898,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_be95", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -938,7 +906,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -964,7 +931,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -984,7 +953,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1018,7 +986,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_135e", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1027,7 +994,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1053,7 +1019,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1073,7 +1041,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1107,7 +1074,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_5982", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1116,7 +1082,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1141,6 +1106,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": "Test Device Custom Field Value", "ntp_servers": [ "pool.ntp.org" ], @@ -1153,7 +1119,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1173,7 +1141,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1214,7 +1181,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1243,7 +1209,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1258,7 +1223,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_a068", "object_type": "ipam.service", "ports": [ 80 @@ -1277,7 +1241,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1297,7 +1263,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1323,7 +1288,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_aac7", "object_type": "ipam.service", "ports": [ 22 @@ -1342,7 +1306,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -1365,7 +1328,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_7ee5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1374,7 +1336,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1394,7 +1355,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1419,7 +1379,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_4371", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1428,7 +1387,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1448,7 +1406,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1473,7 +1430,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_f824", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1482,7 +1438,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1502,7 +1457,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1527,7 +1481,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_3bb5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1536,7 +1489,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1556,7 +1508,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1581,7 +1532,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0ba2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1590,7 +1540,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1610,7 +1559,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1638,7 +1586,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1659,7 +1606,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_87dc", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1668,7 +1614,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1688,7 +1633,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1713,7 +1657,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_9cfb", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1722,7 +1665,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1742,7 +1684,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1767,7 +1708,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_8aee", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1776,7 +1716,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1796,7 +1735,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1821,7 +1759,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4f29", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1830,7 +1767,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1850,7 +1786,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1875,7 +1810,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_d390", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1884,7 +1818,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1904,7 +1837,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1932,7 +1864,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1955,7 +1886,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1978,7 +1908,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1996,7 +1925,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2-2.2_plurals.json b/tests/integration/targets/inventory/files/test_2-2.2_plurals.json index 343851fd..7a374ceb 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_plurals.json +++ b/tests/integration/targets/inventory/files/test_2-2.2_plurals.json @@ -5,7 +5,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -39,7 +41,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -49,7 +50,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -72,7 +75,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -88,7 +93,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -128,7 +132,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_59b6", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -144,10 +147,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -161,7 +162,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -178,7 +178,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -193,7 +192,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a314", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -202,7 +200,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -228,7 +225,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -244,7 +243,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_d562", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -282,7 +280,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_f322", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -298,10 +295,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -315,7 +310,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -332,7 +326,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -347,7 +340,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_be66", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -356,7 +348,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -390,7 +381,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -406,7 +399,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_9171", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -434,7 +426,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_758f", "object_type": "ipam.service", "ports": [ 23 @@ -453,7 +444,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -477,7 +467,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0a6c", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -486,7 +475,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -506,7 +494,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -531,7 +518,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_45be", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -540,7 +526,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -560,7 +545,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -588,7 +572,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_2cf8", "object_type": "ipam.service", "ports": [ 22 @@ -612,7 +595,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_e84a", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -632,7 +614,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -641,7 +622,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -676,7 +659,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -689,7 +671,9 @@ ] } ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_roles": [ "Core Switch" ], @@ -711,7 +695,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -731,7 +717,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -769,7 +754,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -785,10 +769,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_c00f", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -802,7 +784,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -819,7 +800,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -834,7 +814,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_0bc5", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -843,7 +822,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -869,7 +847,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -889,7 +869,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -927,7 +906,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -943,10 +921,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_2d05", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8659", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -960,7 +936,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tenant": null, @@ -977,7 +952,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -992,7 +966,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_be95", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1001,7 +974,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1027,7 +999,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1047,7 +1021,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1081,7 +1054,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_135e", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1090,7 +1062,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1116,7 +1087,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1136,7 +1109,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1170,7 +1142,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_5982", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1179,7 +1150,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1216,7 +1186,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1236,7 +1208,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1277,7 +1248,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_57e3", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1306,7 +1276,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_6117", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1321,7 +1290,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_a068", "object_type": "ipam.service", "ports": [ 80 @@ -1340,7 +1308,9 @@ "asset_tag": null, "cluster": null, "comments": "", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1360,7 +1330,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_12cb", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1386,7 +1355,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_aac7", "object_type": "ipam.service", "ports": [ 22 @@ -1405,7 +1373,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -1434,7 +1401,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_7ee5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1443,7 +1409,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1463,7 +1428,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1488,7 +1452,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_4371", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1497,7 +1460,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1517,7 +1479,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1542,7 +1503,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_f824", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1551,7 +1511,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1571,7 +1530,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1596,7 +1554,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_3bb5", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1605,7 +1562,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1625,7 +1581,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1650,7 +1605,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0ba2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1659,7 +1613,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1679,7 +1632,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_bc38", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1710,7 +1662,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -1735,7 +1686,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_87dc", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1744,7 +1694,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1764,7 +1713,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1789,7 +1737,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_9cfb", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1798,7 +1745,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1818,7 +1764,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1843,7 +1788,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_8aee", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1852,7 +1796,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1872,7 +1815,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1897,7 +1839,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4f29", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1906,7 +1847,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1926,7 +1866,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1951,7 +1890,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_d390", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1960,7 +1898,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1980,7 +1917,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_6d1d", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -2011,7 +1947,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -2041,7 +1976,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -2071,7 +2005,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -2096,7 +2029,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2-2.2_plurals_flatten.json b/tests/integration/targets/inventory/files/test_2-2.2_plurals_flatten.json index 9b04f777..77409822 100644 --- a/tests/integration/targets/inventory/files/test_2-2.2_plurals_flatten.json +++ b/tests/integration/targets/inventory/files/test_2-2.2_plurals_flatten.json @@ -20,6 +20,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "rack_groups": [ "Parent Rack Group" ], @@ -33,7 +34,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -58,6 +58,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "primary_ip4": "172.16.180.11", "status": { "color": "4caf50", @@ -65,7 +66,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -84,7 +84,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -109,6 +108,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "rack_groups": [ "Child Rack Group", "Parent Rack Group" @@ -122,7 +122,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -150,6 +149,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": "Test Device Custom Field Value", "ntp_servers": [ "pool.ntp.org" ], @@ -159,7 +159,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [], @@ -187,7 +186,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -211,7 +209,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -235,7 +232,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -259,7 +255,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] @@ -278,7 +273,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_efb8", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-2.3.json b/tests/integration/targets/inventory/files/test_2.2-2.3.json index 83ec8f39..bc65dd98 100644 --- a/tests/integration/targets/inventory/files/test_2.2-2.3.json +++ b/tests/integration/targets/inventory/files/test_2.2-2.3.json @@ -3,7 +3,9 @@ "hostvars": { "R1-Device": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -26,7 +28,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -34,7 +35,9 @@ "Test Nexus One": { "ansible_host": "172.16.180.11", "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Nexus Parent", "dns_name": "nexus.example.com", "interfaces": [ @@ -53,7 +56,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -69,7 +74,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -110,7 +114,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_69d8", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -125,10 +128,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -142,7 +143,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -159,7 +159,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -174,7 +173,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a1b2", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -183,7 +181,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -210,7 +207,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -226,7 +225,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_cb9c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -265,7 +263,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_ee65", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -280,10 +277,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -297,7 +292,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -314,7 +308,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -329,7 +322,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_93db", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -338,7 +330,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -369,7 +360,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -385,7 +378,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -414,7 +406,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_067d", "object_type": "ipam.service", "ports": [ 23 @@ -433,7 +424,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -455,7 +445,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_f6c0", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -464,7 +453,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -484,7 +472,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -510,7 +497,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_f6e3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -519,7 +505,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -539,7 +524,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -565,7 +549,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cad2", "object_type": "ipam.service", "ports": [ 22 @@ -589,7 +572,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -610,14 +592,15 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -641,7 +624,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -652,7 +634,9 @@ "pool.ntp.org" ] }, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_type": "Cisco Test", "interfaces": [ { @@ -670,7 +654,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -690,7 +676,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -729,7 +714,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -744,10 +728,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -761,7 +743,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -778,7 +759,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -793,7 +773,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_02a0", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -802,7 +781,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -829,7 +807,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -849,7 +829,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -888,7 +867,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -903,10 +881,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8425", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -920,7 +896,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -937,7 +912,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -952,7 +926,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_e074", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -961,7 +934,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -988,7 +960,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1008,7 +982,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1043,7 +1016,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_8438", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1052,7 +1024,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1079,7 +1050,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1099,7 +1072,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1134,7 +1106,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_854c", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1143,7 +1114,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1178,7 +1148,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1198,7 +1170,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1240,7 +1211,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1269,7 +1239,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1284,7 +1253,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_3116", "object_type": "ipam.service", "ports": [ 80 @@ -1304,7 +1272,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1324,7 +1294,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1351,7 +1320,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_bfcf", "object_type": "ipam.service", "ports": [ 22 @@ -1370,7 +1338,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -1395,7 +1362,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_cc3f", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1404,7 +1370,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1424,7 +1389,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1450,7 +1414,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_02b8", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1459,7 +1422,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1479,7 +1441,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1505,7 +1466,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_e6d3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1514,7 +1474,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1534,7 +1493,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1560,7 +1518,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_46e2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1569,7 +1526,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1589,7 +1545,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1615,7 +1570,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_f394", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1624,7 +1578,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1644,7 +1597,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1673,7 +1625,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -1696,7 +1647,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_9dea", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1705,7 +1655,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1725,7 +1674,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1751,7 +1699,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_5f26", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1760,7 +1707,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1780,7 +1726,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1806,7 +1751,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_3f34", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1815,7 +1759,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1835,7 +1778,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1861,7 +1803,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4b7e", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1870,7 +1811,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1890,7 +1830,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1916,7 +1855,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_82d6", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1925,7 +1863,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1945,7 +1882,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1974,7 +1910,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -1999,7 +1934,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2024,7 +1958,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2044,7 +1977,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-2.3_options_flatten.json b/tests/integration/targets/inventory/files/test_2.2-2.3_options_flatten.json index 0db1a04d..151c6e66 100644 --- a/tests/integration/targets/inventory/files/test_2.2-2.3_options_flatten.json +++ b/tests/integration/targets/inventory/files/test_2.2-2.3_options_flatten.json @@ -11,6 +11,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Main Test Rack", "rack_groups": [ "Parent Rack Group" @@ -24,7 +25,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -49,7 +49,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -65,7 +67,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -106,7 +107,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_69d8", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -121,10 +121,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -138,7 +136,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -155,7 +152,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -170,7 +166,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a1b2", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -179,7 +174,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -206,7 +200,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -222,7 +218,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_cb9c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -261,7 +256,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_ee65", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -276,10 +270,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -293,7 +285,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -310,7 +301,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -325,7 +315,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_93db", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -334,7 +323,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -354,6 +342,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "primary_ip4": "172.16.180.11", "role": "Core Switch", "services": [ @@ -365,7 +354,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -381,7 +372,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -410,7 +400,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_067d", "object_type": "ipam.service", "ports": [ 23 @@ -429,7 +418,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -449,7 +437,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_f6c0", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -458,7 +445,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -478,7 +464,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -504,7 +489,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_f6e3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -513,7 +497,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -533,7 +516,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -559,7 +541,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cad2", "object_type": "ipam.service", "ports": [ 22 @@ -583,7 +564,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -604,7 +584,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -620,6 +599,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Sub Test Rack", "rack_groups": [ "Child Rack Group", @@ -633,7 +613,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -656,7 +635,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -676,7 +657,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -715,7 +695,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -730,10 +709,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -747,7 +724,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -764,7 +740,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -779,7 +754,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_02a0", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -788,7 +762,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -815,7 +788,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -835,7 +810,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -874,7 +848,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -889,10 +862,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8425", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -906,7 +877,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -923,7 +893,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -938,7 +907,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_e074", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -947,7 +915,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -974,7 +941,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -994,7 +963,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1029,7 +997,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_8438", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1038,7 +1005,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1065,7 +1031,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1085,7 +1053,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1120,7 +1087,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_854c", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1129,7 +1095,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1154,6 +1119,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": "Test Device Custom Field Value", "ntp_servers": [ "pool.ntp.org" ], @@ -1167,7 +1133,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1187,7 +1155,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1229,7 +1196,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1258,7 +1224,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1273,7 +1238,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_3116", "object_type": "ipam.service", "ports": [ 80 @@ -1293,7 +1257,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1313,7 +1279,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1340,7 +1305,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_bfcf", "object_type": "ipam.service", "ports": [ 22 @@ -1359,7 +1323,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -1382,7 +1345,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_cc3f", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1391,7 +1353,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1411,7 +1372,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1437,7 +1397,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_02b8", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1446,7 +1405,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1466,7 +1424,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1492,7 +1449,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_e6d3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1501,7 +1457,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1521,7 +1476,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1547,7 +1501,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_46e2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1556,7 +1509,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1576,7 +1528,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1602,7 +1553,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_f394", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1611,7 +1561,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1631,7 +1580,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1660,7 +1608,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -1681,7 +1628,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_9dea", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1690,7 +1636,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1710,7 +1655,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1736,7 +1680,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_5f26", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1745,7 +1688,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1765,7 +1707,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1791,7 +1732,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_3f34", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1800,7 +1740,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1820,7 +1759,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1846,7 +1784,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4b7e", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1855,7 +1792,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1875,7 +1811,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1901,7 +1836,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_82d6", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1910,7 +1844,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1930,7 +1863,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1959,7 +1891,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -1982,7 +1913,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2005,7 +1935,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2023,7 +1952,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-2.3_plurals.json b/tests/integration/targets/inventory/files/test_2.2-2.3_plurals.json index 7c3e3a5e..372354c5 100644 --- a/tests/integration/targets/inventory/files/test_2.2-2.3_plurals.json +++ b/tests/integration/targets/inventory/files/test_2.2-2.3_plurals.json @@ -5,7 +5,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -39,7 +41,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -49,7 +50,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -73,7 +76,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -89,7 +94,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -130,7 +134,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_69d8", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -145,10 +148,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -162,7 +163,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -179,7 +179,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -194,7 +193,6 @@ "mode": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "ethernet1-1_test-nexus-one__child-test-location_parent-test-location_a1b2", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -203,7 +201,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -230,7 +227,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -246,7 +245,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_cb9c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -285,7 +283,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_ee65", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -300,10 +297,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -317,7 +312,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -334,7 +328,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -349,7 +342,6 @@ "mode": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "ethernet2-1_test-nexus-child-one__child-test-location_parent-test-location_93db", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -358,7 +350,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -393,7 +384,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -409,7 +402,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -438,7 +430,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_067d", "object_type": "ipam.service", "ports": [ 23 @@ -457,7 +448,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -481,7 +471,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_f6c0", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -490,7 +479,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -510,7 +498,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -536,7 +523,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_f6e3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -545,7 +531,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -565,7 +550,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -594,7 +578,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cad2", "object_type": "ipam.service", "ports": [ 22 @@ -618,7 +601,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -639,7 +621,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -648,7 +629,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -683,7 +666,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -696,7 +678,9 @@ ] } ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_roles": [ "Core Switch" ], @@ -719,7 +703,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -739,7 +725,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -778,7 +763,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -793,10 +777,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_ab44", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -810,7 +792,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -827,7 +808,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -842,7 +822,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "gigabitethernet1_test100_test-tenant_child-test-location_parent-test-location_02a0", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -851,7 +830,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -878,7 +856,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -898,7 +878,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -937,7 +916,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -952,10 +930,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_1fa9", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_8425", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -969,7 +945,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tenant": null, @@ -986,7 +961,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -1001,7 +975,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "gigabitethernet2_test100_test-tenant_child-test-location_parent-test-location_e074", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1010,7 +983,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1037,7 +1009,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1057,7 +1031,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1092,7 +1065,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "gigabitethernet3_test100_test-tenant_child-test-location_parent-test-location_8438", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1101,7 +1073,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1128,7 +1099,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1148,7 +1121,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1183,7 +1155,6 @@ "mode": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "gigabitethernet4_test100_test-tenant_child-test-location_parent-test-location_854c", "object_type": "dcim.interface", "parent_interface": null, "status": { @@ -1192,7 +1163,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1230,7 +1200,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1250,7 +1222,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1292,7 +1263,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1321,7 +1291,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1336,7 +1305,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_3116", "object_type": "ipam.service", "ports": [ 80 @@ -1356,7 +1324,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1376,7 +1346,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1403,7 +1372,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_bfcf", "object_type": "ipam.service", "ports": [ 22 @@ -1422,7 +1390,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -1451,7 +1418,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_cc3f", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1460,7 +1426,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1480,7 +1445,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1506,7 +1470,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_02b8", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1515,7 +1478,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1535,7 +1497,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1561,7 +1522,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_e6d3", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1570,7 +1530,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1590,7 +1549,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1616,7 +1574,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_46e2", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1625,7 +1582,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1645,7 +1601,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1671,7 +1626,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_f394", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1680,7 +1634,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1700,7 +1653,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_b0bc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1732,7 +1684,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -1757,7 +1708,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_9dea", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1766,7 +1716,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1786,7 +1735,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1812,7 +1760,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_5f26", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1821,7 +1768,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1841,7 +1787,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1867,7 +1812,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_3f34", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1876,7 +1820,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1896,7 +1839,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1922,7 +1864,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4b7e", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1931,7 +1872,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1951,7 +1891,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1977,7 +1916,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_82d6", "object_type": "virtualization.vminterface", "parent_interface": null, "status": { @@ -1986,7 +1924,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tagged_vlans": [], @@ -2006,7 +1943,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_68f2", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -2038,7 +1974,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2068,7 +2003,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2098,7 +2032,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -2123,7 +2056,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-3_legacy.json b/tests/integration/targets/inventory/files/test_2.2-3_legacy.json index e02ef41a..6b4761a5 100644 --- a/tests/integration/targets/inventory/files/test_2.2-3_legacy.json +++ b/tests/integration/targets/inventory/files/test_2.2-3_legacy.json @@ -2,7 +2,9 @@ "_meta": { "hostvars": { "R1-Device": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -35,14 +37,15 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] }, "Test Nexus One": { "ansible_host": "172.16.180.11", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -71,7 +74,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -87,7 +92,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_725b", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -116,7 +120,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_067d", "object_type": "ipam.service", "ports": [ 23 @@ -135,7 +138,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -157,7 +159,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cad2", "object_type": "ipam.service", "ports": [ 22 @@ -181,7 +182,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_8da0", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -202,13 +202,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -242,13 +243,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] }, "test100": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_roles": [ "Core Switch" ], @@ -280,7 +282,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -300,7 +304,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -342,7 +345,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_23b0", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -371,7 +373,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_ee95", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -386,7 +387,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_3116", "object_type": "ipam.service", "ports": [ 80 @@ -406,7 +406,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -426,7 +428,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_939c", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -453,7 +454,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_bfcf", "object_type": "ipam.service", "ports": [ 22 @@ -472,7 +472,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -502,7 +501,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -528,7 +526,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -554,7 +551,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -580,7 +576,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -601,7 +596,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-3_options.json b/tests/integration/targets/inventory/files/test_2.2-3_options.json index 4bea679f..9e82b75b 100644 --- a/tests/integration/targets/inventory/files/test_2.2-3_options.json +++ b/tests/integration/targets/inventory/files/test_2.2-3_options.json @@ -2,7 +2,9 @@ "_meta": { "hostvars": { "R1-Device": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "display": "R1-Device", "is_virtual": false, @@ -24,10 +26,11 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "Test Location Custom Field Value" }, "Test VM With Spaces": { "cluster": "Test Cluster 2", @@ -42,13 +45,14 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "display": "TestDeviceR1", "is_virtual": false, @@ -71,14 +75,17 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "" }, "VC1": { "ansible_host": "nexus.example.com", - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Nexus Parent", "display": "Test Nexus One", "dns_name": "nexus.example.com", @@ -97,13 +104,16 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, - "tags": [] + "tags": [], + "testing_device_cf": "", + "testing_location_cf": "Test Location Custom Field Value" }, "test100": { - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_type": "Cisco Test", "display": "test100", "is_virtual": false, @@ -125,12 +135,13 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], "tenant": "Test Tenant", - "tenant_group": "Test Tenant Group" + "tenant_group": "Test Tenant Group", + "testing_device_cf": "Test Device Custom Field Value", + "testing_location_cf": "Test Location Custom Field Value" }, "test100-vm": { "cluster": "Test Cluster", @@ -150,7 +161,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -173,7 +183,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -196,7 +205,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -219,7 +227,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -237,7 +244,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.2-3_options.yml b/tests/integration/targets/inventory/files/test_2.2-3_options.yml index 50875085..a2eff86d 100644 --- a/tests/integration/targets/inventory/files/test_2.2-3_options.yml +++ b/tests/integration/targets/inventory/files/test_2.2-3_options.yml @@ -51,6 +51,8 @@ compose: display: display rack_id: rack.id ntp_servers: config_context.ntp_servers + testing_device_cf: custom_fields.my_device_custom_field + testing_location_cf: location.custom_fields.my_location_custom_field keyed_groups: - prefix: rack diff --git a/tests/integration/targets/inventory/files/test_2.2-3_plurals_flatten.json b/tests/integration/targets/inventory/files/test_2.2-3_plurals_flatten.json index 08f75a6d..77409822 100644 --- a/tests/integration/targets/inventory/files/test_2.2-3_plurals_flatten.json +++ b/tests/integration/targets/inventory/files/test_2.2-3_plurals_flatten.json @@ -20,6 +20,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "rack_groups": [ "Parent Rack Group" ], @@ -33,7 +34,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -58,6 +58,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "primary_ip4": "172.16.180.11", "status": { "color": "4caf50", @@ -65,7 +66,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -84,7 +84,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -109,6 +108,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": null, "rack_groups": [ "Child Rack Group", "Parent Rack Group" @@ -122,7 +122,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -150,6 +149,7 @@ "manufacturers": [ "Cisco" ], + "my_device_custom_field": "Test Device Custom Field Value", "ntp_servers": [ "pool.ntp.org" ], @@ -159,7 +159,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [], @@ -187,7 +186,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -211,7 +209,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -235,7 +232,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -259,7 +255,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] @@ -278,7 +273,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_e185", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.3-3.json b/tests/integration/targets/inventory/files/test_2.3-3.json index 1e5169c9..83825f3d 100644 --- a/tests/integration/targets/inventory/files/test_2.3-3.json +++ b/tests/integration/targets/inventory/files/test_2.3-3.json @@ -3,7 +3,9 @@ "hostvars": { "R1-Device": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -26,7 +28,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -34,7 +35,9 @@ "Test Nexus One": { "ansible_host": "172.16.180.11", "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Nexus Parent", "dns_name": "nexus.example.com", "interfaces": [ @@ -53,7 +56,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -69,7 +74,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -110,7 +114,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_1597", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -125,10 +128,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -142,7 +143,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -159,7 +159,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -175,7 +174,6 @@ "module": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location___ethernet1-1_b2ec", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -185,7 +183,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -212,7 +209,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -228,7 +227,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_8838", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -267,7 +265,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_1577", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -282,10 +279,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -299,7 +294,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -316,7 +310,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -332,7 +325,6 @@ "module": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location___ethernet2-1_c397", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -342,7 +334,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -373,7 +364,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -389,7 +382,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -418,7 +410,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_a54a", "object_type": "ipam.service", "ports": [ 23 @@ -437,7 +428,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -459,7 +449,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0577", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -469,7 +458,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -489,7 +477,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -515,7 +502,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_8f04", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -525,7 +511,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -545,7 +530,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -571,7 +555,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cbb3", "object_type": "ipam.service", "ports": [ 22 @@ -595,7 +578,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -616,14 +598,15 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] }, "TestDeviceR1": { "config_context": {}, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_type": "Cisco Test", "interfaces": [], "is_virtual": false, @@ -647,7 +630,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -658,7 +640,9 @@ "pool.ntp.org" ] }, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_type": "Cisco Test", "interfaces": [ { @@ -676,7 +660,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -696,7 +682,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -735,7 +720,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -750,10 +734,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -767,7 +749,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -784,7 +765,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -800,7 +780,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet1_a77d", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -810,7 +789,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -837,7 +815,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -857,7 +837,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -896,7 +875,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -911,10 +889,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_12de", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -928,7 +904,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -945,7 +920,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -961,7 +935,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet2_0787", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -971,7 +944,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -998,7 +970,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1018,7 +992,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1054,7 +1027,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet3_75d6", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1064,7 +1036,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1091,7 +1062,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1111,7 +1084,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1147,7 +1119,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet4_9d66", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1157,7 +1128,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1192,7 +1162,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1212,7 +1184,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1254,7 +1225,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1283,7 +1253,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1298,7 +1267,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_19f8", "object_type": "ipam.service", "ports": [ 80 @@ -1318,7 +1286,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1338,7 +1308,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1365,7 +1334,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_b2d4", "object_type": "ipam.service", "ports": [ 22 @@ -1384,7 +1352,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -1409,7 +1376,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_342d", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1419,7 +1385,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1439,7 +1404,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1465,7 +1429,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_ab21", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1475,7 +1438,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1495,7 +1457,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1521,7 +1482,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_2f31", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1531,7 +1491,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1551,7 +1510,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1577,7 +1535,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_8e1c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1587,7 +1544,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1607,7 +1563,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1633,7 +1588,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0d2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1643,7 +1597,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1663,7 +1616,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1692,7 +1644,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -1715,7 +1666,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_fd2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1725,7 +1675,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1745,7 +1694,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1771,7 +1719,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_d10e", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1781,7 +1728,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1801,7 +1747,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1827,7 +1772,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_7baf", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1837,7 +1781,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1857,7 +1800,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1883,7 +1825,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4434", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1893,7 +1834,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1913,7 +1853,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1939,7 +1878,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_2978", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1949,7 +1887,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1969,7 +1906,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1998,7 +1934,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2023,7 +1958,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2048,7 +1982,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2068,7 +2001,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.3-3_options_flatten.json b/tests/integration/targets/inventory/files/test_2.3-3_options_flatten.json index 2a04a654..ec048b0c 100644 --- a/tests/integration/targets/inventory/files/test_2.3-3_options_flatten.json +++ b/tests/integration/targets/inventory/files/test_2.3-3_options_flatten.json @@ -11,6 +11,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Main Test Rack", "rack_groups": [ "Parent Rack Group" @@ -24,7 +25,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -49,7 +49,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -65,7 +67,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -106,7 +107,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_1597", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -121,10 +121,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -138,7 +136,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -155,7 +152,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -171,7 +167,6 @@ "module": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location___ethernet1-1_b2ec", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -181,7 +176,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -208,7 +202,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -224,7 +220,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_8838", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -263,7 +258,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_1577", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -278,10 +272,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -295,7 +287,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -312,7 +303,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -328,7 +318,6 @@ "module": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location___ethernet2-1_c397", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -338,7 +327,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -358,6 +346,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "primary_ip4": "172.16.180.11", "role": "Core Switch", "services": [ @@ -369,7 +358,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -385,7 +376,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -414,7 +404,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_a54a", "object_type": "ipam.service", "ports": [ 23 @@ -433,7 +422,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -453,7 +441,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0577", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -463,7 +450,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -483,7 +469,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -509,7 +494,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_8f04", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -519,7 +503,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -539,7 +522,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -565,7 +547,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cbb3", "object_type": "ipam.service", "ports": [ 22 @@ -589,7 +570,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -610,7 +590,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -626,6 +605,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": null, "rack": "Sub Test Rack", "rack_groups": [ "Child Rack Group", @@ -639,7 +619,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -662,7 +641,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -682,7 +663,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -721,7 +701,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -736,10 +715,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -753,7 +730,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -770,7 +746,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -786,7 +761,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet1_a77d", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -796,7 +770,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -823,7 +796,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -843,7 +818,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -882,7 +856,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -897,10 +870,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_12de", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -914,7 +885,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -931,7 +901,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -947,7 +916,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet2_0787", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -957,7 +925,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -984,7 +951,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1004,7 +973,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1040,7 +1008,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet3_75d6", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1050,7 +1017,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1077,7 +1043,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1097,7 +1065,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1133,7 +1100,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet4_9d66", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1143,7 +1109,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1168,6 +1133,7 @@ "Parent Test Location" ], "manufacturer": "Cisco", + "my_device_custom_field": "Test Device Custom Field Value", "ntp_servers": [ "pool.ntp.org" ], @@ -1181,7 +1147,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1201,7 +1169,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1243,7 +1210,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1272,7 +1238,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1287,7 +1252,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_19f8", "object_type": "ipam.service", "ports": [ 80 @@ -1307,7 +1271,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1327,7 +1293,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1354,7 +1319,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_b2d4", "object_type": "ipam.service", "ports": [ 22 @@ -1373,7 +1337,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -1396,7 +1359,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_342d", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1406,7 +1368,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1426,7 +1387,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1452,7 +1412,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_ab21", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1462,7 +1421,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1482,7 +1440,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1508,7 +1465,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_2f31", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1518,7 +1474,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1538,7 +1493,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1564,7 +1518,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_8e1c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1574,7 +1527,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1594,7 +1546,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1620,7 +1571,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0d2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1630,7 +1580,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1650,7 +1599,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1679,7 +1627,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -1700,7 +1647,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_fd2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1710,7 +1656,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1730,7 +1675,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1756,7 +1700,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_d10e", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1766,7 +1709,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1786,7 +1728,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1812,7 +1753,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_7baf", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1822,7 +1762,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1842,7 +1781,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1868,7 +1806,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4434", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1878,7 +1815,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1898,7 +1834,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1924,7 +1859,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_2978", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1934,7 +1868,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1954,7 +1887,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1983,7 +1915,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2006,7 +1937,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2029,7 +1959,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2047,7 +1976,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/files/test_2.3-3_plurals.json b/tests/integration/targets/inventory/files/test_2.3-3_plurals.json index 82d98aa9..71e09ffe 100644 --- a/tests/integration/targets/inventory/files/test_2.3-3_plurals.json +++ b/tests/integration/targets/inventory/files/test_2.3-3_plurals.json @@ -5,7 +5,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -39,7 +41,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -49,7 +50,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -73,7 +76,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -89,7 +94,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -130,7 +134,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-11_1597", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -145,10 +148,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -162,7 +163,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -179,7 +179,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -195,7 +194,6 @@ "module": null, "mtu": null, "name": "Ethernet1/1", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location___ethernet1-1_b2ec", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -205,7 +203,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -232,7 +229,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -248,7 +247,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus Child One", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location_8838", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -287,7 +285,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-12_1577", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -302,10 +299,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -319,7 +314,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -336,7 +330,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -352,7 +345,6 @@ "module": null, "mtu": null, "name": "Ethernet2/1", - "natural_slug": "test-nexus-child-one__child-test-location_parent-test-location___ethernet2-1_c397", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -362,7 +354,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -397,7 +388,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -413,7 +406,6 @@ "object_type": "dcim.location" }, "name": "Test Nexus One", - "natural_slug": "test-nexus-one__child-test-location_parent-test-location_6bf7", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -442,7 +434,6 @@ "display": "telnet (TCP/23)", "ip_addresses": [], "name": "telnet", - "natural_slug": "telnet____test-nexus-one__child-test-location_parent-test-location_a54a", "object_type": "ipam.service", "ports": [ 23 @@ -461,7 +452,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -485,7 +475,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth0_0577", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -495,7 +484,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -515,7 +503,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -541,7 +528,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster-2__test-vm-with-spaces_eth1_8f04", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -551,7 +537,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -571,7 +556,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -600,7 +584,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh_test-cluster-2__test-vm-with-spaces_cbb3", "object_type": "ipam.service", "ports": [ 22 @@ -624,7 +607,6 @@ "local_config_context_schema": null, "memory": null, "name": "Test VM With Spaces", - "natural_slug": "test-cluster-2__test-vm-with-spaces_6754", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -645,7 +627,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -654,7 +635,9 @@ "config_context": [ {} ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": null + }, "device_roles": [ "Core Switch" ], @@ -689,7 +672,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -702,7 +684,9 @@ ] } ], - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_roles": [ "Core Switch" ], @@ -725,7 +709,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -745,7 +731,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -784,7 +769,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "broadcast": "172.31.255.255", @@ -799,10 +783,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_172-16-0-0_12_418e", "network": "172.16.0.0", "object_type": "ipam.prefix", "parent": null, @@ -816,7 +798,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -833,7 +814,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -849,7 +829,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet1", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet1_a77d", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -859,7 +838,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -886,7 +864,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -906,7 +886,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -945,7 +924,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "broadcast": "2001::ffff:ffff:ffff:ffff", @@ -960,10 +938,8 @@ "display": "Global", "location": null, "name": "Global", - "natural_slug": "global_0603", "object_type": "ipam.namespace" }, - "natural_slug": "global_2001_64_12de", "network": "2001::", "object_type": "ipam.prefix", "parent": null, @@ -977,7 +953,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tenant": null, @@ -994,7 +969,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -1010,7 +984,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet2", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet2_0787", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1020,7 +993,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1047,7 +1019,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1067,7 +1041,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1103,7 +1076,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet3", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet3_75d6", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1113,7 +1085,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1140,7 +1111,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1160,7 +1133,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1196,7 +1168,6 @@ "module": null, "mtu": null, "name": "GigabitEthernet4", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location___gigabitethernet4_9d66", "object_type": "dcim.interface", "parent_interface": null, "role": null, @@ -1206,7 +1177,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1244,7 +1214,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1264,7 +1236,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1306,7 +1277,6 @@ "mask_length": 24, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_172-16-180-1_6b3b", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1335,7 +1305,6 @@ "mask_length": 64, "nat_inside": null, "nat_outside_list": [], - "natural_slug": "global_2001-1-1_80d9", "object_type": "ipam.ipaddress", "parent": { "object_type": "ipam.prefix" @@ -1350,7 +1319,6 @@ } ], "name": "http", - "natural_slug": "http____test100_test-tenant_child-test-location_parent-test-location_19f8", "object_type": "ipam.service", "ports": [ 80 @@ -1370,7 +1338,9 @@ "cluster": null, "comments": "", "controller_managed_device_group": null, - "custom_fields": {}, + "custom_fields": { + "my_device_custom_field": "Test Device Custom Field Value" + }, "device_redundancy_group": null, "device_redundancy_group_priority": null, "device_type": { @@ -1390,7 +1360,6 @@ "object_type": "dcim.location" }, "name": "test100", - "natural_slug": "test100_test-tenant_child-test-location_parent-test-location_eb90", "object_type": "dcim.device", "parent_bay": null, "platform": null, @@ -1417,7 +1386,6 @@ "display": "ssh (TCP/22)", "ip_addresses": [], "name": "ssh", - "natural_slug": "ssh____test100_test-tenant_child-test-location_parent-test-location_b2d4", "object_type": "ipam.service", "ports": [ 22 @@ -1436,7 +1404,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [], @@ -1465,7 +1432,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test100-vm_eth0_342d", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1475,7 +1441,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1495,7 +1460,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1521,7 +1485,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test100-vm_eth1_ab21", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1531,7 +1494,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1551,7 +1513,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1577,7 +1538,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test100-vm_eth2_2f31", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1587,7 +1547,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1607,7 +1566,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1633,7 +1591,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test100-vm_eth3_8e1c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1643,7 +1600,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1663,7 +1619,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1689,7 +1644,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test100-vm_eth4_0d2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1699,7 +1653,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1719,7 +1672,6 @@ "local_config_context_schema": null, "memory": null, "name": "test100-vm", - "natural_slug": "test-cluster__test100-vm_3d00", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1751,7 +1703,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -1776,7 +1727,6 @@ "mode": null, "mtu": null, "name": "Eth0", - "natural_slug": "test-cluster__test101-vm_eth0_fd2c", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1786,7 +1736,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1806,7 +1755,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1832,7 +1780,6 @@ "mode": null, "mtu": null, "name": "Eth1", - "natural_slug": "test-cluster__test101-vm_eth1_d10e", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1842,7 +1789,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1862,7 +1808,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1888,7 +1833,6 @@ "mode": null, "mtu": null, "name": "Eth2", - "natural_slug": "test-cluster__test101-vm_eth2_7baf", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1898,7 +1842,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1918,7 +1861,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -1944,7 +1886,6 @@ "mode": null, "mtu": null, "name": "Eth3", - "natural_slug": "test-cluster__test101-vm_eth3_4434", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -1954,7 +1895,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -1974,7 +1914,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -2000,7 +1939,6 @@ "mode": null, "mtu": null, "name": "Eth4", - "natural_slug": "test-cluster__test101-vm_eth4_2978", "object_type": "virtualization.vminterface", "parent_interface": null, "role": null, @@ -2010,7 +1948,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tagged_vlans": [], @@ -2030,7 +1967,6 @@ "local_config_context_schema": null, "memory": null, "name": "test101-vm", - "natural_slug": "test-cluster__test101-vm_80dc", "object_type": "virtualization.virtualmachine", "platform": null, "primary_ip4": null, @@ -2062,7 +1998,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2092,7 +2027,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2122,7 +2056,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] @@ -2147,7 +2080,6 @@ "description": "Unit is active", "display": "Active", "name": "Active", - "natural_slug": "active_08bd", "object_type": "extras.status" }, "tags": [] diff --git a/tests/integration/targets/inventory/runme.sh b/tests/integration/targets/inventory/runme.sh index 9749666c..b948fa57 100755 --- a/tests/integration/targets/inventory/runme.sh +++ b/tests/integration/targets/inventory/runme.sh @@ -19,7 +19,7 @@ fi declare -a COMPARE_OPTIONS # empty array # OUTPUT_DIR is set by ansible-test -# OUTPUT_INVENTORY_JSON is only set if running hacking/update_test_inventories.sh to update the test diff data +# OUTPUT_INVENTORY_JSON is only set if running `invoke integration --update-inventories` to update the test diff data if [[ -n "${OUTPUT_INVENTORY_JSON:-}" ]] then OUTPUT_DIR="$OUTPUT_INVENTORY_JSON" @@ -73,7 +73,7 @@ do fi # Check if NAUTOBOT_VER is within the specified range if ! printf "%s\n%s\n%s\n" $MIN_VERSION $NAUTOBOT_VER $MAX_VERSION | sort -V -C; then - # The sort statement will return non-zero if the versions are not in order (min <= nautobot_ver <= max) + # The sort statement will return non-zero if the versions are not in order (min <= nautobot_ver < max) echo "NAUTOBOT_VER is $NAUTOBOT_VER, skipping inventory test: $NAME" continue fi diff --git a/tests/integration/targets/inventory/runme_config.template b/tests/integration/targets/inventory/runme_config.template index 1b292e62..c3846b79 100644 --- a/tests/integration/targets/inventory/runme_config.template +++ b/tests/integration/targets/inventory/runme_config.template @@ -4,3 +4,4 @@ # (integration_config.yml files are only helpful to ansible yaml-based tests) export NAUTOBOT_VER=${NAUTOBOT_VER} +export OUTPUT_INVENTORY_JSON=${OUTPUT_INVENTORY_JSON:-} diff --git a/tests/integration/targets/latest/tasks/admin_permission.yml b/tests/integration/targets/latest/tasks/admin_permission.yml index ea3491d6..19d0af68 100755 --- a/tests/integration/targets/latest/tasks/admin_permission.yml +++ b/tests/integration/targets/latest/tasks/admin_permission.yml @@ -8,11 +8,6 @@ nb_user: "{{ lookup('networktocode.nautobot.lookup', 'admin-users', api_endpoint=nautobot_url, token=nautobot_token, api_filter='username=\"a_admin_user\"') }}" nb_group: "{{ lookup('networktocode.nautobot.lookup', 'admin-groups', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"A Test Admin User Group\"') }}" -- debug: - var: nb_user -- debug: - var: nb_group - - name: "PERMISSION 1: Necessary info creation" networktocode.nautobot.admin_permission: url: "{{ nautobot_url }}" @@ -58,9 +53,6 @@ state: present register: test_two -- debug: - var: test_two - - name: "PERMISSION 2: ASSERT - Create duplicate" assert: that: diff --git a/tests/integration/targets/latest/tasks/cloud_account.yml b/tests/integration/targets/latest/tasks/cloud_account.yml index 2b0fedba..e324457b 100644 --- a/tests/integration/targets/latest/tasks/cloud_account.yml +++ b/tests/integration/targets/latest/tasks/cloud_account.yml @@ -4,153 +4,148 @@ ### PYNAUTOBOT_CLOUD_ACCOUNT ## ## +- set_fact: + cisco_provider: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Cisco') }}" + cloud_secrets_group: "{{ lookup('networktocode.nautobot.lookup', 'secrets-groups', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Secrets Group\"') }}" -- name: "NAUTOBOT 2.3+ CLOUD ACCOUNTS TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cisco_provider: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Cisco') }}" - cloud_secrets_group: "{{ lookup('networktocode.nautobot.lookup', 'secrets-groups', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Secrets Group\"') }}" - - - name: "1 - Create cloud account within Nautobot with only required information" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - provider: Cisco - account_number: "123456" - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['cloud_account']['name'] == "Cisco Quantum Account" - - test_create_min['msg'] == "cloud_account Cisco Quantum Account created" - - - name: "2 - Duplicate" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "cloud_account Cisco Quantum Account already exists" - - test_create_idem['cloud_account']['name'] == "Cisco Quantum Account" - - - name: "3 - Update cloud_account" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - description: The rootest of all root accounts! - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['description'] == "" - - test_update['diff']['after']['description'] == "The rootest of all root accounts!" - - - name: "4 - Update idempotent" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - description: The rootest of all root accounts! - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "cloud_account Cisco Quantum Account already exists" - - test_update_idem['cloud_account']['name'] == "Cisco Quantum Account" - - - name: "5 - Create cloud_account with all parameters" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Not So Root Account - provider: Cisco - description: Rooty but not the rootest! - account_number: "654321" - secrets_group: "{{ cloud_secrets_group['key'] }}" - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['cloud_account']['name'] == "Cisco Quantum Not So Root Account" - - test_create_max['cloud_account']['provider'] == cisco_provider['key'] - - test_create_max['cloud_account']['description'] == "Rooty but not the rootest!" - - test_create_max['cloud_account']['account_number'] == "654321" - - test_create_max['cloud_account']['secrets_group'] == cloud_secrets_group['key'] - - - name: "5.1 - ASSERT" - assert: - that: - - cloud_account['value']['name'] == "Cisco Quantum Not So Root Account" - vars: - cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Not So Root Account\"') }}" - - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Not So Root Account - provider: Cisco - description: Rooty but not the rootest! - account_number: "654321" - secrets_group: "{{ cloud_secrets_group['key'] }}" - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "cloud_account Cisco Quantum Not So Root Account already exists" - - test_create_max_idem['cloud_account']['name'] == "Cisco Quantum Not So Root Account" - - - name: "7 - Delete cloud_account" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_account']['name'] == "Cisco Quantum Account" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.cloud_account: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Account - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "1 - Create cloud account within Nautobot with only required information" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + provider: Cisco + account_number: "123456" + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['cloud_account']['name'] == "Cisco Quantum Account" + - test_create_min['msg'] == "cloud_account Cisco Quantum Account created" + +- name: "2 - Duplicate" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "cloud_account Cisco Quantum Account already exists" + - test_create_idem['cloud_account']['name'] == "Cisco Quantum Account" + +- name: "3 - Update cloud_account" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + description: The rootest of all root accounts! + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "The rootest of all root accounts!" + +- name: "4 - Update idempotent" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + description: The rootest of all root accounts! + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "cloud_account Cisco Quantum Account already exists" + - test_update_idem['cloud_account']['name'] == "Cisco Quantum Account" + +- name: "5 - Create cloud_account with all parameters" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Not So Root Account + provider: Cisco + description: Rooty but not the rootest! + account_number: "654321" + secrets_group: "{{ cloud_secrets_group['key'] }}" + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['cloud_account']['name'] == "Cisco Quantum Not So Root Account" + - test_create_max['cloud_account']['provider'] == cisco_provider['key'] + - test_create_max['cloud_account']['description'] == "Rooty but not the rootest!" + - test_create_max['cloud_account']['account_number'] == "654321" + - test_create_max['cloud_account']['secrets_group'] == cloud_secrets_group['key'] + +- name: "5.1 - ASSERT" + assert: + that: + - cloud_account['value']['name'] == "Cisco Quantum Not So Root Account" + vars: + cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Not So Root Account\"') }}" + + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Not So Root Account + provider: Cisco + description: Rooty but not the rootest! + account_number: "654321" + secrets_group: "{{ cloud_secrets_group['key'] }}" + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "cloud_account Cisco Quantum Not So Root Account already exists" + - test_create_max_idem['cloud_account']['name'] == "Cisco Quantum Not So Root Account" + +- name: "7 - Delete cloud_account" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_account']['name'] == "Cisco Quantum Account" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.cloud_account: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Account + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/cloud_network.yml b/tests/integration/targets/latest/tasks/cloud_network.yml index 9a246b1a..919e465f 100644 --- a/tests/integration/targets/latest/tasks/cloud_network.yml +++ b/tests/integration/targets/latest/tasks/cloud_network.yml @@ -4,161 +4,156 @@ ### PYNAUTOBOT_CLOUD_NETWORK ## ## +- set_fact: + cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetworkType') }}" + cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudAccount') }}" + cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" -- name: "NAUTOBOT 2.3+ CLOUD NETWORKS TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetworkType') }}" - cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudAccount') }}" - cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" - - - name: "1 - Create cloud network within Nautobot with only required information" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - cloud_resource_type: CiscoCloudNetworkType - cloud_account: CiscoCloudAccount - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['cloud_network']['name'] == "Cisco Quantum Network" - - test_create_min['msg'] == "cloud_network Cisco Quantum Network created" - - - name: "2 - Duplicate" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "cloud_network Cisco Quantum Network already exists" - - test_create_idem['cloud_network']['name'] == "Cisco Quantum Network" - - - name: "3 - Update cloud_network" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - description: Super fast quantum network! - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['description'] == "" - - test_update['diff']['after']['description'] == "Super fast quantum network!" - - - name: "4 - Update idempotent" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - description: Super fast quantum network! - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "cloud_network Cisco Quantum Network already exists" - - test_update_idem['cloud_network']['name'] == "Cisco Quantum Network" - - - name: "5 - Create cloud_network with all parameters" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Faster Network - cloud_resource_type: CiscoCloudNetworkType - cloud_account: CiscoCloudAccount - parent: CiscoCloudNetwork - description: Super faster quantum network! - extra_config: - my_config: - foo: bar - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['cloud_network']['name'] == "Cisco Quantum Faster Network" - - test_create_max['cloud_network']['cloud_resource_type'] == cloud_resource_type['key'] - - test_create_max['cloud_network']['cloud_account'] == cloud_account['key'] - - test_create_max['cloud_network']['description'] == "Super faster quantum network!" - - test_create_max['cloud_network']['parent'] == cloud_network['key'] - - test_create_max['cloud_network']['extra_config']['my_config']['foo'] == "bar" - - - name: "5.1 - ASSERT" - assert: - that: - - new_cloud_network['value']['name'] == "Cisco Quantum Faster Network" - vars: - new_cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Faster Network\"') }}" - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Faster Network - cloud_resource_type: CiscoCloudNetworkType - cloud_account: CiscoCloudAccount - parent: CiscoCloudNetwork - description: Super faster quantum network! - extra_config: - my_config: - foo: bar - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "cloud_network Cisco Quantum Faster Network already exists" - - test_create_max_idem['cloud_network']['name'] == "Cisco Quantum Faster Network" - - test_create_max_idem['cloud_network']['extra_config']['my_config']['foo'] == "bar" - - - name: "7 - Delete cloud_network" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Faster Network - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_network']['name'] == "Cisco Quantum Faster Network" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.cloud_network: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Faster Network - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "1 - Create cloud network within Nautobot with only required information" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + cloud_resource_type: CiscoCloudNetworkType + cloud_account: CiscoCloudAccount + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['cloud_network']['name'] == "Cisco Quantum Network" + - test_create_min['msg'] == "cloud_network Cisco Quantum Network created" + +- name: "2 - Duplicate" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "cloud_network Cisco Quantum Network already exists" + - test_create_idem['cloud_network']['name'] == "Cisco Quantum Network" + +- name: "3 - Update cloud_network" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + description: Super fast quantum network! + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "Super fast quantum network!" + +- name: "4 - Update idempotent" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + description: Super fast quantum network! + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "cloud_network Cisco Quantum Network already exists" + - test_update_idem['cloud_network']['name'] == "Cisco Quantum Network" + +- name: "5 - Create cloud_network with all parameters" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Faster Network + cloud_resource_type: CiscoCloudNetworkType + cloud_account: CiscoCloudAccount + parent: CiscoCloudNetwork + description: Super faster quantum network! + extra_config: + my_config: + foo: bar + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['cloud_network']['name'] == "Cisco Quantum Faster Network" + - test_create_max['cloud_network']['cloud_resource_type'] == cloud_resource_type['key'] + - test_create_max['cloud_network']['cloud_account'] == cloud_account['key'] + - test_create_max['cloud_network']['description'] == "Super faster quantum network!" + - test_create_max['cloud_network']['parent'] == cloud_network['key'] + - test_create_max['cloud_network']['extra_config']['my_config']['foo'] == "bar" + +- name: "5.1 - ASSERT" + assert: + that: + - new_cloud_network['value']['name'] == "Cisco Quantum Faster Network" + vars: + new_cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Faster Network\"') }}" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Faster Network + cloud_resource_type: CiscoCloudNetworkType + cloud_account: CiscoCloudAccount + parent: CiscoCloudNetwork + description: Super faster quantum network! + extra_config: + my_config: + foo: bar + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "cloud_network Cisco Quantum Faster Network already exists" + - test_create_max_idem['cloud_network']['name'] == "Cisco Quantum Faster Network" + - test_create_max_idem['cloud_network']['extra_config']['my_config']['foo'] == "bar" + +- name: "7 - Delete cloud_network" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Faster Network + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_network']['name'] == "Cisco Quantum Faster Network" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.cloud_network: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Faster Network + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/cloud_network_prefix_assignment.yml b/tests/integration/targets/latest/tasks/cloud_network_prefix_assignment.yml index 15c2ec00..e44fbfce 100644 --- a/tests/integration/targets/latest/tasks/cloud_network_prefix_assignment.yml +++ b/tests/integration/targets/latest/tasks/cloud_network_prefix_assignment.yml @@ -4,79 +4,74 @@ ### PYNAUTOBOT_CLOUD_NETWORK_PREFIX_ASSIGNMENT ## ## +- set_fact: + cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" + cloud_prefix: "{{ lookup('networktocode.nautobot.lookup', 'prefixes', api_endpoint=nautobot_url, token=nautobot_token, api_filter='prefix=10.10.0.0/16') }}" -- name: "NAUTOBOT 2.3+ CLOUD NETWORK PREFIX ASSIGNMENT TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" - cloud_prefix: "{{ lookup('networktocode.nautobot.lookup', 'prefixes', api_endpoint=nautobot_url, token=nautobot_token, api_filter='prefix=10.10.0.0/16') }}" +- name: "1 - Create cloud network to prefix assignment" + networktocode.nautobot.cloud_network_prefix_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_network: CiscoCloudNetwork + prefix: 10.10.0.0/16 + register: test_create_one - - name: "1 - Create cloud network to prefix assignment" - networktocode.nautobot.cloud_network_prefix_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_network: CiscoCloudNetwork - prefix: 10.10.0.0/16 - register: test_create_one +- name: "1 - ASSERT" + assert: + that: + - test_create_one is changed + - test_create_one['diff']['before']['state'] == "absent" + - test_create_one['diff']['after']['state'] == "present" + - test_create_one['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] + - test_create_one['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] + - "'created' in test_create_one['msg']" - - name: "1 - ASSERT" - assert: - that: - - test_create_one is changed - - test_create_one['diff']['before']['state'] == "absent" - - test_create_one['diff']['after']['state'] == "present" - - test_create_one['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] - - test_create_one['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] - - "'created' in test_create_one['msg']" +- name: "2 - Duplicate" + networktocode.nautobot.cloud_network_prefix_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_network: CiscoCloudNetwork + prefix: 10.10.0.0/16 + register: test_create_idem - - name: "2 - Duplicate" - networktocode.nautobot.cloud_network_prefix_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_network: CiscoCloudNetwork - prefix: 10.10.0.0/16 - register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - "'already exists' in test_create_idem['msg']" + - test_create_idem['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] + - test_create_idem['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - "'already exists' in test_create_idem['msg']" - - test_create_idem['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] - - test_create_idem['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] - - - name: "3 - Delete cloud_network_prefix_assignment" - networktocode.nautobot.cloud_network_prefix_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_network: CiscoCloudNetwork - prefix: 10.10.0.0/16 - state: absent - register: test_delete - - - name: "3 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] - - test_delete['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] - - "'deleted' in test_delete['msg']" - - - name: "4 - Delete idempotent" - networktocode.nautobot.cloud_network_prefix_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_network: CiscoCloudNetwork - prefix: 10.10.0.0/16 - state: absent - register: test_delete_idem +- name: "3 - Delete cloud_network_prefix_assignment" + networktocode.nautobot.cloud_network_prefix_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_network: CiscoCloudNetwork + prefix: 10.10.0.0/16 + state: absent + register: test_delete - - name: "4 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "3 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_network_prefix_assignment']['cloud_network'] == cloud_network['key'] + - test_delete['cloud_network_prefix_assignment']['prefix'] == cloud_prefix['key'] + - "'deleted' in test_delete['msg']" + +- name: "4 - Delete idempotent" + networktocode.nautobot.cloud_network_prefix_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_network: CiscoCloudNetwork + prefix: 10.10.0.0/16 + state: absent + register: test_delete_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/cloud_resource_type.yml b/tests/integration/targets/latest/tasks/cloud_resource_type.yml index c87f3b27..834d470a 100644 --- a/tests/integration/targets/latest/tasks/cloud_resource_type.yml +++ b/tests/integration/targets/latest/tasks/cloud_resource_type.yml @@ -4,159 +4,154 @@ ### PYNAUTOBOT_CLOUD_RESOURCE_TYPE ## ## +- set_fact: + cisco_provider: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Cisco') }}" -- name: "NAUTOBOT 2.3+ CLOUD RESOURCE TYPE TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cisco_provider: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Cisco') }}" - - - name: "1 - Create cloud resource type within Nautobot with only required information" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - provider: Cisco - content_types: - - "cloud.cloudnetwork" - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['cloud_resource_type']['name'] == "Cisco Quantum Network" - - test_create_min['msg'] == "cloud_resource_type Cisco Quantum Network created" - - - name: "2 - Duplicate" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "cloud_resource_type Cisco Quantum Network already exists" - - test_create_idem['cloud_resource_type']['name'] == "Cisco Quantum Network" - - - name: "3 - Update cloud_resource_type" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - description: Very fast network! - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['description'] == "" - - test_update['diff']['after']['description'] == "Very fast network!" - - - name: "4 - Update idempotent" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network - description: Very fast network! - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "cloud_resource_type Cisco Quantum Network already exists" - - test_update_idem['cloud_resource_type']['name'] == "Cisco Quantum Network" - - - name: "5 - Create cloud_resource_type with all parameters" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network Remix - provider: Cisco - description: Very fast network reimagined! - content_types: - - "cloud.cloudnetwork" - config_schema: - my_config: - foo: bar - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" - - test_create_max['cloud_resource_type']['provider'] == cisco_provider['key'] - - test_create_max['cloud_resource_type']['description'] == "Very fast network reimagined!" - - test_create_max['cloud_resource_type']['content_types'] == ["cloud.cloudnetwork"] - - test_create_max['cloud_resource_type']['config_schema']['my_config']['foo'] == "bar" - - - name: "5.1 - ASSERT" - assert: - that: - - test_cloud_resource_type['value']['config_schema']['my_config']['foo'] == "bar" - vars: - test_cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Network Remix\"') }}" - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network Remix - provider: Cisco - description: Very fast network reimagined! - content_types: - - "cloud.cloudnetwork" - config_schema: - my_config: - foo: bar - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "cloud_resource_type Cisco Quantum Network Remix already exists" - - test_create_max_idem['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" - - test_create_max_idem['cloud_resource_type']['config_schema']['my_config']['foo'] == "bar" - - - name: "7 - Delete cloud_resource_type" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network Remix - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.cloud_resource_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Network Remix - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "1 - Create cloud resource type within Nautobot with only required information" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + provider: Cisco + content_types: + - "cloud.cloudnetwork" + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['cloud_resource_type']['name'] == "Cisco Quantum Network" + - test_create_min['msg'] == "cloud_resource_type Cisco Quantum Network created" + +- name: "2 - Duplicate" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "cloud_resource_type Cisco Quantum Network already exists" + - test_create_idem['cloud_resource_type']['name'] == "Cisco Quantum Network" + +- name: "3 - Update cloud_resource_type" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + description: Very fast network! + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "Very fast network!" + +- name: "4 - Update idempotent" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network + description: Very fast network! + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "cloud_resource_type Cisco Quantum Network already exists" + - test_update_idem['cloud_resource_type']['name'] == "Cisco Quantum Network" + +- name: "5 - Create cloud_resource_type with all parameters" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network Remix + provider: Cisco + description: Very fast network reimagined! + content_types: + - "cloud.cloudnetwork" + config_schema: + my_config: + foo: bar + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" + - test_create_max['cloud_resource_type']['provider'] == cisco_provider['key'] + - test_create_max['cloud_resource_type']['description'] == "Very fast network reimagined!" + - test_create_max['cloud_resource_type']['content_types'] == ["cloud.cloudnetwork"] + - test_create_max['cloud_resource_type']['config_schema']['my_config']['foo'] == "bar" + +- name: "5.1 - ASSERT" + assert: + that: + - test_cloud_resource_type['value']['config_schema']['my_config']['foo'] == "bar" + vars: + test_cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Network Remix\"') }}" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network Remix + provider: Cisco + description: Very fast network reimagined! + content_types: + - "cloud.cloudnetwork" + config_schema: + my_config: + foo: bar + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "cloud_resource_type Cisco Quantum Network Remix already exists" + - test_create_max_idem['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" + - test_create_max_idem['cloud_resource_type']['config_schema']['my_config']['foo'] == "bar" + +- name: "7 - Delete cloud_resource_type" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network Remix + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_resource_type']['name'] == "Cisco Quantum Network Remix" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.cloud_resource_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Network Remix + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/cloud_service.yml b/tests/integration/targets/latest/tasks/cloud_service.yml index 9f8cb700..a085493d 100644 --- a/tests/integration/targets/latest/tasks/cloud_service.yml +++ b/tests/integration/targets/latest/tasks/cloud_service.yml @@ -4,157 +4,152 @@ ### PYNAUTOBOT_CLOUD_SERVICE ## ## +- set_fact: + cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudServiceType') }}" + cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudAccount') }}" -- name: "NAUTOBOT 2.3+ CLOUD SERVICES TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cloud_resource_type: "{{ lookup('networktocode.nautobot.lookup', 'cloud-resource-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudServiceType') }}" - cloud_account: "{{ lookup('networktocode.nautobot.lookup', 'cloud-accounts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudAccount') }}" - - - name: "1 - Create cloud service within Nautobot with only required information" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Service - cloud_resource_type: CiscoCloudServiceType - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['cloud_service']['name'] == "Cisco Quantum Service" - - test_create_min['msg'] == "cloud_service Cisco Quantum Service created" - - - name: "2 - Duplicate" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Service - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "cloud_service Cisco Quantum Service already exists" - - test_create_idem['cloud_service']['name'] == "Cisco Quantum Service" - - - name: "3 - Update cloud_service" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Service - description: Super secret quantum service! - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['description'] == "" - - test_update['diff']['after']['description'] == "Super secret quantum service!" - - - name: "4 - Update idempotent" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Service - description: Super secret quantum service! - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "cloud_service Cisco Quantum Service already exists" - - test_update_idem['cloud_service']['name'] == "Cisco Quantum Service" - - - name: "5 - Create cloud_service with all parameters" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Secreter Service - cloud_resource_type: CiscoCloudServiceType - cloud_account: CiscoCloudAccount - description: Super secreter quantum service! - extra_config: - my_config: - foo: bar - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['cloud_service']['name'] == "Cisco Quantum Secreter Service" - - test_create_max['cloud_service']['cloud_resource_type'] == cloud_resource_type['key'] - - test_create_max['cloud_service']['cloud_account'] == cloud_account['key'] - - test_create_max['cloud_service']['description'] == "Super secreter quantum service!" - - test_create_max['cloud_service']['extra_config']['my_config']['foo'] == "bar" - - - name: "5.1 - ASSERT" - assert: - that: - - cloud_service['value']['name'] == "Cisco Quantum Secreter Service" - - cloud_service['value']['extra_config']['my_config']['foo'] == "bar" - vars: - cloud_service: "{{ lookup('networktocode.nautobot.lookup', 'cloud-services', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Secreter Service\"') }}" - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Secreter Service - cloud_resource_type: CiscoCloudServiceType - cloud_account: CiscoCloudAccount - description: Super secreter quantum service! - extra_config: - my_config: - foo: bar - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "cloud_service Cisco Quantum Secreter Service already exists" - - test_create_max_idem['cloud_service']['name'] == "Cisco Quantum Secreter Service" - - test_create_max_idem['cloud_service']['extra_config']['my_config']['foo'] == "bar" - - - name: "7 - Delete cloud_service" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Secreter Service - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_service']['name'] == "Cisco Quantum Secreter Service" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.cloud_service: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Cisco Quantum Secreter Service - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "1 - Create cloud service within Nautobot with only required information" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Service + cloud_resource_type: CiscoCloudServiceType + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['cloud_service']['name'] == "Cisco Quantum Service" + - test_create_min['msg'] == "cloud_service Cisco Quantum Service created" + +- name: "2 - Duplicate" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Service + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "cloud_service Cisco Quantum Service already exists" + - test_create_idem['cloud_service']['name'] == "Cisco Quantum Service" + +- name: "3 - Update cloud_service" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Service + description: Super secret quantum service! + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "Super secret quantum service!" + +- name: "4 - Update idempotent" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Service + description: Super secret quantum service! + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "cloud_service Cisco Quantum Service already exists" + - test_update_idem['cloud_service']['name'] == "Cisco Quantum Service" + +- name: "5 - Create cloud_service with all parameters" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Secreter Service + cloud_resource_type: CiscoCloudServiceType + cloud_account: CiscoCloudAccount + description: Super secreter quantum service! + extra_config: + my_config: + foo: bar + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['cloud_service']['name'] == "Cisco Quantum Secreter Service" + - test_create_max['cloud_service']['cloud_resource_type'] == cloud_resource_type['key'] + - test_create_max['cloud_service']['cloud_account'] == cloud_account['key'] + - test_create_max['cloud_service']['description'] == "Super secreter quantum service!" + - test_create_max['cloud_service']['extra_config']['my_config']['foo'] == "bar" + +- name: "5.1 - ASSERT" + assert: + that: + - cloud_service['value']['name'] == "Cisco Quantum Secreter Service" + - cloud_service['value']['extra_config']['my_config']['foo'] == "bar" + vars: + cloud_service: "{{ lookup('networktocode.nautobot.lookup', 'cloud-services', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Cisco Quantum Secreter Service\"') }}" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Secreter Service + cloud_resource_type: CiscoCloudServiceType + cloud_account: CiscoCloudAccount + description: Super secreter quantum service! + extra_config: + my_config: + foo: bar + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "cloud_service Cisco Quantum Secreter Service already exists" + - test_create_max_idem['cloud_service']['name'] == "Cisco Quantum Secreter Service" + - test_create_max_idem['cloud_service']['extra_config']['my_config']['foo'] == "bar" + +- name: "7 - Delete cloud_service" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Secreter Service + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_service']['name'] == "Cisco Quantum Secreter Service" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.cloud_service: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Cisco Quantum Secreter Service + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/cloud_service_network_assignment.yml b/tests/integration/targets/latest/tasks/cloud_service_network_assignment.yml index 6fb07eeb..d505eb47 100644 --- a/tests/integration/targets/latest/tasks/cloud_service_network_assignment.yml +++ b/tests/integration/targets/latest/tasks/cloud_service_network_assignment.yml @@ -4,79 +4,74 @@ ### PYNAUTOBOT_CLOUD_SERVICE_NETWORK_ASSIGNMENT ## ## +- set_fact: + cloud_service: "{{ lookup('networktocode.nautobot.lookup', 'cloud-services', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudService') }}" + cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" -- name: "NAUTOBOT 2.3+ CLOUD SERVICE NETWORK ASSIGNMENT TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - cloud_service: "{{ lookup('networktocode.nautobot.lookup', 'cloud-services', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudService') }}" - cloud_network: "{{ lookup('networktocode.nautobot.lookup', 'cloud-networks', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=CiscoCloudNetwork') }}" +- name: "1 - Create cloud service to cloud network assignment" + networktocode.nautobot.cloud_service_network_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_service: CiscoCloudService + cloud_network: CiscoCloudNetwork + register: test_create_one - - name: "1 - Create cloud service to cloud network assignment" - networktocode.nautobot.cloud_service_network_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_service: CiscoCloudService - cloud_network: CiscoCloudNetwork - register: test_create_one +- name: "1 - ASSERT" + assert: + that: + - test_create_one is changed + - test_create_one['diff']['before']['state'] == "absent" + - test_create_one['diff']['after']['state'] == "present" + - test_create_one['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] + - test_create_one['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] + - "'created' in test_create_one['msg']" - - name: "1 - ASSERT" - assert: - that: - - test_create_one is changed - - test_create_one['diff']['before']['state'] == "absent" - - test_create_one['diff']['after']['state'] == "present" - - test_create_one['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] - - test_create_one['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] - - "'created' in test_create_one['msg']" +- name: "2 - Duplicate" + networktocode.nautobot.cloud_service_network_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_service: CiscoCloudService + cloud_network: CiscoCloudNetwork + register: test_create_idem - - name: "2 - Duplicate" - networktocode.nautobot.cloud_service_network_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_service: CiscoCloudService - cloud_network: CiscoCloudNetwork - register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - "'already exists' in test_create_idem['msg']" + - test_create_idem['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] + - test_create_idem['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - "'already exists' in test_create_idem['msg']" - - test_create_idem['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] - - test_create_idem['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] - - - name: "3 - Delete cloud_service_network_assignment" - networktocode.nautobot.cloud_service_network_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_service: CiscoCloudService - cloud_network: CiscoCloudNetwork - state: absent - register: test_delete - - - name: "3 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] - - test_delete['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] - - "'deleted' in test_delete['msg']" - - - name: "4 - Delete idempotent" - networktocode.nautobot.cloud_service_network_assignment: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - cloud_service: CiscoCloudService - cloud_network: CiscoCloudNetwork - state: absent - register: test_delete_idem +- name: "3 - Delete cloud_service_network_assignment" + networktocode.nautobot.cloud_service_network_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_service: CiscoCloudService + cloud_network: CiscoCloudNetwork + state: absent + register: test_delete - - name: "4 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" \ No newline at end of file +- name: "3 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['cloud_service_network_assignment']['cloud_service'] == cloud_service['key'] + - test_delete['cloud_service_network_assignment']['cloud_network'] == cloud_network['key'] + - "'deleted' in test_delete['msg']" + +- name: "4 - Delete idempotent" + networktocode.nautobot.cloud_service_network_assignment: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + cloud_service: CiscoCloudService + cloud_network: CiscoCloudNetwork + state: absent + register: test_delete_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/contact.yml b/tests/integration/targets/latest/tasks/contact.yml index 9f6babb4..60111038 100644 --- a/tests/integration/targets/latest/tasks/contact.yml +++ b/tests/integration/targets/latest/tasks/contact.yml @@ -4,147 +4,142 @@ ### PYNAUTOBOT_CONTACT ## ## -- block: - - set_fact: - test_team: "{{ lookup('networktocode.nautobot.lookup', 'teams', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Test Team\"') }}" - - - name: "1 - Create contact within Nautobot with only required information" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['contact']['name'] == "Test Contact" - - test_create_min['msg'] == "contact Test Contact created" - - - name: "2 - Duplicate" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "contact Test Contact already exists" - - test_create_idem['contact']['name'] == "Test Contact" - - - name: "3 - Update contact" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact - comments: Test Comments - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['comments'] == "" - - test_update['diff']['after']['comments'] == "Test Comments" - - - name: "4 - Update idempotent" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact - comments: Test Comments - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "contact Test Contact already exists" - - test_update_idem['contact']['name'] == "Test Contact" - - - name: "5 - Create contact with all parameters" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact 2 - phone: "123456789" - email: user@example.com - address: Test Address - teams: - - name: My Test Team - comments: Test Comments - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['contact']['name'] == "Test Contact 2" - - test_create_max['contact']['phone'] == "123456789" - - test_create_max['contact']['email'] == "user@example.com" - - test_create_max['contact']['address'] == "Test Address" - - test_create_max['contact']['teams'][0] == test_team['key'] - - test_create_max['contact']['comments'] == "Test Comments" - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact 2 - phone: "123456789" - email: user@example.com - address: Test Address - teams: - - name: My Test Team - comments: Test Comments - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "contact Test Contact 2 already exists" - - test_create_max_idem['contact']['name'] == "Test Contact 2" - - - name: "7 - Delete contact" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact 2 - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['contact']['name'] == "Test Contact 2" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.contact: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Contact 2 - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" - - when: - # Contacts are only available on Nautobot 2.2+ - - "nautobot_version is version('2.2', '>=')" +- set_fact: + test_team: "{{ lookup('networktocode.nautobot.lookup', 'teams', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Test Team\"') }}" + +- name: "1 - Create contact within Nautobot with only required information" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['contact']['name'] == "Test Contact" + - test_create_min['msg'] == "contact Test Contact created" + +- name: "2 - Duplicate" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "contact Test Contact already exists" + - test_create_idem['contact']['name'] == "Test Contact" + +- name: "3 - Update contact" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact + comments: Test Comments + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['comments'] == "" + - test_update['diff']['after']['comments'] == "Test Comments" + +- name: "4 - Update idempotent" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact + comments: Test Comments + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "contact Test Contact already exists" + - test_update_idem['contact']['name'] == "Test Contact" + +- name: "5 - Create contact with all parameters" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact 2 + phone: "123456789" + email: user@example.com + address: Test Address + teams: + - name: My Test Team + comments: Test Comments + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['contact']['name'] == "Test Contact 2" + - test_create_max['contact']['phone'] == "123456789" + - test_create_max['contact']['email'] == "user@example.com" + - test_create_max['contact']['address'] == "Test Address" + - test_create_max['contact']['teams'][0] == test_team['key'] + - test_create_max['contact']['comments'] == "Test Comments" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact 2 + phone: "123456789" + email: user@example.com + address: Test Address + teams: + - name: My Test Team + comments: Test Comments + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "contact Test Contact 2 already exists" + - test_create_max_idem['contact']['name'] == "Test Contact 2" + +- name: "7 - Delete contact" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact 2 + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['contact']['name'] == "Test Contact 2" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.contact: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Contact 2 + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" diff --git a/tests/integration/targets/latest/tasks/controller.yml b/tests/integration/targets/latest/tasks/controller.yml index 62645b55..e8bcfabd 100644 --- a/tests/integration/targets/latest/tasks/controller.yml +++ b/tests/integration/targets/latest/tasks/controller.yml @@ -1,125 +1,115 @@ --- -- debug: - msg: "{{ nautobot_version }}" +- set_fact: + parent_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Parent Test Location\"') }}" -- block: - - set_fact: - parent_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Parent Test Location\"') }}" +- name: "CONTROLLER 1: Necessary info creation" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Controller One + location: "Parent Test Location" + state: present + status: "Active" + register: test_one_controller - - name: "CONTROLLER 1: Necessary info creation" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Controller One - location: "Parent Test Location" - state: present - status: "Active" - register: test_one_controller +- name: "CONTROLLER 1: ASSERT - Necessary info creation" + assert: + that: + - test_one_controller is changed + - test_one_controller['diff']['before']['state'] == "absent" + - test_one_controller['diff']['after']['state'] == "present" + - test_one_controller['controller']['name'] == "Test Controller One" + - test_one_controller['controller']['object_type'] == "dcim.controller" + - test_one_controller['msg'] == "controller Test Controller One created" - - name: "CONTROLLER 1: ASSERT - Necessary info creation" - assert: - that: - - test_one_controller is changed - - test_one_controller['diff']['before']['state'] == "absent" - - test_one_controller['diff']['after']['state'] == "present" - - test_one_controller['controller']['name'] == "Test Controller One" - - test_one_controller['controller']['object_type'] == "dcim.controller" - - test_one_controller['msg'] == "controller Test Controller One created" +- name: "CONTROLLER 2: Create duplicate" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Controller One + location: "Parent Test Location" + state: present + status: "Active" + register: test_two - - name: "CONTROLLER 2: Create duplicate" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Controller One - location: "Parent Test Location" - state: present - status: "Active" - register: test_two +- name: "CONTROLLER 2: ASSERT - Create duplicate" + assert: + that: + - not test_two['changed'] + - test_two['controller']['name'] == "Test Controller One" + - test_two['msg'] == "controller Test Controller One already exists" - - name: "CONTROLLER 2: ASSERT - Create duplicate" - assert: - that: - - not test_two['changed'] - - test_two['controller']['name'] == "Test Controller One" - - test_two['msg'] == "controller Test Controller One already exists" +- name: "CONTROLLER 3: Update" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Controller One + description: "Test Controller changed description" + location: "Parent Test Location" + state: present + status: "Active" + register: test_three - - name: "CONTROLLER 3: Update" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Controller One - description: "Test Controller changed description" - location: "Parent Test Location" - state: present - status: "Active" - register: test_three +- name: "CONTROLLER 3: ASSERT - Update" + assert: + that: + - test_three['changed'] + - test_three['controller']['name'] == "Test Controller One" + - test_three['controller']['description'] == "Test Controller changed description" + - test_three['msg'] == "controller Test Controller One updated" - - debug: - msg: "{{ test_three}}" +- name: "CONTROLLER 4: ASSERT - Delete" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Controller One + state: absent + register: test_four - - name: "CONTROLLER 3: ASSERT - Update" - assert: - that: - - test_three['changed'] - - test_three['controller']['name'] == "Test Controller One" - - test_three['controller']['description'] == "Test Controller changed description" - - test_three['msg'] == "controller Test Controller One updated" +- name: "CONTROLLER 4: ASSERT - Delete" + assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "controller Test Controller One deleted" - - name: "CONTROLLER 4: ASSERT - Delete" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Controller One - state: absent - register: test_four +- name: "CONTROLLER 5: ASSERT - Delete non existing" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Controller Two + state: absent + register: test_five - - name: "CONTROLLER 4: ASSERT - Delete" - assert: - that: - - test_four is changed - - test_four['diff']['before']['state'] == "present" - - test_four['diff']['after']['state'] == "absent" - - test_four['msg'] == "controller Test Controller One deleted" +- name: "CONTROLLER 5: ASSERT - Delete non existing" + assert: + that: + - not test_five['changed'] + - test_five['controller'] == None + - test_five['msg'] == "controller Test Controller Two already absent" - - name: "CONTROLLER 5: ASSERT - Delete non existing" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Controller Two - state: absent - register: test_five +- name: "CONTROLLER 6: CREATE A CONTROLLER WITH AS MUCH AS POSSIBLE" + networktocode.nautobot.controller: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: "test_controller_3" + status: "Active" + location: "Parent Test Location" + # external_integration: "" + role: "Test Controller Role" + tenant: "Test Tenant" + controller_device_redundancy_group: "My Device Redundancy Group" + tags: + - Controller Tag + register: test_six_controller - - name: "CONTROLLER 5: ASSERT - Delete non existing" - assert: - that: - - not test_five['changed'] - - test_five['controller'] == None - - test_five['msg'] == "controller Test Controller Two already absent" - - - name: "CONTROLLER 6: CREATE A CONTROLLER WITH AS MUCH AS POSSIBLE" - networktocode.nautobot.controller: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: "test_controller_3" - status: "Active" - location: "Parent Test Location" - # external_integration: "" - role: "Test Controller Role" - tenant: "Test Tenant" - controller_device_redundancy_group: "My Device Redundancy Group" - tags: - - Controller Tag - register: test_six_controller - - - name: "CONTROLLER 7: ASSERT - As Much As Possible Info creation" - assert: - that: - - test_six_controller is changed - - test_six_controller['diff']['before']['state'] == "absent" - - test_six_controller['diff']['after']['state'] == "present" - - test_six_controller['controller']['name'] == "test_controller_3" - - test_six_controller['controller']['object_type'] == "dcim.controller" - - test_six_controller['msg'] == "controller test_controller_3 created" - when: - # Controllers are only available on Nautobot 2.2+ - - "nautobot_version is version('2.2', '>=')" +- name: "CONTROLLER 7: ASSERT - As Much As Possible Info creation" + assert: + that: + - test_six_controller is changed + - test_six_controller['diff']['before']['state'] == "absent" + - test_six_controller['diff']['after']['state'] == "present" + - test_six_controller['controller']['name'] == "test_controller_3" + - test_six_controller['controller']['object_type'] == "dcim.controller" + - test_six_controller['msg'] == "controller test_controller_3 created" diff --git a/tests/integration/targets/latest/tasks/dynamic_group.yml b/tests/integration/targets/latest/tasks/dynamic_group.yml new file mode 100644 index 00000000..8e707bb8 --- /dev/null +++ b/tests/integration/targets/latest/tasks/dynamic_group.yml @@ -0,0 +1,316 @@ +--- +## +## +### PYNAUTOBOT_DYNAMIC_GROUP +## +## +- name: "1 - Create dynamic group within Nautobot with only required information" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['dynamic_group']['name'] == "TestFilterGroup" + - test_create_min['dynamic_group']['content_type'] == "dcim.device" + - test_create_min['dynamic_group']['filter']['location'][0] == "Child-Child Test Location" + - test_create_min['msg'] == "dynamic_group TestFilterGroup created" + +- name: "2 - Duplicate" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + register: test_create_idem + +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "dynamic_group TestFilterGroup already exists" + - test_create_idem['dynamic_group']['name'] == "TestFilterGroup" + +- name: "3 - Update dynamic_group" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + description: An update to prove it updates + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "An update to prove it updates" + +- name: "4 - Update idempotent" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + description: An update to prove it updates + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "dynamic_group TestFilterGroup already exists" + - test_update_idem['dynamic_group']['name'] == "TestFilterGroup" + - test_update_idem['dynamic_group']['description'] == "An update to prove it updates" + +- name: "5 - Create dynamic_group with all parameters" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroupTwo + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + description: Another dynamic group + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['dynamic_group']['name'] == "TestFilterGroupTwo" + - test_create_max['dynamic_group']['description'] == "Another dynamic group" + - test_create_max['dynamic_group']['content_type'] == "dcim.device" + - test_create_max['dynamic_group']['filter']['location'][0] == "Child-Child Test Location" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroupTwo + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + description: Another dynamic group + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "dynamic_group TestFilterGroupTwo already exists" + - test_create_max_idem['dynamic_group']['name'] == "TestFilterGroupTwo" + - test_create_max_idem['dynamic_group']['description'] == "Another dynamic group" + - test_create_max_idem['dynamic_group']['content_type'] == "dcim.device" + - test_create_max_idem['dynamic_group']['filter']['location'][0] == "Child-Child Test Location" + +- name: "7 - Delete dynamic_group" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['dynamic_group']['name'] == "TestFilterGroup" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" + +- name: "NAUTOBOT 2.3+ DYNAMIC GROUPS TESTS" + when: + - "nautobot_version is version('2.3', '>=')" + block: + - set_fact: + test_tenant: "{{ lookup('networktocode.nautobot.lookup', 'tenants', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Tenant\"') }}" + test_tag: "{{ lookup('networktocode.nautobot.lookup', 'tags', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Dynamic Group Tag\"') }}" + + - name: "1 - Create dynamic group within Nautobot with only required information" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + group_type: dynamic-filter + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + register: test_create_min + + - name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['dynamic_group']['name'] == "TestFilterGroup" + - test_create_min['dynamic_group']['group_type'] == "dynamic-filter" + - test_create_min['dynamic_group']['content_type'] == "dcim.device" + - test_create_min['dynamic_group']['filter']['location'][0] == "Child-Child Test Location" + - test_create_min['msg'] == "dynamic_group TestFilterGroup created" + + - name: "2 - Duplicate" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + group_type: dynamic-filter + content_type: dcim.device + filter: + location: + - "Child-Child Test Location" + register: test_create_idem + + - name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "dynamic_group TestFilterGroup already exists" + - test_create_idem['dynamic_group']['name'] == "TestFilterGroup" + + - name: "3 - Update dynamic_group" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + description: An update to prove it updates + register: test_update + + - name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['description'] == "" + - test_update['diff']['after']['description'] == "An update to prove it updates" + + - name: "4 - Update idempotent" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + description: An update to prove it updates + register: test_update_idem + + - name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "dynamic_group TestFilterGroup already exists" + - test_update_idem['dynamic_group']['name'] == "TestFilterGroup" + - test_update_idem['dynamic_group']['description'] == "An update to prove it updates" + + - name: "5 - Create dynamic_group with all parameters" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestNestedGroup + description: A group of groups + group_type: dynamic-set + content_type: dcim.device + tenant: "Test Tenant" + tags: + - "Dynamic Group Tag" + register: test_create_max + + - name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['dynamic_group']['name'] == "TestNestedGroup" + - test_create_max['dynamic_group']['description'] == "A group of groups" + - test_create_max['dynamic_group']['group_type'] == "dynamic-set" + - test_create_max['dynamic_group']['content_type'] == "dcim.device" + - test_create_max['dynamic_group']['tenant'] == test_tenant['key'] + - test_create_max['dynamic_group']['tags'][0] == test_tag['key'] + + - name: "6 - Duplicate create with all parameters" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestNestedGroup + description: A group of groups + group_type: dynamic-set + content_type: dcim.device + tenant: "Test Tenant" + tags: + - "Dynamic Group Tag" + register: test_create_max_idem + + - name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "dynamic_group TestNestedGroup already exists" + - test_create_max_idem['dynamic_group']['name'] == "TestNestedGroup" + - test_create_max_idem['dynamic_group']['description'] == "A group of groups" + - test_create_max_idem['dynamic_group']['group_type'] == "dynamic-set" + - test_create_max_idem['dynamic_group']['content_type'] == "dcim.device" + - test_create_max_idem['dynamic_group']['tenant'] == test_tenant['key'] + - test_create_max_idem['dynamic_group']['tags'][0] == test_tag['key'] + + - name: "7 - Delete dynamic_group" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + state: absent + register: test_delete + + - name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['dynamic_group']['name'] == "TestFilterGroup" + - "'deleted' in test_delete['msg']" + + - name: "8 - Delete idempotent" + networktocode.nautobot.dynamic_group: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TestFilterGroup + state: absent + register: test_delete_idem + + - name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/job_button.yml b/tests/integration/targets/latest/tasks/job_button.yml new file mode 100644 index 00000000..061179b7 --- /dev/null +++ b/tests/integration/targets/latest/tasks/job_button.yml @@ -0,0 +1,177 @@ +--- +## +## +### PYNAUTOBOT_JOB_BUTTON +## +## +- set_fact: + test_job: "{{ lookup('networktocode.nautobot.lookup', 'jobs', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Example Simple Job Button Receiver\"') }}" + +- name: "1 - Create job button within Nautobot with only required information" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButton + content_types: + - dcim.device + job: "Example Simple Job Button Receiver" + text: SubmitMe + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['job_button']['name'] == "MyJobButton" + - test_create_min['job_button']['content_types'] == ['dcim.device'] + - test_create_min['job_button']['job'] == test_job['key'] + - test_create_min['job_button']['text'] == "SubmitMe" + - test_create_min['msg'] == "job_button MyJobButton created" + +- name: "2 - Duplicate" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButton + content_types: + - dcim.device + job: "Example Simple Job Button Receiver" + text: SubmitMe + register: test_create_idem + +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "job_button MyJobButton already exists" + - test_create_idem['job_button']['name'] == "MyJobButton" + +- name: "3 - Update job button" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButton + content_types: + - dcim.device + - dcim.location + job: "Example Simple Job Button Receiver" + text: SubmitMe + confirmation: false + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['content_types'] == ['dcim.device'] + - test_update['diff']['before']['confirmation'] == true + - test_update['diff']['after']['content_types'] == ['dcim.device', 'dcim.location'] + - test_update['diff']['after']['confirmation'] == false + +- name: "4 - Update idempotent" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButton + content_types: + - dcim.device + - dcim.location + job: "Example Simple Job Button Receiver" + text: SubmitMe + confirmation: false + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "job_button MyJobButton already exists" + - test_update_idem['job_button']['name'] == "MyJobButton" + +- name: "5 - Create job button with all parameters" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButtonTwo + content_types: + - dcim.device + job: "Example Simple Job Button Receiver" + text: SubmitMeToo + enabled: "{{ false if nautobot_version is version('2.3', '>=') else omit }}" + confirmation: false + weight: 200 + group_name: Groop + button_class: primary + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['job_button']['name'] == "MyJobButtonTwo" + - test_create_max['job_button']['content_types'] == ['dcim.device'] + - test_create_max['job_button']['job'] == test_job['key'] + - test_create_max['job_button']['text'] == "SubmitMeToo" + - test_create_max['job_button']['confirmation'] == false + - test_create_max['job_button']['weight'] == 200 + - test_create_max['job_button']['group_name'] == "Groop" + - test_create_max['job_button']['button_class'] == "primary" + - test_create_max['msg'] == "job_button MyJobButtonTwo created" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButtonTwo + content_types: + - dcim.device + job: "Example Simple Job Button Receiver" + text: SubmitMeToo + enabled: "{{ false if nautobot_version is version('2.3', '>=') else omit }}" + confirmation: false + weight: 200 + group_name: Groop + button_class: primary + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "job_button MyJobButtonTwo already exists" + - test_create_max_idem['job_button']['name'] == "MyJobButtonTwo" + +- name: "7 - Delete job button" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButtonTwo + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['job_button']['name'] == "MyJobButtonTwo" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.job_button: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: MyJobButtonTwo + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" diff --git a/tests/integration/targets/latest/tasks/location_type.yml b/tests/integration/targets/latest/tasks/location_type.yml index f1cb68e5..cd3f431a 100644 --- a/tests/integration/targets/latest/tasks/location_type.yml +++ b/tests/integration/targets/latest/tasks/location_type.yml @@ -55,7 +55,8 @@ token: "{{ nautobot_token }}" name: Test Location Type 2 description: Test Location Type 2 Description - parent: "{{ test_create_min['location_type']['name'] }}" + parent: + name: "{{ test_create_min['location_type']['name'] }}" nestable: "{{ true if nautobot_version is version('1.5', '>=') else omit }}" content_types: - "dcim.device" @@ -80,7 +81,8 @@ token: "{{ nautobot_token }}" name: Test Location Type 2 description: Test Location Type 2 Description - parent: "{{ test_create_min['location_type']['name'] }}" + parent: + name: "{{ test_create_min['location_type']['name'] }}" nestable: "{{ true if nautobot_version is version('1.5', '>=') else omit }}" content_types: - "dcim.device" diff --git a/tests/integration/targets/latest/tasks/main.yml b/tests/integration/targets/latest/tasks/main.yml index e4fe1a30..e52ada08 100644 --- a/tests/integration/targets/latest/tasks/main.yml +++ b/tests/integration/targets/latest/tasks/main.yml @@ -528,33 +528,6 @@ tags: - namespace -- name: "PYNAUTOBOT_VLAN_LOCATION TESTS" - include_tasks: - file: "vlan_location.yml" - apply: - tags: - - vlan_location - tags: - - vlan_location - -- name: "PYNAUTOBOT_CONTACT TESTS" - include_tasks: - file: "contact.yml" - apply: - tags: - - contact - tags: - - contact - -- name: "PYNAUTOBOT_TEAM TESTS" - include_tasks: - file: "team.yml" - apply: - tags: - - team - tags: - - team - - name: "PYNAUTOBOT_USER TESTS" include_tasks: file: "admin_user.yml" @@ -582,111 +555,216 @@ tags: - admin_permission -- name: "PYNAUTOBOT_CONTROLLER TESTS" +- name: "PYNAUTOBOT_DYNAMIC_GROUP TESTS" include_tasks: - file: "controller.yml" + file: "dynamic_group.yml" apply: tags: - - controller + - dynamic_group tags: - - controller + - dynamic_group -- name: "PYNAUTOBOT_CONTROLLER_MANAGED_DEVICE_GROUP TESTS" +- name: "PYNAUTOBOT_JOB_BUTTON TESTS" include_tasks: - file: "controller_managed_device_group.yml" + file: "job_button.yml" apply: tags: - - controller_managed_device_group + - job_button tags: - - controller_managed_device_group + - job_button -- name: "PYNAUTOBOT_MODULE_TYPE TESTS" - include_tasks: - file: "module_type.yml" - apply: +########################## +## +### NAUTOBOT 2.2+ TESTS +## +########################## + +- name: "NAUTOBOT 2.2+ TESTS" + when: + - "nautobot_version is version('2.2', '>=')" + block: + - name: "PYNAUTOBOT_CONTACT TESTS" + include_tasks: + file: "contact.yml" + apply: + tags: + - contact tags: - - module_type - tags: - - module_type + - contact -- name: "PYNAUTOBOT_MODULE_BAY_TEMPLATE TESTS" - include_tasks: - file: "module_bay_template.yml" - apply: + - name: "PYNAUTOBOT_TEAM TESTS" + include_tasks: + file: "team.yml" + apply: + tags: + - team tags: - - module_bay_template - tags: - - module_bay_template + - team -- name: "PYNAUTOBOT_MODULE_BAY TESTS" - include_tasks: - file: "module_bay.yml" - apply: + - name: "PYNAUTOBOT_CONTROLLER TESTS" + include_tasks: + file: "controller.yml" + apply: + tags: + - controller tags: - - module_bay - tags: - - module_bay + - controller -- name: "PYNAUTOBOT_MODULE TESTS" +- name: "PYNAUTOBOT_CONTROLLER_MANAGED_DEVICE_GROUP TESTS" include_tasks: - file: "module.yml" + file: "controller_managed_device_group.yml" apply: tags: - - module + - controller_managed_device_group tags: - - module + - controller_managed_device_group -- name: "PYNAUTOBOT_CLOUD_ACCOUNT TESTS" +- name: "PYNAUTOBOT_MODULE_TYPE TESTS" include_tasks: - file: "cloud_account.yml" + file: "module_type.yml" apply: + - name: "PYNAUTOBOT_VLAN_LOCATION TESTS" + include_tasks: + file: "vlan_location.yml" + apply: + tags: + - vlan_location + tags: + - vlan_location + + +########################## +## +### NAUTOBOT 2.3+ TESTS +## +########################## + +- name: "NAUTOBOT 2.3+ TESTS" + when: + - "nautobot_version is version('2.3', '>=')" + block: + - name: "PYNAUTOBOT_CLOUD_ACCOUNT TESTS" + include_tasks: + file: "cloud_account.yml" + apply: + tags: + - cloud_account tags: - cloud_account - tags: - - cloud_account -- name: "PYNAUTOBOT_CLOUD_NETWORK TESTS" - include_tasks: - file: "cloud_network.yml" - apply: + - name: "PYNAUTOBOT_CLOUD_NETWORK TESTS" + include_tasks: + file: "cloud_network.yml" + apply: + tags: + - cloud_network tags: - cloud_network - tags: - - cloud_network -- name: "PYNAUTOBOT_CLOUD_RESOURCE_TYPE TESTS" - include_tasks: - file: "cloud_resource_type.yml" - apply: + - name: "PYNAUTOBOT_CLOUD_RESOURCE_TYPE TESTS" + include_tasks: + file: "cloud_resource_type.yml" + apply: + tags: + - cloud_resource_type tags: - cloud_resource_type - tags: - - cloud_resource_type -- name: "PYNAUTOBOT_CLOUD_SERVICE TESTS" - include_tasks: - file: "cloud_service.yml" - apply: + - name: "PYNAUTOBOT_CLOUD_SERVICE TESTS" + include_tasks: + file: "cloud_service.yml" + apply: + tags: + - cloud_service tags: - cloud_service - tags: - - cloud_service -- name: "PYNAUTOBOT_CLOUD_SERVICE_NETWORK_ASSIGNMENT TESTS" - include_tasks: - file: "cloud_service_network_assignment.yml" - apply: + - name: "PYNAUTOBOT_CLOUD_SERVICE_NETWORK_ASSIGNMENT TESTS" + include_tasks: + file: "cloud_service_network_assignment.yml" + apply: + tags: + - cloud_service_network_assignment tags: - cloud_service_network_assignment - tags: - - cloud_service_network_assignment -- name: "PYNAUTOBOT_CLOUD_NETWORK_PREFIX_ASSIGNMENT TESTS" - include_tasks: - file: "cloud_network_prefix_assignment.yml" - apply: + - name: "PYNAUTOBOT_CLOUD_NETWORK_PREFIX_ASSIGNMENT TESTS" + include_tasks: + file: "cloud_network_prefix_assignment.yml" + apply: + tags: + - cloud_network_prefix_assignment tags: - cloud_network_prefix_assignment - tags: - - cloud_network_prefix_assignment - \ No newline at end of file + + - name: "PYNAUTOBOT_METADATA_TYPE TESTS" + include_tasks: + file: "metadata_type.yml" + apply: + tags: + - metadata_type + tags: + - metadata_type + + - name: "PYNAUTOBOT_METADATA_CHOICE TESTS" + include_tasks: + file: "metadata_choice.yml" + apply: + tags: + - metadata_choice + tags: + - metadata_choice + + - name: "PYNAUTOBOT_OBJECT_METADATA TESTS" + include_tasks: + file: "object_metadata.yml" + apply: + tags: + - object_metadata + tags: + - object_metadata + + - name: "PYNAUTOBOT_MODULE_TYPE TESTS" + include_tasks: + file: "module_type.yml" + apply: + tags: + - module_type + tags: + - module_type + + - name: "PYNAUTOBOT_MODULE_BAY_TEMPLATE TESTS" + include_tasks: + file: "module_bay_template.yml" + apply: + tags: + - module_bay_template + tags: + - module_bay_template + + - name: "PYNAUTOBOT_MODULE_BAY TESTS" + include_tasks: + file: "module_bay.yml" + apply: + tags: + - module_bay + tags: + - module_bay + + - name: "PYNAUTOBOT_MODULE TESTS" + include_tasks: + file: "module.yml" + apply: + tags: + - module + tags: + - module + + - name: "PYNAUTOBOT_STATIC_GROUP_ASSOCIATION TESTS" + include_tasks: + file: "static_group_association.yml" + apply: + tags: + - static_group_association + tags: + - static_group_association diff --git a/tests/integration/targets/latest/tasks/metadata_choice.yml b/tests/integration/targets/latest/tasks/metadata_choice.yml new file mode 100644 index 00000000..95a83c3a --- /dev/null +++ b/tests/integration/targets/latest/tasks/metadata_choice.yml @@ -0,0 +1,107 @@ +--- +## +## +### PYNAUTOBOT_METADATA_CHOICE +## +## +- set_fact: + test_metadata_type: "{{ lookup('networktocode.nautobot.lookup', 'metadata-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"TestMetadataType\"') }}" + +- name: "1 - Create metadata choice within Nautobot" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + weight: 150 + register: test_create + +- name: "1 - ASSERT" + assert: + that: + - test_create is changed + - test_create['diff']['before']['state'] == "absent" + - test_create['diff']['after']['state'] == "present" + - test_create['metadata_choice']['value'] == "Test Metadata Choice" + - test_create['metadata_choice']['weight'] == 150 + - test_create['metadata_choice']['metadata_type'] == test_metadata_type['key'] + - test_create['msg'] == "metadata_choice Test Metadata Choice created" + +- name: "2 - Duplicate" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + register: test_create_idem + +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "metadata_choice Test Metadata Choice already exists" + - test_create_idem['metadata_choice']['value'] == "Test Metadata Choice" + +- name: "3 - Update metadata choice" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + weight: 200 + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['weight'] == 150 + - test_update['diff']['after']['weight'] == 200 + +- name: "4 - Update metadata choice idempotent" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + weight: 200 + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "metadata_choice Test Metadata Choice already exists" + - test_update_idem['metadata_choice']['value'] == "Test Metadata Choice" + +- name: "5 - Delete metadata choice" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + state: absent + register: test_delete + +- name: "5 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - "'deleted' in test_delete['msg']" + +- name: "6 - Delete idempotent" + networktocode.nautobot.metadata_choice: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataType" + value: "Test Metadata Choice" + state: absent + register: test_delete_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" diff --git a/tests/integration/targets/latest/tasks/metadata_type.yml b/tests/integration/targets/latest/tasks/metadata_type.yml new file mode 100644 index 00000000..8e9859dd --- /dev/null +++ b/tests/integration/targets/latest/tasks/metadata_type.yml @@ -0,0 +1,169 @@ +--- +## +## +### PYNAUTOBOT_METADATA_TYPE +## +## +- name: "1 - Create metadata type with minimum information" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfo + data_type: text + content_types: + - dcim.device + state: present + register: test_one + +- name: "1 - ASSERT" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['metadata_type']['name'] == "TopSecretInfo" + - test_one['metadata_type']['data_type'] == "text" + - test_one['metadata_type']['content_types'] == ['dcim.device'] + - test_one['msg'] == "metadata_type TopSecretInfo created" + +- name: "2 - Create metadata type with minimum information idempotent" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfo + data_type: text + content_types: + - dcim.device + state: present + register: test_two + +- name: "2 - ASSERT" + assert: + that: + - not test_two['changed'] + - test_two['metadata_type']['name'] == "TopSecretInfo" + - test_two['metadata_type']['data_type'] == "text" + - test_two['metadata_type']['content_types'] == ['dcim.device'] + - test_two['msg'] == "metadata_type TopSecretInfo already exists" + +- name: "3 - Update metadata type" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfo + description: The topest secretest info + data_type: text + content_types: + - dcim.device + - dcim.location + state: present + register: test_three + +- name: "3 - ASSERT" + assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The topest secretest info" + - test_three['diff']['after']['content_types'] == ['dcim.device', 'dcim.location'] + - test_three['metadata_type']['name'] == "TopSecretInfo" + - test_three['metadata_type']['description'] == "The topest secretest info" + - test_three['metadata_type']['data_type'] == "text" + - test_three['metadata_type']['content_types'] == ['dcim.device', 'dcim.location'] + - test_three['msg'] == "metadata_type TopSecretInfo updated" + +- name: "4 - Update idempotent" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfo + description: The topest secretest info + data_type: text + content_types: + - dcim.device + - dcim.location + state: present + register: test_four + +- name: "4 - ASSERT" + assert: + that: + - not test_four['changed'] + - test_four['metadata_type']['name'] == "TopSecretInfo" + - test_four['msg'] == "metadata_type TopSecretInfo already exists" + +- name: "5 - Create metadata type with all params" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfoToo + description: The topest secretest info too + data_type: text + content_types: + - dcim.device + - dcim.location + state: present + register: test_five + +- name: "5 - ASSERT" + assert: + that: + - test_five is changed + - test_five['metadata_type']['name'] == "TopSecretInfoToo" + - test_five['metadata_type']['description'] == "The topest secretest info too" + - test_five['metadata_type']['data_type'] == "text" + - test_five['metadata_type']['content_types'] == ['dcim.device', 'dcim.location'] + - test_five['msg'] == "metadata_type TopSecretInfoToo created" + +- name: "6 - Create metadata type with all params idempotent" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfoToo + description: The topest secretest info too + data_type: text + content_types: + - dcim.device + - dcim.location + state: present + register: test_six + +- name: "6 - ASSERT" + assert: + that: + - not test_six['changed'] + - test_six['metadata_type']['name'] == "TopSecretInfoToo" + - test_six['metadata_type']['description'] == "The topest secretest info too" + - test_six['metadata_type']['data_type'] == "text" + - test_six['metadata_type']['content_types'] == ['dcim.device', 'dcim.location'] + - test_six['msg'] == "metadata_type TopSecretInfoToo already exists" + +- name: "7 - Delete" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfoToo + state: absent + register: test_seven + +- name: "7 - ASSERT" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "metadata_type TopSecretInfoToo deleted" + +- name: "8 - Delete idempotent" + networktocode.nautobot.metadata_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: TopSecretInfoToo + state: absent + register: test_eight + +- name: "8 - ASSERT`" + assert: + that: + - not test_eight['changed'] + - test_eight['metadata_type'] == None + - test_eight['msg'] == "metadata_type TopSecretInfoToo already absent" diff --git a/tests/integration/targets/latest/tasks/module.yml b/tests/integration/targets/latest/tasks/module.yml index 6e0760e7..d33934c4 100644 --- a/tests/integration/targets/latest/tasks/module.yml +++ b/tests/integration/targets/latest/tasks/module.yml @@ -4,200 +4,196 @@ ### PYNAUTOBOT_MODULE ## ## -- name: "NAUTOBOT 2.3+ MODULE TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - test_module_type: '{{ lookup(''networktocode.nautobot.lookup'', ''module-types'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''model="HooverMaxProModel60"'') }}' - test_module_role: "{{ lookup('networktocode.nautobot.lookup', 'roles', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Module Role\"') }}" - test_module_bay: '{{ lookup(''networktocode.nautobot.lookup'', ''module-bays'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="PowerStripTwo"'') }}' - test_module_status: "{{ lookup('networktocode.nautobot.lookup', 'statuses', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Active') }}" - test_module_tenant: "{{ lookup('networktocode.nautobot.lookup', 'tenants', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Tenant\"') }}" - test_module_child_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Child Test Location\" parent=\"Parent Test Location\"') }}" - - - name: "1 - Create module with minimum information" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - parent_module_bay: - name: PowerStripTwo - parent_device: test100 - status: Active - state: present - register: test_one - - - name: "1 - ASSERT" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['module']['module_type'] == test_module_type['key'] - - test_one['module']['parent_module_bay'] == test_module_bay['key'] - - test_one['module']['status'] == test_module_status['key'] - - test_one['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 created" - - - name: "2 - Create module with minimum information idempotent" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - parent_module_bay: - name: PowerStripTwo - parent_device: test100 - status: Active - state: present - register: test_two - - - name: "2 - ASSERT" - assert: - that: - - not test_two['changed'] - - test_two['module']['module_type'] == test_module_type['key'] - - test_two['module']['parent_module_bay'] == test_module_bay['key'] - - test_two['module']['status'] == test_module_status['key'] - - test_two['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 already exists" - - - name: "3 - Update module" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - parent_module_bay: - name: PowerStripTwo - parent_device: test100 - serial: "123456" - asset_tag: "654321" - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['serial'] == "123456" - - test_three['diff']['after']['asset_tag'] == "654321" - - test_three['module']['module_type'] == test_module_type['key'] - - test_three['module']['parent_module_bay'] == test_module_bay['key'] - - test_three['module']['status'] == test_module_status['key'] - - test_three['module']['serial'] == "123456" - - test_three['module']['asset_tag'] == "654321" - - test_three['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 updated" - - - name: "4 - Update idempotent" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - parent_module_bay: - name: PowerStripTwo - parent_device: test100 - serial: "123456" - asset_tag: "654321" - state: present - register: test_four - - - name: "4 - ASSERT" - assert: - that: - - not test_four['changed'] - - test_four['module']['module_type'] == test_module_type['key'] - - test_four['module']['parent_module_bay'] == test_module_bay['key'] - - test_four['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 already exists" - - - name: "5 - Create module with all params" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - location: - name: "Child Test Location" - parent: "Parent Test Location" - serial: "654321" - asset_tag: "123456" - role: Test Module Role - status: Active - tenant: Test Tenant - state: present - register: test_five - - - name: "5 - ASSERT" - assert: - that: - - test_five is changed - - test_five['module']['module_type'] == test_module_type['key'] - - test_five['module']['location'] == test_module_child_location['key'] - - test_five['module']['serial'] == "654321" - - test_five['module']['asset_tag'] == "123456" - - test_five['module']['role'] == test_module_role['key'] - - test_five['module']['status'] == test_module_status['key'] - - test_five['module']['tenant'] == test_module_tenant['key'] - - test_five['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 created" - - - name: "6 - Create module with all params idempotent" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - location: - name: "Child Test Location" - parent: "Parent Test Location" - serial: "654321" - asset_tag: "123456" - role: Test Module Role - status: Active - tenant: Test Tenant - state: present - register: test_six - - - name: "6 - ASSERT" - assert: - that: - - not test_six['changed'] - - test_six['module']['module_type'] == test_module_type['key'] - - test_six['module']['location'] == test_module_child_location['key'] - - test_six['module']['serial'] == "654321" - - test_six['module']['asset_tag'] == "123456" - - test_six['module']['role'] == test_module_role['key'] - - test_six['module']['status'] == test_module_status['key'] - - test_six['module']['tenant'] == test_module_tenant['key'] - - test_six['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 already exists" - - - name: "7 - Delete" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - location: - name: "Child Test Location" - parent: "Parent Test Location" - state: absent - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - test_seven is changed - - test_seven['diff']['before']['state'] == "present" - - test_seven['diff']['after']['state'] == "absent" - - test_seven['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 deleted" - - - name: "8 - Delete idempotent" - networktocode.nautobot.module: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - location: - name: "Child Test Location" - parent: "Parent Test Location" - state: absent - register: test_eight - - - name: "8 - ASSERT`" - assert: - that: - - not test_eight['changed'] - - test_eight['module'] == None - - test_eight['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 already absent" +- set_fact: + test_module_type: '{{ lookup(''networktocode.nautobot.lookup'', ''module-types'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''model="HooverMaxProModel60"'') }}' + test_module_role: "{{ lookup('networktocode.nautobot.lookup', 'roles', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Module Role\"') }}" + test_module_bay: '{{ lookup(''networktocode.nautobot.lookup'', ''module-bays'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="PowerStripTwo"'') }}' + test_module_status: "{{ lookup('networktocode.nautobot.lookup', 'statuses', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Active') }}" + test_module_tenant: "{{ lookup('networktocode.nautobot.lookup', 'tenants', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Tenant\"') }}" + test_module_child_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Child Test Location\" parent=\"Parent Test Location\"') }}" + +- name: "1 - Create module with minimum information" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + parent_module_bay: + name: PowerStripTwo + parent_device: test100 + status: Active + state: present + register: test_one + +- name: "1 - ASSERT" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module']['module_type'] == test_module_type['key'] + - test_one['module']['parent_module_bay'] == test_module_bay['key'] + - test_one['module']['status'] == test_module_status['key'] + - test_one['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 created" + +- name: "2 - Create module with minimum information idempotent" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + parent_module_bay: + name: PowerStripTwo + parent_device: test100 + status: Active + state: present + register: test_two + +- name: "2 - ASSERT" + assert: + that: + - not test_two['changed'] + - test_two['module']['module_type'] == test_module_type['key'] + - test_two['module']['parent_module_bay'] == test_module_bay['key'] + - test_two['module']['status'] == test_module_status['key'] + - test_two['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 already exists" + +- name: "3 - Update module" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + parent_module_bay: + name: PowerStripTwo + parent_device: test100 + serial: "123456" + asset_tag: "654321" + state: present + register: test_three + +- name: "3 - ASSERT" + assert: + that: + - test_three is changed + - test_three['diff']['after']['serial'] == "123456" + - test_three['diff']['after']['asset_tag'] == "654321" + - test_three['module']['module_type'] == test_module_type['key'] + - test_three['module']['parent_module_bay'] == test_module_bay['key'] + - test_three['module']['status'] == test_module_status['key'] + - test_three['module']['serial'] == "123456" + - test_three['module']['asset_tag'] == "654321" + - test_three['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 updated" + +- name: "4 - Update idempotent" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + parent_module_bay: + name: PowerStripTwo + parent_device: test100 + serial: "123456" + asset_tag: "654321" + state: present + register: test_four + +- name: "4 - ASSERT" + assert: + that: + - not test_four['changed'] + - test_four['module']['module_type'] == test_module_type['key'] + - test_four['module']['parent_module_bay'] == test_module_bay['key'] + - test_four['msg'] == "module test100 > PowerStripTwo > HooverMaxProModel60 already exists" + +- name: "5 - Create module with all params" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + location: + name: "Child Test Location" + parent: "Parent Test Location" + serial: "654321" + asset_tag: "123456" + role: Test Module Role + status: Active + tenant: Test Tenant + state: present + register: test_five + +- name: "5 - ASSERT" + assert: + that: + - test_five is changed + - test_five['module']['module_type'] == test_module_type['key'] + - test_five['module']['location'] == test_module_child_location['key'] + - test_five['module']['serial'] == "654321" + - test_five['module']['asset_tag'] == "123456" + - test_five['module']['role'] == test_module_role['key'] + - test_five['module']['status'] == test_module_status['key'] + - test_five['module']['tenant'] == test_module_tenant['key'] + - test_five['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 created" + +- name: "6 - Create module with all params idempotent" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + location: + name: "Child Test Location" + parent: "Parent Test Location" + serial: "654321" + asset_tag: "123456" + role: Test Module Role + status: Active + tenant: Test Tenant + state: present + register: test_six + +- name: "6 - ASSERT" + assert: + that: + - not test_six['changed'] + - test_six['module']['module_type'] == test_module_type['key'] + - test_six['module']['location'] == test_module_child_location['key'] + - test_six['module']['serial'] == "654321" + - test_six['module']['asset_tag'] == "123456" + - test_six['module']['role'] == test_module_role['key'] + - test_six['module']['status'] == test_module_status['key'] + - test_six['module']['tenant'] == test_module_tenant['key'] + - test_six['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 already exists" + +- name: "7 - Delete" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + location: + name: "Child Test Location" + parent: "Parent Test Location" + state: absent + register: test_seven + +- name: "7 - ASSERT" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 deleted" + +- name: "8 - Delete idempotent" + networktocode.nautobot.module: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + location: + name: "Child Test Location" + parent: "Parent Test Location" + state: absent + register: test_eight + +- name: "8 - ASSERT`" + assert: + that: + - not test_eight['changed'] + - test_eight['module'] == None + - test_eight['msg'] == "module Parent Test Location > Child Test Location > HooverMaxProModel60 already absent" diff --git a/tests/integration/targets/latest/tasks/module_bay.yml b/tests/integration/targets/latest/tasks/module_bay.yml index 9446b299..a369d81e 100644 --- a/tests/integration/targets/latest/tasks/module_bay.yml +++ b/tests/integration/targets/latest/tasks/module_bay.yml @@ -4,179 +4,175 @@ ### PYNAUTOBOT_MODULE_BAY ## ## -- name: "NAUTOBOT 2.3+ MODULE BAY TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - test_module: '{{ lookup(''networktocode.nautobot.lookup'', ''modules'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''q="HooverMaxProModel60"'') }}' - test_device: "{{ lookup('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"test100\"') }}" - test_module_bay: '{{ lookup(''networktocode.nautobot.lookup'', ''module-bays'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="PowerStrip"'') }}' - - - name: "1 - Create module bay with minimum information" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_device: test100 - name: Watch Bay - state: present - register: test_one - - - name: "1 - ASSERT" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['module_bay']['name'] == "Watch Bay" - - test_one['module_bay']['parent_device'] == test_device['key'] - - test_one['msg'] == "module_bay Watch Bay created" - - - name: "2 - Create module bay with minimum information idempotent" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_device: test100 - name: Watch Bay - state: present - register: test_two - - - name: "2 - ASSERT" - assert: - that: - - not test_two['changed'] - - test_two['module_bay']['name'] == "Watch Bay" - - test_two['module_bay']['parent_device'] == test_device['key'] - - test_two['msg'] == "module_bay Watch Bay already exists" - - - name: "3 - Update module bay" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_device: test100 - name: Watch Bay - label: watchbay - position: "42" - description: The bay of watches - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['label'] == "watchbay" - - test_three['diff']['after']['position'] == "42" - - test_three['diff']['after']['description'] == "The bay of watches" - - test_three['module_bay']['name'] == "Watch Bay" - - test_three['module_bay']['parent_device'] == test_device['key'] - - test_three['module_bay']['label'] == "watchbay" - - test_three['module_bay']['position'] == "42" - - test_three['module_bay']['description'] == "The bay of watches" - - test_three['msg'] == "module_bay Watch Bay updated" - - - name: "4 - Update idempotent" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_device: test100 - name: Watch Bay - label: watchbay - position: "42" - description: The bay of watches - state: present - register: test_four - - - name: "4 - ASSERT" - assert: - that: - - not test_four['changed'] - - test_four['module_bay']['name'] == "Watch Bay" - - test_four['msg'] == "module_bay Watch Bay already exists" - - - name: "5 - Create module bay with all params" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_module: - module_type: HooverMaxProModel60 - parent_module_bay: "{{ test_module_bay['key'] }}" - name: Fixing Good - label: FiXiNgGoOd - position: "321" - description: Good Fixing is better than Bad Breaking - state: present - register: test_five - - - name: "5 - ASSERT" - assert: - that: - - test_five is changed - - test_five['module_bay']['name'] == "Fixing Good" - - test_five['module_bay']['label'] == "FiXiNgGoOd" - - test_five['module_bay']['position'] == "321" - - test_five['module_bay']['description'] == "Good Fixing is better than Bad Breaking" - - test_five['module_bay']['parent_module'] == test_module['key'] - - test_five['msg'] == "module_bay Fixing Good created" - - - name: "6 - Create module bay with all params idempotent" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_module: - module_type: HooverMaxProModel60 - parent_module_bay: "{{ test_module_bay['key'] }}" - name: Fixing Good - label: FiXiNgGoOd - position: "321" - description: Good Fixing is better than Bad Breaking - state: present - register: test_six - - - name: "6 - ASSERT" - assert: - that: - - not test_six['changed'] - - test_six['module_bay']['name'] == "Fixing Good" - - test_six['module_bay']['label'] == "FiXiNgGoOd" - - test_six['module_bay']['position'] == "321" - - test_six['module_bay']['description'] == "Good Fixing is better than Bad Breaking" - - test_six['module_bay']['parent_module'] == test_module['key'] - - test_six['msg'] == "module_bay Fixing Good already exists" - - - name: "7 - Delete" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_module: - module_type: HooverMaxProModel60 - parent_module_bay: "{{ test_module_bay['key'] }}" - name: Fixing Good - state: absent - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - test_seven is changed - - test_seven['diff']['before']['state'] == "present" - - test_seven['diff']['after']['state'] == "absent" - - test_seven['msg'] == "module_bay Fixing Good deleted" - - - name: "8 - Delete idempotent" - networktocode.nautobot.module_bay: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent_module: - module_type: HooverMaxProModel60 - parent_module_bay: "{{ test_module_bay['key'] }}" - name: Fixing Good - state: absent - register: test_eight - - - name: "8 - ASSERT`" - assert: - that: - - not test_eight['changed'] - - test_eight['module_bay'] == None - - test_eight['msg'] == "module_bay Fixing Good already absent" +- set_fact: + test_module: '{{ lookup(''networktocode.nautobot.lookup'', ''modules'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''q="HooverMaxProModel60"'') }}' + test_device: "{{ lookup('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"test100\"') }}" + test_module_bay: '{{ lookup(''networktocode.nautobot.lookup'', ''module-bays'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="PowerStrip"'') }}' + +- name: "1 - Create module bay with minimum information" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_device: test100 + name: Watch Bay + state: present + register: test_one + +- name: "1 - ASSERT" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module_bay']['name'] == "Watch Bay" + - test_one['module_bay']['parent_device'] == test_device['key'] + - test_one['msg'] == "module_bay Watch Bay created" + +- name: "2 - Create module bay with minimum information idempotent" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_device: test100 + name: Watch Bay + state: present + register: test_two + +- name: "2 - ASSERT" + assert: + that: + - not test_two['changed'] + - test_two['module_bay']['name'] == "Watch Bay" + - test_two['module_bay']['parent_device'] == test_device['key'] + - test_two['msg'] == "module_bay Watch Bay already exists" + +- name: "3 - Update module bay" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_device: test100 + name: Watch Bay + label: watchbay + position: "42" + description: The bay of watches + state: present + register: test_three + +- name: "3 - ASSERT" + assert: + that: + - test_three is changed + - test_three['diff']['after']['label'] == "watchbay" + - test_three['diff']['after']['position'] == "42" + - test_three['diff']['after']['description'] == "The bay of watches" + - test_three['module_bay']['name'] == "Watch Bay" + - test_three['module_bay']['parent_device'] == test_device['key'] + - test_three['module_bay']['label'] == "watchbay" + - test_three['module_bay']['position'] == "42" + - test_three['module_bay']['description'] == "The bay of watches" + - test_three['msg'] == "module_bay Watch Bay updated" + +- name: "4 - Update idempotent" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_device: test100 + name: Watch Bay + label: watchbay + position: "42" + description: The bay of watches + state: present + register: test_four + +- name: "4 - ASSERT" + assert: + that: + - not test_four['changed'] + - test_four['module_bay']['name'] == "Watch Bay" + - test_four['msg'] == "module_bay Watch Bay already exists" + +- name: "5 - Create module bay with all params" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_module: + module_type: HooverMaxProModel60 + parent_module_bay: "{{ test_module_bay['key'] }}" + name: Fixing Good + label: FiXiNgGoOd + position: "321" + description: Good Fixing is better than Bad Breaking + state: present + register: test_five + +- name: "5 - ASSERT" + assert: + that: + - test_five is changed + - test_five['module_bay']['name'] == "Fixing Good" + - test_five['module_bay']['label'] == "FiXiNgGoOd" + - test_five['module_bay']['position'] == "321" + - test_five['module_bay']['description'] == "Good Fixing is better than Bad Breaking" + - test_five['module_bay']['parent_module'] == test_module['key'] + - test_five['msg'] == "module_bay Fixing Good created" + +- name: "6 - Create module bay with all params idempotent" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_module: + module_type: HooverMaxProModel60 + parent_module_bay: "{{ test_module_bay['key'] }}" + name: Fixing Good + label: FiXiNgGoOd + position: "321" + description: Good Fixing is better than Bad Breaking + state: present + register: test_six + +- name: "6 - ASSERT" + assert: + that: + - not test_six['changed'] + - test_six['module_bay']['name'] == "Fixing Good" + - test_six['module_bay']['label'] == "FiXiNgGoOd" + - test_six['module_bay']['position'] == "321" + - test_six['module_bay']['description'] == "Good Fixing is better than Bad Breaking" + - test_six['module_bay']['parent_module'] == test_module['key'] + - test_six['msg'] == "module_bay Fixing Good already exists" + +- name: "7 - Delete" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_module: + module_type: HooverMaxProModel60 + parent_module_bay: "{{ test_module_bay['key'] }}" + name: Fixing Good + state: absent + register: test_seven + +- name: "7 - ASSERT" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "module_bay Fixing Good deleted" + +- name: "8 - Delete idempotent" + networktocode.nautobot.module_bay: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent_module: + module_type: HooverMaxProModel60 + parent_module_bay: "{{ test_module_bay['key'] }}" + name: Fixing Good + state: absent + register: test_eight + +- name: "8 - ASSERT`" + assert: + that: + - not test_eight['changed'] + - test_eight['module_bay'] == None + - test_eight['msg'] == "module_bay Fixing Good already absent" diff --git a/tests/integration/targets/latest/tasks/module_bay_template.yml b/tests/integration/targets/latest/tasks/module_bay_template.yml index 40a6cb7d..663eec8b 100644 --- a/tests/integration/targets/latest/tasks/module_bay_template.yml +++ b/tests/integration/targets/latest/tasks/module_bay_template.yml @@ -4,170 +4,166 @@ ### PYNAUTOBOT_MODULE_BAY_TEMPLATE ## ## -- name: "NAUTOBOT 2.3+ MODULE BAY TEMPLATE TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - test_module_type: "{{ lookup('networktocode.nautobot.lookup', 'module-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"HooverMaxProModel60\"') }}" - test_device_type: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Cisco Test\"') }}" - - - name: "1 - Create module bay template with minimum information" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - name: Edward Galbraith - state: present - register: test_one - - - name: "1 - ASSERT" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['module_bay_template']['name'] == "Edward Galbraith" - - test_one['module_bay_template']['module_type'] == test_module_type['key'] - - test_one['msg'] == "module_bay_template Edward Galbraith created" - - - name: "2 - Create module bay template with minimum information idempotent" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - name: Edward Galbraith - state: present - register: test_two - - - name: "2 - ASSERT" - assert: - that: - - not test_two['changed'] - - test_two['module_bay_template']['name'] == "Edward Galbraith" - - test_two['module_bay_template']['module_type'] == test_module_type['key'] - - test_two['msg'] == "module_bay_template Edward Galbraith already exists" - - - name: "3 - Update module bay template" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - name: Edward Galbraith - label: Br Ba - position: "1" - description: Granite State - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['label'] == "Br Ba" - - test_three['diff']['after']['position'] == "1" - - test_three['diff']['after']['description'] == "Granite State" - - test_three['module_bay_template']['name'] == "Edward Galbraith" - - test_three['module_bay_template']['module_type'] == test_module_type['key'] - - test_three['module_bay_template']['label'] == "Br Ba" - - test_three['module_bay_template']['position'] == "1" - - test_three['module_bay_template']['description'] == "Granite State" - - test_three['msg'] == "module_bay_template Edward Galbraith updated" - - - name: "4 - Update idempotent" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - module_type: HooverMaxProModel60 - name: Edward Galbraith - label: Br Ba - position: "1" - description: Granite State - state: present - register: test_four - - - name: "4 - ASSERT" - assert: - that: - - not test_four['changed'] - - test_four['module_bay_template']['name'] == "Edward Galbraith" - - test_four['msg'] == "module_bay_template Edward Galbraith already exists" - - - name: "5 - Create module bay template with all params" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - device_type: Cisco Test - name: Test1234 - label: test1234 - position: "42" - description: Cisco Test Module Bay - state: present - register: test_five - - - name: "5 - ASSERT" - assert: - that: - - test_five is changed - - test_five['module_bay_template']['name'] == "Test1234" - - test_five['module_bay_template']['label'] == "test1234" - - test_five['module_bay_template']['position'] == "42" - - test_five['module_bay_template']['description'] == "Cisco Test Module Bay" - - test_five['module_bay_template']['device_type'] == test_device_type['key'] - - test_five['msg'] == "module_bay_template Test1234 created" - - - name: "6 - Create module bay template with all params idempotent" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - device_type: Cisco Test - name: Test1234 - label: test1234 - position: "42" - description: Cisco Test Module Bay - state: present - register: test_six - - - name: "6 - ASSERT" - assert: - that: - - not test_six['changed'] - - test_six['module_bay_template']['name'] == "Test1234" - - test_six['module_bay_template']['label'] == "test1234" - - test_six['module_bay_template']['position'] == "42" - - test_six['module_bay_template']['description'] == "Cisco Test Module Bay" - - test_six['module_bay_template']['device_type'] == test_device_type['key'] - - test_six['msg'] == "module_bay_template Test1234 already exists" - - - name: "7 - Delete" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - device_type: Cisco Test - name: Test1234 - state: absent - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - test_seven is changed - - test_seven['diff']['before']['state'] == "present" - - test_seven['diff']['after']['state'] == "absent" - - test_seven['msg'] == "module_bay_template Test1234 deleted" - - - name: "8 - Delete idempotent" - networktocode.nautobot.module_bay_template: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - device_type: Cisco Test - name: Test1234 - state: absent - register: test_eight - - - name: "8 - ASSERT`" - assert: - that: - - not test_eight['changed'] - - test_eight['module_bay_template'] == None - - test_eight['msg'] == "module_bay_template Test1234 already absent" +- set_fact: + test_module_type: "{{ lookup('networktocode.nautobot.lookup', 'module-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"HooverMaxProModel60\"') }}" + test_device_type: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Cisco Test\"') }}" + +- name: "1 - Create module bay template with minimum information" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + name: Edward Galbraith + state: present + register: test_one + +- name: "1 - ASSERT" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module_bay_template']['name'] == "Edward Galbraith" + - test_one['module_bay_template']['module_type'] == test_module_type['key'] + - test_one['msg'] == "module_bay_template Edward Galbraith created" + +- name: "2 - Create module bay template with minimum information idempotent" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + name: Edward Galbraith + state: present + register: test_two + +- name: "2 - ASSERT" + assert: + that: + - not test_two['changed'] + - test_two['module_bay_template']['name'] == "Edward Galbraith" + - test_two['module_bay_template']['module_type'] == test_module_type['key'] + - test_two['msg'] == "module_bay_template Edward Galbraith already exists" + +- name: "3 - Update module bay template" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + name: Edward Galbraith + label: Br Ba + position: "1" + description: Granite State + state: present + register: test_three + +- name: "3 - ASSERT" + assert: + that: + - test_three is changed + - test_three['diff']['after']['label'] == "Br Ba" + - test_three['diff']['after']['position'] == "1" + - test_three['diff']['after']['description'] == "Granite State" + - test_three['module_bay_template']['name'] == "Edward Galbraith" + - test_three['module_bay_template']['module_type'] == test_module_type['key'] + - test_three['module_bay_template']['label'] == "Br Ba" + - test_three['module_bay_template']['position'] == "1" + - test_three['module_bay_template']['description'] == "Granite State" + - test_three['msg'] == "module_bay_template Edward Galbraith updated" + +- name: "4 - Update idempotent" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + module_type: HooverMaxProModel60 + name: Edward Galbraith + label: Br Ba + position: "1" + description: Granite State + state: present + register: test_four + +- name: "4 - ASSERT" + assert: + that: + - not test_four['changed'] + - test_four['module_bay_template']['name'] == "Edward Galbraith" + - test_four['msg'] == "module_bay_template Edward Galbraith already exists" + +- name: "5 - Create module bay template with all params" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + device_type: Cisco Test + name: Test1234 + label: test1234 + position: "42" + description: Cisco Test Module Bay + state: present + register: test_five + +- name: "5 - ASSERT" + assert: + that: + - test_five is changed + - test_five['module_bay_template']['name'] == "Test1234" + - test_five['module_bay_template']['label'] == "test1234" + - test_five['module_bay_template']['position'] == "42" + - test_five['module_bay_template']['description'] == "Cisco Test Module Bay" + - test_five['module_bay_template']['device_type'] == test_device_type['key'] + - test_five['msg'] == "module_bay_template Test1234 created" + +- name: "6 - Create module bay template with all params idempotent" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + device_type: Cisco Test + name: Test1234 + label: test1234 + position: "42" + description: Cisco Test Module Bay + state: present + register: test_six + +- name: "6 - ASSERT" + assert: + that: + - not test_six['changed'] + - test_six['module_bay_template']['name'] == "Test1234" + - test_six['module_bay_template']['label'] == "test1234" + - test_six['module_bay_template']['position'] == "42" + - test_six['module_bay_template']['description'] == "Cisco Test Module Bay" + - test_six['module_bay_template']['device_type'] == test_device_type['key'] + - test_six['msg'] == "module_bay_template Test1234 already exists" + +- name: "7 - Delete" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + device_type: Cisco Test + name: Test1234 + state: absent + register: test_seven + +- name: "7 - ASSERT" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "module_bay_template Test1234 deleted" + +- name: "8 - Delete idempotent" + networktocode.nautobot.module_bay_template: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + device_type: Cisco Test + name: Test1234 + state: absent + register: test_eight + +- name: "8 - ASSERT`" + assert: + that: + - not test_eight['changed'] + - test_eight['module_bay_template'] == None + - test_eight['msg'] == "module_bay_template Test1234 already absent" diff --git a/tests/integration/targets/latest/tasks/module_type.yml b/tests/integration/targets/latest/tasks/module_type.yml index e3650ed3..c618bed6 100644 --- a/tests/integration/targets/latest/tasks/module_type.yml +++ b/tests/integration/targets/latest/tasks/module_type.yml @@ -4,158 +4,154 @@ ### PYNAUTOBOT_MODULE_TYPE ## ## -- name: "NAUTOBOT 2.3+ MODULE TYPE TESTS" - when: - - "nautobot_version is version('2.3', '>=')" - block: - - set_fact: - manufacturer: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Manufacturer\"') }}" - - - name: "1 - Create module type with minimum information" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750 - manufacturer: Test Manufacturer - state: present - register: test_one - - - name: "1 - ASSERT" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['module_type']['model'] == "ws-test-3750" - - test_one['module_type']['manufacturer'] == manufacturer['key'] - - test_one['msg'] == "module_type ws-test-3750 created" - - - name: "2 - Create module type with minimum information idempotent" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: "ws-test-3750" - manufacturer: Test Manufacturer - state: present - register: test_two - - - name: "2 - ASSERT" - assert: - that: - - not test_two['changed'] - - test_two['module_type']['model'] == "ws-test-3750" - - test_two['module_type']['manufacturer'] == manufacturer['key'] - - test_two['msg'] == "module_type ws-test-3750 already exists" - - - name: "3 - Update module type" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750 - manufacturer: Test Manufacturer - part_number: ws-3750g-v2 - comments: With great power comes great responsibility! - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['part_number'] == "ws-3750g-v2" - - test_three['module_type']['model'] == "ws-test-3750" - - test_three['module_type']['manufacturer'] == manufacturer['key'] - - test_three['module_type']['comments'] == "With great power comes great responsibility!" - - test_three['module_type']['part_number'] == "ws-3750g-v2" - - test_three['msg'] == "module_type ws-test-3750 updated" - - - name: "4 - Update idempotent" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750 - manufacturer: Test Manufacturer - part_number: ws-3750g-v2 - comments: With great power comes great responsibility! - state: present - register: test_four - - - name: "4 - ASSERT" - assert: - that: - - not test_four['changed'] - - test_four['module_type']['model'] == "ws-test-3750" - - test_four['msg'] == "module_type ws-test-3750 already exists" - - - name: "5 - Create module type with all params" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750-2 - manufacturer: Test Manufacturer - part_number: ws-3750g-v3 - comments: With great power comes great responsibility! - state: present - register: test_five - - - name: "5 - ASSERT" - assert: - that: - - test_five is changed - - test_five['module_type']['model'] == "ws-test-3750-2" - - test_five['module_type']['manufacturer'] == manufacturer['key'] - - test_five['module_type']['comments'] == "With great power comes great responsibility!" - - test_five['module_type']['part_number'] == "ws-3750g-v3" - - test_five['msg'] == "module_type ws-test-3750-2 created" - - - name: "6 - Create module type with all params idempotent" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750-2 - manufacturer: Test Manufacturer - part_number: ws-3750g-v3 - comments: With great power comes great responsibility! - state: present - register: test_six - - - name: "6 - ASSERT" - assert: - that: - - not test_six['changed'] - - test_six['module_type']['model'] == "ws-test-3750-2" - - test_six['module_type']['manufacturer'] == manufacturer['key'] - - test_six['module_type']['comments'] == "With great power comes great responsibility!" - - test_six['module_type']['part_number'] == "ws-3750g-v3" - - test_six['msg'] == "module_type ws-test-3750-2 already exists" - - - name: "7 - Delete" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: ws-test-3750-2 - state: absent - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - test_seven is changed - - test_seven['diff']['before']['state'] == "present" - - test_seven['diff']['after']['state'] == "absent" - - test_seven['msg'] == "module_type ws-test-3750-2 deleted" - - - name: "8 - Delete idempotent" - networktocode.nautobot.module_type: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - model: "ws-test-3750-2" - state: absent - register: test_eight - - - name: "8 - ASSERT`" - assert: - that: - - not test_eight['changed'] - - test_eight['module_type'] == None - - test_eight['msg'] == "module_type ws-test-3750-2 already absent" +- set_fact: + manufacturer: "{{ lookup('networktocode.nautobot.lookup', 'manufacturers', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test Manufacturer\"') }}" + +- name: "1 - Create module type with minimum information" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750 + manufacturer: Test Manufacturer + state: present + register: test_one + +- name: "1 - ASSERT" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module_type']['model'] == "ws-test-3750" + - test_one['module_type']['manufacturer'] == manufacturer['key'] + - test_one['msg'] == "module_type ws-test-3750 created" + +- name: "2 - Create module type with minimum information idempotent" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: "ws-test-3750" + manufacturer: Test Manufacturer + state: present + register: test_two + +- name: "2 - ASSERT" + assert: + that: + - not test_two['changed'] + - test_two['module_type']['model'] == "ws-test-3750" + - test_two['module_type']['manufacturer'] == manufacturer['key'] + - test_two['msg'] == "module_type ws-test-3750 already exists" + +- name: "3 - Update module type" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750 + manufacturer: Test Manufacturer + part_number: ws-3750g-v2 + comments: With great power comes great responsibility! + state: present + register: test_three + +- name: "3 - ASSERT" + assert: + that: + - test_three is changed + - test_three['diff']['after']['part_number'] == "ws-3750g-v2" + - test_three['module_type']['model'] == "ws-test-3750" + - test_three['module_type']['manufacturer'] == manufacturer['key'] + - test_three['module_type']['comments'] == "With great power comes great responsibility!" + - test_three['module_type']['part_number'] == "ws-3750g-v2" + - test_three['msg'] == "module_type ws-test-3750 updated" + +- name: "4 - Update idempotent" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750 + manufacturer: Test Manufacturer + part_number: ws-3750g-v2 + comments: With great power comes great responsibility! + state: present + register: test_four + +- name: "4 - ASSERT" + assert: + that: + - not test_four['changed'] + - test_four['module_type']['model'] == "ws-test-3750" + - test_four['msg'] == "module_type ws-test-3750 already exists" + +- name: "5 - Create module type with all params" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750-2 + manufacturer: Test Manufacturer + part_number: ws-3750g-v3 + comments: With great power comes great responsibility! + state: present + register: test_five + +- name: "5 - ASSERT" + assert: + that: + - test_five is changed + - test_five['module_type']['model'] == "ws-test-3750-2" + - test_five['module_type']['manufacturer'] == manufacturer['key'] + - test_five['module_type']['comments'] == "With great power comes great responsibility!" + - test_five['module_type']['part_number'] == "ws-3750g-v3" + - test_five['msg'] == "module_type ws-test-3750-2 created" + +- name: "6 - Create module type with all params idempotent" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750-2 + manufacturer: Test Manufacturer + part_number: ws-3750g-v3 + comments: With great power comes great responsibility! + state: present + register: test_six + +- name: "6 - ASSERT" + assert: + that: + - not test_six['changed'] + - test_six['module_type']['model'] == "ws-test-3750-2" + - test_six['module_type']['manufacturer'] == manufacturer['key'] + - test_six['module_type']['comments'] == "With great power comes great responsibility!" + - test_six['module_type']['part_number'] == "ws-3750g-v3" + - test_six['msg'] == "module_type ws-test-3750-2 already exists" + +- name: "7 - Delete" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: ws-test-3750-2 + state: absent + register: test_seven + +- name: "7 - ASSERT" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "module_type ws-test-3750-2 deleted" + +- name: "8 - Delete idempotent" + networktocode.nautobot.module_type: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + model: "ws-test-3750-2" + state: absent + register: test_eight + +- name: "8 - ASSERT`" + assert: + that: + - not test_eight['changed'] + - test_eight['module_type'] == None + - test_eight['msg'] == "module_type ws-test-3750-2 already absent" diff --git a/tests/integration/targets/latest/tasks/object_metadata.yml b/tests/integration/targets/latest/tasks/object_metadata.yml new file mode 100644 index 00000000..e08e22ad --- /dev/null +++ b/tests/integration/targets/latest/tasks/object_metadata.yml @@ -0,0 +1,188 @@ +## +## +### PYNAUTOBOT_OBJECT_METADATA +## +## +- set_fact: + test_metadata_type: "{{ lookup('networktocode.nautobot.lookup', 'metadata-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"TestMetadataTextType\"') }}" + test_metadata_type_two: "{{ lookup('networktocode.nautobot.lookup', 'metadata-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"TestMetadataContactType\"') }}" + test_metadata_device: "{{ lookup('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=TestDeviceR1') }}" + +- name: "OBJECT METADATA 1: Create" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + scoped_fields: + - name + state: present + register: test_one + +- name: "OBJECT METADATA 1: ASSERT - Create" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['object_metadata']['metadata_type'] == test_metadata_type['key'] + - test_one['object_metadata']['assigned_object_type'] == "dcim.device" + - test_one['object_metadata']['assigned_object_id'] == test_metadata_device['key'] + - test_one['object_metadata']['scoped_fields'] == ["name"] + - "'created' in test_one['msg']" + +- name: "OBJECT METADATA 2: Test duplication association (Idempotency)" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + scoped_fields: + - name + state: present + register: test_two + +- name: "OBJECT METADATA 2: ASSERT - Item already exists (Idempotency)" + assert: + that: + - test_two is not changed + - test_two['object_metadata']['metadata_type'] == test_metadata_type['key'] + - "'already exists' in test_two['msg']" + +- name: "OBJECT METADATA 3: Update" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + scoped_fields: + - name + - serial + state: present + register: test_three + +- name: "OBJECT METADATA 3: ASSERT - Update" + assert: + that: + - test_three is changed + - test_three['diff']['after']['scoped_fields'] == ["name", "serial"] + - test_three['object_metadata']['metadata_type'] == test_metadata_type['key'] + - test_three['object_metadata']['assigned_object_type'] == "dcim.device" + - test_three['object_metadata']['assigned_object_id'] == test_metadata_device['key'] + - test_three['object_metadata']['scoped_fields'] == ["name", "serial"] + - test_three['msg'] == "object_metadata Foobar updated" + +- name: "OBJECT METADATA 4: Update (Idempotent)" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + scoped_fields: + - name + - serial + state: present + register: test_four + +- name: "OBJECT METADATA 4: ASSERT Update (Idempotent)" + assert: + that: + - not test_four['changed'] + - test_four['object_metadata']['value'] == "Foobar" + - test_four['msg'] == "object_metadata Foobar already exists" + +- name: "OBJECT METADATA 5: Test absent state" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + state: absent + register: test_five + +- name: "OBJECT METADATA 5: ASSERT - Item removed" + assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['object_metadata']['metadata_type'] == test_metadata_type['key'] + - test_five['object_metadata']['assigned_object_type'] == "dcim.device" + - test_five['object_metadata']['assigned_object_id'] == test_metadata_device['key'] + - "'deleted' in test_five['msg']" + +- name: "OBJECT METADATA 6: Test absent state (Idempotent)" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataTextType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + value: "Foobar" + state: absent + register: test_six + +- name: "OBJECT METADATA 6: ASSERT - Item not removed (Idempotent)" + assert: + that: + - test_six is not changed + - "'already absent' in test_six['msg']" + +- name: "OBJECT METADATA 7: Create contact type metadata" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataContactType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + contact: + name: "My Contact" + scoped_fields: + - name + state: present + register: test_seven + +- name: "OBJECT METADATA 7: ASSERT - Create" + assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "absent" + - test_seven['diff']['after']['state'] == "present" + - test_seven['object_metadata']['metadata_type'] == test_metadata_type_two['key'] + - test_seven['object_metadata']['assigned_object_type'] == "dcim.device" + - test_seven['object_metadata']['assigned_object_id'] == test_metadata_device['key'] + - test_seven['object_metadata']['scoped_fields'] == ["name"] + - "'created' in test_seven['msg']" + +- name: "OBJECT METADATA 8: Test absent state" + networktocode.nautobot.object_metadata: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + metadata_type: "TestMetadataContactType" + assigned_object_type: "dcim.device" + assigned_object_id: "{{ test_metadata_device['key'] }}" + contact: + name: "My Contact" + state: absent + register: test_eight + +- name: "OBJECT METADATA 8: ASSERT - Item removed" + assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == "present" + - test_eight['diff']['after']['state'] == "absent" + - test_eight['object_metadata']['metadata_type'] == test_metadata_type_two['key'] + - test_eight['object_metadata']['assigned_object_type'] == "dcim.device" + - test_eight['object_metadata']['assigned_object_id'] == test_metadata_device['key'] + - "'deleted' in test_eight['msg']" \ No newline at end of file diff --git a/tests/integration/targets/latest/tasks/prefix.yml b/tests/integration/targets/latest/tasks/prefix.yml index 2882fd9d..5e5b0333 100644 --- a/tests/integration/targets/latest/tasks/prefix.yml +++ b/tests/integration/targets/latest/tasks/prefix.yml @@ -235,34 +235,29 @@ - test_nine['prefix']['prefix'] == "10.157.0.0/19" - test_nine['prefix']['location'] == test_child_location['key'] -- block: - - name: "10 - Get a new /24 inside 10.157.0.0/19 within Nautobot with additional values" - networktocode.nautobot.prefix: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent: 10.157.0.0/19 - prefix_length: 24 - location: - name: "Child Test Location" - parent: "Parent Test Location" - status: "Active" - state: present - first_available: yes - register: test_ten +- name: "10 - Get a new /24 inside 10.157.0.0/19 within Nautobot with additional values" + networktocode.nautobot.prefix: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent: 10.157.0.0/19 + prefix_length: 24 + location: + name: "Child Test Location" + parent: "Parent Test Location" + status: "Active" + state: present + first_available: yes + register: test_ten - - name: "10 - ASSERT" - assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "prefix 10.157.0.0/24 created" - - test_ten['prefix']['prefix'] == "10.157.0.0/24" - - test_ten['prefix']['location'] == test_child_location['key'] - when: - # Waiting on bug fix for API version in v2.2+ - # https://github.com/nautobot/nautobot/issues/5832 - - "nautobot_version is version('2.2', '<')" +- name: "10 - ASSERT" + assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "prefix 10.157.0.0/24 created" + - test_ten['prefix']['prefix'] == "10.157.0.0/24" + - test_ten['prefix']['location'] == test_child_location['key'] - name: "11 - Get a new /24 inside 10.156.0.0/19 within Nautobot" networktocode.nautobot.prefix: @@ -308,33 +303,28 @@ - test_twelve['prefix']['namespace'] == private_namespace['key'] - test_twelve['prefix']['location'] == test_child_location['key'] -- block: - - name: "13 - Get a new /24 inside 10.157.0.0/19 within Nautobot in Private namespace" - networktocode.nautobot.prefix: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - parent: 10.157.0.0/19 - prefix_length: 24 - location: - name: "Child Test Location" - parent: "Parent Test Location" - namespace: Private - status: "Active" - state: present - first_available: yes - register: test_thirteen +- name: "13 - Get a new /24 inside 10.157.0.0/19 within Nautobot in Private namespace" + networktocode.nautobot.prefix: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + parent: 10.157.0.0/19 + prefix_length: 24 + location: + name: "Child Test Location" + parent: "Parent Test Location" + namespace: Private + status: "Active" + state: present + first_available: yes + register: test_thirteen - - name: "13 - ASSERT" - assert: - that: - - test_thirteen is changed - - test_thirteen['diff']['before']['state'] == "absent" - - test_thirteen['diff']['after']['state'] == "present" - - test_thirteen['msg'] == "prefix 10.157.0.0/24 created" - - test_thirteen['prefix']['prefix'] == "10.157.0.0/24" - - test_thirteen['prefix']['namespace'] == private_namespace['key'] - - test_thirteen['prefix']['location'] == test_child_location['key'] - when: - # Waiting on bug fix for API version in v2.2+ - # https://github.com/nautobot/nautobot/issues/5832 - - "nautobot_version is version('2.2', '<')" \ No newline at end of file +- name: "13 - ASSERT" + assert: + that: + - test_thirteen is changed + - test_thirteen['diff']['before']['state'] == "absent" + - test_thirteen['diff']['after']['state'] == "present" + - test_thirteen['msg'] == "prefix 10.157.0.0/24 created" + - test_thirteen['prefix']['prefix'] == "10.157.0.0/24" + - test_thirteen['prefix']['namespace'] == private_namespace['key'] + - test_thirteen['prefix']['location'] == test_child_location['key'] diff --git a/tests/integration/targets/latest/tasks/static_group_association.yml b/tests/integration/targets/latest/tasks/static_group_association.yml new file mode 100644 index 00000000..235a4bd6 --- /dev/null +++ b/tests/integration/targets/latest/tasks/static_group_association.yml @@ -0,0 +1,84 @@ +--- +## +## +### PYNAUTOBOT_STATIC_GROUP_ASSOCIATION +## +## +- set_fact: + static_dynamic_group: "{{ lookup('networktocode.nautobot.lookup', 'dynamic-groups', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"TestStaticAssociations\"') }}" + static_device: "{{ lookup('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=TestDeviceR1') }}" + +- name: "STATIC GROUP ASSOCIATION 1: Necessary info creation" + networktocode.nautobot.static_group_association: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + dynamic_group: "TestStaticAssociations" + associated_object_type: "dcim.device" + associated_object_id: "{{ static_device['key'] }}" + state: present + register: test_one + +- name: "STATIC GROUP ASSOCIATION 1: ASSERT - Necessary info creation" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['static_group_association']['dynamic_group'] == static_dynamic_group['key'] + - test_one['static_group_association']['associated_object_type'] == "dcim.device" + - test_one['static_group_association']['associated_object_id'] == static_device['key'] + - "'created' in test_one['msg']" + +- name: "STATIC GROUP ASSOCIATION 2: Test duplication association (Idempotency)" + networktocode.nautobot.static_group_association: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + dynamic_group: "TestStaticAssociations" + associated_object_type: "dcim.device" + associated_object_id: "{{ static_device['key'] }}" + state: present + register: test_two + +- name: "STATIC GROUP ASSOCIATION 2: ASSERT - Item already exists (Idempotency)" + assert: + that: + - test_two is not changed + - test_two['static_group_association']['dynamic_group'] == static_dynamic_group['key'] + - "'already exists' in test_two['msg']" + +- name: "STATIC GROUP ASSOCIATION 3: Test absent state" + networktocode.nautobot.static_group_association: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + dynamic_group: "TestStaticAssociations" + associated_object_type: "dcim.device" + associated_object_id: "{{ static_device['key'] }}" + state: absent + register: test_three + +- name: "STATIC GROUP ASSOCIATION 3: ASSERT - Item removed" + assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - test_three['static_group_association']['dynamic_group'] == static_dynamic_group['key'] + - test_three['static_group_association']['associated_object_type'] == "dcim.device" + - test_three['static_group_association']['associated_object_id'] == static_device['key'] + - "'deleted' in test_three['msg']" + +- name: "STATIC GROUP ASSOCIATION 4: Test absent state (Idempotent)" + networktocode.nautobot.static_group_association: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + dynamic_group: "TestStaticAssociations" + associated_object_type: "dcim.device" + associated_object_id: "{{ static_device['key'] }}" + state: absent + register: test_four + +- name: "STATIC GROUP ASSOCIATION 4: ASSERT - Item not removed (Idempotent)" + assert: + that: + - test_four is not changed + - "'already absent' in test_four['msg']" diff --git a/tests/integration/targets/latest/tasks/team.yml b/tests/integration/targets/latest/tasks/team.yml index c9f0f88a..01b97931 100644 --- a/tests/integration/targets/latest/tasks/team.yml +++ b/tests/integration/targets/latest/tasks/team.yml @@ -4,151 +4,146 @@ ### PYNAUTOBOT_TEAM ## ## -- block: - - set_fact: - test_contact: "{{ lookup('networktocode.nautobot.lookup', 'contacts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Contact\"') }}" - test_contact2: "{{ lookup('networktocode.nautobot.lookup', 'contacts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Contact 2\"') }}" - - - name: "1 - Create team within Nautobot with only required information" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team - register: test_create_min - - - name: "1 - ASSERT" - assert: - that: - - test_create_min is changed - - test_create_min['diff']['before']['state'] == "absent" - - test_create_min['diff']['after']['state'] == "present" - - test_create_min['team']['name'] == "Test Team" - - test_create_min['msg'] == "team Test Team created" - - - name: "2 - Duplicate" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team - - register: test_create_idem - - name: "2 - ASSERT" - assert: - that: - - not test_create_idem['changed'] - - test_create_idem['msg'] == "team Test Team already exists" - - test_create_idem['team']['name'] == "Test Team" - - - name: "3 - Update team" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team - comments: Test Comments - register: test_update - - - name: "3 - ASSERT" - assert: - that: - - test_update is changed - - test_update['diff']['before']['comments'] == "" - - test_update['diff']['after']['comments'] == "Test Comments" - - - name: "4 - Update idempotent" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team - comments: Test Comments - register: test_update_idem - - - name: "4 - ASSERT" - assert: - that: - - not test_update_idem['changed'] - - test_update_idem['msg'] == "team Test Team already exists" - - test_update_idem['team']['name'] == "Test Team" - - - name: "5 - Create team with all parameters" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team 2 - phone: "123456789" - email: user@example.com - address: Test Address - contacts: - - name: My Contact - - name: My Contact 2 - comments: Test Comments - register: test_create_max - - - name: "5 - ASSERT" - assert: - that: - - test_create_max is changed - - test_create_max['diff']['before']['state'] == "absent" - - test_create_max['diff']['after']['state'] == "present" - - test_create_max['team']['name'] == "Test Team 2" - - test_create_max['team']['phone'] == "123456789" - - test_create_max['team']['email'] == "user@example.com" - - test_create_max['team']['address'] == "Test Address" - - test_create_max['team']['contacts'][0] == test_contact['key'] - - test_create_max['team']['contacts'][1] == test_contact2['key'] - - test_create_max['team']['comments'] == "Test Comments" - - - name: "6 - Duplicate create with all parameters" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team 2 - phone: "123456789" - email: user@example.com - address: Test Address - contacts: - - name: My Contact - - name: My Contact 2 - comments: Test Comments - register: test_create_max_idem - - - name: "6 - ASSERT" - assert: - that: - - not test_create_max_idem['changed'] - - test_create_max_idem['msg'] == "team Test Team 2 already exists" - - test_create_max_idem['team']['name'] == "Test Team 2" - - - name: "7 - Delete team" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team 2 - state: absent - register: test_delete - - - name: "7 - ASSERT" - assert: - that: - - test_delete is changed - - test_delete['diff']['before']['state'] == "present" - - test_delete['diff']['after']['state'] == "absent" - - test_delete['team']['name'] == "Test Team 2" - - "'deleted' in test_delete['msg']" - - - name: "8 - Delete idempotent" - networktocode.nautobot.team: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - name: Test Team 2 - state: absent - register: test_delete_idem - - - name: "8 - ASSERT" - assert: - that: - - not test_delete_idem['changed'] - - "'already absent' in test_delete_idem['msg']" - - when: - # Teams are only available on Nautobot 2.2+ - - "nautobot_version is version('2.2', '>=')" +- set_fact: + test_contact: "{{ lookup('networktocode.nautobot.lookup', 'contacts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Contact\"') }}" + test_contact2: "{{ lookup('networktocode.nautobot.lookup', 'contacts', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"My Contact 2\"') }}" + +- name: "1 - Create team within Nautobot with only required information" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team + register: test_create_min + +- name: "1 - ASSERT" + assert: + that: + - test_create_min is changed + - test_create_min['diff']['before']['state'] == "absent" + - test_create_min['diff']['after']['state'] == "present" + - test_create_min['team']['name'] == "Test Team" + - test_create_min['msg'] == "team Test Team created" + +- name: "2 - Duplicate" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team + + register: test_create_idem +- name: "2 - ASSERT" + assert: + that: + - not test_create_idem['changed'] + - test_create_idem['msg'] == "team Test Team already exists" + - test_create_idem['team']['name'] == "Test Team" + +- name: "3 - Update team" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team + comments: Test Comments + register: test_update + +- name: "3 - ASSERT" + assert: + that: + - test_update is changed + - test_update['diff']['before']['comments'] == "" + - test_update['diff']['after']['comments'] == "Test Comments" + +- name: "4 - Update idempotent" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team + comments: Test Comments + register: test_update_idem + +- name: "4 - ASSERT" + assert: + that: + - not test_update_idem['changed'] + - test_update_idem['msg'] == "team Test Team already exists" + - test_update_idem['team']['name'] == "Test Team" + +- name: "5 - Create team with all parameters" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team 2 + phone: "123456789" + email: user@example.com + address: Test Address + contacts: + - name: My Contact + - name: My Contact 2 + comments: Test Comments + register: test_create_max + +- name: "5 - ASSERT" + assert: + that: + - test_create_max is changed + - test_create_max['diff']['before']['state'] == "absent" + - test_create_max['diff']['after']['state'] == "present" + - test_create_max['team']['name'] == "Test Team 2" + - test_create_max['team']['phone'] == "123456789" + - test_create_max['team']['email'] == "user@example.com" + - test_create_max['team']['address'] == "Test Address" + - test_create_max['team']['contacts'][0] == test_contact['key'] + - test_create_max['team']['contacts'][1] == test_contact2['key'] + - test_create_max['team']['comments'] == "Test Comments" + +- name: "6 - Duplicate create with all parameters" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team 2 + phone: "123456789" + email: user@example.com + address: Test Address + contacts: + - name: My Contact + - name: My Contact 2 + comments: Test Comments + register: test_create_max_idem + +- name: "6 - ASSERT" + assert: + that: + - not test_create_max_idem['changed'] + - test_create_max_idem['msg'] == "team Test Team 2 already exists" + - test_create_max_idem['team']['name'] == "Test Team 2" + +- name: "7 - Delete team" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team 2 + state: absent + register: test_delete + +- name: "7 - ASSERT" + assert: + that: + - test_delete is changed + - test_delete['diff']['before']['state'] == "present" + - test_delete['diff']['after']['state'] == "absent" + - test_delete['team']['name'] == "Test Team 2" + - "'deleted' in test_delete['msg']" + +- name: "8 - Delete idempotent" + networktocode.nautobot.team: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Test Team 2 + state: absent + register: test_delete_idem + +- name: "8 - ASSERT" + assert: + that: + - not test_delete_idem['changed'] + - "'already absent' in test_delete_idem['msg']" diff --git a/tests/integration/targets/latest/tasks/vlan_location.yml b/tests/integration/targets/latest/tasks/vlan_location.yml index 74dfe6a1..406a931f 100644 --- a/tests/integration/targets/latest/tasks/vlan_location.yml +++ b/tests/integration/targets/latest/tasks/vlan_location.yml @@ -4,87 +4,82 @@ ### PYNAUTOBOT_VLAN_LOCATION ## ## -- block: - - set_fact: - test_vlan: "{{ lookup('networktocode.nautobot.lookup', 'vlans', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test VLAN 600\"') }}" - test_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Child Test Location\" parent=\"Parent Test Location\"') }}" +- set_fact: + test_vlan: "{{ lookup('networktocode.nautobot.lookup', 'vlans', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Test VLAN 600\"') }}" + test_location: "{{ lookup('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"Child Test Location\" parent=\"Parent Test Location\"') }}" - - name: "VLAN Location 1: Create VLAN Location assignment" - networktocode.nautobot.vlan_location: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - vlan: Test VLAN 600 - location: - name: Child Test Location - parent: Parent Test Location - state: present - register: test_one +- name: "VLAN Location 1: Create VLAN Location assignment" + networktocode.nautobot.vlan_location: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + vlan: Test VLAN 600 + location: + name: Child Test Location + parent: Parent Test Location + state: present + register: test_one - - name: "VLAN Location 1: ASSERT - Create VLAN Location assignment" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['vlan_location_assignments']['vlan'] == test_vlan['key'] - - test_one['vlan_location_assignments']['location'] == test_location['key'] - - test_one['msg'] == "vlan_location_assignments Test VLAN 600 (600): Child Test Location created" +- name: "VLAN Location 1: ASSERT - Create VLAN Location assignment" + assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['vlan_location_assignments']['vlan'] == test_vlan['key'] + - test_one['vlan_location_assignments']['location'] == test_location['key'] + - test_one['msg'] == "vlan_location_assignments Test VLAN 600 (600): Child Test Location created" - - name: "VLAN Location 2: Create idempotent" - networktocode.nautobot.vlan_location: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - vlan: Test VLAN 600 - location: - name: Child Test Location - parent: Parent Test Location - state: present - register: test_two - - - name: "VLAN Location 2: ASSERT - Create idempotent" - assert: - that: - - not test_two['changed'] - - test_two['vlan_location_assignments']['vlan'] == test_vlan['key'] - - test_two['vlan_location_assignments']['location'] == test_location['key'] - - test_two['msg'] == "vlan_location_assignments Test VLAN 600 (600): Child Test Location already exists" - - - name: "VLAN Location 3: Delete VLAN Location assignment" - networktocode.nautobot.vlan_location: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - vlan: Test VLAN 600 - location: - name: Child Test Location - parent: Parent Test Location - state: absent - register: test_three +- name: "VLAN Location 2: Create idempotent" + networktocode.nautobot.vlan_location: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + vlan: Test VLAN 600 + location: + name: Child Test Location + parent: Parent Test Location + state: present + register: test_two - - name: "VLAN Location 3: ASSERT - Delete VLAN Location assignment" - assert: - that: - - test_three is changed - - test_three['diff']['before']['state'] == "present" - - test_three['diff']['after']['state'] == "absent" - - "'deleted' in test_three['msg']" +- name: "VLAN Location 2: ASSERT - Create idempotent" + assert: + that: + - not test_two['changed'] + - test_two['vlan_location_assignments']['vlan'] == test_vlan['key'] + - test_two['vlan_location_assignments']['location'] == test_location['key'] + - test_two['msg'] == "vlan_location_assignments Test VLAN 600 (600): Child Test Location already exists" - - name: "VLAN Location 4: Delete idempotent" - networktocode.nautobot.vlan_location: - url: "{{ nautobot_url }}" - token: "{{ nautobot_token }}" - vlan: Test VLAN 600 - location: - name: Child Test Location - parent: Parent Test Location - state: absent - register: test_four +- name: "VLAN Location 3: Delete VLAN Location assignment" + networktocode.nautobot.vlan_location: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + vlan: Test VLAN 600 + location: + name: Child Test Location + parent: Parent Test Location + state: absent + register: test_three - - name: "VLAN Location 4: ASSERT - Delete idempotent" - assert: - that: - - not test_four['changed'] - - "'already absent' in test_four['msg']" +- name: "VLAN Location 3: ASSERT - Delete VLAN Location assignment" + assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - "'deleted' in test_three['msg']" - when: - # VLAN to Location assignments are only in Nautobot v2.2+ - - "nautobot_version is version('2.2', '>=')" +- name: "VLAN Location 4: Delete idempotent" + networktocode.nautobot.vlan_location: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + vlan: Test VLAN 600 + location: + name: Child Test Location + parent: Parent Test Location + state: absent + register: test_four + +- name: "VLAN Location 4: ASSERT - Delete idempotent" + assert: + that: + - not test_four['changed'] + - "'already absent' in test_four['msg']" diff --git a/tests/integration/targets/latest/tasks/vm_interface.yml b/tests/integration/targets/latest/tasks/vm_interface.yml index 77ccb007..01186a5c 100644 --- a/tests/integration/targets/latest/tasks/vm_interface.yml +++ b/tests/integration/targets/latest/tasks/vm_interface.yml @@ -196,9 +196,6 @@ state: present register: test_ten - - debug: - msg: "{{ test_ten }}" - - name: "PYNAUTOBOT_VM_INTERFACE 10: ASSERT - Created" assert: that: diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt new file mode 100644 index 00000000..935f26da --- /dev/null +++ b/tests/sanity/ignore-2.18.txt @@ -0,0 +1,2 @@ +plugins/modules/custom_field.py validate-modules:no-log-needed # key is not an actual secret that requires no_log to be set +plugins/modules/device_redundancy_group.py validate-modules:no-log-needed # secrets_group is not an actual secret that requires no_log to be set diff --git a/tests/unit/inventory/test_nb_inventory.py b/tests/unit/inventory/test_nb_inventory.py index ccfee73b..c86f3a2d 100644 --- a/tests/unit/inventory/test_nb_inventory.py +++ b/tests/unit/inventory/test_nb_inventory.py @@ -111,6 +111,7 @@ def test_refresh_url(inventory_fixture, options, expected): assert result == tuple(expected) +@pytest.mark.filterwarnings("ignore:Exception") def test_refresh_lookups(inventory_fixture): def raises_exception(): raise Exception("Error from within a thread") diff --git a/tests/unit/lookup/test_lookup.py b/tests/unit/lookup/test_lookup.py new file mode 100644 index 00000000..4140059c --- /dev/null +++ b/tests/unit/lookup/test_lookup.py @@ -0,0 +1,115 @@ +"""Tests for Nautobot Query Lookup Plugin.""" + +from ansible.errors import AnsibleError +from ansible.template import Templar +from ansible.parsing.dataloader import DataLoader +from ansible.vars.manager import VariableManager +from ansible.inventory.manager import InventoryManager +import pytest +from unittest.mock import patch, MagicMock + + +try: + from plugins.lookup.lookup import LookupModule +except ImportError: + import sys + + sys.path.append("tests") + sys.path.append("plugins/lookup") + + from lookup import LookupModule + + +@pytest.fixture +def lookup(): + """Fixture to create an instance of your lookup plugin.""" + return LookupModule() + + +@patch("plugins.lookup.lookup.pynautobot.api") +def test_basic_run(mock_pynautobot, lookup): + """Test basic functionality of the run method.""" + mock_api = MagicMock() + mock_pynautobot.return_value = mock_api + mock_api.dcim.devices.all.return_value = [{"id": 1, "name": "device1"}] + + terms = ["devices"] + kwargs = { + "token": "fake-token", + "api_endpoint": "https://nautobot.local", + } + result = lookup.run(terms, **kwargs) + + mock_pynautobot.assert_called_once_with("https://nautobot.local", token="fake-token", api_version=None, verify=True, retries="0") + assert result == [{"key": 1, "value": {"id": 1, "name": "device1"}}], "Expected a successful result" + + +def test_invalid_terms(lookup): + """Test when terms is not a list or valid input.""" + with pytest.raises(AnsibleError, match="Unrecognised term"): + with patch("plugins.lookup.lookup.get_endpoint", side_effect=KeyError): + kwargs = { + "token": "fake-token", + "api_endpoint": "https://nautobot.local", + } + lookup.run("invalid.term", **kwargs) + + +@patch("plugins.lookup.lookup.pynautobot.api") +def test_no_token_or_endpoint(mock_pynautobot, lookup): + """Test when neither token nor endpoint is provided.""" + with pytest.raises(AnsibleError): + lookup.run(["devices"], token=None, api_endpoint=None) + + +@patch("plugins.lookup.lookup.pynautobot.api") +def test_run_with_static_filter(mock_pynautobot, lookup): + """Test filters functionality of the run method.""" + mock_api = MagicMock() + mock_pynautobot.return_value = mock_api + mock_api.dcim.devices.filter.return_value = [{"id": 1, "name": "device1"}] + + # Initialize Ansible's Templar with necessary components + loader = DataLoader() + inventory = InventoryManager(loader=loader, sources=[]) + variable_manager = VariableManager(loader=loader, inventory=inventory) + templar = Templar(loader=loader, variables=variable_manager.get_vars()) + lookup._templar = templar + + terms = ["devices"] + kwargs = { + "token": "fake-token", + "api_endpoint": "https://nautobot.local", + "api_filter": "{'name': 'device1'}", + } + result = lookup.run(terms, **kwargs) + + mock_pynautobot.assert_called_once_with("https://nautobot.local", token="fake-token", api_version=None, verify=True, retries="0") + mock_api.dcim.devices.filter.assert_called_once_with(_raw_params=["{'name':", "'device1'}"]) + assert result == [{"key": 1, "value": {"id": 1, "name": "device1"}}], "Expected a successful result" + + +@patch("plugins.lookup.lookup.pynautobot.api") +def test_run_with_dynamic_filter(mock_pynautobot, lookup): + """Test dynamic filters functionality of the run method.""" + mock_api = MagicMock() + mock_pynautobot.return_value = mock_api + mock_api.dcim.devices.filter.return_value = [{"id": 1, "name": "device1"}] + + # Initialize Ansible's Templar with necessary components + loader = DataLoader() + variables = {"device_name": "device1"} + templar = Templar(loader=loader, variables=variables) + lookup._templar = templar + + terms = ["devices"] + kwargs = { + "token": "fake-token", + "api_endpoint": "https://nautobot.local", + "api_filter": "{'name': '{{ device_name }}'}", + } + result = lookup.run(terms, **kwargs) + + mock_pynautobot.assert_called_once_with("https://nautobot.local", token="fake-token", api_version=None, verify=True, retries="0") + mock_api.dcim.devices.filter.assert_called_once_with(_raw_params=["{'name':", "'device1'}"]) + assert result == [{"key": 1, "value": {"id": 1, "name": "device1"}}], "Expected a successful result" diff --git a/tests/unit/module_utils/test_nautobot_base_class.py b/tests/unit/module_utils/test_nautobot_base_class.py index e71b110c..f6c3baa0 100644 --- a/tests/unit/module_utils/test_nautobot_base_class.py +++ b/tests/unit/module_utils/test_nautobot_base_class.py @@ -231,7 +231,7 @@ def test_build_diff_returns_valid_diff(mock_module): def test_create_object_check_mode_false(mock_module, endpoint_mock, normalized_data, on_creation_diff): return_value = endpoint_mock.create().serialize() serialized_obj, diff = mock_module._create_object(endpoint_mock, normalized_data) - assert endpoint_mock.create.called_once_with(normalized_data) + endpoint_mock.create.assert_called_with(**normalized_data) assert serialized_obj.serialize() == return_value assert diff == on_creation_diff @@ -239,7 +239,7 @@ def test_create_object_check_mode_false(mock_module, endpoint_mock, normalized_d def test_create_object_check_mode_true(mock_module, endpoint_mock, normalized_data, on_creation_diff): mock_module.check_mode = True serialized_obj, diff = mock_module._create_object(endpoint_mock, normalized_data) - assert endpoint_mock.create.not_called() + endpoint_mock.create.assert_not_called() assert serialized_obj == normalized_data assert diff == on_creation_diff @@ -247,7 +247,7 @@ def test_create_object_check_mode_true(mock_module, endpoint_mock, normalized_da def test_delete_object_check_mode_false(mock_module, obj_mock, on_deletion_diff): mock_module.nb_object = obj_mock diff = mock_module._delete_object() - assert obj_mock.delete.called_once() + obj_mock.delete.assert_called_once() assert diff == on_deletion_diff @@ -255,7 +255,7 @@ def test_delete_object_check_mode_true(mock_module, obj_mock, on_deletion_diff): mock_module.check_mode = True mock_module.object = obj_mock diff = mock_module._delete_object() - assert obj_mock.delete.not_called() + obj_mock.delete.assert_not_called() assert diff == on_deletion_diff @@ -263,7 +263,7 @@ def test_update_object_no_changes(mock_module, obj_mock): mock_module.nb_object = obj_mock unchanged_data = obj_mock.serialize() serialized_object, diff = mock_module._update_object(unchanged_data) - assert obj_mock.update.not_called() + obj_mock.update.assert_not_called() assert serialized_object == unchanged_data assert diff is None @@ -271,7 +271,7 @@ def test_update_object_no_changes(mock_module, obj_mock): def test_update_object_with_changes_check_mode_false(mock_module, obj_mock, changed_serialized_obj, on_update_diff): mock_module.nb_object = obj_mock serialized_obj, diff = mock_module._update_object(changed_serialized_obj) - assert obj_mock.update.called_once_with(changed_serialized_obj) + obj_mock.update.assert_called_once_with(changed_serialized_obj) assert serialized_obj == obj_mock.serialize() assert diff == on_update_diff @@ -283,7 +283,7 @@ def test_update_object_with_changes_check_mode_true(mock_module, obj_mock, chang updated_serialized_obj.update(changed_serialized_obj) serialized_obj, diff = mock_module._update_object(changed_serialized_obj) - assert obj_mock.update.not_called() + obj_mock.update.assert_not_called() assert serialized_obj == updated_serialized_obj assert diff == on_update_diff