Get request Fixed_ips method in OpenStack to solve the idea

Source: Internet
Author: User
Tags json

background : Due to business needs IP blurring of Port API in neutron (Port API Official document: HTTPS://DEVELOPER.OPENSTACK.ORG/API-REF/NETWORK/V2/ Index.html#ports), but by get/v2.0/ports the list of ports without parameters, it is found that the value of Fixed_ips is an array of key values consisting of Subnet_ip and IP_Address, as shown in the following figure. However, there is a problem with how to make a GET request pass for this fixed_ips.


Solution Ideas:

Before I solved this problem, I tried a variety of ways, but all failed and returned to Invalidinput. Here are some ways to try a few failures:

1. JSON encapsulation of Key=value value directly in the GET request as shown above, for example: fixed_ips={"subnet_id": "Value1", "IP_Address": "10.0.0.9"}, Result failed

2. Incoming JSON data in the request body, the result still fails

Finally inadvertently see the official website on the API to use the CLI way to request, and the CLI request with the Fixed_ips option, address: https://docs.openstack.org/python-openstackclient/pike/cli/ Command-objects/port.html as shown in the figure:


Then I can make a GET request via CLI, with the fixed_ips option so that I can tail-f the neutron log in the background Neutron-server.log | grep GET (The premise here is best to open debug mode for the neutron.conf file under this component, which is off by default) as shown in the figure:



At this point, you can see the fetch request with the Fixed_ips parameter, from which you can see that the URL escapes the equal sign = in value.

I finally tested it with restclient and found that I was able to return an exact match. The following figure:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.