[openstack-dev] [neutron] weird behavior of neutron create port with extra dhcp option

Moshe Levi moshele at mellanox.com
Fri Jul 29 21:49:06 UTC 2016


Hi,
I encounter a weird behavior with neutron create port command.
I am using neutron master.

When I run this neutron create-port command 
stack at r-dcs88:/opt/devstack$ neutron port-create --device-id=984b4a6d-a66d-4db7-8acc-1113cd1097ef --device-owner=baremetal:none --mac-address 7c:fe:90:29:22:4e --extra-dhcp-opt 'opt_value'='ff:00:00:00:00:00:02:00:00:02:c9:00:7c:fe:90:03:00:29:22:4e','opt_name'='client-id' --admin_state_up=True private
port is created as expected see [1]

when I create a port with the following command:
stack at r-dcs88:/opt/devstack$ neutron port-create --device-id=984b4a6d-a66d-4db7-8acc-1113cd1097ef --device-owner=baremetal:none --mac-address 7c:fe:90:29:22:4e --extra-dhcp-opt 'opt_value'='ff:00:00:00:00:00:02:00:00:02:c9:00:7c:fe:90:03:00:29:22:4e','opt_name'='client-id' --vnic_type=baremetal --admin_state_up=True private
port is created but in neutron client  show the extra_dhcp_opts attribute without the options. The only difference in the command is that I added --vnic_type=baremetal to it.
I looked in the neutron database and I can see the extra_dhcp_opts in the table.

I debugged the neutron server and the problem is with 
https://github.com/openstack/neutron/blob/master/neutron/plugins/ml2/plugin.py#L1217 that calling the _extend_port_dict_extra_dhcp_opt and clearing the 
extra_dhcp_opts from the result variable. If I comment this line(_apply_dict_extend_functions)  I will get the correct result.
Commenting it don't seem to me as the correct fix and I have a hard time understating the code.
It seems that the dhcp opt extend the result in 2 places  here [3] and here [4].

Does anyone know what is the proper way to fix this issue? Help would be much appreciated 


[1] - http://paste.openstack.org/show/544013/
[2] - http://paste.openstack.org/show/544014/ 
[3] - https://github.com/openstack/neutron/blob/master/neutron/db/extradhcpopt_db.py#L37-L53
[4] - https://github.com/openstack/neutron/blob/1fd1b505ca0a4dcaa7184df02dbd53ba63355083/neutron/db/extradhcpopt_db.py#L116-L121





More information about the OpenStack-dev mailing list