Ask Your Question
1

Find the server associated with a port

asked 2015-04-21 20:10:13 -0500

Alex Altair gravatar image

The output of neutron port-show <port-id> has a lot of information, but I don't see the ID of the server that it is attached too. I could theoretically use the mac address, but as I'm doing this in a script, that seems pretty hard. I understand that neutron more or less isn't concerned with the existence of VMs, but is there a good way to figure out what server the port is connected to?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2015-04-22 10:15:24 -0500

fgorbat gravatar image

Check out, if the following command gives you what you are looking for:

for ins in ` nova list|grep -v "\-\-"|grep -v ID|awk '{print $2}'`; do  echo Instance: $ins; nova interface-list $ins; done

Output will look similar to this:

Instance: 2a3ad035-a7d8-47ee-86a0-000dd4341fe2
+------------+--------------------------------------+--------------------------------------+-----------------+-------------------+
| Port State | Port ID                              | Net ID                               | IP addresses    | MAC Addr          |
+------------+--------------------------------------+--------------------------------------+-----------------+-------------------+
| ACTIVE     | 56760e21-e183-4300-b7ff-b869f4a1d61e | dbd20e97-ed14-4bde-a896-86b07152b6f2 | 192.168.0.24    | fa:16:3e:1a:e0:c9 |
| ACTIVE     | 902793db-2a1c-4998-b112-fd82a42445ca | 9f985256-7931-4ccc-b934-2fd0f9a55fe4 | 192.168.100.111 | fa:16:3e:b8:cb:a4 |
+------------+--------------------------------------+--------------------------------------+-----------------+-------------------+
edit flag offensive delete link more
1

answered 2015-04-22 10:35:21 -0500

So what piece of information do you have the mac_address or the fixed or floating ip, either way you should be able to do the following. Can you explain a bit more of what you are trying to achieve. Good luck.

[root@node-1 ~]# neutron port-list --fixed_ips ip_address=192.168.10.6
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                           |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| d8672a79-a3cf-4e52-90d4-1cd025b92aa8 |      | fa:16:3e:61:ac:4d | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.6"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
[root@node-1 ~]# neutron port-list --mac_address fa:16:3e:61:ac:4d
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                           |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| d8672a79-a3cf-4e52-90d4-1cd025b92aa8 |      | fa:16:3e:61:ac:4d | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.6"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
[root@node-1 ~]# neutron port-list
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                            |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
| 008a30af-71a5-42d7-ab0f-c874df7523d4 |      | fa:16:3e:7b:d4:1d | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.20"} |
| 141e1391-2921-4574-8136-68479ccfd28e |      | fa:16:3e:d8:38:48 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.130"}  |
| 17cf0f8f-cdbd-4059-94c4-270b6fa9e6db |      | fa:16:3e:a6:1f:1d | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.2"}  |
| 1ecd17c8-b604-438b-9417-f7237b4f38fb |      | fa:16:3e:05:e1:be | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.131"}  |
| 251607b4-8523-457c-8d05-fb5f23b90e61 |      | fa:16:3e:16:59:c0 | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.3"}  |
| 3c210903-69ef-41a3-8150-eb2702015a62 |      | fa:16:3e:24:a0:e8 | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.5"}  |
| 51952db7-501d-499b-aa2e-df0108d1d051 |      | fa:16:3e:84:03:12 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.140"}  |
| 5507dd23-56b2-4a85-96fc-20b35e72719a |      | fa:16:3e:50:de:4a | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.136"}  |
| 60ae3113-26ad-4e67-b653-139a2e2ef4d2 |      | fa:16:3e:ae:7d:07 | {"subnet_id": "b41d97be-b7b5-48cf-8bd9-5de33ddca633", "ip_address": "192.168.111.8"} |
| 63ab881b-44c1-414d-b429-c926e58025d0 |      | fa:16:3e:df:d0:27 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.132"}  |
| 679dcb61-3d99-4477-868c-629407088095 |      | fa:16:3e:5d:47:48 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.134"}  |
| 6e4bf182-9521-427c-b3d6-84ca893ff300 |      | fa:16:3e:a6:d6:61 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.138"}  |
| 702dc512-197f-42a3-81e0-580a19f9ca5c |      | fa:16:3e:a5:7c:17 | {"subnet_id": "b41d97be-b7b5-48cf-8bd9-5de33ddca633", "ip_address": "192.168.111.1"} |
| 898dec1e-df60-4b73-b15f-875fef6e45df |      | fa:16:3e:f5:da:57 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.137"}  |
| a5e1ae38-b470-4899-affb-8cde37877e35 |      | fa:16:3e:66:7f:53 | {"subnet_id": "b41d97be-b7b5-48cf-8bd9-5de33ddca633", "ip_address": "192.168.111.4"} |
| aa356b02-4695-44f8-a5fd-e447ecd2d9b8 |      | fa:16:3e:a9:4c:da | {"subnet_id": "b41d97be-b7b5-48cf-8bd9-5de33ddca633", "ip_address": "192.168.111.2"} |
| b5c75ecc-a519-44cd-8969-9f7b1f7002fb |      | fa:16:3e:f1:b0:3f | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.135"}  |
| bc4228d4-1ede-407b-85f4-91b7d5a4e908 |      | fa:16:3e:90:ca:17 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.139"}  |
| bdaf6b1c-0f55-4a4b-b422-c42b77a452d5 |      | fa:16:3e:5d:90:c4 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.141"}  |
| bde43c10-6edf-4db0-87cc-ea50023d4196 |      | fa:16:3e:ad:ae:32 | {"subnet_id": "49e07f41-2a4a-432c-97b7-772e5a70e4d7", "ip_address": "172.16.0.133"}  |
| d8672a79-a3cf-4e52-90d4-1cd025b92aa8 |      | fa:16:3e:61:ac:4d | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.6"}  |
| dbb781bb-400a-4299-b3e7-4aa95016cf71 |      | fa:16:3e:fa:81:e5 | {"subnet_id": "523d0b97-d857-4ecb-b91f-dbbcf6930f75", "ip_address": "192.168.10.7"}  |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
edit flag offensive delete link more
0

answered 2019-08-27 07:10:06 -0500

panticz gravatar image

You can search server ID by port ID with folowing command:

openstack port show -c device_id -f value ${PORT_ID}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-04-21 20:10:13 -0500

Seen: 3,804 times

Last updated: Aug 27