Comment 3 for bug 1876021

Revision history for this message
uchenily (uchenily) wrote :

@Bondarev, I have checked it, all dhcp agent is ok, if I didn't use `reserved_dhcp_port` and enable dhcp directly, 3 dhcp ports will be active.

root@mgt01:~# openstack network agent list --agent-type dhcp
+--------------------------------------+------------+-------+-------------------+-------+-------+--------------------+
| ID | Agent Type | Host | Availability Zone | Alive | State | Binary |
+--------------------------------------+------------+-------+-------------------+-------+-------+--------------------+
| 4e9de69c-57d7-4c70-bac0-e40c6cf09833 | DHCP agent | mgt04 | az1 | :-) | UP | neutron-dhcp-agent |
| 87c80360-3495-4638-9212-f9edf0a95634 | DHCP agent | mgt06 | az1 | :-) | UP | neutron-dhcp-agent |
| e8e1aff0-772f-4f9f-9edb-7159f349fe32 | DHCP agent | mgt05 | az1 | :-) | UP | neutron-dhcp-agent |
+--------------------------------------+------------+-------+-------------------+-------+-------+--------------------+
root@mgt01:~# openstack port list --network 6a0f68ff-1382-4959-aa22-c52da91177f2

root@mgt01:~# openstack subnet set e80b4163-2308-4b3d-afe3-45992e1b652c --dhcp
root@mgt01:~# openstack port list --network 6a0f68ff-1382-4959-aa22-c52da91177f2
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------+--------+
| 4587e5c1-fec6-4169-b2f8-eb0850b314ba | | fa:16:3e:80:f8:3d | ip_address='172.30.0.4', subnet_id='e80b4163-2308-4b3d-afe3-45992e1b652c' | ACTIVE |
| 91b8e6bd-f965-4f19-ae51-c40df34bc8f6 | | fa:16:3e:7c:89:f2 | ip_address='172.30.0.3', subnet_id='e80b4163-2308-4b3d-afe3-45992e1b652c' | ACTIVE |
| ecb6caf3-9d09-43bb-80da-61c3f6642eaf | | fa:16:3e:9f:31:04 | ip_address='172.30.0.2', subnet_id='e80b4163-2308-4b3d-afe3-45992e1b652c' | ACTIVE |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------+--------+

Besides, there is a alternative to solve it without using `reserved_dhcp_port`:

>>> network_id='6a0f68ff-1382-4959-aa22-c52da91177f2'
>>> import uuid
>>> host_uuid=uuid.uuid5(uuid.NAMESPACE_DNS, 'mgt04')
>>> print('dhcp%s-%s' % (host_uuid, network_id))
dhcp7901d681-a80e-5942-aa5d-f7c842f10b6e-6a0f68ff-1382-4959-aa22-c52da91177f2

ref: https://opendev.org/openstack/neutron/src/branch/stable/rocky/neutron/common/utils.py#L130-L136

openstack port create --network 6a0f68ff-1382-4959-aa22-c52da91177f2 --device dhcp7901d681-a80e-5942-aa5d-f7c842f10b6e-6a0f68ff-1382-4959-aa22-c52da91177f2 --device-owner network:dhcp --host mgt04 --fixed-ip subnet=e80b4163-2308-4b3d-afe3-45992e1b652c,ip-address=172.30.0.251 --disable-port-security dhcp-port-1
openstack port create --network 6a0f68ff-1382-4959-aa22-c52da91177f2 --device ${device_id_x} --device-owner network:dhcp --host mgt05 --fixed-ip subnet=e80b4163-2308-4b3d-afe3-45992e1b652c,ip-address=172.30.0.252 --disable-port-security dhcp-port-2
openstack port create --network 6a0f68ff-1382-4959-aa22-c52da91177f2 --device ${device_id_y} --device-owner network:dhcp --host mgt06 --fixed-ip subnet=e80b4163-2308-4b3d-afe3-45992e1b652c,ip-address=172.30.0.253 --disable-port-security dhcp-port-3

it works, but it's difficult to calculate the device id, `reserved_dhcp_port` may be a solution but we cannot create sereval reserved_dhcp_ports at the same time.