Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adds parent_location to QUERY_TYPES for query_params use with locations. #304

Merged

Conversation

nicholaskuechler
Copy link
Contributor

Fixes #303

After installing this change locally, I can successfully and repeatedly run the ansible snippet from issue #303:

TASK [locations : Create default locations] ********************************************************************************************************************************************************************
changed: [0.0.0.0] => (item={'name': 'Company', 'description': 'Company', 'parent_location': 'Global', 'location_type': 'Company', 'status': 'Active'})
changed: [0.0.0.0] => (item={'name': 'ABC', 'description': 'ABC Metro', 'parent_location': 'Company', 'location_type': 'Region', 'status': 'Active'})
changed: [0.0.0.0] => (item={'name': 'XYZ', 'description': 'XYZ Metro', 'parent_location': 'Company', 'location_type': 'Region', 'status': 'Active'})
changed: [0.0.0.0] => (item={'name': 'ABC1', 'description': 'ABC1 Data Center', 'parent_location': 'ABC', 'location_type': 'Site', 'status': 'Active'})
changed: [0.0.0.0] => (item={'name': 'XYZ1', 'description': 'XYZ1 Data Center', 'parent_location': 'XYZ', 'location_type': 'Site', 'status': 'Active'})

@joewesch
Copy link
Contributor

@nicholaskuechler thanks for the PR! Can you please revert the version changes you made to galaxy.yml and pyproject.toml? We will change those when are ready for the next release and determine if all of the changes are major, minor or patches.

@joewesch
Copy link
Contributor

Also, let's make this official by adding the following test to tests/integration/targets/latest/tasks/location.yml

- name: "9 - Use Parent Location Name"
  networktocode.nautobot.location:
    url: "{{ nautobot_url }}"
    token: "{{ nautobot_token }}"
    name: Testing Parent Name Lookup
    # Testing issue #303, where the location name lookup is exact instead of contains
    # 'Parent Test Location' and 'Parent Test Location 2' are both valid parent locations
    parent_location: "Parent Test Location"
    status: Active
    location_type: "{{ child_location_type['key'] }}"
  register: test_parent_name

- name: "9 - ASSERT"
  assert:
    that:
      - test_parent_name is changed
      - test_parent_name['diff']['before']['state'] == "absent"
      - test_parent_name['diff']['after']['state'] == "present"
      - test_parent_name['location']['name'] == "Testing Parent Name Lookup"
      - test_parent_name['location']['status'] == active['key']
      - test_parent_name['location']['location_type'] == child_location_type["key"]

@nicholaskuechler nicholaskuechler force-pushed the add-parent-locations-query-type branch 2 times, most recently from 55458b4 to 7ebd980 Compare January 12, 2024 14:49
@joewesch
Copy link
Contributor

Hmm, it looks like it broke some other tests. If you have a chance to try and diagnose them and fix them please do.

@nicholaskuechler nicholaskuechler force-pushed the add-parent-locations-query-type branch from 479f051 to ba34e3a Compare January 12, 2024 18:10
@nicholaskuechler
Copy link
Contributor Author

Hmm, it looks like it broke some other tests. If you have a chance to try and diagnose them and fix them please do.

Fixed the tests. Thanks for your help!

@joewesch joewesch merged commit 8ed1920 into nautobot:develop Jan 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem updating locations which have a parent_location
2 participants