Having a non-normalized mac address might result different results when filtering one port by address, some db backends are case-insensitive (mysql defaults) and some others are sensitive (pgsql defaults), we need to make sure that the address of ports are normalized before saving it to the db.
Two ways to solve this problem:
1) Normalizing the supplied MAC address on the API side.
2) Make sure the address column in the database is case insensitive regardless of the db backend.
After a small talk on IRC was decided that normalizing it on the API side would be better:
<lucasagomes> devananda, ping... should we normalize the mac address on the API side?
<lucasagomes> or at lease make the address column in the db case insensitive
<devananda> lucasagomes: morning
<devananda> lucasagomes: we should not rely on the db case-sensitivity.
<lucasagomes> Haomeng, raised that in one of my patches (actually 2 of them)
<devananda> mysql defaults to case-insensitive, but can be changed. IIRC< pgsql defaults to sensitive.
<lucasagomes> right
<lucasagomes> I thought there would be something on sqlalchmey that would take care of diff backends
<devananda> lucasagomes: i'm not aware of any setting that automatically munges the case of all inputs
<lucasagomes> devananda, right
<lucasagomes> so I think we can validate (correct format and colon-separated) and normalize it to all lower or upper (pref is lower) case in the API
<devananda> lucasagomes: ++
Reviewed: https:/ /review. openstack. org/60890 /git.openstack. org/cgit/ openstack/ ironic/ commit/ ?id=c0e6e8c2b9b 5cdb3c6504d0c4b 0b087d33a8ce3a
Committed: https:/
Submitter: Jenkins
Branch: master
commit c0e6e8c2b9b5cdb 3c6504d0c4b0b08 7d33a8ce3a
Author: Lucas Alvares Gomes <email address hidden>
Date: Mon Dec 9 17:38:12 2013 +0000
API: Validate and normalize address
On the API side, checks whether the supplied MAC address is formally
correct and normalize it to all lower case.
The patch also improves the docstring of the is_valid_mac function.
Change-Id: I6ae13888a9e17a 10bba20acf829cb d01df535a3c
Closes-Bug: #1259269