Re-add UUID limit matching for full UUIDs
This *was* valuable when passing a full UUID in, so go back to that. Verify first that the limit string is an actual UUID, and then compare against it if applicable.
This commit is contained in:
parent
4e2a1c3e52
commit
f91c07fdcf
|
@ -24,6 +24,8 @@ import re
|
||||||
import lxml.objectify
|
import lxml.objectify
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
|
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
import daemon_lib.common as common
|
import daemon_lib.common as common
|
||||||
|
|
||||||
import daemon_lib.ceph as ceph
|
import daemon_lib.ceph as ceph
|
||||||
|
@ -823,15 +825,25 @@ def get_list(zkhandler, node, state, limit, is_fuzzy=True):
|
||||||
full_vm_list = zkhandler.children('base.domain')
|
full_vm_list = zkhandler.children('base.domain')
|
||||||
|
|
||||||
# Set our limit to a sensible regex
|
# Set our limit to a sensible regex
|
||||||
if limit and is_fuzzy:
|
if limit:
|
||||||
|
# Check if the limit is a UUID
|
||||||
|
is_limit_uuid = False
|
||||||
try:
|
try:
|
||||||
# Implcitly assume fuzzy limits
|
uuid_obj = UUID(limit, version=4)
|
||||||
if not re.match(r'\^.*', limit):
|
limit = str(uuid_obj)
|
||||||
limit = '.*' + limit
|
is_limit_uuid = True
|
||||||
if not re.match(r'.*\$', limit):
|
except ValueError:
|
||||||
limit = limit + '.*'
|
pass
|
||||||
except Exception as e:
|
|
||||||
return False, 'Regex Error: {}'.format(e)
|
if is_fuzzy and not is_limit_uuid:
|
||||||
|
try:
|
||||||
|
# Implcitly assume fuzzy limits
|
||||||
|
if not re.match(r'\^.*', limit):
|
||||||
|
limit = '.*' + limit
|
||||||
|
if not re.match(r'.*\$', limit):
|
||||||
|
limit = limit + '.*'
|
||||||
|
except Exception as e:
|
||||||
|
return False, 'Regex Error: {}'.format(e)
|
||||||
|
|
||||||
get_vm_info = dict()
|
get_vm_info = dict()
|
||||||
for vm in full_vm_list:
|
for vm in full_vm_list:
|
||||||
|
@ -842,7 +854,10 @@ def get_list(zkhandler, node, state, limit, is_fuzzy=True):
|
||||||
|
|
||||||
# Check on limit
|
# Check on limit
|
||||||
if limit:
|
if limit:
|
||||||
|
# Try to match the limit against the UUID (if applicable) and name
|
||||||
try:
|
try:
|
||||||
|
if is_limit_uuid and re.match(limit, vm):
|
||||||
|
is_limit_match = True
|
||||||
if re.match(limit, name):
|
if re.match(limit, name):
|
||||||
is_limit_match = True
|
is_limit_match = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue