diff options
author | wangyao <wangyao@cmss.chinamobile.com> | 2017-04-17 13:08:37 +0800 |
---|---|---|
committer | wangyao <wangyao@cmss.chinamobile.com> | 2017-05-31 09:00:22 +0800 |
commit | 4bfe5b58a1b4709e5df4d4c1b325ddddf6f4f2d9 (patch) | |
tree | ed322069a8317b42ecfb8f7d767f93d951330471 /trove/common/db | |
parent | 00fde782be276698a5372066bb3fec74509e0fa8 (diff) | |
download | trove-4bfe5b58a1b4709e5df4d4c1b325ddddf6f4f2d9.tar.gz |
Fix user-list failed if host uses host_ip/netmask
According bug exception trace this problem cause by host name validate .
The origin code use netaddr.IPAddress to validate host name, it just fit ip address,
so the ip/netmask style do not match this rule.To solve this problem,
I changed this method to netaddr.IPNetwork, which support ip and
ip/netmask. Also provide a test case to validate the method.
Change-Id: I8dad9d1496d09372698821b832d1baa4f0c35a0d
Closes-Bug: #1673874
Diffstat (limited to 'trove/common/db')
-rw-r--r-- | trove/common/db/mysql/models.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/trove/common/db/mysql/models.py b/trove/common/db/mysql/models.py index cf9d0fbf..50700b10 100644 --- a/trove/common/db/mysql/models.py +++ b/trove/common/db/mysql/models.py @@ -145,8 +145,8 @@ class MySQLUser(models.DatastoreUser): if CONF.hostname_require_valid_ip: try: # '%' works as a MySQL wildcard, but it is not a valid - # part of an IPAddress - netaddr.IPAddress(value.replace('%', '1')) + # part of an IPNetwork + netaddr.IPNetwork(value.replace('%', '1')) except (ValueError, netaddr.AddrFormatError): return False else: |