Provide resource for finding available interface by name #615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resource is similar to
netbox_available_ip_address
as it allows creating a resource based on what other resources are present in a certain namespace.In this case we're looking at all interfaces of a device with a certain prefix and create an interface with the lowest number suffix to a prefix so that it doesn't clash with an existing interface.
Notably, it doesn't use an existing API in Netbox to accomplish this, but instead does an API call to list the interfaces and constructs the name in the provider. This might be prone to race conditions when creating multiple interfaces for the same device with the same prefix at the same time.