SatelliteQE / 5minute

5minute tool is the client tool for easy work with openstack.
GNU General Public License v2.0
9 stars 16 forks source link

Change way of gettig floating IPs for the given instance #62

Open ogajduse opened 5 years ago

ogajduse commented 5 years ago

Currently we list info for the given instance and we parse the info about the floating IPs from there. 5minute should not be relying on the nova proxy API and should use the neutron API directly.

Currently we do: https://github.com/SatelliteQE/5minute/blob/master/vminute/vminute.py#L708

What we should do (explained using OSP CLI tooling):

openstack port list --server <server uuid>

^ This will return the ID of the port.

openstack floating ip list --port <port id>

For example:

$ openstack port list --server c5d5ca2e-16bd-4e10-817a-25123ad82422
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                          | Status |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------+--------+
| c7b58401-32d0-4435-ac08-0c25cae16d9a |      | fa:16:3e:07:33:f3 | ip_address='172.16.20.39', subnet_id='bdc26b91-22c5-45e6-b125-d37ed857dcab' | ACTIVE |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------+--------+
$ openstack floating ip list --port c7b58401-32d0-4435-ac08-0c25cae16d9a
+--------------------------------------+---------------------+------------------+--------------------------------------+--------------------------------------+----------------------------------+
| ID                                   | Floating IP Address | Fixed IP Address | Port                                 | Floating Network                     | Project                          |
+--------------------------------------+---------------------+------------------+--------------------------------------+--------------------------------------+----------------------------------+
| 703cda9a-390d-4302-859a-3cbb9cbbf1c8 | 10.0.149.240        | 172.16.20.39     | c7b58401-32d0-4435-ac08-0c25cae16d9a | 25ec4907-36fc-4035-b8d5-b797246330f2 | f02e46e85bee44fda348ac49cc4b6b6d |
+--------------------------------------+---------------------+------------------+--------------------------------------+--------------------------------------+----------------------------------+

This way we can get the 10.0.149.240 floating IP and disassociate it

ogajduse commented 5 years ago

From IRC discussion with OSP devs:

you can get the fixed ips via "openstack port list --server " then loop over them with openstack floating ip list --fixed-ip $ip

actually rather then --fixed-ip you can also do "openstack floating ip list --port " for each port returned by "openstack port list --server" that is more efficient