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

provider/openstack: Add network_id to Network data source #12615

Merged
merged 1 commit into from
Mar 12, 2017

Conversation

jtopjian
Copy link
Contributor

This commit adds the ability to search for a network by its ID. This
is useful for doing ID-to-name translations.

For #9952

This commit adds the ability to search for a network by its ID. This
is useful for doing ID-to-name translations.
@@ -56,6 +60,7 @@ func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{})
networkingClient, err := config.networkingV2Client(GetRegion(d))

listOpts := networks.ListOpts{
ID: d.Get("network_id").(string),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to send an empty string to the API? If the optional param isn't given then the ID will be ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, Gophercloud will ignore zero-value parameters in the GET URL. For example, here's the URL that's built for searching by name

GET http://10.1.12.81:9696/v2.0/networks?name=tf_test_network&status=ACTIVE

and for searching by network_id:

GET http://10.1.12.81:9696/v2.0/networks?id=d1f4958c-dc7b-4726-8b3a-1a748b131e74&status=ACTIVE

tenant_id is also unset for both, which doesn't get passed through :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 In that case, LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Paul!

@stack72 stack72 merged commit aa4676e into hashicorp:master Mar 12, 2017
stack72 pushed a commit that referenced this pull request Mar 13, 2017
This commit adds the ability to search for a network by its ID. This
is useful for doing ID-to-name translations.
yanndegat pushed a commit to yanndegat/terraform that referenced this pull request Mar 13, 2017
…12615)

This commit adds the ability to search for a network by its ID. This
is useful for doing ID-to-name translations.
@ghost
Copy link

ghost commented Apr 15, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants